From 1d3893c5cde19f2602fc7a6b671948936e0691b8 Mon Sep 17 00:00:00 2001 From: Pablo Andres Fuente Date: Fri, 4 Oct 2024 10:19:06 -0300 Subject: [PATCH] Improving detection of ccache on Mac Before this commit, ccache where only used on Mac when `OSXCROSS_ROOT` was defined. Now, it could be used even when that environment variable is not defined. --- platform/macos/detect.py | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) diff --git a/platform/macos/detect.py b/platform/macos/detect.py index a8968b592e7..316277c554f 100644 --- a/platform/macos/detect.py +++ b/platform/macos/detect.py @@ -114,6 +114,10 @@ def configure(env: "SConsEnvironment"): env.Append(CCFLAGS=["-fobjc-arc"]) + ccache_path = os.environ.get("CCACHE", "") + if ccache_path != "": + ccache_path = ccache_path + " " + if "osxcross" not in env: # regular native build if env["macports_clang"] != "no": mpprefix = os.environ.get("MACPORTS_PREFIX", "/opt/local") @@ -124,8 +128,8 @@ def configure(env: "SConsEnvironment"): env["RANLIB"] = mpprefix + "/libexec/llvm-" + mpclangver + "/bin/llvm-ranlib" env["AS"] = mpprefix + "/libexec/llvm-" + mpclangver + "/bin/llvm-as" else: - env["CC"] = "clang" - env["CXX"] = "clang++" + env["CC"] = ccache_path + "clang" + env["CXX"] = ccache_path + "clang++" detect_darwin_sdk_path("macos", env) env.Append(CCFLAGS=["-isysroot", "$MACOS_SDK_PATH"]) @@ -138,15 +142,8 @@ def configure(env: "SConsEnvironment"): else: basecmd = root + "/target/bin/x86_64-apple-" + env["osxcross_sdk"] + "-" - ccache_path = os.environ.get("CCACHE") - if ccache_path is None: - env["CC"] = basecmd + "cc" - env["CXX"] = basecmd + "c++" - else: - # there aren't any ccache wrappers available for macOS cross-compile, - # to enable caching we need to prepend the path to the ccache binary - env["CC"] = ccache_path + " " + basecmd + "cc" - env["CXX"] = ccache_path + " " + basecmd + "c++" + env["CC"] = ccache_path + basecmd + "cc" + env["CXX"] = ccache_path + basecmd + "c++" env["AR"] = basecmd + "ar" env["RANLIB"] = basecmd + "ranlib" env["AS"] = basecmd + "as"