回复: Ninja compilation f ails after using include path file instead of "-I" option

liruncong2018 via Scons-users <[email protected]>
Newsgroups gmane.comp.programming.tools.scons.user
Message-ID <[email protected]>
The "TEMPFILE" function should be improved to improve compilation efficiency. At present, we have tested our actual project and changed "@file" to "TEMPFILE". When ninja is not enabled, the compilation time (j32) is increased from 3:45 to 6:30. The duration has increased by almost 3 minutes, which should be related to the massive creation of temporary files. If put "-o $TARGET" and "$SOURCE" directly on the command line without writing temporary files, the number of temporary files generated in large numbers can be as few as 2~3.




------------------&nbsp;原始邮件&nbsp;------------------
发件人:                                                                                                                        "SCons users mailing list"                                                                                    <[email protected]&gt;;
发送时间:&nbsp;2022年4月10日(星期天) 凌晨2:31
收件人:&nbsp;"SCons users mailing list"<[email protected]&gt;;

主题:&nbsp;Re: [Scons-users] Ninja compilation fails after using include path file instead of "-I" option



Daniel,


Is it likely we should define TEMPFILE for mingw as we do for win32?


-Bill



On Sat, Apr 9, 2022 at 12:39 AM Daniel Moody <[email protected]&gt; wrote:

hello liruncong,

You can not directly use the&nbsp;@ 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&nbsp;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):
&nbsp; &nbsp; &nbsp;env.Depends(objs, [incPathsFile])
&nbsp; &nbsp; &nbsp;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):
+ &nbsp; &nbsp;arg = quote_spaces(arg)
+ &nbsp; &nbsp;return arg.replace('\\', '/')
+env["TEMPFILEARGESCFUNC"] = tempfile_arg_esc_func
+
+#incPathsFile = GenIncPathsFile(env, objs)
+#env["_CPPINCFLAGS"] = "@%s" % (incPathsFile)

&nbsp;# make a building
&nbsp;DoBuilding(TARGET, objs)







On Fri, Apr 8, 2022 at 7:23 PM liruncong2018 via Scons-users <[email protected]&gt; wrote:


git repository:&nbsp;https://github.com/liruncong/NinJaTest.git&nbsp;bsp: beaglebone
mingw:&nbsp;https://download-sh-cmcc.rt-thread.org:9151/www/aozima/env_released_1%20.2.0.7z&nbsp;gcc position : env\tools\gnu_gcc\arm_gcc\mingw\bin
python: 3.8.5(anaconda)
platform: win11
scons:&nbsp;https://github.com/SCons/scons.git

Directly using the "scons" command can compile successfully, but using "scons --experimental=ninja" will fail to compile.&nbsp;Ninja compilation fails after using include path file instead of "-I" option · Issue #4130 · SCons/scons (github.com)

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" option.


_______________________________________________
 Scons-users mailing list
 [email protected]
 https://pairlist4.pair.net/mailman/listinfo/scons-users
 
 _______________________________________________
 Scons-users mailing list
 [email protected]
 https://pairlist4.pair.net/mailman/listinfo/scons-users

_______________________________________________
Scons-users mailing list
[email protected]
https://pairlist4.pair.net/mailman/listinfo/scons-users
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.