|
|
@ -666,10 +666,10 @@ class NinjaBackend(backends.Backend): |
|
|
|
# TODO: Rather than an explicit list here, rules could be marked in the |
|
|
|
# TODO: Rather than an explicit list here, rules could be marked in the |
|
|
|
# rule store as being wanted in compdb |
|
|
|
# rule store as being wanted in compdb |
|
|
|
for for_machine in MachineChoice: |
|
|
|
for for_machine in MachineChoice: |
|
|
|
for lang in self.environment.coredata.compilers[for_machine]: |
|
|
|
for compiler in self.environment.coredata.compilers[for_machine].values(): |
|
|
|
rules += [f"{rule}{ext}" for rule in [self.get_compiler_rule_name(lang, for_machine)] |
|
|
|
rules += [f"{rule}{ext}" for rule in [self.compiler_to_rule_name(compiler)] |
|
|
|
for ext in ['', '_RSP']] |
|
|
|
for ext in ['', '_RSP']] |
|
|
|
rules += [f"{rule}{ext}" for rule in [self.get_pch_rule_name(lang, for_machine)] |
|
|
|
rules += [f"{rule}{ext}" for rule in [self.compiler_to_pch_rule_name(compiler)] |
|
|
|
for ext in ['', '_RSP']] |
|
|
|
for ext in ['', '_RSP']] |
|
|
|
compdb_options = ['-x'] if mesonlib.version_compare(self.ninja_version, '>=1.9') else [] |
|
|
|
compdb_options = ['-x'] if mesonlib.version_compare(self.ninja_version, '>=1.9') else [] |
|
|
|
ninja_compdb = self.ninja_command + ['-t', 'compdb'] + compdb_options + rules |
|
|
|
ninja_compdb = self.ninja_command + ['-t', 'compdb'] + compdb_options + rules |
|
|
@ -986,6 +986,9 @@ class NinjaBackend(backends.Backend): |
|
|
|
obj_list.append(o) |
|
|
|
obj_list.append(o) |
|
|
|
compiled_sources.append(s) |
|
|
|
compiled_sources.append(s) |
|
|
|
source2object[s] = o |
|
|
|
source2object[s] = o |
|
|
|
|
|
|
|
if isinstance(target, build.CompileTarget): |
|
|
|
|
|
|
|
# Skip the link stage for this special type of target |
|
|
|
|
|
|
|
return |
|
|
|
linker, stdlib_args = self.determine_linker_and_stdlib_args(target) |
|
|
|
linker, stdlib_args = self.determine_linker_and_stdlib_args(target) |
|
|
|
if isinstance(target, build.StaticLibrary) and target.prelink: |
|
|
|
if isinstance(target, build.StaticLibrary) and target.prelink: |
|
|
|
final_obj_list = self.generate_prelink(target, obj_list) |
|
|
|
final_obj_list = self.generate_prelink(target, obj_list) |
|
|
@ -1426,7 +1429,7 @@ class NinjaBackend(backends.Backend): |
|
|
|
commands += self.build.get_project_args(compiler, target.subproject, target.for_machine) |
|
|
|
commands += self.build.get_project_args(compiler, target.subproject, target.for_machine) |
|
|
|
commands += self.build.get_global_args(compiler, target.for_machine) |
|
|
|
commands += self.build.get_global_args(compiler, target.for_machine) |
|
|
|
|
|
|
|
|
|
|
|
elem = NinjaBuildElement(self.all_outputs, outputs, self.get_compiler_rule_name('cs', target.for_machine), rel_srcs + generated_rel_srcs) |
|
|
|
elem = NinjaBuildElement(self.all_outputs, outputs, self.compiler_to_rule_name(compiler), rel_srcs + generated_rel_srcs) |
|
|
|
elem.add_dep(deps) |
|
|
|
elem.add_dep(deps) |
|
|
|
elem.add_item('ARGS', commands) |
|
|
|
elem.add_item('ARGS', commands) |
|
|
|
self.add_build(elem) |
|
|
|
self.add_build(elem) |
|
|
@ -1959,7 +1962,7 @@ class NinjaBackend(backends.Backend): |
|
|
|
getattr(target, 'rust_crate_type', '') == 'procmacro', |
|
|
|
getattr(target, 'rust_crate_type', '') == 'procmacro', |
|
|
|
output, project_deps) |
|
|
|
output, project_deps) |
|
|
|
|
|
|
|
|
|
|
|
compiler_name = self.get_compiler_rule_name('rust', target.for_machine) |
|
|
|
compiler_name = self.compiler_to_rule_name(rustc) |
|
|
|
element = NinjaBuildElement(self.all_outputs, target_name, compiler_name, main_rust_file) |
|
|
|
element = NinjaBuildElement(self.all_outputs, target_name, compiler_name, main_rust_file) |
|
|
|
if orderdeps: |
|
|
|
if orderdeps: |
|
|
|
element.add_orderdep(orderdeps) |
|
|
|
element.add_orderdep(orderdeps) |
|
|
@ -1978,20 +1981,16 @@ class NinjaBackend(backends.Backend): |
|
|
|
return PerMachine('_FOR_BUILD', '')[for_machine] |
|
|
|
return PerMachine('_FOR_BUILD', '')[for_machine] |
|
|
|
|
|
|
|
|
|
|
|
@classmethod |
|
|
|
@classmethod |
|
|
|
def get_compiler_rule_name(cls, lang: str, for_machine: MachineChoice) -> str: |
|
|
|
def get_compiler_rule_name(cls, lang: str, for_machine: MachineChoice, mode: str = 'COMPILER') -> str: |
|
|
|
return '{}_COMPILER{}'.format(lang, cls.get_rule_suffix(for_machine)) |
|
|
|
return f'{lang}_{mode}{cls.get_rule_suffix(for_machine)}' |
|
|
|
|
|
|
|
|
|
|
|
@classmethod |
|
|
|
|
|
|
|
def get_pch_rule_name(cls, lang: str, for_machine: MachineChoice) -> str: |
|
|
|
|
|
|
|
return '{}_PCH{}'.format(lang, cls.get_rule_suffix(for_machine)) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@classmethod |
|
|
|
@classmethod |
|
|
|
def compiler_to_rule_name(cls, compiler: Compiler) -> str: |
|
|
|
def compiler_to_rule_name(cls, compiler: Compiler) -> str: |
|
|
|
return cls.get_compiler_rule_name(compiler.get_language(), compiler.for_machine) |
|
|
|
return cls.get_compiler_rule_name(compiler.get_language(), compiler.for_machine, compiler.mode) |
|
|
|
|
|
|
|
|
|
|
|
@classmethod |
|
|
|
@classmethod |
|
|
|
def compiler_to_pch_rule_name(cls, compiler: Compiler) -> str: |
|
|
|
def compiler_to_pch_rule_name(cls, compiler: Compiler) -> str: |
|
|
|
return cls.get_pch_rule_name(compiler.get_language(), compiler.for_machine) |
|
|
|
return cls.get_compiler_rule_name(compiler.get_language(), compiler.for_machine, 'PCH') |
|
|
|
|
|
|
|
|
|
|
|
def swift_module_file_name(self, target): |
|
|
|
def swift_module_file_name(self, target): |
|
|
|
return os.path.join(self.get_target_private_dir(target), |
|
|
|
return os.path.join(self.get_target_private_dir(target), |
|
|
@ -2090,7 +2089,7 @@ class NinjaBackend(backends.Backend): |
|
|
|
objects.append(oname) |
|
|
|
objects.append(oname) |
|
|
|
rel_objects.append(os.path.join(self.get_target_private_dir(target), oname)) |
|
|
|
rel_objects.append(os.path.join(self.get_target_private_dir(target), oname)) |
|
|
|
|
|
|
|
|
|
|
|
rulename = self.get_compiler_rule_name('swift', target.for_machine) |
|
|
|
rulename = self.compiler_to_rule_name(swiftc) |
|
|
|
|
|
|
|
|
|
|
|
# Swiftc does not seem to be able to emit objects and module files in one go. |
|
|
|
# Swiftc does not seem to be able to emit objects and module files in one go. |
|
|
|
elem = NinjaBuildElement(self.all_outputs, rel_objects, rulename, abssrc) |
|
|
|
elem = NinjaBuildElement(self.all_outputs, rel_objects, rulename, abssrc) |
|
|
@ -2099,9 +2098,7 @@ class NinjaBackend(backends.Backend): |
|
|
|
elem.add_item('ARGS', compile_args + header_imports + abs_generated + module_includes) |
|
|
|
elem.add_item('ARGS', compile_args + header_imports + abs_generated + module_includes) |
|
|
|
elem.add_item('RUNDIR', rundir) |
|
|
|
elem.add_item('RUNDIR', rundir) |
|
|
|
self.add_build(elem) |
|
|
|
self.add_build(elem) |
|
|
|
elem = NinjaBuildElement(self.all_outputs, out_module_name, |
|
|
|
elem = NinjaBuildElement(self.all_outputs, out_module_name, rulename, abssrc) |
|
|
|
self.get_compiler_rule_name('swift', target.for_machine), |
|
|
|
|
|
|
|
abssrc) |
|
|
|
|
|
|
|
elem.add_dep(in_module_files + rel_generated) |
|
|
|
elem.add_dep(in_module_files + rel_generated) |
|
|
|
elem.add_item('ARGS', compile_args + abs_generated + module_includes + swiftc.get_mod_gen_args()) |
|
|
|
elem.add_item('ARGS', compile_args + abs_generated + module_includes + swiftc.get_mod_gen_args()) |
|
|
|
elem.add_item('RUNDIR', rundir) |
|
|
|
elem.add_item('RUNDIR', rundir) |
|
|
@ -2312,7 +2309,7 @@ https://gcc.gnu.org/bugzilla/show_bug.cgi?id=47485''')) |
|
|
|
crstr = self.get_rule_suffix(compiler.for_machine) |
|
|
|
crstr = self.get_rule_suffix(compiler.for_machine) |
|
|
|
if langname == 'fortran': |
|
|
|
if langname == 'fortran': |
|
|
|
self.generate_fortran_dep_hack(crstr) |
|
|
|
self.generate_fortran_dep_hack(crstr) |
|
|
|
rule = self.get_compiler_rule_name(langname, compiler.for_machine) |
|
|
|
rule = self.compiler_to_rule_name(compiler) |
|
|
|
depargs = NinjaCommandArg.list(compiler.get_dependency_gen_args('$out', '$DEPFILE'), Quoting.none) |
|
|
|
depargs = NinjaCommandArg.list(compiler.get_dependency_gen_args('$out', '$DEPFILE'), Quoting.none) |
|
|
|
command = compiler.get_exelist() |
|
|
|
command = compiler.get_exelist() |
|
|
|
args = ['$ARGS'] + depargs + NinjaCommandArg.list(compiler.get_output_args('$out'), Quoting.none) + compiler.get_compile_only_args() + ['$in'] |
|
|
|
args = ['$ARGS'] + depargs + NinjaCommandArg.list(compiler.get_output_args('$out'), Quoting.none) + compiler.get_compile_only_args() + ['$in'] |
|
|
@ -2368,6 +2365,8 @@ https://gcc.gnu.org/bugzilla/show_bug.cgi?id=47485''')) |
|
|
|
self.generate_llvm_ir_compile_rule(compiler) |
|
|
|
self.generate_llvm_ir_compile_rule(compiler) |
|
|
|
self.generate_compile_rule_for(langname, compiler) |
|
|
|
self.generate_compile_rule_for(langname, compiler) |
|
|
|
self.generate_pch_rule_for(langname, compiler) |
|
|
|
self.generate_pch_rule_for(langname, compiler) |
|
|
|
|
|
|
|
for mode in compiler.get_modes(): |
|
|
|
|
|
|
|
self.generate_compile_rule_for(langname, mode) |
|
|
|
|
|
|
|
|
|
|
|
def generate_generator_list_rules(self, target): |
|
|
|
def generate_generator_list_rules(self, target): |
|
|
|
# CustomTargets have already written their rules and |
|
|
|
# CustomTargets have already written their rules and |
|
|
|