[Scons-users] Ninja compilation fails after using include path file instead of "-I" option
Daniel Moody
dmoody256 at gmail.com
Sat Apr 9 03:38:41 EDT 2022
hello liruncong,
You can not directly use the @ response file syntax with ninja, you should
instead use SCons internal feature for this, TEMPFILE, as the ninja tool
will know how to process that.
TEMPFILE is meant to be substituted in the full command line, here is an
example how to make your CC compile commands use the tempfile:
env['_RT_CCCOM'] = env['CCCOM']
env['CCCOM'] = "${TEMPFILE('$_RT_CCCOM', '$CCCOMSTR')}"
Here is a diff of your project where I am using the response file in scons
and it works with ninja:
diff --git a/bsp/beaglebone/SConstruct b/bsp/beaglebone/SConstruct
index e9eceb553..01c27a83f 100644
--- a/bsp/beaglebone/SConstruct
+++ b/bsp/beaglebone/SConstruct
@@ -56,8 +56,26 @@ def GenIncPathsFile(env, objs):
env.Depends(objs, [incPathsFile])
return incPathsFile
-incPathsFile = GenIncPathsFile(env, objs)
-env["_CPPINCFLAGS"] = "@%s" % (incPathsFile)
+env['_RT_CCCOM'] = env['CCCOM']
+env['CCCOM'] = "${TEMPFILE('$_RT_CCCOM', '$CCCOMSTR')}"
+
+# This is only to see the output command using the response file if
building with scons
+env['CCCOMSTR'] = None
+
+# My system did not hit the limit in order to use response file,
+# so I had to force it to make sure
+# I could see the response files in use by scons
+env['MAXLINELENGTH'] = 10
+
+# This function make the response file use the correct slash for mingw
+from SCons.Subst import quote_spaces
+def tempfile_arg_esc_func(arg):
+ arg = quote_spaces(arg)
+ return arg.replace('\\', '/')
+env["TEMPFILEARGESCFUNC"] = tempfile_arg_esc_func
+
+#incPathsFile = GenIncPathsFile(env, objs)
+#env["_CPPINCFLAGS"] = "@%s" % (incPathsFile)
# make a building
DoBuilding(TARGET, objs)
On Fri, Apr 8, 2022 at 7:23 PM liruncong2018 via Scons-users <
scons-users at scons.org> wrote:
> git repository: https://github.com/liruncong/NinJaTest.git bsp: beaglebone
> mingw:
> https://download-sh-cmcc.rt-thread.org:9151/www/aozima/env_released_1%20.2.0.7z gcc
> position : env\tools\gnu_gcc\arm_gcc\mingw\bin
> python: 3.8.5(anaconda)
> platform: win11
> scons: https://github.com/SCons/scons.git
>
> Directly using the "scons" command can compile successfully, but using
> "scons --experimental=ninja" will fail to compile. Ninja compilation
> fails after using include path file instead of "-I" option · Issue #4130 ·
> SCons/scons (github.com) <https://github.com/SCons/scons/issues/4130>
>
> Due to the length limit of the windows command line, in our actual
> project, the command will exceed the length limit of the windows command
> line, so this test case uses the "@file <https://github.com/file>" option.
>
>
> _______________________________________________
> Scons-users mailing list
> Scons-users at scons.org
> https://pairlist4.pair.net/mailman/listinfo/scons-users
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://pairlist4.pair.net/pipermail/scons-users/attachments/20220409/1220c2bd/attachment.htm>
More information about the Scons-users
mailing list