From 3dadcbc9a73ab9c07ecc8bfd513d6e5ef791dd00 Mon Sep 17 00:00:00 2001 From: Jussi Pakkanen Date: Mon, 10 Mar 2014 23:33:24 +0200 Subject: [PATCH] Can create jar objects. --- backends.py | 2 ++ build.py | 7 +++++++ interpreter.py | 15 ++++++++++++++- 3 files changed, 23 insertions(+), 1 deletion(-) diff --git a/backends.py b/backends.py index 4692a4676..03be9a558 100644 --- a/backends.py +++ b/backends.py @@ -715,6 +715,8 @@ class NinjaBackend(Backend): else: static_linker = self.build.static_linker crstr = '' + if static_linker is None: + return rule = 'rule STATIC%s_LINKER\n' % crstr command = ' command = %s $LINK_FLAGS %s $in\n' % \ (' '.join(static_linker.get_exelist()), diff --git a/build.py b/build.py index 991938d4b..5da669c26 100644 --- a/build.py +++ b/build.py @@ -518,6 +518,13 @@ class SharedLibrary(BuildTarget): aliases.append(self.get_shbase()) return aliases +class Jar(BuildTarget): + def __init__(self, name, subdir, is_cross, sources, objects, environment, kwargs): + super().__init__(name, subdir, is_cross, sources, objects, environment, kwargs); + for s in self.sources: + if not s.endswith('.java'): + raise InvalidArguments('Jar source %s is not a java file.' % s) + class ConfigureFile(): def __init__(self, subdir, sourcename, targetname, configuration_data): diff --git a/interpreter.py b/interpreter.py index 6070c8065..3205d4b4d 100644 --- a/interpreter.py +++ b/interpreter.py @@ -360,6 +360,10 @@ class SharedLibraryHolder(BuildTargetHolder): def __init__(self, name, subdir, is_cross, sources, objects, environment, kwargs): super().__init__(build.SharedLibrary, name, subdir, is_cross, sources, objects, environment, kwargs) +class JarHolder(BuildTargetHolder): + def __init__(self, name, subdir, is_cross, sources, objects, environment, kwargs): + super().__init__(build.Jar, name, subdir, is_cross, sources, objects, environment, kwargs) + class Test(InterpreterObject): def __init__(self, name, exe, is_parallel, cmd_args, env): InterpreterObject.__init__(self) @@ -632,6 +636,7 @@ class Interpreter(): 'dependency' : self.func_dependency, 'static_library' : self.func_static_lib, 'shared_library' : self.func_shared_lib, + 'jar' : self.func_jar, 'generator' : self.func_generator, 'test' : self.func_test, 'headers' : self.func_headers, @@ -966,13 +971,21 @@ class Interpreter(): def func_shared_lib(self, node, args, kwargs): return self.build_target(node, args, kwargs, SharedLibraryHolder) + def func_jar(self, node, args, kwargs): + return self.build_target(node, args, kwargs, JarHolder) + def func_generator(self, node, args, kwargs): gen = GeneratorHolder(args, kwargs) self.generators.append(gen) return gen def func_test(self, node, args, kwargs): - self.validate_arguments(args, 2, [str, ExecutableHolder]) + if len(args) != 2: + raise InterpreterException('Incorrect number of arguments') + if not isinstance(args[0], str): + raise InterpreterException('First argument of test must be a string.') + if not isinstance(args[1], ExecutableHolder) and not isinstance(args[1], JarHolder): + raise InterpreterException('Second argument must be executable.') par = kwargs.get('is_parallel', True) if not isinstance(par, bool): raise InterpreterException('Keyword argument is_parallel must be a boolean.')