summaryrefslogtreecommitdiff
path: root/tools
diff options
context:
space:
mode:
authorFabio Alessandrelli <fabio.alessandrelli@gmail.com>2023-06-20 17:30:14 +0200
committerFabio Alessandrelli <fabio.alessandrelli@gmail.com>2023-06-20 17:45:23 +0200
commit54c8586235f497cb080fcc6c2fae169460769aad (patch)
tree4fea8b1675014c255b0f5b13fb971c2fd4c54eb4 /tools
parentf19011f2fb794ab831b9cd53376fc52e8a5057db (diff)
downloadfork-godot-webrtc-native-54c8586235f497cb080fcc6c2fae169460769aad.tar.gz
fork-godot-webrtc-native-54c8586235f497cb080fcc6c2fae169460769aad.tar.bz2
fork-godot-webrtc-native-54c8586235f497cb080fcc6c2fae169460769aad.zip
[SCons] Fix regression causing unnecessary rebuilds.
The num_jobs (-j flag) was being tracked as part of the cmake and openssl build actions, thus causing a rebuild when compiling with different concurrently. This commit strip the -j flag from the signature of the actions so scons won't rebuild openssl/libdatachannel when changing the parallelism option.
Diffstat (limited to 'tools')
-rw-r--r--tools/cmake.py15
-rw-r--r--tools/openssl.py21
-rw-r--r--tools/rtc.py2
3 files changed, 23 insertions, 15 deletions
diff --git a/tools/cmake.py b/tools/cmake.py
index 28e1269..4141ee0 100644
--- a/tools/cmake.py
+++ b/tools/cmake.py
@@ -87,9 +87,13 @@ def cmake_emitter(target, source, env):
return [str(target[0]) + "/CMakeCache.txt"] + target[1:], [str(source[0]) + "/CMakeLists.txt"] + source[1:]
-cmake_configure_action = SCons.Action.Action("$CMAKECONFCOM", "$CMAKECONFCOMSTR")
-cmake_build_action = SCons.Action.Action("$CMAKEBUILDCOM", "$CMAKEBUILDCOMSTR")
-cmake_builder = SCons.Builder.Builder(action=[cmake_configure_action, cmake_build_action], emitter=cmake_emitter)
+def cmake_generator(target, source, env, for_signature):
+ # Strip the -j option for signature to avoid rebuilding when num_jobs changes.
+ build = env["CMAKEBUILDCOM"].replace("-j$CMAKEBUILDJOBS", "") if for_signature else env["CMAKEBUILDCOM"]
+ return [
+ SCons.Action.Action("$CMAKECONFCOM", "$CMAKECONFCOMSTR"),
+ SCons.Action.Action(build, "$CMAKEBUILDCOMSTR"),
+ ]
def exists(env):
@@ -104,6 +108,7 @@ def generate(env):
env["CMAKEGENERATOR"] = ""
env["CMAKECONFFLAGS"] = SCons.Util.CLVar("")
env["CMAKECONFCOM"] = "$CMAKE -B ${TARGET.dir} $CMAKEPLATFORMCONFIG $CMAKECONFFLAGS ${SOURCE.dir}"
+ env["CMAKEBUILDJOBS"] = "${__env__.GetOption('num_jobs')}"
env["CMAKEBUILDFLAGS"] = SCons.Util.CLVar("")
- env["CMAKEBUILDCOM"] = "$CMAKE --build ${TARGET.dir} $CMAKEBUILDFLAGS"
- env["BUILDERS"]["CMake"] = cmake_builder
+ env["CMAKEBUILDCOM"] = "$CMAKE --build ${TARGET.dir} $CMAKEBUILDFLAGS -j$CMAKEBUILDJOBS"
+ env["BUILDERS"]["CMake"] = SCons.Builder.Builder(generator=cmake_generator, emitter=cmake_emitter)
diff --git a/tools/openssl.py b/tools/openssl.py
index 936895d..8af782a 100644
--- a/tools/openssl.py
+++ b/tools/openssl.py
@@ -144,6 +144,17 @@ def build_openssl(env, jobs=None):
return ssl
+def ssl_generator(target, source, env, for_signature):
+ # Strip the -j option for signature to avoid rebuilding when num_jobs changes.
+ build = env["SSLBUILDCOM"].replace("-j$SSLBUILDJOBS", "") if for_signature else env["SSLBUILDCOM"]
+ return [
+ Mkdir("$SSL_BUILD"),
+ Mkdir("$SSL_INSTALL"),
+ SCons.Action.Action("$SSLCONFIGCOM", "$SSLCONFIGCOMSTR"),
+ SCons.Action.Action(build, "$SSLBUILDCOMSTR"),
+ ]
+
+
def options(opts):
opts.Add(PathVariable("openssl_source", "Path to the openssl sources.", "thirdparty/openssl"))
opts.Add("openssl_build", "Destination path of the openssl build.", "bin/thirdparty/openssl")
@@ -194,13 +205,5 @@ def generate(env):
if env["platform"] == "windows" and env.get("is_msvc", False):
env["SSLBUILDCOM"] = "cd ${TARGET.dir} && nmake install_sw install_ssldirs"
- env["BUILDERS"]["OpenSSLBuilder"] = SCons.Builder.Builder(
- action=[
- Mkdir("$SSL_BUILD"),
- Mkdir("$SSL_INSTALL"),
- SCons.Action.Action("$SSLCONFIGCOM", "$SSLCONFIGCOMSTR"),
- SCons.Action.Action("$SSLBUILDCOM", "$SSLBUILDCOMSTR"),
- ],
- emitter=ssl_emitter,
- )
+ env["BUILDERS"]["OpenSSLBuilder"] = SCons.Builder.Builder(generator=ssl_generator, emitter=ssl_emitter)
env.AddMethod(build_openssl, "OpenSSL")
diff --git a/tools/rtc.py b/tools/rtc.py
index 798dc94..61b6bcc 100644
--- a/tools/rtc.py
+++ b/tools/rtc.py
@@ -27,7 +27,7 @@ def build_library(env):
rtc_targets = [env.Dir(env["RTC_BUILD"])] + env["RTC_LIBS"]
rtc_sources = [env.Dir(env["RTC_SOURCE"])]
rtc_env.Append(CMAKECONFFLAGS=["'-D%s=%s'" % it for it in rtc_cmake_config(env).items()])
- rtc_env.Append(CMAKEBUILDFLAGS=["-t", "datachannel-static", "-j%s" % env.GetOption("num_jobs")])
+ rtc_env.Append(CMAKEBUILDFLAGS=["-t", "datachannel-static"])
rtc = rtc_env.CMake(rtc_targets, rtc_sources, CMAKEBUILDTYPE=env["RTC_BUILD_TYPE"])
rtc_env.Depends(rtc, rtc_env["SSL_LIBS"])
return rtc