From fc540b72a668c6ef4196f5501b0d385822e8657e Mon Sep 17 00:00:00 2001 From: Nirbheek Chauhan Date: Mon, 12 Dec 2016 14:15:40 +0530 Subject: vala: Fix duplicate output detection The same vapi or vala might be added multiple times. Don't freak out if that happens. Only freak out if a vapi or vala generated source by the same name and the output same path is added twice. This should never happen anyway since we would refuse to create the target in the first place in theory, but it might happen because of bugs in generators and custom targets. Closes #1084 --- mesonbuild/backend/ninjabackend.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'mesonbuild/backend') diff --git a/mesonbuild/backend/ninjabackend.py b/mesonbuild/backend/ninjabackend.py index 3562cf8..0516829 100644 --- a/mesonbuild/backend/ninjabackend.py +++ b/mesonbuild/backend/ninjabackend.py @@ -951,7 +951,7 @@ int dummy; else: srctype = othersgen # Duplicate outputs are disastrous - if f in srctype: + if f in srctype and srctype[f] is not gensrc: msg = 'Duplicate output {0!r} from {1!r} {2!r}; ' \ 'conflicts with {0!r} from {4!r} {3!r}' \ ''.format(f, type(gensrc).__name__, gensrc.name, -- cgit v1.1 From 79f66268676ec8bf94c6964a555ecc9144daca8e Mon Sep 17 00:00:00 2001 From: Nirbheek Chauhan Date: Wed, 14 Dec 2016 22:03:56 +0530 Subject: Pass --gresources to valac for each compiled gresource Without this, the user has to both compile the resource with gnome.compile_resources, pass that to the target sources, and also pass --gresources=/path/to/gres.xml to vala_args in the target. With this, we will do that automatically. --- mesonbuild/backend/backends.py | 35 ++++++++++++++++++++++------------- mesonbuild/backend/ninjabackend.py | 5 +++++ 2 files changed, 27 insertions(+), 13 deletions(-) (limited to 'mesonbuild/backend') diff --git a/mesonbuild/backend/backends.py b/mesonbuild/backend/backends.py index 48dfb11..a489d04 100644 --- a/mesonbuild/backend/backends.py +++ b/mesonbuild/backend/backends.py @@ -504,19 +504,13 @@ class Backend(): libs.append(os.path.join(self.get_target_dir(t), f)) return libs - def eval_custom_target_command(self, target, absolute_paths=False): - if not absolute_paths: - ofilenames = [os.path.join(self.get_target_dir(target), i) for i in target.output] - else: - ofilenames = [os.path.join(self.environment.get_build_dir(), self.get_target_dir(target), i) \ - for i in target.output] + def get_custom_target_sources(self, target, absolute_paths=False): + ''' + Custom target sources can be of various object types; strings, File, + BuildTarget, even other CustomTargets. + Returns the path to them relative to the build root directory. + ''' srcs = [] - outdir = self.get_target_dir(target) - # Many external programs fail on empty arguments. - if outdir == '': - outdir = '.' - if absolute_paths: - outdir = os.path.join(self.environment.get_build_dir(), outdir) for i in target.get_sources(): if hasattr(i, 'held_object'): i = i.held_object @@ -531,8 +525,23 @@ class Backend(): else: fname = [i.rel_to_builddir(self.build_to_src)] if absolute_paths: - fname =[os.path.join(self.environment.get_build_dir(), f) for f in fname] + fname = [os.path.join(self.environment.get_build_dir(), f) for f in fname] srcs += fname + return srcs + + def eval_custom_target_command(self, target, absolute_paths=False): + if not absolute_paths: + ofilenames = [os.path.join(self.get_target_dir(target), i) for i in target.output] + else: + ofilenames = [os.path.join(self.environment.get_build_dir(), self.get_target_dir(target), i) \ + for i in target.output] + srcs = self.get_custom_target_sources(target, absolute_paths) + outdir = self.get_target_dir(target) + # Many external programs fail on empty arguments. + if outdir == '': + outdir = '.' + if absolute_paths: + outdir = os.path.join(self.environment.get_build_dir(), outdir) cmd = [] for i in target.command: if isinstance(i, build.Executable): diff --git a/mesonbuild/backend/ninjabackend.py b/mesonbuild/backend/ninjabackend.py index 0516829..fa71ae5 100644 --- a/mesonbuild/backend/ninjabackend.py +++ b/mesonbuild/backend/ninjabackend.py @@ -1032,6 +1032,11 @@ int dummy; args += ['--pkg', d.name] elif isinstance(d, dependencies.ExternalLibrary): args += d.get_lang_args('vala') + # Detect gresources and add --gresources arguments for each + for (gres, gensrc) in other_src[1].items(): + if hasattr(gensrc, 'gresource_c_output'): + gres_xml, = self.get_custom_target_sources(gensrc) + args += ['--gresources=' + gres_xml] extra_args = [] for a in target.extra_args.get('vala', []): -- cgit v1.1 From e6f48a03fc989119bb56ea5c7b748f99f0404b5b Mon Sep 17 00:00:00 2001 From: Nirbheek Chauhan Date: Wed, 14 Dec 2016 22:13:38 +0530 Subject: Allow all code to access module target classes It is often useful to be able to check if a specific object is of a type defined in a module. To that end, define all such targets in modules/__init__.py so that everyone can refer to them without poking into module-specific code. --- mesonbuild/backend/ninjabackend.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'mesonbuild/backend') diff --git a/mesonbuild/backend/ninjabackend.py b/mesonbuild/backend/ninjabackend.py index fa71ae5..ec46933 100644 --- a/mesonbuild/backend/ninjabackend.py +++ b/mesonbuild/backend/ninjabackend.py @@ -13,6 +13,7 @@ # limitations under the License. from . import backends +from .. import modules from .. import environment, mesonlib from .. import build from .. import mlog @@ -1034,7 +1035,7 @@ int dummy; args += d.get_lang_args('vala') # Detect gresources and add --gresources arguments for each for (gres, gensrc) in other_src[1].items(): - if hasattr(gensrc, 'gresource_c_output'): + if isinstance(gensrc, modules.GResourceTarget): gres_xml, = self.get_custom_target_sources(gensrc) args += ['--gresources=' + gres_xml] extra_args = [] -- cgit v1.1 From d5f7ba862bb37ad75b68e007b8b55f40b6f6fd19 Mon Sep 17 00:00:00 2001 From: Nirbheek Chauhan Date: Thu, 15 Dec 2016 13:35:46 +0530 Subject: gnome.mkenums: Use absolute paths for all commandline args Closes #973 test cases/vala/8 generated sources/ tests this. --- mesonbuild/backend/backends.py | 19 ++++++++++--------- mesonbuild/backend/vs2010backend.py | 3 +++ 2 files changed, 13 insertions(+), 9 deletions(-) (limited to 'mesonbuild/backend') diff --git a/mesonbuild/backend/backends.py b/mesonbuild/backend/backends.py index a489d04..e8d6beb 100644 --- a/mesonbuild/backend/backends.py +++ b/mesonbuild/backend/backends.py @@ -504,7 +504,7 @@ class Backend(): libs.append(os.path.join(self.get_target_dir(t), f)) return libs - def get_custom_target_sources(self, target, absolute_paths=False): + def get_custom_target_sources(self, target): ''' Custom target sources can be of various object types; strings, File, BuildTarget, even other CustomTargets. @@ -524,23 +524,24 @@ class Backend(): fname = [os.path.join(self.get_target_private_dir(target), p) for p in i.get_outputs()] else: fname = [i.rel_to_builddir(self.build_to_src)] - if absolute_paths: + if target.absolute_paths: fname = [os.path.join(self.environment.get_build_dir(), f) for f in fname] srcs += fname return srcs - def eval_custom_target_command(self, target, absolute_paths=False): - if not absolute_paths: + def eval_custom_target_command(self, target, absolute_outputs=False): + # We only want the outputs to be absolute when using the VS backend + if not absolute_outputs: ofilenames = [os.path.join(self.get_target_dir(target), i) for i in target.output] else: ofilenames = [os.path.join(self.environment.get_build_dir(), self.get_target_dir(target), i) \ for i in target.output] - srcs = self.get_custom_target_sources(target, absolute_paths) + srcs = self.get_custom_target_sources(target) outdir = self.get_target_dir(target) # Many external programs fail on empty arguments. if outdir == '': outdir = '.' - if absolute_paths: + if target.absolute_paths: outdir = os.path.join(self.environment.get_build_dir(), outdir) cmd = [] for i in target.command: @@ -554,9 +555,9 @@ class Backend(): i = os.path.join(self.get_target_dir(i), tmp) elif isinstance(i, mesonlib.File): i = i.rel_to_builddir(self.build_to_src) - if absolute_paths: + if target.absolute_paths: i = os.path.join(self.environment.get_build_dir(), i) - # FIXME: str types are blindly added and ignore the 'absolute_paths' argument + # FIXME: str types are blindly added ignoring 'target.absolute_paths' elif not isinstance(i, str): err_msg = 'Argument {0} is of unknown type {1}' raise RuntimeError(err_msg.format(str(i), str(type(i)))) @@ -602,7 +603,7 @@ class Backend(): ''.format(target.name, i) raise MesonException(msg) source = match.group(0) - if match.group(1) is None and not absolute_paths: + if match.group(1) is None and not target.absolute_paths: lead_dir = '' else: lead_dir = self.environment.get_build_dir() diff --git a/mesonbuild/backend/vs2010backend.py b/mesonbuild/backend/vs2010backend.py index d043455..f3e9b4f 100644 --- a/mesonbuild/backend/vs2010backend.py +++ b/mesonbuild/backend/vs2010backend.py @@ -392,6 +392,9 @@ class Vs2010Backend(backends.Backend): root = self.create_basic_crap(target) action = ET.SubElement(root, 'ItemDefinitionGroup') customstep = ET.SubElement(action, 'CustomBuildStep') + # We need to always use absolute paths because our invocation is always + # from the target dir, not the build root. + target.absolute_paths = True (srcs, ofilenames, cmd) = self.eval_custom_target_command(target, True) cmd_templ = '''"%s" '''*len(cmd) ET.SubElement(customstep, 'Command').text = cmd_templ % tuple(cmd) -- cgit v1.1