2024-01-11 14:08:11 +00:00
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
## This script creates project structure needed for LimboAI development using GDExtension.
|
|
|
|
## Works only on Unix-likes. You can still use the directory layout below, if you are on Windows.
|
|
|
|
##
|
|
|
|
## Instructions:
|
|
|
|
## 1) Create the project root directory, name doesn't matter.
|
|
|
|
## 2) Inside the project root directory, clone the limboai repository:
|
|
|
|
## git clone https://github.com/limbonaut/limboai
|
|
|
|
## 3) From the project root directory, run:
|
|
|
|
## bash ./limboai/gdextension/setup_gdextension.sh
|
|
|
|
##
|
|
|
|
## Directory layout:
|
|
|
|
## project/ -- call this script from here, directory name doesn't matter.
|
|
|
|
## project/limboai/ -- LimboAI repository should be here after you clone it.
|
|
|
|
## project/godot-cpp/ -- will be created by this script.
|
|
|
|
## project/demo/ -- symbolic link that will be created by this script.
|
|
|
|
## project/SConstruct -- symbolic link that will be created by this script.
|
|
|
|
##
|
|
|
|
## Dependencies: bash, git, python3.
|
|
|
|
|
|
|
|
# Script Settings
|
|
|
|
GODOT_CPP_VERSION=4.2
|
|
|
|
PYTHON=python
|
|
|
|
|
|
|
|
# Colors
|
|
|
|
HIGHLIGHT_COLOR='\033[1;36m' # Light Cyan
|
|
|
|
NC='\033[0m' # No Color
|
|
|
|
ERROR_COLOR="\033[0;31m" # Red
|
|
|
|
|
2024-01-17 11:01:13 +00:00
|
|
|
usage() { echo "Usage: $0 [--copy-demo] [--copy-all] [--trash-old]"; }
|
2024-01-16 09:21:51 +00:00
|
|
|
|
2024-01-11 14:08:11 +00:00
|
|
|
msg () { echo -e "$@"; }
|
|
|
|
highlight() { echo -e "${HIGHLIGHT_COLOR}$@${NC}"; }
|
|
|
|
error () { echo -e "${ERROR_COLOR}$@${NC}" >&2; }
|
|
|
|
|
|
|
|
if [ ! -d "${PWD}/limboai/" ]; then
|
|
|
|
error Aborting: \"limboai\" subdirectory is not found.
|
|
|
|
msg Tip: Run this script from the project root directory with limboai repository cloned into \"limboai\" subdirectory.
|
|
|
|
msg Command: bash ./limboai/gdextension/setup_gdextension.sh
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
# Interrupt execution and exit on Ctrl-C
|
|
|
|
trap exit SIGINT
|
|
|
|
|
|
|
|
set -e
|
|
|
|
|
2024-01-16 09:21:51 +00:00
|
|
|
copy_demo=0
|
2024-01-17 11:01:13 +00:00
|
|
|
copy_all=0
|
|
|
|
trash_old=0
|
2024-01-16 09:21:51 +00:00
|
|
|
|
|
|
|
# Parsing arguments
|
|
|
|
for i in "$@"
|
|
|
|
do
|
|
|
|
case "${i}" in
|
|
|
|
--copy-demo)
|
|
|
|
copy_demo=1
|
|
|
|
shift
|
|
|
|
;;
|
2024-01-17 11:01:13 +00:00
|
|
|
--copy-all)
|
|
|
|
copy_demo=1
|
|
|
|
copy_all=1
|
|
|
|
shift
|
|
|
|
;;
|
|
|
|
--trash-old)
|
|
|
|
trash_old=1
|
|
|
|
shift
|
|
|
|
;;
|
2024-01-16 09:21:51 +00:00
|
|
|
*)
|
|
|
|
usage
|
2024-01-17 11:01:13 +00:00
|
|
|
exit 1
|
2024-01-16 09:21:51 +00:00
|
|
|
;;
|
|
|
|
esac
|
|
|
|
done
|
|
|
|
|
2024-01-11 14:08:11 +00:00
|
|
|
highlight Setup started.
|
|
|
|
|
2024-01-17 16:54:20 +00:00
|
|
|
${PYTHON} limboai/gdextension/update_icons.py --silent
|
|
|
|
highlight -- Icon declarations updated.
|
|
|
|
|
2024-01-17 11:01:13 +00:00
|
|
|
transfer="ln -s"
|
|
|
|
transfer_word="Linked"
|
|
|
|
if [ ${copy_all} == 1 ]; then
|
|
|
|
transfer="cp -R"
|
|
|
|
transfer_word="Copied"
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [ ${trash_old} == 1 ]; then
|
|
|
|
if ! command -v trash &> /dev/null; then
|
|
|
|
error trash command not available. Aborting.
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
trash SConstruct limboai/demo/addons demo || /bin/true
|
|
|
|
highlight -- Trashed old setup.
|
|
|
|
fi
|
|
|
|
|
2024-01-11 14:08:11 +00:00
|
|
|
if [ ! -d "${PWD}/godot-cpp/" ]; then
|
|
|
|
highlight -- Cloning godot-cpp...
|
|
|
|
git clone -b ${GODOT_CPP_VERSION} https://github.com/godotengine/godot-cpp
|
|
|
|
highlight -- Finished cloning godot-cpp.
|
|
|
|
else
|
|
|
|
highlight -- Skipping \"godot-cpp\". Directory already exists!
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [ ! -f "${PWD}/SConstruct" ]; then
|
2024-01-17 11:01:13 +00:00
|
|
|
${transfer} limboai/gdextension/SConstruct SConstruct
|
|
|
|
highlight -- ${transfer_word} SConstruct.
|
2024-01-11 14:08:11 +00:00
|
|
|
else
|
|
|
|
highlight -- Skipping \"SConstruct\". File already exists!
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [ ! -e "${PWD}/demo" ]; then
|
2024-01-16 09:21:51 +00:00
|
|
|
if [ ${copy_demo} == 1 ]; then
|
2024-01-17 11:01:13 +00:00
|
|
|
cp -R limboai/demo demo
|
2024-01-16 09:21:51 +00:00
|
|
|
highlight -- Copied demo.
|
|
|
|
else
|
|
|
|
ln -s limboai/demo demo
|
|
|
|
highlight -- Linked demo project.
|
|
|
|
fi
|
2024-01-11 14:08:11 +00:00
|
|
|
else
|
|
|
|
highlight -- Skipping \"demo\". File already exists!
|
|
|
|
fi
|
|
|
|
|
2024-01-17 11:01:13 +00:00
|
|
|
if [ ! -e "${PWD}/demo/addons/limboai/bin/limboai.gdextension" ]; then
|
|
|
|
mkdir -p ./demo/addons/limboai/bin/
|
|
|
|
cd ./demo/addons/limboai/bin/
|
|
|
|
if [ -f "../../../../gdextension/limboai.gdextension" ]; then
|
|
|
|
${transfer} ../../../../gdextension/limboai.gdextension limboai.gdextension
|
|
|
|
else
|
|
|
|
${transfer} ../../../../limboai/gdextension/limboai.gdextension limboai.gdextension
|
|
|
|
fi
|
2024-01-11 19:16:00 +00:00
|
|
|
cd -
|
2024-01-17 11:01:13 +00:00
|
|
|
highlight -- ${transfer_word} limboai.gdextension.
|
2024-01-11 14:08:11 +00:00
|
|
|
else
|
|
|
|
highlight -- Skipping limboai.gdextension. File already exists!
|
|
|
|
fi
|
|
|
|
|
2024-01-17 11:01:13 +00:00
|
|
|
if [ ! -e "${PWD}/demo/addons/limboai/icons/" ]; then
|
|
|
|
cd ./demo/addons/limboai/
|
|
|
|
if [ -d "../../../icons" ]; then
|
|
|
|
${transfer} ../../../icons icons
|
|
|
|
else
|
|
|
|
${transfer} ../../../limboai/icons icons
|
|
|
|
fi
|
2024-01-11 19:16:00 +00:00
|
|
|
cd -
|
2024-01-17 11:01:13 +00:00
|
|
|
highlight -- ${transfer_word} icons.
|
2024-01-11 16:06:06 +00:00
|
|
|
else
|
2024-01-17 11:01:13 +00:00
|
|
|
highlight -- Skipping icons. File already exists!
|
2024-01-11 16:06:06 +00:00
|
|
|
fi
|
|
|
|
|
2024-01-11 14:08:11 +00:00
|
|
|
highlight Setup complete.
|