From e4b7b534cefedeb8d58825512df4571c942ee72b Mon Sep 17 00:00:00 2001 From: Ralph Boehme Date: Fri, 19 Dec 2014 09:05:33 +0100 Subject: [PATCH] wafsamba: flags from enviroment are put before our own internal versions Ensure user provided CPPFLAGS and LDFLAGS are put *behind* our internally computed compiler and linker flags. Bug: https://bugzilla.samba.org/show_bug.cgi?id=10877 Pair-Programmed-With: Stefan Metzmacher Signed-off-by: Ralph Boehme --- buildtools/wafsamba/samba_optimisation.py | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/buildtools/wafsamba/samba_optimisation.py b/buildtools/wafsamba/samba_optimisation.py index 1333f8b..512fbae 100644 --- a/buildtools/wafsamba/samba_optimisation.py +++ b/buildtools/wafsamba/samba_optimisation.py @@ -59,6 +59,13 @@ def apply_incpaths(self): self.env.append_value('INC_PATHS', node) @feature('cc') +@before('apply_incpaths') +def samba_stash_cppflags(self): + """Fix broken waf ordering of CPPFLAGS""" + self.env['SAVED_CPPFLAGS'] = self.env['CPPFLAGS'] + self.env['CPPFLAGS'] = [] + +@feature('cc') @after('apply_incpaths') def apply_obj_vars_cc(self): """after apply_incpaths for INC_PATHS""" @@ -89,6 +96,10 @@ def apply_obj_vars_cc(self): for i in env['CPPPATH']: app('_CCINCFLAGS', cpppath_st % i) + # append stashed user CPPFLAGS after our internally computed flags + app('_CCINCFLAGS', env['SAVED_CPPFLAGS']) + env['SAVED_CPPFLAGS'] = [] + import Node, Environment def vari(self): @@ -308,3 +319,20 @@ def apply_lib_vars(self): val = self.env[v + '_' + x] if val: self.env.append_value(v, val) + +@feature('cprogram', 'cshlib', 'cstaticlib') +@before('apply_obj_vars', 'add_extra_flags') +def samba_stash_linkflags(self): + """stash away LINKFLAGS in order to fix waf's broken ordering wrt or + user LDFLAGS""" + + self.env.SAVE_LINKFLAGS = self.env['LINKFLAGS'] + self.env['LINKFLAGS'] = [] + +@feature('cprogram', 'cshlib', 'cstaticlib') +@after('apply_obj_vars', 'add_extra_flags') +def samba_pop_linkflags(self): + """after apply_obj_vars append saved LDFLAGS""" + + self.env.append_value('LINKFLAGS', self.env.SAVE_LINKFLAGS) + self.env.SAVE_LINKFLAGS = [] -- 1.9.3