build: try faster includes processing
authorAndrew Tridgell <tridge@samba.org>
Tue, 16 Mar 2010 23:58:07 +0000 (10:58 +1100)
committerAndrew Tridgell <tridge@samba.org>
Tue, 6 Apr 2010 10:26:50 +0000 (20:26 +1000)
buildtools/wafsamba/samba_deps.py
buildtools/wafsamba/samba_utils.py
buildtools/wafsamba/wafsamba.py
source4/wscript

index cc013eed6b7f913e4f6714e6f8d74ba5f07d61e2..24807f844e9f3f611645caecd57e0384ccd60679 100644 (file)
@@ -146,9 +146,9 @@ def build_includes(self):
     if getattr(self, 'local_include', True) == True and not getattr(self, 'local_include_first', True):
         includes.append('.')
 
-    self.includes = unique_list(includes)
-    debug('deps: includes for target %s: includes=%s',
-          self.sname, self.includes)
+    self.env['INC_PATHS'] = unique_list(includes)
+    debug('deps: includes for target %s: INC_PATHS=%s',
+          self.sname, self.env['INC_PATHS'])
 
 
 
@@ -572,9 +572,10 @@ def calculate_final_deps(bld, tgt_list):
 
 ######################################################################
 # this provides a way to save our dependency calculations between runs
-savedeps_version = 1
+savedeps_version = 2
 savedeps_inputs  = ['samba_deps', 'samba_includes', 'local_include', 'local_include_first', 'samba_cflags']
 savedeps_outputs = ['uselib', 'uselib_local', 'add_objects', 'includes', 'ccflags']
+savedeps_outenv  = ['INC_PATHS']
 savedeps_caches  = ['GLOBAL_DEPENDENCIES', 'TARGET_ALIAS', 'TARGET_TYPE', 'INIT_FUNCTIONS']
 
 def save_samba_deps(bld, tgt_list):
@@ -587,6 +588,7 @@ def save_samba_deps(bld, tgt_list):
     denv.savedeps_outputs = savedeps_outputs
     denv.input = {}
     denv.output = {}
+    denv.outenv = {}
     denv.caches = {}
 
     for c in savedeps_caches:
@@ -611,6 +613,13 @@ def save_samba_deps(bld, tgt_list):
         if tdeps != {}:
             denv.output[t.sname] = tdeps
 
+        tdeps = {}
+        for attr in savedeps_outenv:
+            if attr in t.env:
+                tdeps[attr] = t.env[attr]
+        if tdeps != {}:
+            denv.outenv[t.sname] = tdeps
+
     depsfile = os.path.join(bld.bdir, "sambadeps")
     denv.store(depsfile)
 
@@ -656,6 +665,13 @@ def load_samba_deps(bld, tgt_list):
         for a in tdeps:
             setattr(t, a, tdeps[a])
 
+    # put output env vars in place
+    for t in tgt_list:
+        if not t.sname in denv.outenv: continue
+        tdeps = denv.outenv[t.sname]
+        for a in tdeps:
+            t.env[a] = tdeps[a]
+
     debug('deps: loaded saved dependencies')
     return True
 
index d01edcf3b45315a0fd65bf65e8f892699258234b..5fbb801ef62e2186d1557dfd70855eefbc7eccb7 100644 (file)
@@ -301,4 +301,3 @@ def mkdir_p(dir):
         return
     mkdir_p(os.path.dirname(dir))
     os.mkdir(dir)
-
index db4b7b80d2c003c3bbc005b8150000cb54c92811..302e0676b130658cab59a90e3e8896b1c8006b99 100644 (file)
@@ -447,3 +447,4 @@ def SAMBA_SCRIPT(bld, name, pattern, installdir, installname=None):
         t.env.LINK_TARGET = target
 
 Build.BuildContext.SAMBA_SCRIPT = SAMBA_SCRIPT
+
index aecea2df5f5b228fc68d2ffa872c568f6783a690..bac4e06aeceb161196bd024bd78ef18f1ad369f4 100644 (file)
@@ -63,3 +63,84 @@ def configure(conf):
     conf.sub_config('lib/smbreadline')
 
     conf.SAMBA_CONFIG_H('include/config.h')
+
+
+
+from TaskGen import feature, before, after
+
+kak = {}
+@feature('cc', 'cxx')
+@after('apply_type_vars', 'apply_lib_vars', 'apply_core')
+def apply_incpaths(self):
+    """used by the scanner
+    after processing the uselib for CPPPATH
+    after apply_core because some processing may add include paths
+    """
+    lst = []
+    # TODO move the uselib processing out of here
+    for lib in self.to_list(self.uselib):
+        for path in self.env['CPPPATH_' + lib]:
+            if not path in lst:
+                lst.append(path)
+    if preproc.go_absolute:
+        for path in preproc.standard_includes:
+            if not path in lst:
+                lst.append(path)
+
+    for path in self.to_list(self.includes):
+        if not path in lst:
+            if preproc.go_absolute or not os.path.isabs(path):
+                lst.append(path)
+            else:
+                self.env.prepend_value('CPPPATH', path)
+
+    for path in lst:
+        try:
+            #print len(kak.items())
+            node = kak[(self.path.id, path)]
+        except KeyError:
+
+            node = None
+            if os.path.isabs(path):
+                if preproc.go_absolute:
+                    node = self.bld.root.find_dir(path)
+            elif path[0] == '#':
+                node = self.bld.srcnode
+                if len(path) > 1:
+                    node = node.find_dir(path[1:])
+            else:
+                node = self.path.find_dir(path)
+
+            kak[(self.path.id, path)] = node
+        if node:
+            self.env.append_value('INC_PATHS', node)
+    # TODO WAF 1.6
+    if USE_TOP_LEVEL:
+        self.env.append_value('INC_PATHS', self.bld.srcnode)
+
+
+
+cac = {}
+@feature('cc')
+@after('apply_incpaths')
+def apply_obj_vars_cc(self):
+    """after apply_incpaths for INC_PATHS"""
+    env = self.env
+    app = env.append_unique
+    cpppath_st = env['CPPPATH_ST']
+
+    global cac
+
+    # local flags come first
+    # set the user-defined includes paths
+    for i in env['INC_PATHS']:
+
+        try:
+            app('_CCINCFLAGS', cac[i.id])
+        except KeyError:
+            cac[i.id] = [cpppath_st % i.bldpath(env), cpppath_st % i.srcpath(env)]
+            app('_CCINCFLAGS', cac[i.id])
+
+    # set the library include paths
+    for i in env['CPPPATH']:
+        app('_CCINCFLAGS', cpppath_st % i)