[jhbuild] distclean: Use git clean -d -f -x



commit 9d900c226474732d20b4ca4a9774ce6cb5b978c3
Author: Colin Walters <walters verbum org>
Date:   Thu Jul 19 19:12:52 2012 -0400

    distclean: Use git clean -d -f -x
    
    Many forms of build failure are due to unclean source trees.  The
    autotools are particularly susceptible to this.  For example,
    previously when one did:
    
    $ jhbuild buildone -afc glib
    
    The jhbuild 'clean' operation ran *after* we ran configure, so
    there can easily be stale libraries or binaries lying around
    that were in the *old* Makefiles but not the *new* ones.
    
    However, it would be dangerous to change the "clean" operation to be
    "git clean -dfx" for developers; if they have unstaged/uncommitted
    files lying around, they'll be deleted on a 'jhbuild make -afc'.
    
    Therefore, I've added a new --distclean option.
    
    This should *definitely* be used for tinderboxes.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=656081

 jhbuild/commands/base.py      |   15 ++++++++++++++-
 jhbuild/config.py             |    7 ++++++-
 jhbuild/defaults.jhbuildrc    |    1 +
 jhbuild/modtypes/autotools.py |   16 +++++++++++-----
 jhbuild/versioncontrol/git.py |    4 ++++
 5 files changed, 36 insertions(+), 7 deletions(-)
---
diff --git a/jhbuild/commands/base.py b/jhbuild/commands/base.py
index 8f05ce6..6c7f720 100644
--- a/jhbuild/commands/base.py
+++ b/jhbuild/commands/base.py
@@ -127,6 +127,9 @@ class cmd_cleanone(Command):
             make_option('--honour-config',
                         action='store_true', dest='honour_config', default=False,
                         help=_('honour the makeclean setting in config file')),
+            make_option('--distclean',
+                        action='store_true', dest='distclean', default=False,
+                        help=_('completely clean source tree')),
             ])
 
     def run(self, config, options, args, help=None):
@@ -147,7 +150,11 @@ class cmd_cleanone(Command):
             return 0
 
         build = jhbuild.frontends.get_buildscript(config, module_list, module_set=module_set)
-        return build.build(phases=['clean'])
+        if options.distclean:
+            clean_phase = 'distclean'
+        else:
+            clean_phase = 'clean'
+        return build.build(phases=[clean_phase])
 
 register_command(cmd_cleanone)
 
@@ -163,6 +170,9 @@ class cmd_build(BuildCommand):
             make_option('-a', '--autogen',
                         action='store_true', dest='_unused', default=False,
                         help=optparse.SUPPRESS_HELP), # no longer used
+            make_option('', '--distclean',
+                        action='store_true', dest='distclean', default=False,
+                        help=_('completely clean source tree')),
             make_option('-c', '--clean',
                         action='store_true', dest='clean', default=False,
                         help=_('run make clean before make')),
@@ -274,6 +284,9 @@ class cmd_buildone(BuildCommand):
             make_option('-c', '--clean',
                         action='store_true', dest='clean', default=False,
                         help=_('run make clean before make')),
+            make_option('', '--distclean',
+                        action='store_true', dest='distclean', default=False,
+                        help=_('completely clean source tree')),
             make_option('--check',
                         action='store_true', dest='check', default=False,
                         help=_('run make check after building')),
