aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDan Kegel <dank@kegel.com>2020-06-01 19:04:16 -0700
committerDan Kegel <dank@kegel.com>2020-06-05 14:15:32 -0700
commit10e6a989ba337e931ad7abae8d960ee9dc0a0b1d (patch)
tree602461b4fe9ee159b8ab9f471dcf43dffe1ab2e7
parent877dcdbccad25ed496b7b2d6221e7daf94cfd3da (diff)
downloadmeson-10e6a989ba337e931ad7abae8d960ee9dc0a0b1d.zip
meson-10e6a989ba337e931ad7abae8d960ee9dc0a0b1d.tar.gz
meson-10e6a989ba337e931ad7abae8d960ee9dc0a0b1d.tar.bz2
ninja: response file threshold now more accurate, overridable, portable.
-rw-r--r--mesonbuild/backend/ninjabackend.py22
1 files changed, 20 insertions, 2 deletions
diff --git a/mesonbuild/backend/ninjabackend.py b/mesonbuild/backend/ninjabackend.py
index 1686a5d..08fe092 100644
--- a/mesonbuild/backend/ninjabackend.py
+++ b/mesonbuild/backend/ninjabackend.py
@@ -86,8 +86,26 @@ else:
execute_wrapper = []
rmfile_prefix = ['rm', '-f', '{}', '&&']
-# a conservative estimate of the command-line length limit on windows
-rsp_threshold = 4096
+def get_rsp_threshold():
+ '''Return a conservative estimate of the commandline size in bytes
+ above which a response file should be used. May be overridden for
+ debugging by setting environment variable MESON_RSP_THRESHOLD.'''
+
+ if mesonlib.is_windows():
+ # Usually 32k, but some projects might use cmd.exe,
+ # and that has a limit of 8k.
+ limit = 8192
+ else:
+ # On Linux, ninja always passes the commandline as a single
+ # big string to /bin/sh, and the kernel limits the size of a
+ # single argument; see MAX_ARG_STRLEN
+ limit = 131072
+ # Be conservative
+ limit = limit / 2
+ return int(os.environ.get('MESON_RSP_THRESHOLD', limit))
+
+# a conservative estimate of the command-line length limit
+rsp_threshold = get_rsp_threshold()
# ninja variables whose value should remain unquoted. The value of these ninja
# variables (or variables we use them in) is interpreted directly by ninja