2024-01-09 12:34:24 +00:00
|
|
|
#!/usr/bin/env python
|
2024-08-09 12:13:01 +00:00
|
|
|
"""
|
|
|
|
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.
|
|
|
|
"""
|
|
|
|
|
2024-01-09 12:34:24 +00:00
|
|
|
import os
|
|
|
|
import sys
|
2024-08-09 12:13:01 +00:00
|
|
|
import subprocess
|
|
|
|
from limboai_version import generate_module_version_header, godot_cpp_ref
|
2024-01-09 12:34:24 +00:00
|
|
|
|
2024-08-09 12:13:01 +00:00
|
|
|
# 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.")
|
2024-08-07 13:01:50 +00:00
|
|
|
|
|
|
|
AddOption(
|
|
|
|
"--project",
|
|
|
|
dest="project",
|
|
|
|
type="string",
|
|
|
|
nargs=1,
|
|
|
|
action="store",
|
|
|
|
metavar="DIR",
|
|
|
|
default="demo",
|
2024-08-08 11:14:44 +00:00
|
|
|
help="Specify project directory",
|
2024-08-07 13:01:50 +00:00
|
|
|
)
|
2024-08-08 11:14:44 +00:00
|
|
|
|
|
|
|
help_text = """
|
|
|
|
Options:
|
|
|
|
--project=DIR Specify project directory (default: "demo");
|
|
|
|
built targets will be placed in DIR/addons/limboai/bin
|
|
|
|
"""
|
|
|
|
Help(help_text)
|
|
|
|
|
2024-08-07 13:01:50 +00:00
|
|
|
project_dir = GetOption("project")
|
2024-08-08 11:14:44 +00:00
|
|
|
if not os.path.isdir(project_dir):
|
|
|
|
print("Project directory not found: " + project_dir)
|
2024-08-09 12:13:01 +00:00
|
|
|
Exit(2)
|
2024-08-07 13:01:50 +00:00
|
|
|
|
2024-08-08 19:54:19 +00:00
|
|
|
# Parse LimboAI-specific variables.
|
|
|
|
vars = Variables()
|
|
|
|
vars.AddVariables(
|
|
|
|
BoolVariable("deploy_manifest", help="Deploy limboai.gdextension into PROJECT/addons/limboai/bin", default=True),
|
|
|
|
BoolVariable("deploy_icons", help="Deploy icons into PROJECT/addons/limboai/icons", default=True),
|
|
|
|
)
|
|
|
|
env = Environment(tools=["default"], PLATFORM="", variables=vars)
|
|
|
|
Help(vars.GenerateHelpText(env))
|
|
|
|
|
|
|
|
# Read LimboAI-specific variables.
|
|
|
|
deploy_manifest = env["deploy_manifest"]
|
|
|
|
deploy_icons = env["deploy_icons"]
|
|
|
|
|
|
|
|
# Remove processed variables from ARGUMENTS to avoid godot-cpp warnings.
|
|
|
|
for o in vars.options:
|
|
|
|
if o.key in ARGUMENTS:
|
|
|
|
del ARGUMENTS[o.key]
|
2024-01-09 12:34:24 +00:00
|
|
|
|
|
|
|
# For reference:
|
|
|
|
# - CCFLAGS are compilation flags shared between C and C++
|
|
|
|
# - CFLAGS are for C-specific compilation flags
|
|
|
|
# - CXXFLAGS are for C++-specific compilation flags
|
|
|
|
# - CPPFLAGS are for pre-processor flags
|
|
|
|
# - CPPDEFINES are for pre-processor defines
|
|
|
|
# - LINKFLAGS are for linking flags
|
|
|
|
|
2024-08-08 19:54:19 +00:00
|
|
|
env = SConscript("godot-cpp/SConstruct")
|
|
|
|
|
2024-05-30 13:55:49 +00:00
|
|
|
# Generate version header.
|
2024-08-07 15:19:51 +00:00
|
|
|
print("Generating LimboAI version header...")
|
|
|
|
generate_module_version_header()
|
|
|
|
|
|
|
|
# Update icon entries in limboai.gdextension file.
|
|
|
|
# Note: This will remove everything after [icons] section, and rebuild it with generated icon entries.
|
|
|
|
sys.path.append("gdextension")
|
|
|
|
from update_icon_entries import update_icon_entries
|
|
|
|
|
|
|
|
print("Updating LimboAI icon entries...")
|
|
|
|
update_icon_entries(silent=True)
|
|
|
|
sys.path.remove("gdextension")
|
2024-05-30 13:55:49 +00:00
|
|
|
|
|
|
|
# Tweak this if you want to use different folders, or more folders, to store your source code in.
|
2024-05-02 22:21:51 +00:00
|
|
|
env.Append(CPPDEFINES=["LIMBOAI_GDEXTENSION"])
|
2024-08-07 13:01:50 +00:00
|
|
|
sources = Glob("*.cpp")
|
|
|
|
sources += Glob("blackboard/*.cpp")
|
|
|
|
sources += Glob("blackboard/bb_param/*.cpp")
|
|
|
|
sources += Glob("bt/*.cpp")
|
|
|
|
sources += Glob("bt/tasks/*.cpp")
|
|
|
|
sources += Glob("bt/tasks/blackboard/*.cpp")
|
|
|
|
sources += Glob("bt/tasks/composites/*.cpp")
|
|
|
|
sources += Glob("bt/tasks/decorators/*.cpp")
|
|
|
|
sources += Glob("bt/tasks/scene/*.cpp")
|
|
|
|
sources += Glob("bt/tasks/utility/*.cpp")
|
|
|
|
sources += Glob("gdextension/*.cpp")
|
|
|
|
sources += Glob("editor/debugger/*.cpp")
|
|
|
|
sources += Glob("editor/*.cpp")
|
|
|
|
sources += Glob("hsm/*.cpp")
|
|
|
|
sources += Glob("util/*.cpp")
|
2024-01-09 12:34:24 +00:00
|
|
|
|
2024-06-30 13:40:18 +00:00
|
|
|
# Generate documentation header.
|
|
|
|
if env["target"] in ["editor", "template_debug"]:
|
2024-08-07 13:01:50 +00:00
|
|
|
doc_data = env.GodotCPPDocData("gen/doc_data.gen.cpp", source=Glob("doc_classes/*.xml"))
|
2024-06-30 13:40:18 +00:00
|
|
|
sources.append(doc_data)
|
2024-01-09 12:34:24 +00:00
|
|
|
|
2024-08-08 12:41:25 +00:00
|
|
|
# Build library.
|
2024-01-09 12:34:24 +00:00
|
|
|
if env["platform"] == "macos":
|
|
|
|
library = env.SharedLibrary(
|
2024-08-07 13:01:50 +00:00
|
|
|
project_dir
|
|
|
|
+ "/addons/limboai/bin/liblimboai.{}.{}.framework/liblimboai.{}.{}".format(
|
2024-01-09 12:34:24 +00:00
|
|
|
env["platform"], env["target"], env["platform"], env["target"]
|
|
|
|
),
|
|
|
|
source=sources,
|
|
|
|
)
|
|
|
|
else:
|
|
|
|
library = env.SharedLibrary(
|
2024-08-07 13:01:50 +00:00
|
|
|
project_dir + "/addons/limboai/bin/liblimboai{}{}".format(env["suffix"], env["SHLIBSUFFIX"]),
|
2024-01-09 12:34:24 +00:00
|
|
|
source=sources,
|
|
|
|
)
|
|
|
|
|
2024-08-08 19:54:19 +00:00
|
|
|
Default(library)
|
|
|
|
|
|
|
|
# Deploy icons into PROJECT/addons/limboai/icons.
|
|
|
|
if deploy_icons:
|
|
|
|
cmd_deploy_icons = env.Command(
|
|
|
|
project_dir + "/addons/limboai/icons/",
|
|
|
|
"icons/",
|
|
|
|
Copy("$TARGET", "$SOURCE"),
|
|
|
|
)
|
|
|
|
Default(cmd_deploy_icons)
|
2024-08-08 12:41:25 +00:00
|
|
|
|
2024-08-08 19:54:19 +00:00
|
|
|
# Deploy limboai.gdextension into PROJECT/addons/limboai/bin.
|
|
|
|
if deploy_manifest:
|
|
|
|
cmd_deploy_manifest = env.Command(
|
|
|
|
project_dir + "/addons/limboai/bin/limboai.gdextension",
|
|
|
|
"gdextension/limboai.gdextension",
|
|
|
|
Copy("$TARGET", "$SOURCE"),
|
|
|
|
)
|
|
|
|
Default(cmd_deploy_manifest)
|