我为预编译,编译,汇编和链接程序编写了四个SCons生成器。我的意思是将预编译器输出用于后期编译脚本,而其他三个构建器应构建实际的可执行文件。
如果我不选择预编译器,一切都会很好。
如果添加预编译器,SCons会调用预编译器,然后再链接程序。当然,没有目标文件,链接过程中断。 此外,预处理器的输出放在为编译器输出指定的路径中,因此SCons会忽略VariantDir()给定的输出路径。
我试图以不同的顺序添加构建器,但这似乎无济于事。有任何想法吗?
------------- Preparser -------------------------
builders['preParser'] = Builder(action=Action(preParserCommand),
suffix=".i",
src_suffix=".c",
single_source=1)
currentOutputPath = "C:\\Users\\BLABLUB\\Desktop\\TMP"
tool['preParser'].VariantDir(currentOutputPath, os.path.relpath(ps.sourcePath), duplicate=0)
tool['preParser']["BUILDERS"] = {"run": builders['preParser']}
tool['preParser']["PLATFORM"] = currentTool["arch"]
tool['preParser']["PRINT_CMD_LINE_FUNC"] = print_cmd_line
tool['preParser'].Decider("MD5-timestamp")
------------- Compiler --------------------------
builders[key] = Builder(action=Action(currentCommands[key]["command"]),
suffix=currentCommands[key] ["suffix_target"],
src_suffix=currentCommands[key]["suffix_source"],
single_source=1)
tool[key].VariantDir(os.path.relpath(
outputPaths[key]), os.path.relpath(ps.sourcePath), duplicate=0)
tool[key]["BUILDERS"] = {"run": builders[key]}
tool[key]["PLATFORM"] = currentTool["arch"]
tool[key]["PRINT_CMD_LINE_FUNC"] = print_cmd_line
tool[key].Decider("MD5-timestamp")
continue
------------- Assembler ---------------------------------
...
# compile
targets += tool["compiler"].run(compFileList)
# precompile
targets += tool['preParser'].run(compFileList)
# disassemble
targets += tool["assembler"].run(assemFileList)
# link
finalTargetSuffix = currentCommands["linker"]["suffix_target"]
fTarget = tool["linker"].run(finalTarget + finalTargetSuffix, targets)