From 34ef1043ee1783f8ab20e74a8f883a235a96d629 Mon Sep 17 00:00:00 2001 From: Fabio Alessandrelli Date: Wed, 14 Feb 2024 22:21:57 +0100 Subject: [Linux] Add arm32/arm64 linux builds support Fix arch detection in GDNative builds (3.x) and add a small patch to avoid warnings spam on ARM. Make CMake march flags explicit for Linux arm32/arm64. Add new platforms to CI. --- SConstruct | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) (limited to 'SConstruct') diff --git a/SConstruct b/SConstruct index c77b469..54ecca5 100644 --- a/SConstruct +++ b/SConstruct @@ -12,7 +12,11 @@ def add_sources(sources, dirpath, extension): def replace_flags(flags, replaces): for k, v in replaces.items(): - if k in flags: + if k not in flags: + continue + if v is None: + flags.remove(k) + else: flags[flags.index(k)] = v @@ -33,11 +37,11 @@ if env["godot_version"] == "3": if "platform" in ARGUMENTS and ARGUMENTS["platform"] == "macos": ARGUMENTS["platform"] = "osx" # compatibility with old osx name - env = SConscript("godot-cpp-3.x/SConstruct") + cpp_env = SConscript("godot-cpp-3.x/SConstruct") # Patch base env replace_flags( - env["CCFLAGS"], + cpp_env["CCFLAGS"], { "-mios-simulator-version-min=10.0": "-mios-simulator-version-min=11.0", "-miphoneos-version-min=10.0": "-miphoneos-version-min=11.0", @@ -46,7 +50,7 @@ if env["godot_version"] == "3": }, ) - env = env.Clone() + env = cpp_env.Clone() if env["target"] == "debug": env.Append(CPPDEFINES=["DEBUG_ENABLED"]) @@ -64,7 +68,7 @@ if env["godot_version"] == "3": # Normalize suffix if env["platform"] in ["windows", "linux"]: - env["arch"] = "x86_32" if env["bits"] == "32" else "x86_64" + env["arch"] = ARGUMENTS.get("arch", "x86_32" if env["bits"] == "32" else "x86_64") env["arch_suffix"] = env["arch"] elif env["platform"] == "macos": env["arch"] = env["macos_arch"] @@ -96,6 +100,10 @@ if env["godot_version"] == "3": elif not env["use_mingw"]: # Mark as MSVC build (would have failed to build the library otherwise). env["is_msvc"] = True + # Some linux specific hacks to allow cross-compiling for non-x86 machines. + if env["platform"] == "linux" and env["arch"] not in ("x86_32", "x86_64"): + for flags in (env["CCFLAGS"], env["LINKFLAGS"], cpp_env["CCFLAGS"], cpp_env["LINKFLAGS"]): + replace_flags(flags, {"-m32": None, "-m64": None}) elif env["godot_version"] == "4.0": env = SConscript("godot-cpp-4.0/SConstruct").Clone() else: -- cgit v1.2.3