From 65b730bd59790338a6bfad6f976ff74b12d6bc13 Mon Sep 17 00:00:00 2001 From: Robert Bragg Date: Thu, 8 Feb 2018 00:25:33 +0000 Subject: ninja: pass separated paths to javac -sourcepath The -sourcepath option can't be passed multiple times to javac, since it simply overrides prior arguments. Instead -sourcepath takes a colon (or semi-colon on windows) separated list of paths. --- mesonbuild/backend/ninjabackend.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'mesonbuild/backend') diff --git a/mesonbuild/backend/ninjabackend.py b/mesonbuild/backend/ninjabackend.py index c508cec..cb51f3b 100644 --- a/mesonbuild/backend/ninjabackend.py +++ b/mesonbuild/backend/ninjabackend.py @@ -1029,9 +1029,12 @@ int dummy; 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)) + sourcepath = '' for i in target.include_dirs: for idir in i.get_incdirs(): - args += ['-sourcepath', os.path.join(self.build_to_src, i.curdir, idir)] + sourcepath += os.path.join(self.build_to_src, i.curdir, idir) + os.pathsep + if sourcepath != '': + args += ['-sourcepath', sourcepath] rel_src = src.rel_to_builddir(self.build_to_src) plain_class_path = src.fname[:-4] + 'class' rel_obj = os.path.join(self.get_target_private_dir(target), plain_class_path) -- cgit v1.1 From 61dd46811b324a070c9a5007ac9b92a58fce9bb4 Mon Sep 17 00:00:00 2001 From: Robert Bragg Date: Thu, 8 Feb 2018 00:11:26 +0000 Subject: ninja: avoid needing include_directory('.') with jar() Although only one file is passed to javac at a time, if your code has any inter-file dependencies javac still needs to know how to find other source files for its -implicit:class feature to work whereby it will automatically also compile files that the given file depends on. -implicit:class is the default, practical, behaviour of javac since otherwise it would be necessary to declare the class dependencies for parallel java builds to be feasible. Passing "include_directory: include_directory('.')" to jar() causes -souredir to be passed to javac which then enables your source code to have inter-file class dependencies - assuming none of your source code is generated. This ensures that '.' is included by default. --- mesonbuild/backend/ninjabackend.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'mesonbuild/backend') diff --git a/mesonbuild/backend/ninjabackend.py b/mesonbuild/backend/ninjabackend.py index cb51f3b..8ac7658 100644 --- a/mesonbuild/backend/ninjabackend.py +++ b/mesonbuild/backend/ninjabackend.py @@ -1029,12 +1029,12 @@ int dummy; 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)) - sourcepath = '' + curdir = target.get_subdir() + sourcepath = os.path.join(self.build_to_src, curdir) + os.pathsep for i in target.include_dirs: for idir in i.get_incdirs(): sourcepath += os.path.join(self.build_to_src, i.curdir, idir) + os.pathsep - if sourcepath != '': - args += ['-sourcepath', sourcepath] + args += ['-sourcepath', sourcepath] rel_src = src.rel_to_builddir(self.build_to_src) plain_class_path = src.fname[:-4] + 'class' rel_obj = os.path.join(self.get_target_private_dir(target), plain_class_path) -- cgit v1.1 From ec7b834b6e76aac8cc64b37a9cad643d556139c5 Mon Sep 17 00:00:00 2001 From: Robert Bragg Date: Thu, 8 Feb 2018 00:33:17 +0000 Subject: ninja: add build dir to javac -sourcepath To allow the javac -implicit:class behaviour to know where to find generated .java files then the build directory for the target is also added to the -sourcefile path. --- mesonbuild/backend/ninjabackend.py | 1 + 1 file changed, 1 insertion(+) (limited to 'mesonbuild/backend') diff --git a/mesonbuild/backend/ninjabackend.py b/mesonbuild/backend/ninjabackend.py index 8ac7658..c7e194e 100644 --- a/mesonbuild/backend/ninjabackend.py +++ b/mesonbuild/backend/ninjabackend.py @@ -1031,6 +1031,7 @@ int dummy; args += compiler.get_output_args(self.get_target_private_dir(target)) curdir = target.get_subdir() sourcepath = os.path.join(self.build_to_src, curdir) + os.pathsep + sourcepath += os.path.normpath(curdir) + os.pathsep for i in target.include_dirs: for idir in i.get_incdirs(): sourcepath += os.path.join(self.build_to_src, i.curdir, idir) + os.pathsep -- cgit v1.1