예제 #1
0
    def maybe_do_clobber(self, cwd, allow_auto=False, fh=sys.stderr):
        """Perform a clobber if it is required. Maybe.

        This is the API the build system invokes to determine if a clobber
        is needed and to automatically perform that clobber if we can.

        This returns a tuple of (bool, bool, str). The elements are:

          - Whether a clobber was/is required.
          - Whether a clobber was performed.
          - The reason why the clobber failed or could not be performed. This
            will be None if no clobber is required or if we clobbered without
            error.
        """
        assert cwd
        cwd = os.path.normpath(cwd)

        if not self.clobber_needed():
            print('Clobber not needed.', file=fh)
            self.ensure_objdir_state()
            return False, False, None

        # So a clobber is needed. We only perform a clobber if we are
        # allowed to perform an automatic clobber (off by default) and if the
        # current directory is not under the object directory. The latter is
        # because operating systems, filesystems, and shell can throw fits
        # if the current working directory is deleted from under you. While it
        # can work in some scenarios, we take the conservative approach and
        # never try.
        if not allow_auto:
            return True, False, \
               self._message('Automatic clobbering is not enabled\n'
                              '  (add "mk_add_options AUTOCLOBBER=1" to your '
                              'mozconfig).')

        if cwd.startswith(self.topobjdir) and cwd != self.topobjdir:
            return True, False, self._message(
                'Cannot clobber while the shell is inside the object directory.'
            )

        print('Automatically clobbering %s' % self.topobjdir, file=fh)
        try:
            if cwd == self.topobjdir:
                for entry in os.listdir(self.topobjdir):
                    full = os.path.join(self.topobjdir, entry)

                    if os.path.isdir(full):
                        rmtree(full)
                    else:
                        os.unlink(full)

            else:
                rmtree(self.topobjdir)

            self.ensure_objdir_state()
            print('Successfully completed auto clobber.', file=fh)
            return True, True, None
        except (IOError) as error:
            return True, False, self._message(
                'Error when automatically clobbering: ' + str(error))
예제 #2
0
    def maybe_do_clobber(self, cwd, allow_auto=False, fh=sys.stderr):
        """Perform a clobber if it is required. Maybe.

        This is the API the build system invokes to determine if a clobber
        is needed and to automatically perform that clobber if we can.

        This returns a tuple of (bool, bool, str). The elements are:

          - Whether a clobber was/is required.
          - Whether a clobber was performed.
          - The reason why the clobber failed or could not be performed. This
            will be None if no clobber is required or if we clobbered without
            error.
        """
        assert cwd
        cwd = os.path.normpath(cwd)

        if not self.clobber_needed():
            print('Clobber not needed.', file=fh)
            self.ensure_objdir_state()
            return False, False, None

        # So a clobber is needed. We only perform a clobber if we are
        # allowed to perform an automatic clobber (off by default) and if the
        # current directory is not under the object directory. The latter is
        # because operating systems, filesystems, and shell can throw fits
        # if the current working directory is deleted from under you. While it
        # can work in some scenarios, we take the conservative approach and
        # never try.
        if not allow_auto:
            return True, False, \
               self._message('Automatic clobbering is not enabled\n'
                              '  (add "mk_add_options AUTOCLOBBER=1" to your '
                              'mozconfig).')

        if cwd.startswith(self.topobjdir) and cwd != self.topobjdir:
            return True, False, self._message(
                'Cannot clobber while the shell is inside the object directory.')

        print('Automatically clobbering %s' % self.topobjdir, file=fh)
        try:
            if cwd == self.topobjdir:
                for entry in os.listdir(self.topobjdir):
                    full = os.path.join(self.topobjdir, entry)

                    if os.path.isdir(full):
                        rmtree(full)
                    else:
                        os.unlink(full)

            else:
                rmtree(self.topobjdir)

            self.ensure_objdir_state()
            print('Successfully completed auto clobber.', file=fh)
            return True, True, None
        except (IOError) as error:
            return True, False, self._message(
                'Error when automatically clobbering: ' + str(error))
예제 #3
0
파일: base.py 프로젝트: hansman/gecko-dev
    def remove_objdir(self):
        """Remove the entire object directory."""

        if sys.platform.startswith('win') and self.have_winrm():
            subprocess.check_call(['winrm', '-rf', self.topobjdir])
        else:
            # We use mozfile because it is faster than shutil.rmtree().
            # mozfile doesn't like unicode arguments (bug 818783).
            rmtree(self.topobjdir.encode('utf-8'))
예제 #4
0
파일: base.py 프로젝트: marxin/gecko-dev
    def remove_objdir(self):
        """Remove the entire object directory."""

        # We use mozfile because it is faster than shutil.rmtree().
        # mozfile doesn't like unicode arguments (bug 818783).
        rmtree(self.topobjdir.encode('utf-8'))
예제 #5
0
파일: base.py 프로젝트: ChaosJohn/Icefox
    def remove_objdir(self):
        """Remove the entire object directory."""

        # We use mozfile because it is faster than shutil.rmtree().
        # mozfile doesn't like unicode arguments (bug 818783).
        rmtree(self.topobjdir.encode('utf-8'))