Commit ba80937b authored by Mike Hommey's avatar Mike Hommey
Browse files

Bug 1257516 - Send the debug output from our logger to config.log. r=ted

And since the file is also used for old-configure, close our handle on
the file before spawning old-configure, and make old-configure append
there instead of truncating the file.
parent 47d916d8
Loading
Loading
Loading
Loading
+21 −4
Original line number Diff line number Diff line
@@ -121,11 +121,17 @@ def prepare_configure(old_configure, mozconfig, autoconf, build_env, shell,

    if refresh:
        log.info('Refreshing %s with %s', old_configure, autoconf)
        with open(old_configure, 'wb') as fh:
            subprocess.check_call([
        script = subprocess.check_output([
            shell, autoconf,
            '--localdir=%s' % os.path.dirname(old_configure),
                old_configure + '.in'], stdout=fh)
            old_configure + '.in'])

        # Make old-configure append to config.log, where we put our own log.
        # This could be done with a m4 macro, but it's way easier this way
        script = script.replace('>./config.log', '>>./config.log')

        with open(old_configure, 'wb') as fh:
            fh.write(script)

    cmd = [shell, old_configure]
    with encoded_open('old-configure.vars', 'w') as out:
@@ -368,6 +374,7 @@ def old_configure_options(*options):
@advanced
def old_configure(prepare_configure, extra_old_configure_args, all_options,
                  *options):
    import logging
    import os
    import subprocess
    import sys
@@ -393,6 +400,16 @@ def old_configure(prepare_configure, extra_old_configure_args, all_options,

    # For debugging purpose, in case it's not what we'd expect.
    log.info('running %s', ' '.join(quote(a) for a in cmd))

    # Our logging goes to config.log, the same file old.configure uses.
    # We can't share the handle on the file, so close it. We assume nothing
    # beyond this point is going to be interesting to log to config.log from
    # our end, so we don't make the effort to recreate a logging.FileHandler.
    logger = logging.getLogger('moz.configure')
    for handler in logger.handlers:
        if isinstance(handler, logging.FileHandler):
            handler.close()

    ret = subprocess.call(cmd)
    if ret:
        sys.exit(ret)
+8 −1
Original line number Diff line number Diff line
@@ -129,7 +129,7 @@ class ConfigureSandbox(dict):
        self._config = config

        if logger is None:
            logger = logging.getLogger('moz.configure')
            logger = moz_logger = logging.getLogger('moz.configure')
            logger.setLevel(logging.INFO)
            formatter = logging.Formatter('%(levelname)s: %(message)s')
            handler = ConfigureOutputHandler(stdout, stderr)
@@ -139,6 +139,7 @@ class ConfigureSandbox(dict):

        else:
            assert isinstance(logger, logging.Logger)
            moz_logger = None

        self.log_impl = ReadOnlyNamespace(**{
                k: getattr(logger, k)
@@ -154,6 +155,12 @@ class ConfigureSandbox(dict):
        if self._option_values[self._help_option]:
            self._help = HelpFormatter(argv[0])
            self._help.add(self._help_option)
        elif moz_logger:
            logger.setLevel(logging.DEBUG)
            handler = logging.FileHandler('config.log', mode='w', delay=True)
            handler.setLevel(logging.DEBUG)
            handler.setFormatter(formatter)
            logger.addHandler(handler)

    def exec_file(self, path):
        '''Execute one file within the sandbox. Users of this class probably