Beispiel #1
0
def gradle(log,
           topsrcdir=None,
           topobjdir=None,
           tasks=[],
           extra_args=[],
           verbose=True):
    sys.path.insert(0, os.path.join(topsrcdir, "mobile", "android"))
    from gradle import gradle_lock

    with gradle_lock(topobjdir, max_wait_seconds=GRADLE_LOCK_MAX_WAIT_SECONDS):
        # The android-lint parameter can be used by gradle tasks to run special
        # logic when they are run for a lint using
        #   project.hasProperty('android-lint')
        cmd_args = ([
            sys.executable,
            os.path.join(topsrcdir, "mach"),
            "gradle",
            "--verbose",
            "-Pandroid-lint",
            "--",
        ] + tasks + extra_args)

        cmd = " ".join(six.moves.shlex_quote(arg) for arg in cmd_args)
        log.debug(cmd)

        # Gradle and mozprocess do not get along well, so we use subprocess
        # directly.
        proc = subprocess.Popen(cmd_args, cwd=topsrcdir)
        status = None
        # Leave it to the subprocess to handle Ctrl+C. If it terminates as a result
        # of Ctrl+C, proc.wait() will return a status code, and, we get out of the
        # loop. If it doesn't, like e.g. gdb, we continue waiting.
        while status is None:
            try:
                status = proc.wait()
            except KeyboardInterrupt:
                pass

        try:
            proc.wait()
        except KeyboardInterrupt:
            proc.kill()
            raise
Beispiel #2
0
def gradle(log,
           topsrcdir=None,
           topobjdir=None,
           tasks=[],
           extra_args=[],
           verbose=True):
    sys.path.insert(0, os.path.join(topsrcdir, 'mobile', 'android'))
    from gradle import gradle_lock

    with gradle_lock(topobjdir, max_wait_seconds=GRADLE_LOCK_MAX_WAIT_SECONDS), \
            open(os.devnull, 'wb') as devnull:
        cmd_args = [sys.executable, os.path.join(topsrcdir, 'mach'),
                    'gradle', '--verbose', '--'] + \
            tasks + \
            extra_args

        cmd = ' '.join(six.moves.shlex_quote(arg) for arg in cmd_args)
        log.debug(cmd)

        # Gradle and mozprocess do not get along well, so we use subprocess
        # directly.
        proc = subprocess.Popen(cmd_args,
                                cwd=topsrcdir,
                                stdout=devnull,
                                stderr=devnull)
        status = None
        # Leave it to the subprocess to handle Ctrl+C. If it terminates as a result
        # of Ctrl+C, proc.wait() will return a status code, and, we get out of the
        # loop. If it doesn't, like e.g. gdb, we continue waiting.
        while status is None:
            try:
                status = proc.wait()
            except KeyboardInterrupt:
                pass

        try:
            proc.wait()
        except KeyboardInterrupt:
            proc.kill()
            raise