mirror of
https://github.com/Z3Prover/z3
synced 2025-06-07 06:33:23 +00:00
Java API: added automatic detection of jar
Signed-off-by: Christoph M. Wintersteiger <cwinter@microsoft.com>
This commit is contained in:
parent
f5cdc14737
commit
14f582eca5
1 changed files with 20 additions and 1 deletions
|
@ -35,6 +35,7 @@ JNI_HOME=getenv("JNI_HOME", None)
|
||||||
CXX_COMPILERS=['g++', 'clang++']
|
CXX_COMPILERS=['g++', 'clang++']
|
||||||
C_COMPILERS=['gcc', 'clang']
|
C_COMPILERS=['gcc', 'clang']
|
||||||
JAVAC=None
|
JAVAC=None
|
||||||
|
JAR=None
|
||||||
PYTHON_PACKAGE_DIR=distutils.sysconfig.get_python_lib()
|
PYTHON_PACKAGE_DIR=distutils.sysconfig.get_python_lib()
|
||||||
BUILD_DIR='build'
|
BUILD_DIR='build'
|
||||||
REV_BUILD_DIR='..'
|
REV_BUILD_DIR='..'
|
||||||
|
@ -215,6 +216,7 @@ def find_jni_h(path):
|
||||||
def check_java():
|
def check_java():
|
||||||
global JNI_HOME
|
global JNI_HOME
|
||||||
global JAVAC
|
global JAVAC
|
||||||
|
global JAR
|
||||||
|
|
||||||
JDK_HOME = getenv('JDK_HOME', None) # we only need to check this locally.
|
JDK_HOME = getenv('JDK_HOME', None) # we only need to check this locally.
|
||||||
|
|
||||||
|
@ -246,6 +248,17 @@ def check_java():
|
||||||
if JAVAC == None:
|
if JAVAC == None:
|
||||||
raise MKException('No java compiler in the path, please adjust your PATH or set JDK_HOME to the location of the JDK.')
|
raise MKException('No java compiler in the path, please adjust your PATH or set JDK_HOME to the location of the JDK.')
|
||||||
|
|
||||||
|
if is_verbose():
|
||||||
|
print("Finding jar ...")
|
||||||
|
|
||||||
|
if IS_WINDOWS:
|
||||||
|
JAR = os.path.join(os.path.dirname(JAVAC), 'jar.exe')
|
||||||
|
else:
|
||||||
|
JAR = os.path.join(os.path.dirname(JAVAC), 'jar')
|
||||||
|
|
||||||
|
if not os.path.exists(JAR):
|
||||||
|
raise MKException("Failed to detect jar at '%s'; the environment variable JDK_HOME is probably set to the wrong path." % os.path.join(JDK_HOME))
|
||||||
|
|
||||||
if is_verbose():
|
if is_verbose():
|
||||||
print("Testing %s..." % JAVAC)
|
print("Testing %s..." % JAVAC)
|
||||||
|
|
||||||
|
@ -1120,6 +1133,9 @@ class JavaDLLComponent(Component):
|
||||||
self.manifest_file = manifest_file
|
self.manifest_file = manifest_file
|
||||||
|
|
||||||
def mk_makefile(self, out):
|
def mk_makefile(self, out):
|
||||||
|
global JAVAC
|
||||||
|
global JAR
|
||||||
|
|
||||||
if is_java_enabled():
|
if is_java_enabled():
|
||||||
mk_dir(os.path.join(BUILD_DIR, 'api', 'java', 'classes'))
|
mk_dir(os.path.join(BUILD_DIR, 'api', 'java', 'classes'))
|
||||||
dllfile = '%s$(SO_EXT)' % self.dll_name
|
dllfile = '%s$(SO_EXT)' % self.dll_name
|
||||||
|
@ -1146,6 +1162,9 @@ class JavaDLLComponent(Component):
|
||||||
deps += '%s ' % os.path.join(self.to_src_dir, 'enumerations', jfile)
|
deps += '%s ' % os.path.join(self.to_src_dir, 'enumerations', jfile)
|
||||||
out.write(deps)
|
out.write(deps)
|
||||||
out.write('\n')
|
out.write('\n')
|
||||||
|
if IS_WINDOWS:
|
||||||
|
JAVAC = '"%s"' % JAVAC
|
||||||
|
JAR = '"%s"' % JAR
|
||||||
t = ('\t%s %s.java -d %s\n' % (JAVAC, os.path.join(self.to_src_dir, 'enumerations', '*'), os.path.join('api', 'java', 'classes')))
|
t = ('\t%s %s.java -d %s\n' % (JAVAC, os.path.join(self.to_src_dir, 'enumerations', '*'), os.path.join('api', 'java', 'classes')))
|
||||||
out.write(t)
|
out.write(t)
|
||||||
t = ('\t%s -cp %s %s.java -d %s\n' % (JAVAC,
|
t = ('\t%s -cp %s %s.java -d %s\n' % (JAVAC,
|
||||||
|
@ -1153,7 +1172,7 @@ class JavaDLLComponent(Component):
|
||||||
os.path.join(self.to_src_dir, '*'),
|
os.path.join(self.to_src_dir, '*'),
|
||||||
os.path.join('api', 'java', 'classes')))
|
os.path.join('api', 'java', 'classes')))
|
||||||
out.write(t)
|
out.write(t)
|
||||||
out.write('\tjar cfm %s.jar %s -C %s .\n' % (self.package_name,
|
out.write('\t%s cfm %s.jar %s -C %s .\n' % (JAR, self.package_name,
|
||||||
os.path.join(self.to_src_dir, 'manifest'),
|
os.path.join(self.to_src_dir, 'manifest'),
|
||||||
os.path.join('api', 'java', 'classes')))
|
os.path.join('api', 'java', 'classes')))
|
||||||
out.write('java: %s.jar\n\n' % self.package_name)
|
out.write('java: %s.jar\n\n' % self.package_name)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue