diff options
author | Jussi Pakkanen <jpakkane@gmail.com> | 2020-11-21 19:37:05 +0200 |
---|---|---|
committer | Jussi Pakkanen <jpakkane@gmail.com> | 2020-11-21 19:37:05 +0200 |
commit | b5df58ab12e4ef665100088b4d1f05351fa665d3 (patch) | |
tree | 86f0b541ce6a5c7ccc43495ec38759ea34e3bfc1 | |
parent | 15bbf1ea7581a8a872296435b28d679c7e42a466 (diff) | |
download | meson-b5df58ab12e4ef665100088b4d1f05351fa665d3.zip meson-b5df58ab12e4ef665100088b4d1f05351fa665d3.tar.gz meson-b5df58ab12e4ef665100088b4d1f05351fa665d3.tar.bz2 |
Generate scanning rules for C++ modules.
-rw-r--r-- | mesonbuild/backend/ninjabackend.py | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/mesonbuild/backend/ninjabackend.py b/mesonbuild/backend/ninjabackend.py index 15218c1..7fb1597 100644 --- a/mesonbuild/backend/ninjabackend.py +++ b/mesonbuild/backend/ninjabackend.py @@ -1070,6 +1070,8 @@ int dummy; self.rules = [] self.ruledict = {} + self.add_rule_comment(NinjaComment('Rules for module scanning.')) + self.generate_scanner_rules() self.add_rule_comment(NinjaComment('Rules for compiling.')) self.generate_compile_rules() self.add_rule_comment(NinjaComment('Rules for linking.')) @@ -1103,6 +1105,8 @@ int dummy; self.build_elements.append(comment) def add_rule(self, rule): + if rule.name in self.ruledict: + raise MesonException('Tried to add rule {} twice.'.format(rule.name)) self.rules.append(rule) self.ruledict[rule.name] = rule @@ -1953,6 +1957,26 @@ https://gcc.gnu.org/bugzilla/show_bug.cgi?id=47485''')) self.add_rule(NinjaRule(rule, command, [], description, deps=deps, depfile=depfile)) + + def generate_scanner_rules(self): + scanner_languages = {'cpp'} # Fixme, add Fortran. + for for_machine in MachineChoice: + clist = self.environment.coredata.compilers[for_machine] + for langname, compiler in clist.items(): + if langname not in scanner_languages: + continue + rulename = '{}scan'.format(langname) + if rulename in self.ruledict: + # Scanning command is the same for native and cross compilation. + continue + command = cmd = self.environment.get_build_command() + \ + ['--internal', 'scan'] + args = ['$picklefile', '$out', '$in'] + description = 'Module scanner for {}.'.format(langname) + rule = NinjaRule(rulename, command, args, description) + self.add_rule(rule) + + def generate_compile_rules(self): for for_machine in MachineChoice: clist = self.environment.coredata.compilers[for_machine] |