1 # -*- Mode: python; indent-tabs-mode: nil; tab-width: 40 -*-
2 # vim: set filetype=python:
3 # This Source Code Form is subject to the terms of the Mozilla Public
4 # License, v. 2.0. If a copy of the MPL was not distributed with this
5 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 # ========================================================
11 "--with-java-bin-path",
13 help="Location of Java binaries",
17 @depends("--with-java-bin-path", host, toolchains_base_dir)
18 @imports(_from="mozboot.android", _import="JavaLocationFailedException")
19 @imports(_from="mozboot.android", _import="locate_java_bin_path")
20 @imports(_from="os", _import="environ")
21 @imports(_from="os.path", _import="dirname")
22 def java_search_paths(path, host, toolchains_base_dir):
24 # Look for javac and jar in the specified path.
28 path = locate_java_bin_path(host.kernel, toolchains_base_dir)
30 java_home = environ.get("JAVA_HOME")
31 if java_home and java_home != dirname(path):
33 "Ignoring JAVA_HOME value. Use --with-java-bin-path "
34 "to override the default Java location."
37 except JavaLocationFailedException as e:
41 # Finds the given java tool, failing with a custom error message if we can't
46 def check_java_tool(tool):
48 tool.upper(), (tool,), paths=java_search_paths, allow_missing=True
52 def require_tool(result):
55 "The program %s was not found. Use '--with-java-bin-path={java-bin-dir}'"
63 check_java_tool("java")
67 # ========================================================
69 "--enable-java-coverage",
70 env="MOZ_JAVA_CODE_COVERAGE",
71 help="Enable Java code coverage",
75 "MOZ_JAVA_CODE_COVERAGE", depends("--enable-java-coverage")(lambda v: bool(v))