|
|
|
@ -366,7 +366,11 @@ int dummy; |
|
|
|
|
desc = 'Generating {0} with a {1} command.' |
|
|
|
|
if target.build_always: |
|
|
|
|
deps.append('PHONY') |
|
|
|
|
elem = NinjaBuildElement(self.all_outputs, ofilenames, 'CUSTOM_COMMAND', srcs) |
|
|
|
|
if target.depfile is None: |
|
|
|
|
rulename = 'CUSTOM_COMMAND' |
|
|
|
|
else: |
|
|
|
|
rulename = 'CUSTOM_COMMAND_DEP' |
|
|
|
|
elem = NinjaBuildElement(self.all_outputs, ofilenames, rulename, srcs) |
|
|
|
|
for i in target.depend_files: |
|
|
|
|
if isinstance(i, mesonlib.File): |
|
|
|
|
deps.append(i.rel_to_builddir(self.build_to_src)) |
|
|
|
@ -398,6 +402,11 @@ int dummy; |
|
|
|
|
else: |
|
|
|
|
cmd_type = 'custom' |
|
|
|
|
|
|
|
|
|
if target.depfile is not None: |
|
|
|
|
rel_dfile = os.path.join(self.get_target_private_dir(target), target.depfile) |
|
|
|
|
abs_pdir = os.path.join(self.environment.get_build_dir(), self.get_target_private_dir(target)) |
|
|
|
|
os.makedirs(abs_pdir, exist_ok=True) |
|
|
|
|
elem.add_item('DEPFILE', rel_dfile) |
|
|
|
|
elem.add_item('COMMAND', cmd) |
|
|
|
|
elem.add_item('description', desc.format(target.name, cmd_type)) |
|
|
|
|
elem.write(outfile) |
|
|
|
@ -640,7 +649,6 @@ int dummy; |
|
|
|
|
velem.write(outfile) |
|
|
|
|
|
|
|
|
|
# And then benchmarks. |
|
|
|
|
benchmark_script = os.path.join(script_root, 'meson_benchmark.py') |
|
|
|
|
cmd = [sys.executable, self.environment.get_build_command(), '--internal', 'benchmark', benchmark_data] |
|
|
|
|
elem = NinjaBuildElement(self.all_outputs, 'benchmark', 'CUSTOM_COMMAND', ['all', 'PHONY']) |
|
|
|
|
elem.add_item('COMMAND', cmd) |
|
|
|
@ -661,6 +669,14 @@ int dummy; |
|
|
|
|
outfile.write(' command = $COMMAND\n') |
|
|
|
|
outfile.write(' description = $DESC\n') |
|
|
|
|
outfile.write(' restat = 1\n\n') |
|
|
|
|
# Ninja errors out if you have deps = gcc but no depfile, so we must |
|
|
|
|
# have two rules for custom commands. |
|
|
|
|
outfile.write('rule CUSTOM_COMMAND_DEP\n') |
|
|
|
|
outfile.write(' command = $COMMAND\n') |
|
|
|
|
outfile.write(' description = $DESC\n') |
|
|
|
|
outfile.write(' deps = gcc\n') |
|
|
|
|
outfile.write(' depfile = $DEPFILE\n') |
|
|
|
|
outfile.write(' restat = 1\n\n') |
|
|
|
|
outfile.write('rule REGENERATE_BUILD\n') |
|
|
|
|
c = (quote_char + ninja_quote(sys.executable) + quote_char, |
|
|
|
|
quote_char + ninja_quote(self.environment.get_build_command()) + quote_char, |
|
|
|
@ -1355,8 +1371,16 @@ rule FORTRAN_DEP_HACK |
|
|
|
|
infilename = os.path.join(self.build_to_src, curfile) |
|
|
|
|
outfiles = genlist.get_outputs_for(curfile) |
|
|
|
|
outfiles = [os.path.join(self.get_target_private_dir(target), of) for of in outfiles] |
|
|
|
|
if generator.depfile is None: |
|
|
|
|
rulename = 'CUSTOM_COMMAND' |
|
|
|
|
args = base_args |
|
|
|
|
else: |
|
|
|
|
rulename = 'CUSTOM_COMMAND_DEP' |
|
|
|
|
depfilename = generator.get_dep_outname(infilename) |
|
|
|
|
depfile = os.path.join(self.get_target_private_dir(target), depfilename) |
|
|
|
|
args = [x.replace('@DEPFILE@', depfile) for x in base_args] |
|
|
|
|
args = [x.replace("@INPUT@", infilename).replace('@OUTPUT@', sole_output)\ |
|
|
|
|
for x in base_args] |
|
|
|
|
for x in args] |
|
|
|
|
args = self.replace_outputs(args, self.get_target_private_dir(target), outfilelist) |
|
|
|
|
# We have consumed output files, so drop them from the list of remaining outputs. |
|
|
|
|
if sole_output == '': |
|
|
|
@ -1365,7 +1389,9 @@ rule FORTRAN_DEP_HACK |
|
|
|
|
args = [x.replace("@SOURCE_DIR@", self.build_to_src).replace("@BUILD_DIR@", relout) |
|
|
|
|
for x in args] |
|
|
|
|
cmdlist = exe_arr + self.replace_extra_args(args, genlist) |
|
|
|
|
elem = NinjaBuildElement(self.all_outputs, outfiles, 'CUSTOM_COMMAND', infilename) |
|
|
|
|
elem = NinjaBuildElement(self.all_outputs, outfiles, rulename, infilename) |
|
|
|
|
if generator.depfile is not None: |
|
|
|
|
elem.add_item('DEPFILE', depfile) |
|
|
|
|
if len(extra_dependencies) > 0: |
|
|
|
|
elem.add_dep(extra_dependencies) |
|
|
|
|
elem.add_item('DESC', 'Generating $out') |
|
|
|
|