diff options
author | Fabio Alessandrelli <fabio.alessandrelli@gmail.com> | 2023-06-21 04:34:38 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-06-21 04:34:38 +0200 |
commit | b03099f7b4d29acd06eca67914155f9425da92c1 (patch) | |
tree | b929a16bde002200f430ec4df0d44defd90f0481 /tools/cmake.py | |
parent | 32ae1d11958dcf04d0bd9c5c5ca98e21221a57d7 (diff) | |
parent | 85efdfd6ce365a0ac8502777b8c142be463cfe29 (diff) | |
download | fork-godot-webrtc-native-b03099f7b4d29acd06eca67914155f9425da92c1.tar.gz fork-godot-webrtc-native-b03099f7b4d29acd06eca67914155f9425da92c1.tar.bz2 fork-godot-webrtc-native-b03099f7b4d29acd06eca67914155f9425da92c1.zip |
Merge pull request #105 from Faless/build/tool_options
Linux ARM32/ARM64, better toolchains support.
Diffstat (limited to 'tools/cmake.py')
-rw-r--r-- | tools/cmake.py | 34 |
1 files changed, 21 insertions, 13 deletions
diff --git a/tools/cmake.py b/tools/cmake.py index 4141ee0..c590860 100644 --- a/tools/cmake.py +++ b/tools/cmake.py @@ -5,10 +5,11 @@ import SCons.Builder import SCons.Action -def cmake_platform_config(env): - config = { - "CMAKE_BUILD_TYPE": env["CMAKEBUILDTYPE"], - } +def cmake_default_flags(env): + if env.get("cmake_default_flags", ""): + return SCons.Util.CLVar(env["cmake_default_flags"]) + + config = {} if "CC" in env: config["CMAKE_C_COMPILER"] = env["CC"] @@ -33,13 +34,17 @@ def cmake_platform_config(env): config["CMAKE_ANDROID_STL_TYPE"] = "c++_static" elif env["platform"] == "linux": - march = "-m32" if env["arch"] == "x86_32" else "-m64" - config["CMAKE_C_FLAGS"] = march - config["CMAKE_CXX_FLAGS"] = march + linux_flags = { + "x86_64": "-m64", + "x86_32": "-m32", + }.get(env["arch"], "") + if linux_flags: + config["CMAKE_C_FLAGS"] = linux_flags + config["CMAKE_CXX_FLAGS"] = linux_flags elif env["platform"] == "macos": if env["arch"] == "universal": - config["CMAKE_OSX_ARCHITECTURES"] = "x86_64;arm64" + config["CMAKE_OSX_ARCHITECTURES"] = '"x86_64;arm64"' else: config["CMAKE_OSX_ARCHITECTURES"] = env["arch"] if env["macos_deployment_target"] != "default": @@ -70,7 +75,7 @@ def cmake_platform_config(env): elif env["platform"] == "windows": config["CMAKE_SYSTEM_NAME"] = "Windows" - flags = ["'-D%s=%s'" % it for it in config.items()] + flags = ["-D%s=%s" % it for it in config.items()] if env["CMAKEGENERATOR"]: flags.extend(["-G", env["CMAKEGENERATOR"]]) elif env["platform"] == "windows": @@ -96,18 +101,21 @@ def cmake_generator(target, source, env, for_signature): ] +def options(opts): + opts.Add("cmake_default_flags", "Default CMake platform flags override, will be autodetected if not specified.", "") + + def exists(env): return True def generate(env): env["CMAKE"] = "cmake" - env["_cmake_platform_config"] = cmake_platform_config - env["CMAKEPLATFORMCONFIG"] = "${_cmake_platform_config(__env__)}" - env["CMAKEBUILDTYPE"] = "Release" + env["_cmake_default_flags"] = cmake_default_flags + env["CMAKEDEFAULTFLAGS"] = "${_cmake_default_flags(__env__)}" env["CMAKEGENERATOR"] = "" env["CMAKECONFFLAGS"] = SCons.Util.CLVar("") - env["CMAKECONFCOM"] = "$CMAKE -B ${TARGET.dir} $CMAKEPLATFORMCONFIG $CMAKECONFFLAGS ${SOURCE.dir}" + env["CMAKECONFCOM"] = "$CMAKE -B ${TARGET.dir} $CMAKEDEFAULTFLAGS $CMAKECONFFLAGS ${SOURCE.dir}" env["CMAKEBUILDJOBS"] = "${__env__.GetOption('num_jobs')}" env["CMAKEBUILDFLAGS"] = SCons.Util.CLVar("") env["CMAKEBUILDCOM"] = "$CMAKE --build ${TARGET.dir} $CMAKEBUILDFLAGS -j$CMAKEBUILDJOBS" |