author Tudor-Gabriel Vîjială <>
Tue, 24 Jul 2018 11:44:24 +0100
changeset 429993 92b8a54b4ad42d1d0203d265083b691e769fad1e
parent 405440 b94346ccb352cd6e838e2793270c269853d58a8c
child 436320 aae4f349fa588aa844cfb14fae278b776aed6cb7
permissions -rw-r--r--
Bug 1473313 - Part 1: Set up geckoview build config for androidTest coverage runs. r=nalexander This patch adds JaCoCo as a dependency for the geckoview androidTest configurations, as well as the `mach android archive-geckoview-coverage-artifacts` command, and the `--enable-java-coverage` mozconfig flag. MozReview-Commit-ID: 36jNAzK44g3

# -*- Mode: python; indent-tabs-mode: nil; tab-width: 40 -*-
# vim: set filetype=python:
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at

# Java detection
# ========================================================
option('--with-java-bin-path', nargs=1,
       help='Location of Java binaries (java, javac, jar)')

@imports(_from='os', _import='environ')
def java_search_paths(path):
    if path:
        # Look for javac and jar in the specified path.
        return path
    # With no path specified, look for javac and jar in $JAVA_HOME (if set)
    # and $PATH.
    if 'JAVA_HOME' in environ:
        return [os.path.join(environ['JAVA_HOME'], 'bin'),
                environ.get('PATH', '')]
    return [environ.get('PATH')]

# Finds the given java tool, failing with a custom error message if we can't
# find it.

def check_java_tool(tool):
    check = check_prog(tool.upper(), (tool,), paths=java_search_paths,

    def require_tool(result):
        if result is None:
            die("The program %s was not found.  Set $JAVA_HOME to your Java "
                "SDK directory or use '--with-java-bin-path={java-bin-dir}'"
                % tool)
        return result

    return require_tool

javac = check_java_tool('javac')

@checking('for javac version')
def javac_version(javac):
        output = subprocess.check_output([javac, '-version'],
        version = Version(output.split(' ')[-1])
        if version < '1.8':
            die('javac 1.8 or higher is required (found %s). '
                'Check the JAVA_HOME environment variable.' % version)
        return version
    except subprocess.CalledProcessError as e:
        die('Failed to get javac version: %s', e.output)

# Java Code Coverage
# ========================================================
option('--enable-java-coverage', env='MOZ_JAVA_CODE_COVERAGE', help='Enable Java code coverage')

set_config('MOZ_JAVA_CODE_COVERAGE', depends('--enable-java-coverage')(lambda v: bool(v)))