使用 SCons 创建分层构建 [英] Creating a Hierarchical Build with SCons

查看:37
本文介绍了使用 SCons 创建分层构建的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个库项目,在子文件夹中包含一些示例.

I have a library project that contains some samples in a subfolder.

库本身有一个 SConstruct 文件,每个示例都有自己的文件夹和自己的 SConstruct 文件.

The library itself has a SConstruct file and each sample has its own folder and its own SConstruct file.

我想向主(根)SConstruct 文件添加一个目标,这将允许我像往常一样编译库和所有示例.

I'd like to add a target to the main (root) SConstruct file which would allow me to compile the library as usual, and all the samples, at once.

是否有针对此的现有机制/构建器?

Is there an existing mechanism/builder for this ?

P.S:我不想只有一个大的 SConstruct 文件,因为我希望示例文件夹保持独立.

P.S: I don't want to have only one big SConstruct file because I want the samples folders to remain independant.

推荐答案

http://www.scons.org/doc/production/HTML/scons-man.html

创建分层构建

注意指定的文件名在子目录的 SConscript 文件中相对于该子目录.

Notice that the file names specified in a subdirectory's SConscript file are relative to that subdirectory.

S构造:

env = Environment()
env.Program(target = 'foo', source = 'foo.c')

SConscript('sub/SConscript')

sub/SConscript:

sub/SConscript:

env = Environment()
# Builds sub/foo from sub/foo.c
env.Program(target = 'foo', source = 'foo.c')

SConscript('dir/SConscript')

sub/dir/SConscript:

sub/dir/SConscript:

env = Environment()
# Builds sub/dir/foo from sub/dir/foo.c
env.Program(target = 'foo', source = 'foo.c')

这篇关于使用 SCons 创建分层构建的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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