Compare commits

...

2 Commits

Author SHA1 Message Date
Serhii Snitsaruk 1e1fb5adaf
Clone godot-cpp if not found during scons build 2024-08-09 14:21:40 +02:00
Serhii Snitsaruk 80e3ff705d
Remove setup_gdextension.sh & update README 2024-08-09 13:13:26 +02:00
4 changed files with 35 additions and 134 deletions

View File

@ -93,13 +93,19 @@ LimboAI can be used as either a C++ module or as a GDExtension shared library. G
### Compiling from source
>**🛈 For GDExtension:** Refer to comments in [setup_gdextension.sh](./gdextension/setup_gdextension.sh) file.
- Download the Godot Engine source code and put this module source into the `modules/limboai` directory.
- Consult the Godot Engine documentation for instructions on [how to build from source code](https://docs.godotengine.org/en/stable/contributing/development/compiling/index.html).
- If you plan to export a game utilizing the LimboAI module, you'll also need to build export templates.
- To execute unit tests, compile the engine with `tests=yes` and run it with `--test --tc="*[LimboAI]*"`.
#### For GDExtension
- You'll need SCons build tool and a C++ compiler. See also [Compiling](https://docs.godotengine.org/en/stable/contributing/development/compiling/index.html).
- Run `scons target=editor` to build the plugin library for your current platform.
- SCons will automatically clone the godot-cpp/ repository if it doesn't already exist in the `limboai/godot-cpp` directory.
- By default, built targets are placed in the demo project: `demo/addons/limboai/bin/`
- Check `scons -h` for other options and targets.
## Using the plugin
- [Online Documentation](https://limboai.readthedocs.io/en/latest/index.html)

View File

@ -1,15 +1,32 @@
#!/usr/bin/env python
"""
This is SConstruct file for building GDExtension variant using SCons build system.
For module variant, see SCsub file.
Use --project=DIR to customize output path for built targets.
- Built targets are placed into "DIR/addons/limboai/bin".
- For example: scons --project="../my_project"
- built targets will be placed into "../my_project/addons/limboai/bin".
- If not specified, built targets are put into the demo/ project.
"""
import os
import sys
import subprocess
from limboai_version import generate_module_version_header, godot_cpp_ref
# This is SConstruct file for building GDExtension variant using SCons build system.
# For module variant, see SCsub file.
# Use --project=DIR to customize output path for built targets.
# - Built targets are placed into "DIR/addons/limboai/bin".
# - For example: scons --project="../my_project"
# - built targets will be placed into "../my_project/addons/limboai/bin".
# - If not specified, built targets are put into the demo/ project.
# Check if godot-cpp/ exists
if not os.path.exists("godot-cpp"):
print("Directory godot-cpp/ not found. Cloning repository...")
result = subprocess.run(
["git", "clone", "-b", godot_cpp_ref, "https://github.com/godotengine/godot-cpp.git"],
check=True,
# capture_output=True
)
if result.returncode != 0:
print("Error: Cloning godot-cpp repository failed.")
Exit(1)
print("Finished cloning godot-cpp repository.")
AddOption(
"--project",
@ -32,7 +49,7 @@ Help(help_text)
project_dir = GetOption("project")
if not os.path.isdir(project_dir):
print("Project directory not found: " + project_dir)
Exit(1)
Exit(2)
# Parse LimboAI-specific variables.
vars = Variables()
@ -63,8 +80,6 @@ for o in vars.options:
env = SConscript("godot-cpp/SConstruct")
# Generate version header.
from limboai_version import generate_module_version_header
print("Generating LimboAI version header...")
generate_module_version_header()

View File

@ -1,121 +0,0 @@
#!/bin/bash
## This script sets up limboai project for development with GDExtension.
## 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:
## 1) Clone the limboai repository:
## git clone https://github.com/limbonaut/limboai
## 2) From the limboai root directory, run:
## bash ./gdextension/setup_gdextension.sh
##
## Overview:
## limboai/ -- LimboAI repository after you clone it - call this script from here.
## limboai/godot-cpp/ -- git repo that will be cloned by this script, unless already exists.
## limboai/demo/addons/limboai/limboai.gdextension -- symbolic link created (leads to limboai/gdextension/limboai.gdextension).
## limboai/demo/addons/limboai/icons/ -- symbolic link created (leads to limboai/icons/).
##
## Note: Script creates symbolic links unless --copy-all is set, in which case it copies the files.
##
## Dependencies: bash, git, python3, trash (optional).
# 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
usage() { echo "Usage: $0 [--copy-all] [--trash-old]"; }
msg () { echo -e "$@"; }
highlight() { echo -e "${HIGHLIGHT_COLOR}$@${NC}"; }
error () { echo -e "${ERROR_COLOR}$@${NC}" >&2; }
if [ ! -d "${PWD}/demo/" ]; then
error Aborting: \"demo\" subdirectory is not found.
msg Tip: Run this script from the limboai root directory.
msg Command: bash ./gdextension/setup_gdextension.sh
exit 1
fi
# Interrupt execution and exit on Ctrl-C
trap exit SIGINT
set -e
copy_all=0
trash_old=0
# Parsing arguments
for i in "$@"
do
case "${i}" in
--copy-all)
copy_demo=1
copy_all=1
shift
;;
--trash-old)
trash_old=1
shift
;;
*)
usage
exit 1
;;
esac
done
highlight Setup started.
${PYTHON} gdextension/update_icon_entries.py --silent
highlight -- Icon declarations updated.
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 demo/addons/limboai || /bin/true
highlight -- Trashed old setup.
fi
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 [ ! -e "${PWD}/demo/addons/limboai/bin/limboai.gdextension" ]; then
mkdir -p ./demo/addons/limboai/bin/
cd ./demo/addons/limboai/bin/
${transfer} ../../../../gdextension/limboai.gdextension limboai.gdextension
cd -
highlight -- ${transfer_word} limboai.gdextension.
else
highlight -- Skipping limboai.gdextension. File already exists!
fi
if [ ! -e "${PWD}/demo/addons/limboai/icons/" ]; then
cd ./demo/addons/limboai/
${transfer} ../../../icons icons
cd -
highlight -- ${transfer_word} icons.
else
highlight -- Skipping icons. File already exists!
fi
highlight Setup complete.

View File

@ -5,6 +5,7 @@ minor = 2
patch = 0
status = "dev"
doc_branch = "latest"
godot_cpp_ref = "master"
# Code that generates version header