2023-08-05 22:42:21 +00:00
|
|
|
#!/usr/bin/env python
|
2023-08-17 14:25:50 +00:00
|
|
|
import os
|
|
|
|
|
|
|
|
|
|
|
|
def normalize_path(val, env):
|
|
|
|
return val if os.path.isabs(val) else os.path.join(env.Dir("#").abspath, val)
|
|
|
|
|
|
|
|
|
|
|
|
def validate_parent_dir(key, val, env):
|
|
|
|
if not os.path.isdir(normalize_path(os.path.dirname(val), env)):
|
|
|
|
raise UserError("'%s' is not a directory: %s" % (key, os.path.dirname(val)))
|
|
|
|
|
2023-08-05 22:42:21 +00:00
|
|
|
|
2024-11-26 23:41:39 +00:00
|
|
|
libname = "trenches"
|
2024-03-07 19:16:30 +00:00
|
|
|
projectdir = "godot"
|
2023-08-05 22:42:21 +00:00
|
|
|
|
2023-08-17 14:25:50 +00:00
|
|
|
localEnv = Environment(tools=["default"], PLATFORM="")
|
|
|
|
|
|
|
|
customs = ["custom.py"]
|
|
|
|
customs = [os.path.abspath(path) for path in customs]
|
|
|
|
|
|
|
|
opts = Variables(customs, ARGUMENTS)
|
|
|
|
opts.Add(
|
|
|
|
BoolVariable(
|
|
|
|
key="compiledb",
|
|
|
|
help="Generate compilation DB (`compile_commands.json`) for external tools",
|
|
|
|
default=localEnv.get("compiledb", False),
|
|
|
|
)
|
|
|
|
)
|
|
|
|
opts.Add(
|
|
|
|
PathVariable(
|
|
|
|
key="compiledb_file",
|
|
|
|
help="Path to a custom `compile_commands.json` file",
|
|
|
|
default=localEnv.get("compiledb_file", "compile_commands.json"),
|
|
|
|
validator=validate_parent_dir,
|
|
|
|
)
|
|
|
|
)
|
|
|
|
opts.Update(localEnv)
|
|
|
|
|
|
|
|
Help(opts.GenerateHelpText(localEnv))
|
|
|
|
|
|
|
|
env = localEnv.Clone()
|
|
|
|
env["compiledb"] = False
|
|
|
|
|
|
|
|
env.Tool("compilation_db")
|
|
|
|
compilation_db = env.CompilationDatabase(
|
|
|
|
normalize_path(localEnv["compiledb_file"], localEnv)
|
|
|
|
)
|
|
|
|
env.Alias("compiledb", compilation_db)
|
|
|
|
|
|
|
|
env = SConscript("godot-cpp/SConstruct", {"env": env, "customs": customs})
|
2023-08-05 22:42:21 +00:00
|
|
|
|
|
|
|
env.Append(CPPPATH=["src/"])
|
2024-03-07 19:16:30 +00:00
|
|
|
sources = Glob("src/*.cpp") + Glob("src/utils/*.cpp")
|
2023-08-05 22:42:21 +00:00
|
|
|
|
2023-10-15 17:50:01 +00:00
|
|
|
file = "{}{}{}".format(libname, env["suffix"], env["SHLIBSUFFIX"])
|
|
|
|
|
2024-05-17 11:08:55 +00:00
|
|
|
if env["platform"] == "macos" or env["platform"] == "ios":
|
2023-08-05 22:42:21 +00:00
|
|
|
platlibname = "{}.{}.{}".format(libname, env["platform"], env["target"])
|
2023-10-15 17:50:01 +00:00
|
|
|
file = "{}.framework/{}".format(env["platform"], platlibname, platlibname)
|
|
|
|
|
|
|
|
libraryfile = "bin/{}/{}".format(env["platform"], file)
|
|
|
|
library = env.SharedLibrary(
|
|
|
|
libraryfile,
|
|
|
|
source=sources,
|
|
|
|
)
|
|
|
|
|
2023-11-27 19:55:30 +00:00
|
|
|
copy = env.InstallAs("{}/bin/{}/lib{}".format(projectdir, env["platform"], file), library)
|
2023-08-05 22:42:21 +00:00
|
|
|
|
2023-10-15 17:50:01 +00:00
|
|
|
default_args = [library, copy]
|
2023-08-17 14:25:50 +00:00
|
|
|
if localEnv.get("compiledb", False):
|
|
|
|
default_args += [compilation_db]
|
|
|
|
Default(*default_args)
|