From e90f21ae598cf8f7c11ec01a730895e74d2326eb Mon Sep 17 00:00:00 2001 From: Nirbheek Chauhan Date: Tue, 8 Nov 2016 11:50:12 +0530 Subject: [PATCH 1/2] javac: Fail gracefully if there's no JVM Without this, we error out with an exception if `javac` is found but `java` isn't: [...] File "mesonbuild/interpreter.py", line 1759, in detect_compilers comp.sanity_check(self.environment.get_scratch_dir(), self.environment) File "mesonbuild/compilers.py", line 1279, in sanity_check pe = subprocess.Popen(cmdlist, cwd=work_dir) File "/usr/lib64/python3.5/subprocess.py", line 947, in __init__ restore_signals, start_new_session) File "/usr/lib64/python3.5/subprocess.py", line 1551, in _execute_child raise child_exception_type(errno_num, err_msg) FileNotFoundError: [Errno 2] No such file or directory: 'java' --- mesonbuild/compilers.py | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/mesonbuild/compilers.py b/mesonbuild/compilers.py index 94e8a543c..454cdbaef 100644 --- a/mesonbuild/compilers.py +++ b/mesonbuild/compilers.py @@ -12,6 +12,7 @@ # See the License for the specific language governing permissions and # limitations under the License. +import shutil import contextlib import subprocess, os.path import tempfile @@ -1274,11 +1275,20 @@ class JavaCompiler(Compiler): pc.wait() if pc.returncode != 0: raise EnvironmentException('Java compiler %s can not compile programs.' % self.name_string()) - cmdlist = [self.javarunner, obj] - pe = subprocess.Popen(cmdlist, cwd=work_dir) - pe.wait() - if pe.returncode != 0: - raise EnvironmentException('Executables created by Java compiler %s are not runnable.' % self.name_string()) + runner = shutil.which(self.javarunner) + if runner: + cmdlist = [runner, obj] + pe = subprocess.Popen(cmdlist, cwd=work_dir) + pe.wait() + if pe.returncode != 0: + raise EnvironmentException('Executables created by Java compiler %s are not runnable.' % self.name_string()) + else: + m = "Java Virtual Machine wasn't found, but it's needed by Meson. " \ + "Please install a JRE.\nIf you have specific needs where this " \ + "requirement doesn't make sense, please open a bug at " \ + "https://github.com/mesonbuild/meson/issues/new and tell us " \ + "all about it." + raise EnvironmentException(m) def needs_static_linker(self): return False From 377fe510033043555ed1824362f6db9935547707 Mon Sep 17 00:00:00 2001 From: Nirbheek Chauhan Date: Wed, 9 Nov 2016 02:38:10 +0530 Subject: [PATCH 2/2] project tests: Require both javac and java for Java tests --- run_project_tests.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/run_project_tests.py b/run_project_tests.py index 22e92b8f2..e373ffa6f 100755 --- a/run_project_tests.py +++ b/run_project_tests.py @@ -338,7 +338,7 @@ def detect_tests_to_run(): all_tests.append(('platform-windows', gather_tests('test cases/windows'), False if mesonlib.is_windows() else True)) all_tests.append(('platform-linux', gather_tests('test cases/linuxlike'), False if not (mesonlib.is_osx() or mesonlib.is_windows()) else True)) all_tests.append(('framework', gather_tests('test cases/frameworks'), False if not mesonlib.is_osx() and not mesonlib.is_windows() else True)) - all_tests.append(('java', gather_tests('test cases/java'), False if not mesonlib.is_osx() and shutil.which('javac') else True)) + all_tests.append(('java', gather_tests('test cases/java'), False if not mesonlib.is_osx() and shutil.which('javac') and shutil.which('java') else True)) all_tests.append(('C#', gather_tests('test cases/csharp'), False if shutil.which('mcs') else True)) all_tests.append(('vala', gather_tests('test cases/vala'), False if shutil.which('valac') else True)) all_tests.append(('rust', gather_tests('test cases/rust'), False if shutil.which('rustc') else True))