Skip to content

Commit 13cf09a

Browse files
committed
Fix shell argument limit
1 parent 714c9e2 commit 13cf09a

File tree

2 files changed

+31
-1
lines changed

2 files changed

+31
-1
lines changed

tools/common_compiler_flags.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,3 +121,6 @@ def generate(env):
121121
elif env["lto"] == "full":
122122
env.Append(CCFLAGS=["-flto"])
123123
env.Append(LINKFLAGS=["-flto"])
124+
125+
if env["platform"] == "linux":
126+
env['ARFLAGS'] = "rcs"

tools/godotcpp.py

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import os
22
import platform
3+
import tempfile
34
import sys
45

56
from SCons.Action import Action
@@ -162,6 +163,23 @@ def scons_generate_bindings(target, source, env):
162163
return None
163164

164165

166+
def _build_static_lib_with_rsp(target, source, env):
167+
target_lib = str(target[0])
168+
rsp_fd, rsp_path = tempfile.mkstemp(suffix=".rsp")
169+
os.close(rsp_fd)
170+
try:
171+
with open(rsp_path, "w") as rsp_file:
172+
for src in source:
173+
rsp_file.write(str(src) + "\n")
174+
ar = env['AR']
175+
arflags = env.get("ARFLAGS", "")
176+
command = "{} {} {} @{}".format(ar, arflags, target_lib, rsp_path)
177+
env.Execute(command)
178+
finally:
179+
os.remove(rsp_path)
180+
return None
181+
182+
165183
platforms = ["linux", "macos", "windows", "android", "ios", "web"]
166184

167185
# CPU architecture options.
@@ -513,6 +531,9 @@ def generate(env):
513531
"GodotCPPDocData": Builder(action=scons_generate_doc_source),
514532
}
515533
)
534+
if env["platform"] == "linux":
535+
env.Append(BUILDERS={"GodotStaticLibRspBuilder": Builder(action=Action(_build_static_lib_with_rsp, "$ARCOMSTR"))})
536+
516537
env.AddMethod(_godot_cpp, "GodotCPP")
517538

518539

@@ -547,7 +568,13 @@ def _godot_cpp(env):
547568
library_name = "libgodot-cpp" + env["suffix"] + env["LIBSUFFIX"]
548569

549570
if env["build_library"]:
550-
library = env.StaticLibrary(target=env.File("bin/%s" % library_name), source=sources)
571+
if env["platform"] == "linux":
572+
# Use a custom builder to aggregate object files into a static library using a temporary response file.
573+
# This avoids hitting the shell argument limit.
574+
library = env.GodotStaticLibRspBuilder(target=env.File("bin/%s" % library_name), source=env.Object(sources))
575+
else:
576+
library = env.StaticLibrary(target=env.File("bin/%s" % library_name), source=sources)
577+
551578
env.NoCache(library)
552579
default_args = [library]
553580

0 commit comments

Comments
 (0)