Compare commits
7 Commits
d5becadd59
...
10b90b70fe
Author | SHA1 | Date |
---|---|---|
Serhii Snitsaruk | 10b90b70fe | |
Serhii Snitsaruk | 7708a11840 | |
Serhii Snitsaruk | 98accb1aa8 | |
Serhii Snitsaruk | bf33917cfd | |
Serhii Snitsaruk | 304bd86220 | |
Serhii Snitsaruk | 629062ea26 | |
Serhii Snitsaruk | 2528741333 |
|
@ -256,15 +256,6 @@ jobs:
|
|||
${{env.BIN}}-${{inputs.godot-cpp-ref}}-${{inputs.limboai-ref}}
|
||||
${{env.BIN}}-${{inputs.godot-cpp-ref}}
|
||||
|
||||
- name: Setup project structure for GDExtension
|
||||
shell: bash
|
||||
run: |
|
||||
bash ./gdextension/setup_gdextension.sh --copy-all
|
||||
echo "---"
|
||||
ls -l
|
||||
echo "---"
|
||||
ls -l -R ./demo/
|
||||
|
||||
- name: Compilation
|
||||
shell: bash
|
||||
env:
|
||||
|
|
83
SConstruct
83
SConstruct
|
@ -2,15 +2,14 @@
|
|||
import os
|
||||
import sys
|
||||
|
||||
# This is SConstruct file for building GDExtension variant using SCONS build system.
|
||||
# This is SConstruct file for building GDExtension variant using SCons build system.
|
||||
# For module variant, see SCsub file.
|
||||
|
||||
# For custom projects, you can customize output path for artifacts: scons --project=PATH_TO_YOUR_PROJECT
|
||||
# - artifacts are placed into "addons/limboai/bin" subdirectory inside the project directory.
|
||||
# - for example: scons --project="../my_project"
|
||||
# - artifacts will be placed into "../my_project/addons/limboai/bin" relative to "limboai/" source dir.
|
||||
# - if not specified, the artifacts will be places in the demo/ project.
|
||||
# - For plugin to be loaded, create "addons/limboai/bin" directory in your project and copy limboai.gdextension file to it.
|
||||
# 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.
|
||||
|
||||
AddOption(
|
||||
"--project",
|
||||
|
@ -20,11 +19,38 @@ AddOption(
|
|||
action="store",
|
||||
metavar="DIR",
|
||||
default="demo",
|
||||
help="Specify project directory.",
|
||||
help="Specify project directory",
|
||||
)
|
||||
project_dir = GetOption("project")
|
||||
|
||||
env = SConscript("godot-cpp/SConstruct")
|
||||
help_text = """
|
||||
Options:
|
||||
--project=DIR Specify project directory (default: "demo");
|
||||
built targets will be placed in DIR/addons/limboai/bin
|
||||
"""
|
||||
Help(help_text)
|
||||
|
||||
project_dir = GetOption("project")
|
||||
if not os.path.isdir(project_dir):
|
||||
print("Project directory not found: " + project_dir)
|
||||
Exit(1)
|
||||
|
||||
# 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]
|
||||
|
||||
# For reference:
|
||||
# - CCFLAGS are compilation flags shared between C and C++
|
||||
|
@ -34,10 +60,22 @@ env = SConscript("godot-cpp/SConstruct")
|
|||
# - CPPDEFINES are for pre-processor defines
|
||||
# - LINKFLAGS are for linking flags
|
||||
|
||||
# Generate version header.
|
||||
import limboai_version
|
||||
env = SConscript("godot-cpp/SConstruct")
|
||||
|
||||
limboai_version.generate_module_version_header()
|
||||
# Generate version header.
|
||||
from limboai_version import generate_module_version_header
|
||||
|
||||
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")
|
||||
|
||||
# Tweak this if you want to use different folders, or more folders, to store your source code in.
|
||||
env.Append(CPPDEFINES=["LIMBOAI_GDEXTENSION"])
|
||||
|
@ -62,6 +100,7 @@ if env["target"] in ["editor", "template_debug"]:
|
|||
doc_data = env.GodotCPPDocData("gen/doc_data.gen.cpp", source=Glob("doc_classes/*.xml"))
|
||||
sources.append(doc_data)
|
||||
|
||||
# Build library.
|
||||
if env["platform"] == "macos":
|
||||
library = env.SharedLibrary(
|
||||
project_dir
|
||||
|
@ -77,3 +116,21 @@ else:
|
|||
)
|
||||
|
||||
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)
|
||||
|
||||
# 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)
|
||||
|
|
|
@ -72,7 +72,7 @@ done
|
|||
|
||||
highlight Setup started.
|
||||
|
||||
${PYTHON} gdextension/update_icons.py --silent
|
||||
${PYTHON} gdextension/update_icon_entries.py --silent
|
||||
highlight -- Icon declarations updated.
|
||||
|
||||
transfer="ln -s"
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
#!/usr/bin/python
|
||||
"""
|
||||
Usage: update_icons.py [--silent]
|
||||
Update icon declarations in limboai.gdextension file.
|
||||
Usage: update_icon_entries.py [--silent]
|
||||
Update icon entries in limboai.gdextension file.
|
||||
|
||||
Options:
|
||||
-s, --silent Don't print anything.
|
||||
|
@ -28,7 +28,44 @@ def get_script_dir():
|
|||
return os.path.dirname(os.path.realpath(__file__))
|
||||
|
||||
|
||||
def main():
|
||||
def update_icon_entries(silent=False):
|
||||
config_dir = get_script_dir()
|
||||
config_path = os.path.join(config_dir, "limboai.gdextension")
|
||||
content = ""
|
||||
new_content = ""
|
||||
|
||||
f = open(config_path, "r")
|
||||
for line in f:
|
||||
content += line
|
||||
f.close()
|
||||
|
||||
index = content.find("[icons]")
|
||||
new_content = content[0:index]
|
||||
new_content += "[icons]\n\n"
|
||||
|
||||
icon_files = []
|
||||
icons_dir = os.path.join(config_dir, "../icons/")
|
||||
for icon_file in glob.glob(icons_dir + "/*.svg"):
|
||||
icon_file = os.path.basename(icon_file)
|
||||
icon_files.append(icon_file)
|
||||
|
||||
icon_files.sort()
|
||||
for icon_file in icon_files:
|
||||
new_content += os.path.splitext(icon_file)[0] + ' = "res://addons/limboai/icons/' + icon_file + '"\n'
|
||||
|
||||
if new_content != content:
|
||||
f = open(config_path, "w")
|
||||
f.write(new_content)
|
||||
f.close()
|
||||
if not silent:
|
||||
print(new_content)
|
||||
print("=== Icon entries updated ===")
|
||||
else:
|
||||
if not silent:
|
||||
print("=== No update needed for icon entries ===")
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
silent = False
|
||||
try:
|
||||
opts, args = getopt.getopt(sys.argv[1:], "s", ["silent"])
|
||||
|
@ -50,37 +87,4 @@ def main():
|
|||
elif opt in ("-s", "--silent"):
|
||||
silent = True
|
||||
|
||||
config_dir = get_script_dir()
|
||||
config_path = os.path.join(config_dir, "limboai.gdextension")
|
||||
content = ""
|
||||
|
||||
f = open(config_path, "r")
|
||||
for line in f:
|
||||
if line.startswith("[icons]"):
|
||||
break
|
||||
content += line
|
||||
f.close()
|
||||
|
||||
content += "[icons]\n\n"
|
||||
|
||||
icon_files = []
|
||||
icons_dir = os.path.join(config_dir, "../icons/")
|
||||
for icon_file in glob.glob(icons_dir + "/*.svg"):
|
||||
icon_file = os.path.basename(icon_file)
|
||||
icon_files.append(icon_file)
|
||||
|
||||
icon_files.sort()
|
||||
for icon_file in icon_files:
|
||||
content += os.path.splitext(icon_file)[0] + ' = "res://addons/limboai/icons/' + icon_file + '"\n'
|
||||
|
||||
f = open(config_path, "w")
|
||||
f.write(content)
|
||||
f.close()
|
||||
|
||||
if not silent:
|
||||
print(content)
|
||||
print("======= Icon declarations updated =======")
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
update_icon_entries(silent)
|
Loading…
Reference in New Issue