| 1 |
project('very long command lines', 'c') |
| 2 |
|
| 3 |
# Get the current system's commandline length limit. |
| 4 |
if build_machine.system() == 'windows' |
| 5 |
# Various limits on windows: |
| 6 |
# cmd.exe: 8kb |
| 7 |
# CreateProcess: 32kb |
| 8 |
limit = 32767 |
| 9 |
# NOTE: filename limit is 260 characters unless |
| 10 |
# 1. Python >= 3.6 is being used |
| 11 |
# 2. Windows 10 registry has been edited to enable long pathnames |
| 12 |
# ninja backend uses absolute filenames, so we ensure they don't exceed 260. |
| 13 |
elif build_machine.system() == 'cygwin' |
| 14 |
# cygwin-to-win32: see above |
| 15 |
# cygwin-to-cygwin: no limit? |
| 16 |
# Cygwin is slow, so only test it lightly here. |
| 17 |
limit = 8192 |
| 18 |
else |
| 19 |
# ninja passes whole line as a single argument, for which |
| 20 |
# the limit is 128k as of Linux 2.6.23. See MAX_ARG_STRLEN. |
| 21 |
# BSD seems similar, see https://www.in-ulm.de/~mascheck/various/argmax |
| 22 |
limit = 131072 |
| 23 |
endif |
| 24 |
# Now exceed that limit, but not so far that the test takes too long. |
| 25 |
namelen = 260 |
| 26 |
nfiles = 50 + limit / namelen |
| 27 |
message('Expected link commandline length is approximately ' + '@0@'.format((nfiles * (namelen+28)))) |
| 28 |
|
| 29 |
seq = run_command('name_gen.py', nfiles.to_string(), meson.build_root(), check: true).stdout().strip().split('\n') |
| 30 |
|
| 31 |
sources = [] |
| 32 |
codegen = find_program('codegen.py') |
| 33 |
|
| 34 |
i=0 |
| 35 |
foreach name : seq |
| 36 |
sources += custom_target('codegen' + i.to_string(), |
| 37 |
command: [codegen, i.to_string(), '@OUTPUT@'], |
| 38 |
output: name + '.c') |
| 39 |
i+=1 |
| 40 |
endforeach |
| 41 |
|
| 42 |
shared_library('sharedlib', sources) |
| 43 |
static_library('staticlib', sources) |
| 44 |
executable('app', 'main.c', sources) |
| 45 |
|
| 46 |
# Also test short commandlines to make sure that doesn't regress |
| 47 |
shared_library('sharedlib0', sources[0]) |
| 48 |
static_library('staticlib0', sources[0]) |
| 49 |
executable('app0', 'main.c', sources[0]) |