aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJussi Pakkanen <jpakkane@gmail.com>2020-11-21 19:37:05 +0200
committerJussi Pakkanen <jpakkane@gmail.com>2020-12-11 19:21:02 +0000
commitb8cb53791e7211c5dd8ba7c397e35e4280300e11 (patch)
tree7e00ebfc80dbc4664b85d3a397dbdc4d9fdc5679
parentb65168c558c64cd2af4a9586443c295c5bec1114 (diff)
downloadmeson-b8cb53791e7211c5dd8ba7c397e35e4280300e11.zip
meson-b8cb53791e7211c5dd8ba7c397e35e4280300e11.tar.gz
meson-b8cb53791e7211c5dd8ba7c397e35e4280300e11.tar.bz2
Generate scanning rules for C++ modules.
-rw-r--r--mesonbuild/backend/ninjabackend.py24
1 files changed, 24 insertions, 0 deletions
diff --git a/mesonbuild/backend/ninjabackend.py b/mesonbuild/backend/ninjabackend.py
index 0fe8a2f..de187c4 100644
--- a/mesonbuild/backend/ninjabackend.py
+++ b/mesonbuild/backend/ninjabackend.py
@@ -1074,6 +1074,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.'))
@@ -1107,6 +1109,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
@@ -1957,6 +1961,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]