如何强制 Scons 输出(exe、obj、lib 和 dll)到特定的构建目录? [英] How to force Scons output (exe, obj, lib & dll) to specific build directory?

查看:65
本文介绍了如何强制 Scons 输出(exe、obj、lib 和 dll)到特定的构建目录?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在尝试让 scons 将 exe、obj、lib 和 dll 文件输出到特定的构建目录.

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

我的文件结构如下:

/projectdir
  /build
    /bin
    /obj
  /source
    /subdirs
    /..
  SConstruct

基本上,我现在得到的是我的源目录被 obj 文件污染了.我宁愿将所有内容都集中在一个地方.

Basically, what I get now is my source directory is getting polluted with obj files. I'd rather have it all in one place.

SConstruct 文件如下所示:

The SConstruct file looks like this:

env.VariantDir('build', 'source', duplicate = 0)
env.Program('Hierarchy', source = ['source/sconstest.cpp', 'source/utils/IntUtil.cpp'])

推荐答案

我发现的最简单的方法是使用 2 个文件,一个 SConstruct 文件和一个单独的 SConscript.

The easiest way I've found is to use 2 files, a SConstruct file and a separate SConscript.

在 SConstruct 中,您只需调用另一个文件并指定构建输出的目录:

In the SConstruct you simply call the other file and specify the directory for the build output:

# content SConstruct
SConscript('main.scons', variant_dir='build', duplicate=0)

然后在main.scons"中,您完成构建的主要内容.您可以忘记此文件中的变体目录.

Then in 'main.scons' you do the meat of your build. You can forget about variant directories in this file.

# content of main.scons
env = Environment()
env.Program('Hierarchy',
            source = ['source/sconstest.cpp', 'source/utils/IntUtil.cpp'])

这篇关于如何强制 Scons 输出(exe、obj、lib 和 dll)到特定的构建目录?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