2
0
mirror of https://gitlab.com/ita1024/waf.git synced 2024-11-22 18:07:12 +01:00
waf/docs/book/examples/scenarios_expansion/wscript
2013-12-24 15:32:09 +01:00

45 lines
1.0 KiB
Python

#! /usr/bin/env python
# encoding: utf-8
# Thomas Nagy, 2006-2010 (ita)
"""
Add a task generator method that will expand ${} expressons from various
attributes such as includes, target, source, etc
"""
VERSION='0.0.1'
APPNAME='cc_test'
top = '.'
out = 'build'
def options(opt):
opt.load('compiler_c')
def configure(conf):
conf.load('compiler_c')
def build(bld):
bld.env.FOO = '/usr/includes'
bld.env.MAIN = 'main.c'
bld(
features = 'c cprogram',
source = '${MAIN}',
target = 'app',
includes = '. ${FOO}')
from waflib import Utils, TaskGen
@TaskGen.feature('*')
@TaskGen.before('process_source', 'process_rule', 'apply_incpaths', 'apply_link')
def transform_strings(self):
for x in 'includes target source use libpath linkflags'.split():
val = getattr(self, x, None)
if val:
if isinstance(val, str):
setattr(self, x, Utils.subst_vars(val, self.env))
elif isinstance(val, list):
for i in range(len(val)):
if isinstance(val[i], str):
val[i] = Utils.subst_vars(val[i], self.env)