From 1e1fb5adaf16c3fa23b893b1d489af4515830c22 Mon Sep 17 00:00:00 2001 From: Serhii Snitsaruk Date: Fri, 9 Aug 2024 14:13:01 +0200 Subject: [PATCH] Clone godot-cpp if not found during scons build --- README.md | 9 +-------- SConstruct | 37 ++++++++++++++++++++++++++----------- limboai_version.py | 1 + 3 files changed, 28 insertions(+), 19 deletions(-) diff --git a/README.md b/README.md index 8cabf07..069edf0 100644 --- a/README.md +++ b/README.md @@ -101,18 +101,11 @@ LimboAI can be used as either a C++ module or as a GDExtension shared library. G #### 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). -- Clone godot-cpp repository into `limboai/godot-cpp/` directory, and switch to a supported release tag or branch. - 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. -```bash -git clone https://github.com/limbonaut/limboai -cd limboai/ -git clone -b master https://github.com/godotengine/godot-cpp.git -scons target=editor -``` - ## Using the plugin - [Online Documentation](https://limboai.readthedocs.io/en/latest/index.html) diff --git a/SConstruct b/SConstruct index 06bc33a..c3a9e6c 100644 --- a/SConstruct +++ b/SConstruct @@ -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() diff --git a/limboai_version.py b/limboai_version.py index 09a89e8..eb62f16 100644 --- a/limboai_version.py +++ b/limboai_version.py @@ -5,6 +5,7 @@ minor = 2 patch = 0 status = "dev" doc_branch = "latest" +godot_cpp_ref = "master" # Code that generates version header