From d68e1ff0720589c91fb5849f247f58451d8bd7a5 Mon Sep 17 00:00:00 2001 From: Thomas Nagy Date: Sat, 7 Feb 2015 22:27:54 +0100 Subject: [PATCH] Handle non-string and non-list values in substitutions (subst) --- demos/subst/test.pc.in | 1 + demos/subst/wscript | 2 +- waflib/TaskGen.py | 8 ++++++-- 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/demos/subst/test.pc.in b/demos/subst/test.pc.in index 32fe742f..62ad296d 100644 --- a/demos/subst/test.pc.in +++ b/demos/subst/test.pc.in @@ -3,3 +3,4 @@ Description: ПРИЛОЖЕНИЕ Version: @VERSION@ Libs: -L${libdir} -lgnaa @LIBS@ @XPM_LIBS@ @LIBICONV@ Cflags: -I${includedir} @XPM_CFLAGS@ +extra: @INTVAR@ diff --git a/demos/subst/wscript b/demos/subst/wscript index ce7b8e5f..38078143 100644 --- a/demos/subst/wscript +++ b/demos/subst/wscript @@ -13,7 +13,7 @@ def configure(conf): def build(bld): # the test.pc.in is a special case which is always handled - bld(source='test.pc.in', VERSION='1.1', LIBS='moo', XPM_LIBS='-lxpm', LIBICONV='-liconv', XPM_CFLAGS='-O3') + bld(source='test.pc.in', VERSION='1.1', LIBS='moo', XPM_LIBS='-lxpm', LIBICONV='-liconv', XPM_CFLAGS='-O3', INTVAR=12) tg = bld( features = 'subst', # the feature 'subst' overrides the source/target processing diff --git a/waflib/TaskGen.py b/waflib/TaskGen.py index e55019cb..b1110080 100644 --- a/waflib/TaskGen.py +++ b/waflib/TaskGen.py @@ -701,8 +701,12 @@ class subst_pc(Task.Task): except AttributeError: d = {} for x in lst: - tmp = getattr(self.generator, x, '') or self.env.get_flat(x) or self.env.get_flat(x.upper()) - d[x] = str(tmp) + tmp = getattr(self.generator, x, '') or self.env[x] or self.env[x.upper()] + try: + tmp = ''.join(tmp) + except TypeError: + tmp = str(tmp) + d[x] = tmp code = code % d self.outputs[0].write(code, encoding=getattr(self.generator, 'encoding', 'ISO8859-1'))