diff options
-rw-r--r-- | backends.py | 17 | ||||
-rwxr-xr-x | gtkdochelper.py | 2 | ||||
-rw-r--r-- | ninjabackend.py | 17 | ||||
-rw-r--r-- | test cases/common/97 selfbuilt custom/data.dat | 1 | ||||
-rw-r--r-- | test cases/common/97 selfbuilt custom/mainprog.cpp | 5 | ||||
-rw-r--r-- | test cases/common/97 selfbuilt custom/meson.build | 16 | ||||
-rw-r--r-- | test cases/common/97 selfbuilt custom/tool.cpp | 34 |
7 files changed, 80 insertions, 12 deletions
diff --git a/backends.py b/backends.py index 26ab081..5710fac 100644 --- a/backends.py +++ b/backends.py @@ -352,6 +352,20 @@ class Backend(): deps.append(os.path.join(self.build_to_src, sp, 'meson_options.txt')) return deps + def exe_object_to_cmd_array(self, exe): + if self.environment.is_cross_build() and \ + isinstance(exe, build.BuildTarget) and exe.is_cross: + if 'exe_wrapper' not in self.environment.cross_info: + s = 'Can not use target %s as a generator because it is cross-built\n' + s += 'and no exe wrapper is defined. You might want to set it to native instead.' + s = s % exe.name + raise MesonException(s) + if isinstance(exe, build.BuildTarget): + exe_arr = [os.path.join(self.environment.get_build_dir(), self.get_target_filename(exe))] + else: + exe_arr = exe.get_command() + return exe_arr + def eval_custom_target_command(self, target, absolute_paths=False): ofilenames = [os.path.join(self.get_target_dir(target), i) for i in target.output] srcs = [] @@ -368,6 +382,9 @@ class Backend(): srcs.append(fname) cmd = [] for i in target.command: + if isinstance(i, build.Executable): + cmd += self.exe_object_to_cmd_array(i) + continue if isinstance(i, build.CustomTarget): # GIR scanner will attempt to execute this binary but # it assumes that it is in path, so always give it a full path. diff --git a/gtkdochelper.py b/gtkdochelper.py index c37e4d4..7e476b8 100755 --- a/gtkdochelper.py +++ b/gtkdochelper.py @@ -37,6 +37,8 @@ def build_gtkdoc(source_root, build_root, doc_subdir, src_subdir, scan_cmd = ['gtkdoc-scan', '--module=' + module, '--source-dir=' + abs_src] + scan_args +# print(scan_cmd) +# sys.exit(1) subprocess.check_call(scan_cmd, cwd=abs_out) if main_file.endswith('sgml'): diff --git a/ninjabackend.py b/ninjabackend.py index 2fb3284..d2791a5 100644 --- a/ninjabackend.py +++ b/ninjabackend.py @@ -293,7 +293,10 @@ class NinjaBackend(backends.Backend): # FIXME, should not grab element at zero but rather expand all. if isinstance(i, list): i = i[0] - deps.append(os.path.join(self.get_target_dir(i), i.get_filename()[0])) + fname = i.get_filename() + if isinstance(fname, list): + fname = fname[0] + deps.append(os.path.join(self.get_target_dir(i), fname)) if target.build_always: deps.append('PHONY') elem = NinjaBuildElement(ofilenames, 'CUSTOM_COMMAND', srcs) @@ -1115,19 +1118,9 @@ rule FORTRAN_DEP_HACK continue # Customtarget has already written its output rules generator = genlist.get_generator() exe = generator.get_exe() - if self.environment.is_cross_build() and \ - isinstance(exe, build.BuildTarget) and exe.is_cross: - if 'exe_wrapper' not in self.environment.cross_info: - s = 'Can not use target %s as a generator because it is cross-built\n' - s += 'and no exe wrapper is defined. You might want to set it to native instead.' - s = s % exe.name - raise MesonException(s) + exe_arr = self.exe_object_to_cmd_array(exe) infilelist = genlist.get_infilelist() outfilelist = genlist.get_outfilelist() - if isinstance(exe, build.BuildTarget): - exe_arr = [os.path.join(self.environment.get_build_dir(), self.get_target_filename(exe))] - else: - exe_arr = exe.get_command() base_args = generator.get_arglist() extra_dependencies = [os.path.join(self.build_to_src, i) for i in genlist.extra_depends] for i in range(len(infilelist)): diff --git a/test cases/common/97 selfbuilt custom/data.dat b/test cases/common/97 selfbuilt custom/data.dat new file mode 100644 index 0000000..83fd1d9 --- /dev/null +++ b/test cases/common/97 selfbuilt custom/data.dat @@ -0,0 +1 @@ +generated_function diff --git a/test cases/common/97 selfbuilt custom/mainprog.cpp b/test cases/common/97 selfbuilt custom/mainprog.cpp new file mode 100644 index 0000000..dcf9d20 --- /dev/null +++ b/test cases/common/97 selfbuilt custom/mainprog.cpp @@ -0,0 +1,5 @@ +#include"data.h" + +int main(int, char **) { + return generated_function() != 52; +} diff --git a/test cases/common/97 selfbuilt custom/meson.build b/test cases/common/97 selfbuilt custom/meson.build new file mode 100644 index 0000000..4b677a7 --- /dev/null +++ b/test cases/common/97 selfbuilt custom/meson.build @@ -0,0 +1,16 @@ +project('selfbuilt custom', 'cpp') + +# Build an exe and use it in a custom target +# whose output is used to build a different exe. + +tool = executable('tool', 'tool.cpp') + +hfile = custom_target('datah', + output : 'data.h', + input : 'data.dat', + command : [tool, '@INPUT@', '@OUTPUT@'], +) + +main = executable('mainprog', 'mainprog.cpp', hfile) + +test('maintest', main) diff --git a/test cases/common/97 selfbuilt custom/tool.cpp b/test cases/common/97 selfbuilt custom/tool.cpp new file mode 100644 index 0000000..6a28dd8 --- /dev/null +++ b/test cases/common/97 selfbuilt custom/tool.cpp @@ -0,0 +1,34 @@ +#include<iostream> +#include<fstream> +#include<string> + +using namespace std; + +const char prefix[] = "int "; +const char suffix[] = " () {\n return 52;}\n"; + +int main(int argc, char **argv) { + if(argc != 3) { + cout << "You is fail.\n"; + return 1; + } + ifstream is(argv[1], ifstream::binary); + if(!is) { + cout << "Opening input file failed.\n"; + return 1; + } + string funcname; + is >> funcname; + ofstream os(argv[2], ofstream::binary); + if(!os) { + cout << "Opening output file failed.\n"; + return 1; + } + os << prefix << funcname << suffix; + os.close(); + if(!os.good()) { + cout << "Writing data out failed.\n"; + return 1; + } + return 0; +} |