Chinaunix首页 | 论坛 | 博客
  • 博客访问: 759627
  • 博文数量: 231
  • 博客积分: 3217
  • 博客等级: 中校
  • 技术积分: 2053
  • 用 户 组: 普通用户
  • 注册时间: 2011-07-04 12:01
文章分类

全部博文(231)

文章存档

2015年(1)

2013年(10)

2012年(92)

2011年(128)

分类: LINUX

2012-07-03 14:12:02

Sharing Environments
scons支持export变量从parent的SConstruct到子目录的SCtrucript文件,通过继承共享共同的初始化变量值。
Exporting Variables
有种方法输出变量,比如从SConstruct文件中构建环境变量,可以用到其他SConscript文件中。首先,你可以调用Export函数输出变量,通过调用Export增加一个或者多个变量为全局变量。
env = Environment()
Export(’env’)
你可以export多个变量:
env = Environment()
debug = ARGUMENTS[’debug’]
Export(’env’, ’debug’)
 
Second, you can specify a list of variables to export as a second argument to the SConscript function
call:
SConscript(’src/SConscript’, ’env’)
Or as the exports keyword argument:
SConscript(’src/SConscript’, exports=’env’)
 
These calls export the specified variables to only the listed SConscript files. You may, however, specify
more than one SConscript file in a list:
SConscript([’src1/SConscript’,
’src2/SConscript’], exports=’env’)
 
Importing Variables
如果一个变量已经输出调用SConscript文件,通过调用Import函数可以用在其他的SConscript文件
Import(’env’)
env.Program(’prog’, [’prog.c’])
The Import call makes the env construction environment available to the SConscript file, after which
the variable can be used to build programs, libraries, etc.
 
Like the Export function, the Import function can be used with multiple variable names:
Import(’env’, ’debug’)
env = env.Clone(DEBUG = debug)
env.Program(’prog’, [’prog.c’])
And the Import function will similarly split a string along white-space into separate variable names:
Import(’env debug’)
env = env.Clone(DEBUG = debug)
env.Program(’prog’, [’prog.c’])
 
Lastly, as a special case, you may import all of the variables that have been exported by supplying an asterisk to the Import function:
Import(’*’) 输出所有的已经exported变量
env = env.Clone(DEBUG = debug)
env.Program(’prog’, [’prog.c’])
阅读(2049) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~