aboutsummaryrefslogtreecommitdiff
path: root/mesonbuild/backend/ninjabackend.py
diff options
context:
space:
mode:
Diffstat (limited to 'mesonbuild/backend/ninjabackend.py')
-rw-r--r--mesonbuild/backend/ninjabackend.py15
1 files changed, 14 insertions, 1 deletions
diff --git a/mesonbuild/backend/ninjabackend.py b/mesonbuild/backend/ninjabackend.py
index 94eaa4f..3ee543d 100644
--- a/mesonbuild/backend/ninjabackend.py
+++ b/mesonbuild/backend/ninjabackend.py
@@ -970,7 +970,7 @@ int dummy;
class_list = []
compiler = target.compilers['java']
c = 'c'
- m = ''
+ m = 'm'
e = ''
f = 'f'
main_class = target.get_main_class()
@@ -980,8 +980,18 @@ int dummy;
plain_class_path = self.generate_single_java_compile(src, target, compiler, outfile)
class_list.append(plain_class_path)
class_dep_list = [os.path.join(self.get_target_private_dir(target), i) for i in class_list]
+ manifest_path = os.path.join(self.get_target_private_dir(target), 'META-INF', 'MANIFEST.MF')
+ manifest_fullpath = os.path.join(self.environment.get_build_dir(), manifest_path)
+ os.makedirs(os.path.dirname(manifest_fullpath), exist_ok=True)
+ with open(manifest_fullpath, 'w') as manifest:
+ if any(target.link_targets):
+ manifest.write('Class-Path: ')
+ cp_paths = [os.path.join(self.get_target_dir(l), l.get_filename()) for l in target.link_targets]
+ manifest.write(' '.join(cp_paths))
+ manifest.write('\n')
jar_rule = 'java_LINKER'
commands = [c + m + e + f]
+ commands.append(manifest_path)
if e != '':
commands.append(main_class)
commands.append(self.get_target_filename(target))
@@ -1063,12 +1073,14 @@ int dummy;
self.generate_generator_list_rules(target, outfile)
def generate_single_java_compile(self, src, target, compiler, outfile):
+ deps = [os.path.join(self.get_target_dir(l), l.get_filename()) for l in target.link_targets]
args = []
args += compiler.get_buildtype_args(self.get_option_for_target('buildtype', target))
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))
+ args += target.get_classpath_args()
curdir = target.get_subdir()
sourcepath = os.path.join(self.build_to_src, curdir) + os.pathsep
sourcepath += os.path.normpath(curdir) + os.pathsep
@@ -1080,6 +1092,7 @@ int dummy;
plain_class_path = src.fname[:-4] + 'class'
rel_obj = os.path.join(self.get_target_private_dir(target), plain_class_path)
element = NinjaBuildElement(self.all_outputs, rel_obj, compiler.get_language() + '_COMPILER', rel_src)
+ element.add_dep(deps)
element.add_item('ARGS', args)
element.write(outfile)
return plain_class_path