我不确定为什么你需要创建一个自定义构建器,如果我理解正确的话,我认为你需要的一切都可以使用 SCons 及其内置构建器来完成。
为了执行您所解释的操作,您确实需要 3 个单独的 SConstruct 文件,以便能够进行 3 个单独的构建。我还将添加 3 个 SConscript 文件并将它们全部制作如下:
Edit:在此示例中,最好在 SConstruct 脚本中创建 Environment()
项目根目录/SConstruct
# This SConstruct orchestrates building 3 subdirs
import os
subdirs = ['libfoo_subrepo', 'barapp_subrepo', 'test']
env = Environment()
for subdir in subdirs:
SConscript(os.path.join(subdir, 'SConscript'), exports = ['env'])
libfoo_subrepo/SConstruct
# This SConstruct does nothing more than load the SConscript in this dir
# The Environment() is created in the SConstruct script
# This dir can be built standalone by executing scons here, or together
# by executing scons in the parent directory
env = Environment()
SConscript('SConscript', exports = ['env'])
libfoo_subrepo/SConscript
# This SConstruct orchestrates building 2 subdirs
import os
Import('env')
subdirs = ['src', 'test']
for subdir in subdirs:
SConscript(os.path.join(subdir, 'SConscript'), exports = ['env'])
barapp_subrepo/SConstruct
# This SConstruct does nothing more than load the SConscript in this dir
# The Environment() is created in the SConstruct script
# This dir can be build standalone by executing scons here, or together
# by executing scons in the parent directory
env = Environment()
SConscript('SConscript', exports = ['env'])
barapp_subrepo/SConscript
# This SConstruct orchestrates building 2 subdirs
import os
Import('env')
subdirs = ['src', 'test']
for subdir in subdirs:
SConscript(os.path.join(subdir, 'SConscript'), exports = ['env'])
我希望每个文件中的注释都能解释其目的。
希望这可以帮助。