diff --git a/jhbuild/config.py b/jhbuild/config.py
index 9b6167f..f85217f 100644
--- a/jhbuild/config.py
+++ b/jhbuild/config.py
@@ -45,7 +45,7 @@ _known_keys = [ 'moduleset', 'modules', 'skip', 'tags', 'prefix',
                 'installprog', 'repos', 'branches', 'noxvfb', 'xvfbargs',
                 'builddir_pattern', 'module_autogenargs', 'module_makeargs',
                 'interact', 'buildscript', 'nonetwork', 'nobuild',
-                'noinstall', 'makeclean', 'makecheck', 'module_makecheck',
+                'noinstall', 'makeclean', 'makedistclean', 'makecheck', 'module_makecheck',
                 'use_lib64', 'tinderbox_outputdir', 'sticky_date',
                 'tarballdir', 'pretty_print', 'svn_program', 'makedist',
                 'makedistcheck', 'nonotify', 'notrayicon', 'cvs_program',
@@ -605,6 +605,8 @@ class Config:
             self.build_targets.insert(0, 'check')
         if self.makeclean and not 'clean' in self.build_targets:
             self.build_targets.insert(0, 'clean')
+        if self.makedistclean and not 'distclean' in self.build_targets:
+            self.build_targets.insert(0, 'distclean')
         if self.nobuild:
             # nobuild actually means "checkout"
             for phase in ('configure', 'build', 'check', 'clean', 'install'):
@@ -627,6 +629,9 @@ class Config:
         if hasattr(options, 'clean') and (
                 options.clean and not 'clean' in self.build_targets):
             self.build_targets.insert(0, 'clean')
+        if hasattr(options, 'distclean') and (
+                options.distclean and not 'distclean' in self.build_targets):
+            self.build_targets.insert(0, 'distclean')
         if hasattr(options, 'dist') and (
                 options.dist and not 'dist' in self.build_targets):
             self.build_targets.append('dist')
diff --git a/jhbuild/defaults.jhbuildrc b/jhbuild/defaults.jhbuildrc
index 1b0cff6..48b3fcb 100644
--- a/jhbuild/defaults.jhbuildrc
+++ b/jhbuild/defaults.jhbuildrc
@@ -90,6 +90,7 @@ nonetwork     = False  # never touch the network
 nobuild       = False  # don't actually build the packages
 noinstall     = False  # don't install the packages
 makeclean     = False  # run make clean before building
+makedistclean = False  # run git clean -dfx before building
 makecheck     = False  # run make check after building
 makedist      = False  # run make dist after building
 makedistcheck = False  # run make distcheck after building
diff --git a/jhbuild/modtypes/autotools.py b/jhbuild/modtypes/autotools.py
index 898952f..921e24d 100644
--- a/jhbuild/modtypes/autotools.py
+++ b/jhbuild/modtypes/autotools.py
@@ -303,13 +303,19 @@ class AutogenModule(Package, DownloadableModule):
     def skip_install(self, buildscript, last_phase):
         return self.config.noinstall or self.skip_install_phase
 
+    def skip_distclean(self, buildscript, last_phase):
+        return self.skip_clean(buildscript, last_phase)
+
     def do_distclean(self, buildscript):
         buildscript.set_action(_('Distcleaning'), self)
-        makeargs = self._get_makeargs(buildscript)
-        cmd = '%s %s distclean' % (os.environ.get('MAKE', 'make'), makeargs)
-        buildscript.execute(cmd, cwd = self.get_builddir(buildscript),
-                    extra_env = self.extra_env)
-    do_distclean.depends = [PHASE_CONFIGURE]
+        if hasattr(self.branch, 'delete_unknown_files'):
+            self.branch.delete_unknown_files(buildscript)
+        else:
+            makeargs = self._get_makeargs(buildscript)
+            cmd = '%s %s distclean' % (os.environ.get('MAKE', 'make'), makeargs)
+            buildscript.execute(cmd, cwd = self.get_builddir(buildscript),
+                                extra_env = self.extra_env)
+    do_distclean.depends = [PHASE_CHECKOUT]
 
     def xml_tag_and_attrs(self):
         return ('autotools',
diff --git a/jhbuild/versioncontrol/git.py b/jhbuild/versioncontrol/git.py
index 4a93cd1..d5820bb 100644
--- a/jhbuild/versioncontrol/git.py
+++ b/jhbuild/versioncontrol/git.py
@@ -448,6 +448,10 @@ class GitBranch(Branch):
             raise CommandError(_('%s not found') % 'git')
         Branch.checkout(self, buildscript)
 
+    def delete_unknown_files(self, buildscript):
+        git_extra_args = {'cwd': self.get_checkoutdir(), 'extra_env': get_git_extra_env()}
+        buildscript.execute(['git', 'clean', '-d', '-f', '-x'], **git_extra_args)
+
     def tree_id(self):
         if not os.path.exists(self.get_checkoutdir()):
             return None



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]