You've already forked godot
mirror of
https://github.com/godotengine/godot.git
synced 2025-11-04 12:00:25 +00:00
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 envirnment variable is not defined.
This commit is contained in:
committed by
Pablo Andres Fuente
parent
19e003bc08
commit
7c4c1100e0
@@ -657,12 +657,14 @@ def detect_darwin_sdk_path(platform, env):
|
|||||||
|
|
||||||
|
|
||||||
def is_apple_clang(env):
|
def is_apple_clang(env):
|
||||||
|
import shlex
|
||||||
|
|
||||||
if env["platform"] not in ["macos", "ios"]:
|
if env["platform"] not in ["macos", "ios"]:
|
||||||
return False
|
return False
|
||||||
if not using_clang(env):
|
if not using_clang(env):
|
||||||
return False
|
return False
|
||||||
try:
|
try:
|
||||||
version = subprocess.check_output([env.subst(env["CXX"]), "--version"]).strip().decode("utf-8")
|
version = subprocess.check_output(shlex.split(env.subst(env["CXX"])) + ["--version"]).strip().decode("utf-8")
|
||||||
except (subprocess.CalledProcessError, OSError):
|
except (subprocess.CalledProcessError, OSError):
|
||||||
print_warning("Couldn't parse CXX environment variable to infer compiler version.")
|
print_warning("Couldn't parse CXX environment variable to infer compiler version.")
|
||||||
return False
|
return False
|
||||||
@@ -677,6 +679,8 @@ def get_compiler_version(env):
|
|||||||
- metadata1, metadata2: Extra information
|
- metadata1, metadata2: Extra information
|
||||||
- date: Date of the build
|
- date: Date of the build
|
||||||
"""
|
"""
|
||||||
|
import shlex
|
||||||
|
|
||||||
ret = {
|
ret = {
|
||||||
"major": -1,
|
"major": -1,
|
||||||
"minor": -1,
|
"minor": -1,
|
||||||
@@ -727,7 +731,7 @@ def get_compiler_version(env):
|
|||||||
# Clang used to return hardcoded 4.2.1: # https://reviews.llvm.org/D56803
|
# Clang used to return hardcoded 4.2.1: # https://reviews.llvm.org/D56803
|
||||||
try:
|
try:
|
||||||
version = subprocess.check_output(
|
version = subprocess.check_output(
|
||||||
[env.subst(env["CXX"]), "--version"], shell=(os.name == "nt"), encoding="utf-8"
|
shlex.split(env.subst(env["CXX"])) + ["--version"], shell=(os.name == "nt"), encoding="utf-8"
|
||||||
).strip()
|
).strip()
|
||||||
except (subprocess.CalledProcessError, OSError):
|
except (subprocess.CalledProcessError, OSError):
|
||||||
print_warning("Couldn't parse CXX environment variable to infer compiler version.")
|
print_warning("Couldn't parse CXX environment variable to infer compiler version.")
|
||||||
|
|||||||
@@ -108,6 +108,10 @@ def configure(env: "SConsEnvironment"):
|
|||||||
|
|
||||||
env.Append(CCFLAGS=["-fobjc-arc"])
|
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 "osxcross" not in env: # regular native build
|
||||||
if env["macports_clang"] != "no":
|
if env["macports_clang"] != "no":
|
||||||
mpprefix = os.environ.get("MACPORTS_PREFIX", "/opt/local")
|
mpprefix = os.environ.get("MACPORTS_PREFIX", "/opt/local")
|
||||||
@@ -118,8 +122,8 @@ def configure(env: "SConsEnvironment"):
|
|||||||
env["RANLIB"] = mpprefix + "/libexec/llvm-" + mpclangver + "/bin/llvm-ranlib"
|
env["RANLIB"] = mpprefix + "/libexec/llvm-" + mpclangver + "/bin/llvm-ranlib"
|
||||||
env["AS"] = mpprefix + "/libexec/llvm-" + mpclangver + "/bin/llvm-as"
|
env["AS"] = mpprefix + "/libexec/llvm-" + mpclangver + "/bin/llvm-as"
|
||||||
else:
|
else:
|
||||||
env["CC"] = "clang"
|
env["CC"] = ccache_path + "clang"
|
||||||
env["CXX"] = "clang++"
|
env["CXX"] = ccache_path + "clang++"
|
||||||
|
|
||||||
detect_darwin_sdk_path("macos", env)
|
detect_darwin_sdk_path("macos", env)
|
||||||
env.Append(CCFLAGS=["-isysroot", "$MACOS_SDK_PATH"])
|
env.Append(CCFLAGS=["-isysroot", "$MACOS_SDK_PATH"])
|
||||||
@@ -132,15 +136,8 @@ def configure(env: "SConsEnvironment"):
|
|||||||
else:
|
else:
|
||||||
basecmd = root + "/target/bin/x86_64-apple-" + env["osxcross_sdk"] + "-"
|
basecmd = root + "/target/bin/x86_64-apple-" + env["osxcross_sdk"] + "-"
|
||||||
|
|
||||||
ccache_path = os.environ.get("CCACHE")
|
env["CC"] = ccache_path + basecmd + "cc"
|
||||||
if ccache_path is None:
|
env["CXX"] = ccache_path + basecmd + "c++"
|
||||||
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["AR"] = basecmd + "ar"
|
env["AR"] = basecmd + "ar"
|
||||||
env["RANLIB"] = basecmd + "ranlib"
|
env["RANLIB"] = basecmd + "ranlib"
|
||||||
env["AS"] = basecmd + "as"
|
env["AS"] = basecmd + "as"
|
||||||
|
|||||||
Reference in New Issue
Block a user