How to force Scons output (exe, obj, lib & dll) to specific build directory?

后端 未结 4 1268
滥情空心
滥情空心 2020-12-18 23:07

I\'ve been trying to get scons to output exe, obj, lib and dll files to a specific build directory.

My file structure looks like this:

/projectdir
          


        
4条回答
  •  轮回少年
    2020-12-18 23:44

    It's not that tough to get VariantDir working using only one SConstruct file (for a small project), but it's very confusing as the configuration is different for the one-file and two-file use case.

    Only SConstruct:

    env = Environment()
    env.VariantDir('build', 'src', duplicate=0)
    files = Glob('build\*.c')
    env.Program("build\program", files)
    

    Notice how the source files are located in .\src but .\build is specified as the location. The output has to be also "prefixed" with .\build otherwise the compiled program will reside in the directory of the SConstruct file.

    When you execute the script SCons will compile the *.c files from .\src and put the resulting objects to .\build.

    No wonder they renamed BuildDir to VariantDir to try to avoid the confusion (without much success).

提交回复
热议问题