[Scons-dev] Bug in MSVC_BATCH handling
Eric Fahlgren
ericfahlgren at gmail.com
Sun Dec 15 12:13:09 EST 2019
Py 3.7 64, Win 10 64
SCons 3.1.1 (but same as master in this case)
While cleaning up some old scripts, I uncovered a bug that I've been
working around for who knows how long and finally isolated it.
Problem: When MSVC_BATCH is enabled globally, files with different target
name are built individually, but ignoring the specified $TARGET name.
Here's a little example, note the first argument to the "cl" output.
Input:
env = Environment(MSVC_BATCH=True)
bug32 = env.Object(target='file32', source='file.cpp')
Output:
cl /FoWIN32\src\\ /c WIN32\src\file.cpp
If you explicitly suppress batching in the Object, then it works fine.
Input:
obj32 = env.Object(target='file32', source='file.cpp', MSVC_BATCH=False)
Output:
cl /FoWIN32\src\file32.obj /c WIN32\src\file.cpp
I chased this to the logic in Tool.msvc, the function msvc_output_flag
where it's checking the state of the MSVC_BATCH variable, and ignores the
difference in base name that the function just above (msvc_batch_key)
performs, see lines 168-173. My hack, which seems to work, is to change
line 191 in msvc.py from:
191: if 'MSVC_BATCH' not in env or env.subst('$MSVC_BATCH') in ('0', '
False', '', None):
to use the already-working logic in the batch key function like this:
191: if msvc_batch_key(None, env, target, source) is None:
I tried it on single file and multi-file compilations, and from my cursory
playing around, this keeps the batched files together and separates out
those with different target base names, but then I didn't try all cases or
check any other downstream code in the pipeline to see if this would break
anything there...
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://pairlist2.pair.net/pipermail/scons-dev/attachments/20191215/3f5dbf0e/attachment.html>
More information about the Scons-dev
mailing list