[Scons-users] expanding $_CPPINCFLAGS with quoting of directory names containing spaces

Kenny, Jason L jason.l.kenny at intel.com
Mon Aug 11 11:41:43 EDT 2014


I believe all you need to do is this:

env[‘CXXCOM’ ]  = '${TEMPFILE("$CXX -o $TARGET -c $CXXFLAGS $CCFLAGS $_CCCOMCOM $SOURCES $CCARCHFLAGS")}'

Jason

From: Scons-users [mailto:scons-users-bounces at scons.org] On Behalf Of Karl Ostmo
Sent: Friday, August 8, 2014 5:59 PM
To: SCons users mailing list
Subject: [Scons-users] expanding $_CPPINCFLAGS with quoting of directory names containing spaces

We are working around an issue of the command-line invocation of the compiler being too long for Windows.

The compiler provides a mechanism to offload command-line arguments to a file.  The path to the arguments file is supplied to the compiler with a @ symbol prefixed.

As an example, this command:
gcc my_source_file.c -o my_compiled_binary.o -Isome_include_dir -Ianother_include_dir

Could be rewritten as this:
gcc my_source_file.c -o my_compiled_binary.o @my_arguments.args

Where "my_arguments.args" contains this:
 -Isome_include_dir -Ianother_include_dir


I've written a Builder that writes the content of the $_CPPINCFLAGS variable to a file, then supplies that file to the compiler.  To obtain the interpolated value of $_CPPINCFLAGS, I used env.subst("$_CPPINCFLAGS").
The problem arises when one of the directory names in the CPPPATH contains spaces.  Before the conversion of this Builder to make use of a @my_arguments.args file, the CPPPATH entries that contained spaces were properly quoted on the command line.
For example, with CPPPATH entries named "some include dir" and "another_include_dir", the final shell command appeared as:

gcc my_source_file.c -o my_compiled_binary.o -I"some include dir" -Ianother_include_dir

However, when expanded via the env.subst() function, the quotes are not inserted.  Instead, I see this as the output to env.subst("$_CPPINCFLAGS"):
 -Isome include dir -Ianother_include_dir


In this case, the words "include" and "dir" are interpreted by the compiler as independent command-line arguments, resulting in an error.  How can I expand the value of $_CPPINCFLAGS in a way that preserves the space-quoting behavior?

Thanks,
Karl
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://four.pairlist.net/pipermail/scons-users/attachments/20140811/b3c1e709/attachment.html>


More information about the Scons-users mailing list