The branch, master has been updated
via 3921d6f s4-waf: automatically remove stale C and header files
via f1f5a23 s4-heimdal: fixed some trailing commas in heimdal build
from 40a6e01 security: ensure the merge of libcli/security doesn't
change s3 behaviour
http://gitweb.samba.org/?p=samba.git;a=shortlog;h=master
- Log -----------------------------------------------------------------
commit 3921d6f4d34211f571cb34d748d4cb1e9484e1c9
Author: Andrew Tridgell <[email protected]>
Date: Thu Oct 14 16:24:50 2010 +1100
s4-waf: automatically remove stale C and header files
this prevents stale .c and .h files in bin/ from causing build
problems
Thanks to Thomas Nagy for the example implementation!
Autobuild-User: Andrew Tridgell <[email protected]>
Autobuild-Date: Thu Oct 14 07:44:13 UTC 2010 on sn-devel-104
commit f1f5a23400df03e209fb66848eeef14b75e31a42
Author: Andrew Tridgell <[email protected]>
Date: Thu Oct 14 16:23:45 2010 +1100
s4-heimdal: fixed some trailing commas in heimdal build
-----------------------------------------------------------------------
Summary of changes:
buildtools/wafsamba/samba_deps.py | 1 +
buildtools/wafsamba/stale_files.py | 96 +++++++++++++++++++++++++++++++++++
buildtools/wafsamba/wafsamba.py | 1 +
source4/heimdal_build/wscript_build | 6 +-
source4/wscript_build | 1 +
5 files changed, 102 insertions(+), 3 deletions(-)
create mode 100644 buildtools/wafsamba/stale_files.py
Changeset truncated at 500 lines:
diff --git a/buildtools/wafsamba/samba_deps.py
b/buildtools/wafsamba/samba_deps.py
index 553a91a..dee9f5d 100644
--- a/buildtools/wafsamba/samba_deps.py
+++ b/buildtools/wafsamba/samba_deps.py
@@ -946,6 +946,7 @@ def check_project_rules(bld):
if load_samba_deps(bld, tgt_list):
return
+ bld.new_rules = True
Logs.info("Checking project rules ...")
debug('deps: project rules checking started')
diff --git a/buildtools/wafsamba/stale_files.py
b/buildtools/wafsamba/stale_files.py
new file mode 100644
index 0000000..dd4270d
--- /dev/null
+++ b/buildtools/wafsamba/stale_files.py
@@ -0,0 +1,96 @@
+#! /usr/bin/env python
+# encoding: utf-8
+# Thomas Nagy, 2006-2010 (ita)
+
+"""
+Add a pre-build hook to remove all build files
+which do not have a corresponding target
+
+This can be used for example to remove the targets
+that have changed name without performing
+a full 'waf clean'
+
+Of course, it will only work if there are no dynamically generated
+nodes/tasks, in which case the method will have to be modified
+to exclude some folders for example.
+"""
+
+import Logs, Build, os, samba_utils, Options, Utils
+from Runner import Parallel
+
+old_refill_task_list = Parallel.refill_task_list
+def replace_refill_task_list(self):
+ '''replacement for refill_task_list() that deletes stale files'''
+
+ iit = old_refill_task_list(self)
+ bld = self.bld
+
+ if not getattr(bld, 'new_rules', False):
+ # we only need to check for stale files if the build rules changed
+ return iit
+
+ if Options.options.compile_targets:
+ # not safe when --target is used
+ return iit
+
+ # execute only once
+ if getattr(self, 'cleanup_done', False):
+ return iit
+ self.cleanup_done = True
+
+ def group_name(g):
+ tm = self.bld.task_manager
+ return [x for x in tm.groups_names if id(tm.groups_names[x]) ==
id(g)][0]
+
+ bin_base = bld.bldnode.abspath()
+ bin_base_len = len(bin_base)
+
+ # paranoia
+ if bin_base[-4:] != '/bin':
+ raise Utils.WafError("Invalid bin base: %s" % bin_base)
+
+ # obtain the expected list of files
+ expected = []
+ for i in range(len(bld.task_manager.groups)):
+ g = bld.task_manager.groups[i]
+ tasks = g.tasks_gen
+ for x in tasks:
+ try:
+ if getattr(x, 'target'):
+ tlist = samba_utils.TO_LIST(getattr(x, 'target'))
+ for t in tlist:
+ p = os.path.join(x.path.abspath(bld.env), t)
+ p = os.path.normpath(p)
+ expected.append(p)
+ for n in x.allnodes:
+ p = n.abspath(bld.env)
+ if p[0:bin_base_len] == bin_base:
+ expected.append(p)
+ except:
+ pass
+
+ for root, dirs, files in os.walk(bin_base):
+ for f in files:
+ p = root + '/' + f
+ if os.path.islink(p):
+ p = os.readlink(p)
+ if f in ['config.h']:
+ continue
+ if f[-2:] not in [ '.c', '.h' ]:
+ continue
+ if f[-7:] == '.inst.h':
+ continue
+ if p.find("/.conf") != -1:
+ continue
+ if not p in expected:
+ Logs.warn("Removing stale file: %s" % p)
+ os.unlink(p)
+ return iit
+
+
+def AUTOCLEANUP_STALE_FILES(bld):
+ """automatically clean up any files in bin that shouldn't be there"""
+ old_refill_task_list = Parallel.refill_task_list
+ Parallel.refill_task_list = replace_refill_task_list
+ Parallel.bld = bld
+Build.BuildContext.AUTOCLEANUP_STALE_FILES = AUTOCLEANUP_STALE_FILES
diff --git a/buildtools/wafsamba/wafsamba.py b/buildtools/wafsamba/wafsamba.py
index e53472b..2f5d786 100644
--- a/buildtools/wafsamba/wafsamba.py
+++ b/buildtools/wafsamba/wafsamba.py
@@ -26,6 +26,7 @@ import irixcc
import generic_cc
import samba_dist
import samba_wildcard
+import stale_files
# some systems have broken threading in python
if os.environ.get('WAF_NOTHREADS') == '1':
diff --git a/source4/heimdal_build/wscript_build
b/source4/heimdal_build/wscript_build
index 3f779f1..ac6575a 100644
--- a/source4/heimdal_build/wscript_build
+++ b/source4/heimdal_build/wscript_build
@@ -59,8 +59,8 @@ def HEIMDAL_ASN1(name, source,
t.env.OPTION_FILE = "--option-file=%s" %
os.path.normpath(os.path.join(bld.curdir, option_file))
cfile = out_files[0][0:-2] + '.c'
- hfile = out_files[1][0:-3] + '.h',
- hpriv = out_files[2][0:-3] + '.h',
+ hfile = out_files[1][0:-3] + '.h'
+ hpriv = out_files[2][0:-3] + '.h'
# now generate a .c file from the .x file
t = bld(rule='''( echo '#include "config.h"' && cat ${SRC} ) > ${TGT}''',
@@ -68,7 +68,7 @@ def HEIMDAL_ASN1(name, source,
target = cfile,
shell = True,
on_results=True,
- ext_out = '.c',
+ ext_out = '.c',
ext_in = '.x',
depends_on = name + '_ASN1',
name = name + '_C')
diff --git a/source4/wscript_build b/source4/wscript_build
index a423664..d2b6e54 100644
--- a/source4/wscript_build
+++ b/source4/wscript_build
@@ -8,6 +8,7 @@ srcdir = ".."
# create separate build groups for building the asn1 and et compiler, then
# building the C from ASN1 and IDL, and finally the main build process
bld.SETUP_BUILD_GROUPS()
+bld.AUTOCLEANUP_STALE_FILES()
bld.SAMBA_MKVERSION('version.h')
--
Samba Shared Repository