Compare commits

...

7 Commits

Author SHA1 Message Date
Serhii Snitsaruk 10b90b70fe
GHA: Don't use setup_gdextension.sh (no longer needed) 2024-08-08 22:55:51 +02:00
Serhii Snitsaruk 7708a11840
Deploy icons on scons build (optionally) 2024-08-08 22:00:16 +02:00
Serhii Snitsaruk 98accb1aa8
Automatically deploy limboai.gdextension on build 2024-08-08 14:41:25 +02:00
Serhii Snitsaruk bf33917cfd
Add help and verification for --project option in SConstruct 2024-08-08 13:27:36 +02:00
Serhii Snitsaruk 304bd86220
Write icon entries to manifest only if changed 2024-08-07 17:47:50 +02:00
Serhii Snitsaruk 629062ea26
Update icon entries during scons build 2024-08-07 17:29:08 +02:00
Serhii Snitsaruk 2528741333
Rename update_icons.py to update_icon_entries.py 2024-08-07 17:11:51 +02:00
4 changed files with 112 additions and 60 deletions

View File

@ -256,15 +256,6 @@ jobs:
${{env.BIN}}-${{inputs.godot-cpp-ref}}-${{inputs.limboai-ref}} ${{env.BIN}}-${{inputs.godot-cpp-ref}}-${{inputs.limboai-ref}}
${{env.BIN}}-${{inputs.godot-cpp-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 - name: Compilation
shell: bash shell: bash
env: env:

View File

@ -2,15 +2,14 @@
import os import os
import sys 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 module variant, see SCsub file.
# For custom projects, you can customize output path for artifacts: scons --project=PATH_TO_YOUR_PROJECT # Use --project=DIR to customize output path for built targets.
# - artifacts are placed into "addons/limboai/bin" subdirectory inside the project directory. # - Built targets are placed into "DIR/addons/limboai/bin".
# - for example: scons --project="../my_project" # - For example: scons --project="../my_project"
# - artifacts will be placed into "../my_project/addons/limboai/bin" relative to "limboai/" source dir. # - built targets will be placed into "../my_project/addons/limboai/bin".
# - if not specified, the artifacts will be places in the demo/ project. # - If not specified, built targets are put into the demo/ project.
# - For plugin to be loaded, create "addons/limboai/bin" directory in your project and copy limboai.gdextension file to it.
AddOption( AddOption(
"--project", "--project",
@ -20,11 +19,38 @@ AddOption(
action="store", action="store",
metavar="DIR", metavar="DIR",
default="demo", 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: # For reference:
# - CCFLAGS are compilation flags shared between C and C++ # - CCFLAGS are compilation flags shared between C and C++
@ -34,10 +60,22 @@ env = SConscript("godot-cpp/SConstruct")
# - CPPDEFINES are for pre-processor defines # - CPPDEFINES are for pre-processor defines
# - LINKFLAGS are for linking flags # - LINKFLAGS are for linking flags
# Generate version header. env = SConscript("godot-cpp/SConstruct")
import limboai_version
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. # Tweak this if you want to use different folders, or more folders, to store your source code in.
env.Append(CPPDEFINES=["LIMBOAI_GDEXTENSION"]) 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")) doc_data = env.GodotCPPDocData("gen/doc_data.gen.cpp", source=Glob("doc_classes/*.xml"))
sources.append(doc_data) sources.append(doc_data)
# Build library.
if env["platform"] == "macos": if env["platform"] == "macos":
library = env.SharedLibrary( library = env.SharedLibrary(
project_dir project_dir
@ -77,3 +116,21 @@ else:
) )
Default(library) 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)

View File

@ -72,7 +72,7 @@ done
highlight Setup started. highlight Setup started.
${PYTHON} gdextension/update_icons.py --silent ${PYTHON} gdextension/update_icon_entries.py --silent
highlight -- Icon declarations updated. highlight -- Icon declarations updated.
transfer="ln -s" transfer="ln -s"

View File

@ -1,7 +1,7 @@
#!/usr/bin/python #!/usr/bin/python
""" """
Usage: update_icons.py [--silent] Usage: update_icon_entries.py [--silent]
Update icon declarations in limboai.gdextension file. Update icon entries in limboai.gdextension file.
Options: Options:
-s, --silent Don't print anything. -s, --silent Don't print anything.
@ -28,7 +28,44 @@ def get_script_dir():
return os.path.dirname(os.path.realpath(__file__)) 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 silent = False
try: try:
opts, args = getopt.getopt(sys.argv[1:], "s", ["silent"]) opts, args = getopt.getopt(sys.argv[1:], "s", ["silent"])
@ -50,37 +87,4 @@ def main():
elif opt in ("-s", "--silent"): elif opt in ("-s", "--silent"):
silent = True silent = True
config_dir = get_script_dir() update_icon_entries(silent)
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()