[Scons-users] expanding $_CPPINCFLAGS with quoting of directory names containing spaces
Karl Ostmo
kostmo at gmail.com
Fri Aug 8 18:58:34 EDT 2014
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/20140808/7abf08f9/attachment.html>
More information about the Scons-users
mailing list