Mirror of roytam1's UXP fork just in case Moonchild and Tobin decide to go after him
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

61 lines
2.1 KiB

# -*- Mode: python; indent-tabs-mode: nil; tab-width: 40 -*-
# 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, 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.7':
die('javac 1.7 or higher is required (found %s)' % version)
return version
except subprocess.CalledProcessError as e:
die('Failed to get javac version: %s', e.output)