DXR is a code search and navigation tool aimed at making sense of large projects. It supports full-text and regex searches as well as structural queries.

Mercurial (ed839e4a3021)

VCS Links

Line Code
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62
# -*- 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 http://mozilla.org/MPL/2.0/.


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


@depends(host, '--with-java-bin-path')
@imports(_from='os', _import='environ')
def java_search_paths(host, 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),
    # JDK registery on Windows, and $PATH.
    if 'JAVA_HOME' in environ:
        return [os.path.join(environ['JAVA_HOME'], 'bin')]
    if host.os == 'WINNT':
        for x in get_registry_values(r'HKEY_LOCAL_MACHINE\SOFTWARE\JavaSoft\Java Development Kit\1.8\JavaHome', get_32_and_64_bit=True):
            return [os.path.join(x[0], 'bin')]
    if host.os == 'OSX':
        home = check_cmd_output('/usr/libexec/java_home', '-v', '1.8', onerror=lambda: '').rstrip()
        if home:
            return [os.path.join(home, 'bin')]
    return [environ.get('PATH')]

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


@template
def check_java_tool(tool):
    check = check_prog(tool.upper(), (tool,), paths=java_search_paths,
                       allow_missing=True)

    @depends(check)
    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


check_java_tool('java')
check_java_tool('jarsigner')
check_java_tool('keytool')


# 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)))