From c9a46fcc93461ece4ac6d83b1875cd0f5fe0c684 Mon Sep 17 00:00:00 2001 From: Jussi Pakkanen Date: Sun, 20 Nov 2016 00:26:45 +0200 Subject: [PATCH] Can set compiler arguments in Java. --- mesonbuild/backend/ninjabackend.py | 3 +++ mesonbuild/build.py | 6 +++++- test cases/java/3 args/com/mesonbuild/Simple.java | 7 +++++++ test cases/java/3 args/meson.build | 9 +++++++++ 4 files changed, 24 insertions(+), 1 deletion(-) create mode 100644 test cases/java/3 args/com/mesonbuild/Simple.java create mode 100644 test cases/java/3 args/meson.build diff --git a/mesonbuild/backend/ninjabackend.py b/mesonbuild/backend/ninjabackend.py index 2bfb82269..659a53da6 100644 --- a/mesonbuild/backend/ninjabackend.py +++ b/mesonbuild/backend/ninjabackend.py @@ -859,6 +859,9 @@ int dummy; def generate_single_java_compile(self, src, target, compiler, outfile): args = [] args += compiler.get_buildtype_args(self.environment.coredata.get_builtin_option('buildtype')) + args += self.build.get_global_args(compiler) + args += self.build.get_project_args(compiler, target.subproject) + args += target.get_java_args() args += compiler.get_output_args(self.get_target_private_dir(target)) for i in target.include_dirs: for idir in i.get_incdirs(): diff --git a/mesonbuild/build.py b/mesonbuild/build.py index 0e2377796..98f05c230 100644 --- a/mesonbuild/build.py +++ b/mesonbuild/build.py @@ -28,6 +28,7 @@ known_basic_kwargs = {'install' : True, 'cs_args' : True, 'vala_args' : True, 'd_args' : True, + 'java_args' : True, 'link_args' : True, 'link_depends': True, 'link_with' : True, @@ -1342,7 +1343,7 @@ class Jar(BuildTarget): if not s.endswith('.java'): raise InvalidArguments('Jar source %s is not a java file.' % s) self.filename = self.name + '.jar' - incdirs = kwargs.get('include_directories', []) + self.java_args = kwargs.get('java_args', []) def get_main_class(self): return self.main_class @@ -1350,6 +1351,9 @@ class Jar(BuildTarget): def type_suffix(self): return "@jar" + def get_java_args(self): + return self.java_args + class ConfigureFile(): def __init__(self, subdir, sourcename, targetname, configuration_data): diff --git a/test cases/java/3 args/com/mesonbuild/Simple.java b/test cases/java/3 args/com/mesonbuild/Simple.java new file mode 100644 index 000000000..325a49a21 --- /dev/null +++ b/test cases/java/3 args/com/mesonbuild/Simple.java @@ -0,0 +1,7 @@ +package com.mesonbuild; + +class Simple { + public static void main(String [] args) { + System.out.println("Java is working.\n"); + } +} diff --git a/test cases/java/3 args/meson.build b/test cases/java/3 args/meson.build new file mode 100644 index 000000000..7a73cf883 --- /dev/null +++ b/test cases/java/3 args/meson.build @@ -0,0 +1,9 @@ +project('simplejava', 'java') + +add_project_arguments('-target', '1.6', language : 'java') + +javaprog = jar('myprog', 'com/mesonbuild/Simple.java', + main_class : 'com.mesonbuild.Simple', + java_args : ['-source', '1.6']) +test('mytest', javaprog) +