diff options
Diffstat (limited to 'tools/godotcpp.py')
-rw-r--r-- | tools/godotcpp.py | 30 |
1 files changed, 23 insertions, 7 deletions
diff --git a/tools/godotcpp.py b/tools/godotcpp.py index 969f8c4..329fffc 100644 --- a/tools/godotcpp.py +++ b/tools/godotcpp.py @@ -33,7 +33,7 @@ def validate_parent_dir(key, val, env): raise UserError("'%s' is not a directory: %s" % (key, os.path.dirname(val))) -platforms = ("linux", "macos", "windows", "android", "ios", "javascript") +platforms = ("linux", "macos", "windows", "android", "ios", "web") # CPU architecture options. architecture_array = [ @@ -175,6 +175,14 @@ def options(opts, env): ) ) + opts.Add( + BoolVariable( + key="use_hot_reload", + help="Enable the extra accounting required to support hot reload.", + default=(env.get("target", "template_debug") != "template_release"), + ) + ) + # Add platform options for pl in platforms: tool = Tool(pl, toolpath=["tools"]) @@ -214,7 +222,7 @@ def generate(env): env["arch"] = "universal" elif env["platform"] == "android": env["arch"] = "arm64" - elif env["platform"] == "javascript": + elif env["platform"] == "web": env["arch"] = "wasm32" else: host_machine = platform.machine().lower() @@ -231,6 +239,9 @@ def generate(env): print("Building for architecture " + env["arch"] + " on platform " + env["platform"]) + if env["use_hot_reload"]: + env.Append(CPPDEFINES=["HOT_RELOAD_ENABLED"]) + tool = Tool(env["platform"], toolpath=["tools"]) if tool is None or not tool.exists(env): @@ -263,9 +274,8 @@ def generate(env): env["OBJSUFFIX"] = suffix + env["OBJSUFFIX"] # compile_commands.json - if env.get("compiledb", False): - env.Tool("compilation_db") - env.Alias("compiledb", env.CompilationDatabase(normalize_path(env["compiledb_file"], env))) + env.Tool("compilation_db") + env.Alias("compiledb", env.CompilationDatabase(normalize_path(env["compiledb_file"], env))) # Builders env.Append(BUILDERS={"GodotCPPBindings": Builder(action=scons_generate_bindings, emitter=scons_emit_files)}) @@ -273,8 +283,8 @@ def generate(env): def _godot_cpp(env): - api_file = normalize_path(env.get("custom_api_file", env.File("gdextension/extension_api.json").abspath), env) extension_dir = normalize_path(env.get("gdextension_dir", env.Dir("gdextension").abspath), env) + api_file = normalize_path(env.get("custom_api_file", env.File(extension_dir + "/extension_api.json").abspath), env) bindings = env.GodotCPPBindings( env.Dir("."), [ @@ -304,7 +314,13 @@ def _godot_cpp(env): if env["build_library"]: library = env.StaticLibrary(target=env.File("bin/%s" % library_name), source=sources) - env.Default(library) + default_args = [library] + + # Add compiledb if the option is set + if env.get("compiledb", False): + default_args += ["compiledb"] + + env.Default(*default_args) env.AppendUnique(LIBS=[env.File("bin/%s" % library_name)]) return library |