From efc79fb85e179aec94faf2f6946d0c23d2e5ee0f Mon Sep 17 00:00:00 2001 From: Jussi Pakkanen Date: Tue, 11 Mar 2014 22:30:05 +0200 Subject: [PATCH] Can run built jar files. --- backends.py | 13 ++++++++++++- build.py | 7 +++++++ test cases/java/1 basic/meson.build | 3 ++- 3 files changed, 21 insertions(+), 2 deletions(-) diff --git a/backends.py b/backends.py index d64bd8bfb..cf233b8f8 100644 --- a/backends.py +++ b/backends.py @@ -249,10 +249,21 @@ class Backend(): obj_list = [] compiler = self.get_compiler_for_source(src_list[0]) assert(compiler.get_language() == 'java') + c = 'c' + m = '' + e = '' + f = 'f' + main_class = target.get_main_class() + if main_class != '': + e = 'e' for src in src_list: obj_list.append(self.generate_single_java_compile(src, target, compiler, outfile)) jar_rule = 'java_LINKER' - commands = ['cf', self.get_target_filename(target)] + obj_list + commands = [c+m+e+f] + if e != '': + commands.append(main_class) + commands.append(self.get_target_filename(target)) + commands += obj_list elem = NinjaBuildElement(outname_rel, jar_rule, []) elem.add_dep(obj_list) elem.add_item('FLAGS', commands) diff --git a/build.py b/build.py index 6685d7f50..a27bff7d3 100644 --- a/build.py +++ b/build.py @@ -261,6 +261,10 @@ class BuildTarget(): if self.custom_install_dir is not None: if not isinstance(self.custom_install_dir, str): raise InvalidArguments('Custom_install_dir must be a string') + main_class = kwargs.get('main_class', '') + if not isinstance(main_class, str): + raise InvalidArguments('Main class must be a string') + self.main_class = main_class def get_subdir(self): return self.subdir @@ -526,6 +530,9 @@ class Jar(BuildTarget): raise InvalidArguments('Jar source %s is not a java file.' % s) self.filename = self.name + '.jar' + def get_main_class(self): + return self.main_class + class ConfigureFile(): def __init__(self, subdir, sourcename, targetname, configuration_data): diff --git a/test cases/java/1 basic/meson.build b/test cases/java/1 basic/meson.build index ae0d941b7..8d5f272d5 100644 --- a/test cases/java/1 basic/meson.build +++ b/test cases/java/1 basic/meson.build @@ -1,4 +1,5 @@ project('simplejava', 'java') -javaprog = jar('myprog', 'com/sourceforge/meson/Simple.java') +javaprog = jar('myprog', 'com/sourceforge/meson/Simple.java', + main_class : 'com.sourceforge.meson.Simple') test('mytest', javaprog)