update setup_gdextension.sh to work with new GDExtension project structure

This commit is contained in:
Serhii Snitsaruk 2024-08-07 15:15:59 +02:00
parent 6134d5130c
commit 650e381659
No known key found for this signature in database
GPG Key ID: A965EF8799FFEC2D
1 changed files with 22 additions and 57 deletions

View File

@ -1,27 +1,24 @@
#!/bin/bash #!/bin/bash
## This script creates project structure needed for LimboAI development using GDExtension. ## This script sets up limboai project for development with GDExtension.
## Works only on Unix-likes. You can still use the directory layout below, if you are on Windows. ## It adds missing files to the demo project for development with GDExtension, and downloads godot-cpp.
## Tested only on Unix-likes. You can perform similar steps manually, if you are on Windows. Check Overview below.
## ##
## Instructions: ## Instructions:
## 1) Create the project root directory, name doesn't matter. ## 1) Clone the limboai repository:
## 2) Inside the project root directory, clone the limboai repository:
## git clone https://github.com/limbonaut/limboai ## git clone https://github.com/limbonaut/limboai
## 3) From the project root directory, run: ## 2) From the limboai root directory, run:
## bash ./limboai/gdextension/setup_gdextension.sh ## bash ./gdextension/setup_gdextension.sh
## ##
## Directory layout: ## Overview:
## project/ -- call this script from here, directory name doesn't matter. ## limboai/ -- LimboAI repository after you clone it - call this script from here.
## project/limboai/ -- LimboAI repository should be here after you clone it. ## limboai/godot-cpp/ -- git repo that will be cloned by this script, unless already exists.
## project/godot-cpp/ -- will be created by this script, unless cloned manually. ## limboai/demo/addons/limboai/limboai.gdextension -- symbolic link created (leads to limboai/gdextension/limboai.gdextension).
## project/demo/ -- symbolic link (leads to limboai/demo). ## limboai/demo/addons/limboai/icons/ -- symbolic link created (leads to limboai/icons/).
## project/demo/addons/limboai/limboai.gdextension -- symbolid link (leads to limboai/gdextension/limboai.gdextension).
## project/demo/addons/limboai/icons/ -- symbolic link (leads to icons/).
## project/SConstruct -- symbolic link (leads to limboai/gdextension/SContruct).
## ##
## Note: Symbolic links will be created by this script. ## Note: Script creates symbolic links unless --copy-all is set, in which case it copies the files.
## ##
## Dependencies: bash, git, python3. ## Dependencies: bash, git, python3, trash (optional).
# Script Settings # Script Settings
GODOT_CPP_VERSION=4.2 GODOT_CPP_VERSION=4.2
@ -32,16 +29,16 @@ HIGHLIGHT_COLOR='\033[1;36m' # Light Cyan
NC='\033[0m' # No Color NC='\033[0m' # No Color
ERROR_COLOR="\033[0;31m" # Red ERROR_COLOR="\033[0;31m" # Red
usage() { echo "Usage: $0 [--copy-demo] [--copy-all] [--trash-old]"; } usage() { echo "Usage: $0 [--copy-all] [--trash-old]"; }
msg () { echo -e "$@"; } msg () { echo -e "$@"; }
highlight() { echo -e "${HIGHLIGHT_COLOR}$@${NC}"; } highlight() { echo -e "${HIGHLIGHT_COLOR}$@${NC}"; }
error () { echo -e "${ERROR_COLOR}$@${NC}" >&2; } error () { echo -e "${ERROR_COLOR}$@${NC}" >&2; }
if [ ! -d "${PWD}/limboai/" ]; then if [ ! -d "${PWD}/demo/" ]; then
error Aborting: \"limboai\" subdirectory is not found. error Aborting: \"demo\" subdirectory is not found.
msg Tip: Run this script from the project root directory with limboai repository cloned into \"limboai\" subdirectory. msg Tip: Run this script from the limboai root directory.
msg Command: bash ./limboai/gdextension/setup_gdextension.sh msg Command: bash ./gdextension/setup_gdextension.sh
exit 1 exit 1
fi fi
@ -50,7 +47,6 @@ trap exit SIGINT
set -e set -e
copy_demo=0
copy_all=0 copy_all=0
trash_old=0 trash_old=0
@ -58,10 +54,6 @@ trash_old=0
for i in "$@" for i in "$@"
do do
case "${i}" in case "${i}" in
--copy-demo)
copy_demo=1
shift
;;
--copy-all) --copy-all)
copy_demo=1 copy_demo=1
copy_all=1 copy_all=1
@ -80,7 +72,7 @@ done
highlight Setup started. highlight Setup started.
${PYTHON} limboai/gdextension/update_icons.py --silent ${PYTHON} gdextension/update_icons.py --silent
highlight -- Icon declarations updated. highlight -- Icon declarations updated.
transfer="ln -s" transfer="ln -s"
@ -95,7 +87,7 @@ if [ ${trash_old} == 1 ]; then
error trash command not available. Aborting. error trash command not available. Aborting.
exit 1 exit 1
fi fi
trash SConstruct limboai/demo/addons demo || /bin/true trash demo/addons/limboai || /bin/true
highlight -- Trashed old setup. highlight -- Trashed old setup.
fi fi
@ -107,33 +99,10 @@ else
highlight -- Skipping \"godot-cpp\". Directory already exists! highlight -- Skipping \"godot-cpp\". Directory already exists!
fi fi
if [ ! -f "${PWD}/SConstruct" ]; then
${transfer} limboai/gdextension/SConstruct SConstruct
highlight -- ${transfer_word} SConstruct.
else
highlight -- Skipping \"SConstruct\". File already exists!
fi
if [ ! -e "${PWD}/demo" ]; then
if [ ${copy_demo} == 1 ]; then
cp -R limboai/demo demo
highlight -- Copied demo.
else
ln -s limboai/demo demo
highlight -- Linked demo project.
fi
else
highlight -- Skipping \"demo\". File already exists!
fi
if [ ! -e "${PWD}/demo/addons/limboai/bin/limboai.gdextension" ]; then if [ ! -e "${PWD}/demo/addons/limboai/bin/limboai.gdextension" ]; then
mkdir -p ./demo/addons/limboai/bin/ mkdir -p ./demo/addons/limboai/bin/
cd ./demo/addons/limboai/bin/ cd ./demo/addons/limboai/bin/
if [ -f "../../../../gdextension/limboai.gdextension" ]; then ${transfer} ../../../../gdextension/limboai.gdextension limboai.gdextension
${transfer} ../../../../gdextension/limboai.gdextension limboai.gdextension
else
${transfer} ../../../../limboai/gdextension/limboai.gdextension limboai.gdextension
fi
cd - cd -
highlight -- ${transfer_word} limboai.gdextension. highlight -- ${transfer_word} limboai.gdextension.
else else
@ -142,11 +111,7 @@ fi
if [ ! -e "${PWD}/demo/addons/limboai/icons/" ]; then if [ ! -e "${PWD}/demo/addons/limboai/icons/" ]; then
cd ./demo/addons/limboai/ cd ./demo/addons/limboai/
if [ -d "../../../icons" ]; then ${transfer} ../../../icons icons
${transfer} ../../../icons icons
else
${transfer} ../../../limboai/icons icons
fi
cd - cd -
highlight -- ${transfer_word} icons. highlight -- ${transfer_word} icons.
else else