[Scons-users] StaticLibrary problems
Mats Wichmann
mats at wichmann.us
Fri Aug 30 16:59:46 EDT 2024
To follow up, for the testcase I hacked together, which was about 500
trivial source files (and a 10.000 char command line), it definitely
failed if I forced the toolchain to be mingw. By adding a revised
version of the $ARCOM variable we can get a command file to be created,
and be passed to ar, but this failed due to the backslashes in pathnames
in the file, which ar doesn't like. So an extra step was needed to get
the file contents translated, for which there's a recipe in the manpage at:
https://scons.org/doc/production/HTML/scons-man.html#cv-TEMPFILEARGESCFUNC
So with this SConstruct my test builds the archive without complaint,
with the actual issued command sequence looking like this:
scons: Building targets ...
Using tempfile C:\Users\mats\AppData\Local\Temp\tmp6eo3tx2i.lnk for
command line:
ar rc libboo.a src/lib/00gsd.o src/lib/015r89p3.o src/lib/04mj84.o
src/lib/06uml3.o ... [lots snipped]
ar @C:\Users\mats\AppData\Local\Temp\tmp6eo3tx2i.lnk
ranlib libboo.a
scons: done building targets.
And the SConstruct:
import sys
import re
from SCons.Subst import quote_spaces
WINPATHSEP_RE = re.compile(r"\\([^\"'\\]|$)")
def escaper(arg):
arg = quote_spaces(arg)
if sys.platform != "win32":
return arg
return WINPATHSEP_RE.sub(r"/\1", arg)
env = Environment(CPPPATH='src/include', tools=["mingw"])
env.Replace(ARCOM="${{TEMPFILE('{0}', '')}}".format(env['ARCOM']))
env.Replace(TEMPFILEARGESCFUNC=escaper)
env.StaticLibrary(target='boo', source=Glob('src/lib/*.c'))
Hope this provides some help getting you back on the air...
More information about the Scons-users
mailing list