diff options
author | Paolo Bonzini <pbonzini@redhat.com> | 2019-07-12 09:31:22 +0200 |
---|---|---|
committer | Paolo Bonzini <pbonzini@redhat.com> | 2019-07-19 00:17:29 +0200 |
commit | 3ef7b231782e3554217a61b4b04f947be76e7ca7 (patch) | |
tree | 6aa5c289e0dbef70cf461c5eef55c5f520f27e8b | |
parent | 28c93ce4af25750b721e2dcaebb1864d509edd32 (diff) | |
download | meson-3ef7b231782e3554217a61b4b04f947be76e7ca7.zip meson-3ef7b231782e3554217a61b4b04f947be76e7ca7.tar.gz meson-3ef7b231782e3554217a61b4b04f947be76e7ca7.tar.bz2 |
backends: hide meson --internal exe cmdline from backends
Return the command line from serialize_executable, which is then
renamed to as_meson_exe_cmdline. This avoids repeating code that
is common to custom targets and generators.
-rw-r--r-- | mesonbuild/backend/backends.py | 4 | ||||
-rw-r--r-- | mesonbuild/backend/ninjabackend.py | 14 | ||||
-rw-r--r-- | mesonbuild/backend/vs2010backend.py | 16 |
3 files changed, 15 insertions, 19 deletions
diff --git a/mesonbuild/backend/backends.py b/mesonbuild/backend/backends.py index 982b0ee..71d5e20 100644 --- a/mesonbuild/backend/backends.py +++ b/mesonbuild/backend/backends.py @@ -323,7 +323,7 @@ class Backend: raise MesonException('Unknown data type in object list.') return obj_list - def serialize_executable(self, tname, exe, cmd_args, workdir, env=None, + def as_meson_exe_cmdline(self, tname, exe, cmd_args, workdir, env=None, extra_paths=None, capture=None): ''' Serialize an executable for running with a generator or a custom target @@ -376,7 +376,7 @@ class Backend: extra_paths, capture, self.environment.need_exe_wrapper()) pickle.dump(es, f) - return exe_data + return self.environment.get_build_command() + ['--internal', 'exe', exe_data] def serialize_tests(self): test_data = os.path.join(self.environment.get_scratch_dir(), 'meson_test_setup.dat') diff --git a/mesonbuild/backend/ninjabackend.py b/mesonbuild/backend/ninjabackend.py index b57a783..3dfb2ae 100644 --- a/mesonbuild/backend/ninjabackend.py +++ b/mesonbuild/backend/ninjabackend.py @@ -679,12 +679,11 @@ int dummy; if extra_paths: serialize = True if serialize: - exe_data = self.serialize_executable(target.name, target.command[0], cmd[1:], - # All targets are built from the build dir - self.environment.get_build_dir(), - extra_paths=extra_paths, - capture=ofilenames[0] if target.capture else None) - cmd = self.environment.get_build_command() + ['--internal', 'exe', exe_data] + cmd = self.as_meson_exe_cmdline(target.name, target.command[0], cmd[1:], + # All targets are built from the build dir + self.environment.get_build_dir(), + extra_paths=extra_paths, + capture=ofilenames[0] if target.capture else None) cmd_type = 'meson_exe.py custom' else: cmd_type = 'custom' @@ -1787,14 +1786,13 @@ https://gcc.gnu.org/bugzilla/show_bug.cgi?id=47485''')) args = self.replace_paths(target, args, override_subdir=subdir) cmdlist = exe_arr + self.replace_extra_args(args, genlist) if generator.capture: - exe_data = self.serialize_executable( + cmd = self.as_meson_exe_cmdline( 'generator ' + cmdlist[0], cmdlist[0], cmdlist[1:], self.environment.get_build_dir(), capture=outfiles[0] ) - cmd = self.environment.get_build_command() + ['--internal', 'exe', exe_data] abs_pdir = os.path.join(self.environment.get_build_dir(), self.get_target_dir(target)) os.makedirs(abs_pdir, exist_ok=True) else: diff --git a/mesonbuild/backend/vs2010backend.py b/mesonbuild/backend/vs2010backend.py index 82fc0cf..716dc27 100644 --- a/mesonbuild/backend/vs2010backend.py +++ b/mesonbuild/backend/vs2010backend.py @@ -144,14 +144,13 @@ class Vs2010Backend(backends.Backend): args = [x.replace('\\', '/') for x in args] cmd = exe_arr + self.replace_extra_args(args, genlist) if generator.capture: - exe_data = self.serialize_executable( + cmd = self.as_meson_exe_cmdline( 'generator ' + cmd[0], cmd[0], cmd[1:], self.environment.get_build_dir(), capture=outfiles[0] ) - cmd = self.environment.get_build_command() + ['--internal', 'exe', exe_data] abs_pdir = os.path.join(self.environment.get_build_dir(), self.get_target_dir(target)) os.makedirs(abs_pdir, exist_ok=True) cbs = ET.SubElement(idgroup, 'CustomBuild', Include=infilename) @@ -559,18 +558,17 @@ class Vs2010Backend(backends.Backend): tdir_abs = os.path.join(self.environment.get_build_dir(), self.get_target_dir(target)) extra_bdeps = target.get_transitive_build_target_deps() extra_paths = self.determine_windows_extra_paths(target.command[0], extra_bdeps) - exe_data = self.serialize_executable(target.name, target.command[0], cmd[1:], - # All targets run from the target dir - tdir_abs, - extra_paths=extra_paths, - capture=ofilenames[0] if target.capture else None) - wrapper_cmd = self.environment.get_build_command() + ['--internal', 'exe', exe_data] + wrapper_cmd = self.as_meson_exe_cmdline(target.name, target.command[0], cmd[1:], + # All targets run from the target dir + tdir_abs, + extra_paths=extra_paths, + capture=ofilenames[0] if target.capture else None) if target.build_always_stale: # Use a nonexistent file to always consider the target out-of-date. ofilenames += [self.nonexistent_file(os.path.join(self.environment.get_scratch_dir(), 'outofdate.file'))] self.add_custom_build(root, 'custom_target', ' '.join(self.quote_arguments(wrapper_cmd)), - deps=[exe_data] + srcs + depend_files, outputs=ofilenames) + deps=wrapper_cmd[-1:] + srcs + depend_files, outputs=ofilenames) ET.SubElement(root, 'Import', Project=r'$(VCTargetsPath)\Microsoft.Cpp.targets') self.generate_custom_generator_commands(target, root) self.add_regen_dependency(root) |