Build SCON和从根目录和子目录生成

Build SCON和从根目录和子目录生成,build,scons,Build,Scons,我正在尝试烤饼,但在安排时遇到了问题。我有两个相关项目,一个是生产代码,另一个是按照以下方式安排的测试: 根 根/生产 根/单元测试 我想配置我的构建,以便键入: SCON-从根目录到构建两者 从生产到仅生成生产代码的SCON 从单元测试到仅构建单元测试的SCON 现在我该怎么做呢? 如果我在根目录下有SConstruct,在生产和单元测试中有SConscript,我只能从根目录下构建。但如果我在每一级都有SConscript,Root的SConscript调用subdirs中的SConsc

我正在尝试烤饼,但在安排时遇到了问题。我有两个相关项目,一个是生产代码,另一个是按照以下方式安排的测试:

  • 根/生产
  • 根/单元测试
我想配置我的构建,以便键入:

  • SCON-从根目录到构建两者
  • 从生产到仅生成生产代码的SCON
  • 从单元测试到仅构建单元测试的SCON
  • 现在我该怎么做呢? 如果我在根目录下有SConstruct,在生产和单元测试中有SConscript,我只能从根目录下构建。但如果我在每一级都有SConscript,Root的SConscript调用subdirs中的SConscript:

        # Just call Sconscripts for src and unitTests
        SConscript('production/SConstruct')
        SConscript('unitTests/SConstruct')
    

    然后,虽然它确实按照预期构建,但它会发出大量关于为目标(…)指定了两个不同环境的警告。。在这种情况下,生产和测试之间的构建确实非常相似,但一旦我让SCON按我所希望的方式工作,我就会转而管理一系列不一定相关的更大项目

    我建议在每个目录中使用一个sconstuct,在每个目录中使用一个SConscript。SConstruct脚本只需调用SConscripts,所有的逻辑都在这里。大概是这样的:

    Root/SConstruct
    Root/Production/SConstruct
    Root/Production/SConscript
    Root/UnitTests/SConstruct
    Root/UnitTests/SConscript
    
    每个文件的内容可以如下:

    根目录/SConstruct

    env = Environment()
    
    # build stuff in this dir
    
    # now call subdir SConscripts
    SConscript('Root/Production/SConscript', exports='env')
    SConscript('Root/UnitTests/SConscript',  exports='env')
    
    env = Environment()
    
    SConscript('SConscript', exports='env')
    
    # This SConscript will be called either from the Root/SConstruct
    # or Root/Production/SConstruct
    
    Import('env')
    
    # Build stuff here
    
    env = Environment()
    
    SConscript('SConscript', exports='env')
    
    # This SConscript will be called either from the Root/SConstruct
    # or Root/UnitTests/SConstruct
    
    Import('env')
    
    # Build stuff here
    
    Root/Production/SConstruct

    env = Environment()
    
    # build stuff in this dir
    
    # now call subdir SConscripts
    SConscript('Root/Production/SConscript', exports='env')
    SConscript('Root/UnitTests/SConscript',  exports='env')
    
    env = Environment()
    
    SConscript('SConscript', exports='env')
    
    # This SConscript will be called either from the Root/SConstruct
    # or Root/Production/SConstruct
    
    Import('env')
    
    # Build stuff here
    
    env = Environment()
    
    SConscript('SConscript', exports='env')
    
    # This SConscript will be called either from the Root/SConstruct
    # or Root/UnitTests/SConstruct
    
    Import('env')
    
    # Build stuff here
    
    Root/Production/SConscript

    env = Environment()
    
    # build stuff in this dir
    
    # now call subdir SConscripts
    SConscript('Root/Production/SConscript', exports='env')
    SConscript('Root/UnitTests/SConscript',  exports='env')
    
    env = Environment()
    
    SConscript('SConscript', exports='env')
    
    # This SConscript will be called either from the Root/SConstruct
    # or Root/Production/SConstruct
    
    Import('env')
    
    # Build stuff here
    
    env = Environment()
    
    SConscript('SConscript', exports='env')
    
    # This SConscript will be called either from the Root/SConstruct
    # or Root/UnitTests/SConstruct
    
    Import('env')
    
    # Build stuff here
    
    Root/UnitTests/SConstruct

    env = Environment()
    
    # build stuff in this dir
    
    # now call subdir SConscripts
    SConscript('Root/Production/SConscript', exports='env')
    SConscript('Root/UnitTests/SConscript',  exports='env')
    
    env = Environment()
    
    SConscript('SConscript', exports='env')
    
    # This SConscript will be called either from the Root/SConstruct
    # or Root/Production/SConstruct
    
    Import('env')
    
    # Build stuff here
    
    env = Environment()
    
    SConscript('SConscript', exports='env')
    
    # This SConscript will be called either from the Root/SConstruct
    # or Root/UnitTests/SConstruct
    
    Import('env')
    
    # Build stuff here
    
    Root/UnitTests/SConscript

    env = Environment()
    
    # build stuff in this dir
    
    # now call subdir SConscripts
    SConscript('Root/Production/SConscript', exports='env')
    SConscript('Root/UnitTests/SConscript',  exports='env')
    
    env = Environment()
    
    SConscript('SConscript', exports='env')
    
    # This SConscript will be called either from the Root/SConstruct
    # or Root/Production/SConstruct
    
    Import('env')
    
    # Build stuff here
    
    env = Environment()
    
    SConscript('SConscript', exports='env')
    
    # This SConscript will be called either from the Root/SConstruct
    # or Root/UnitTests/SConstruct
    
    Import('env')
    
    # Build stuff here
    
    请注意,SConscript脚本不会创建
    环境()
    ,而是使用从根/SConstruct传入的环境,或者使用同一目录中的SConstruct


    还考虑使用<代码> ValuthIdir < /Code >参数,使用<代码> SCONScript()/<代码>函数调用,将所有生成输出放在除了代码目录结构之外的目录结构中。这样做时,还要考虑使用<代码>重复= 0 参数,使用<代码> SCONScript()/<代码>函数调用。SConscript函数很详细,并且。

    @Puchatek,很乐意帮助:)