从存储库(编译)来源$ C ​​$ c未放置在变量dir来分层SCons的项目 [英] Source code compiled from a Repository() is not put in the variant dir for a Hierarchical SCons project

查看:159
本文介绍了从存储库(编译)来源$ C ​​$ c未放置在变量dir来分层SCons的项目的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个使用源$ C ​​$ C从一个普通的系统目录下的分层式项目,我现在用的是使用SCons为其库()功能,希望所有的建设放在variant_dir输出(本地code和从仓库取code)。

I have a Hierarchical project that uses source code from a common system-directory, for which I am using the SCons Repository() function and want all the build output (local code and code taken from the Repository) placed in a variant_dir.

如果我使用库()在一个简单的场景(非hierchical一起子目录SConscripts没有呼叫)功能,然后编译库()目标文件放置在variant_dir如预期。但是,如果我做相同的分层构建,编译库()目标文件放置在项目的根目录。

If I use the Repository() function in a simple scenario (non-hierchical with no calls to sub-directory SConscripts) then the compiled Repository() object file is placed in the variant_dir as expected. But if I do the same in a hierarchical build, the compiled Repository() object file is placed in the project root directory.

假设我想使用位于系统目录下面的源$ C ​​$ C:

Assuming I want to use the following source code located in a system-directory:

/usr/local/repoDir/repoFile.cc

和我有以下项目结构:

# tree .
.
|-- SConstruct
|-- build
|   `-- linux_x86_64
`-- moduleA
    |-- localFile.cc
    `-- SConscript

下面是构建脚本:

SConstruct

SConstruct

编辑:删除了调用文件名库(),从users@scons.tigris.org感谢德克Baechle指出了这一点。

Removed filename from call to Repository(), thanks to Dirk Baechle from users@scons.tigris.org for pointing that out.

env = Environment()

env.Repository('/usr/local/repoDir')

env['variantDir'] = 'build/linux_x86_64'

SConscript('moduleA/SConscript',
           exports = ['env'],
           variant_dir = env['variantDir'],
           duplicate = 0)

moduleA / SConscript

moduleA/SConscript

import os

Import('env')

srcFiles = [
  'localFile.cc',
  #os.path.join(env['variantDir'], 'repoFile.cc'),          # fails to find source file
  #'#%s' % os.path.join(env['variantDir'], 'repoFile.cc'),  # fails to find source file
  #'repoFile.cc',                                           # fails to find source file
  '#repoFile.cc',  # only option that works, but places object in root proj dir
]

env.Append(CPPPATH = ['.', '#'])
env.Program(target = 'myApp', source = srcFiles)

我想 repoFile.cc 文件进行编译和有目标文件放在建立/ linux_x86_64 ,而是其放置在相同的目录中的根SConstruct

I would like the repoFile.cc file to be compiled and have its object file placed in build/linux_x86_64, but instead its placed in the same directory as the root SConstruct.

正如你可以从 moduleA / SConscript 的意见看,我想引用 repoFile.cc 若干不同方式,并且只有工作是如其中所提到的方式。此外,我试图调用库()功能 moduleA / SConscript ,但它没有任何改变。

As you can see from the comments in moduleA/SConscript, I tried referencing the repoFile.cc several different ways, and the only way that worked is as mentioned therein. Additionally, I tried calling the Repository() function in moduleA/SConscript, but it didnt change anything.

修改:这是编译输出

# scons
scons: Reading SConscript files ...
scons: done reading SConscript files.
scons: Building targets ...
g++ -o repoFile.o -c -Ibuild/linux_x86_64 -ImoduleA -I/usr/local/repoDir/moduleA -I/usr/local/repoDir/build/linux_x86_64 -I. -I/usr/local/repoDir /usr/local/repoDir/repoFile.cc
g++ -o build/linux_x86_64/localFile.o -c -Ibuild/linux_x86_64 -ImoduleA -I/usr/local/repoDir/moduleA -I/usr/local/repoDir/build/linux_x86_64 -I. -I/usr/local/repoDir moduleA/localFile.cpp
g++ -o build/linux_x86_64/myApp build/linux_x86_64/localFile.o repoFile.o
scons: done building targets.

和生成的目录结构:

# tree .
.
|-- repoFile.o    <=== This file should be in build/linux_x86_64 NOT here
|-- SConstruct
|-- build
|   `-- linux_x86_64
|       |-- localFile.o
|       `-- myApp
`-- moduleA
    |-- localFile.cpp
    `-- SConscript

我查了一下四周,发现这一点,但它不是完全一样的:

I checked around and found this, but its not quite the same:

使用SCons分层构建与资源库目录

任何建议,我怎么能得到目标文件在正确的地方?

Any suggestions as to how I can get the object file in the right place?

推荐答案

我问在SCons的用户邮件列表同样的问题,并得到了一些信息部分回答了这个问题。由于德克Baechle 帮助我这个问题。

I asked this same question on the SCons-users mailing list, and received some information that partly answers this question. Thanks to Dirk Baechle for helping me with this issue.

库()功能,有效坐骑的传递给SCons的项目的根目录:就是所在的目录 SConstruct 文件。如果需要在SCons的项目子目录中引用,在回购子目录文件,然后子目录的名称(即回购目录和scons的项目目录中)必须匹配。这就是为什么在上面的 SConscript不同选项的问题文件找不到回购的文件。

The Repository() function effectively mounts the directory passed in to the root of the SCons project: that is to the directory where the SConstruct file is. If files in a repo sub-directory need to be referenced in sub-directories of the SCons project, then the sub-directory names (that of the repo dir and scons project dir) must match. That's why the different options in the SConscript file in the question above fail to find the repo file.

如果回购子目录 moduleA 的文件 repoFile.cc 存在,那么它会被发现的预期和编译对象将被放置在预期的variant_dir。

If the repo sub-directory moduleA existed with the file repoFile.cc, then it would be found as expected and the compiled object would be placed in the variant_dir as expected.

一个限制我看到的库()的功能是,你不能的安装的回购目录到SCons的项目子目录。这听起来像一个功能请求。

One limitation I see to the Repository() function is that you can't mount the repo directory to a SCons project sub-directory. This sounds like a feature request.

这SCons的地方编译对象文件中的源目录的事实似乎是我的错误。最起码,应放置在variant_dir根目录中。

The fact that SCons places the compiled object file in the source directory seems like a bug to me. At the very least, it should be placed in the variant_dir root directory.

这篇关于从存储库(编译)来源$ C ​​$ c未放置在变量dir来分层SCons的项目的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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