From 629062ea26d2f2c724f379be095d31e26ba9e96f Mon Sep 17 00:00:00 2001 From: Serhii Snitsaruk Date: Wed, 7 Aug 2024 17:19:51 +0200 Subject: [PATCH] Update icon entries during scons build --- SConstruct | 14 +++++++-- gdextension/update_icon_entries.py | 46 +++++++++++++++--------------- 2 files changed, 35 insertions(+), 25 deletions(-) diff --git a/SConstruct b/SConstruct index 9b11d95..377e793 100644 --- a/SConstruct +++ b/SConstruct @@ -35,9 +35,19 @@ env = SConscript("godot-cpp/SConstruct") # - LINKFLAGS are for linking flags # Generate version header. -import limboai_version +from limboai_version import generate_module_version_header -limboai_version.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"]) diff --git a/gdextension/update_icon_entries.py b/gdextension/update_icon_entries.py index 8af2b36..c27eb09 100755 --- a/gdextension/update_icon_entries.py +++ b/gdextension/update_icon_entries.py @@ -28,28 +28,7 @@ def get_script_dir(): return os.path.dirname(os.path.realpath(__file__)) -def main(): - silent = False - try: - opts, args = getopt.getopt(sys.argv[1:], "s", ["silent"]) - except getopt.GetoptError as e: - print( - "%s: %s!\n" - % ( - os.path.basename(__file__), - e.msg, - ) - ) - usage() - sys.exit(2) - - for opt, arg in opts: - if opt in ("-h", "--help"): - usage() - sys.exit(0) - elif opt in ("-s", "--silent"): - silent = True - +def update_icon_entries(silent=False): config_dir = get_script_dir() config_path = os.path.join(config_dir, "limboai.gdextension") content = "" @@ -83,4 +62,25 @@ def main(): if __name__ == "__main__": - main() + silent = False + try: + opts, args = getopt.getopt(sys.argv[1:], "s", ["silent"]) + except getopt.GetoptError as e: + print( + "%s: %s!\n" + % ( + os.path.basename(__file__), + e.msg, + ) + ) + usage() + sys.exit(2) + + for opt, arg in opts: + if opt in ("-h", "--help"): + usage() + sys.exit(0) + elif opt in ("-s", "--silent"): + silent = True + + update_icon_entries(silent)