Browse Source

Store run target names in build.

This way we can easily check that we only provide builtin targets such
as clang-format if the user has not provided their own.
Jussi Pakkanen 1 month ago
parent
commit
35e809fc5e

+ 6
- 0
mesonbuild/backend/ninjabackend.py View File

@@ -2648,6 +2648,8 @@ https://gcc.gnu.org/bugzilla/show_bug.cgi?id=47485'''))
2648 2648
     def generate_scanbuild(self):
2649 2649
         if not environment.detect_scanbuild():
2650 2650
             return
2651
+        if ('', 'scan-build') in self.build.run_target_names:
2652
+            return
2651 2653
         cmd = self.environment.get_build_command() + \
2652 2654
             ['--internal', 'scanbuild', self.environment.source_dir, self.environment.build_dir] + \
2653 2655
             self.environment.get_build_command() + self.get_user_option_args()
@@ -2665,6 +2667,8 @@ https://gcc.gnu.org/bugzilla/show_bug.cgi?id=47485'''))
2665 2667
             return
2666 2668
         if target_name in self.all_outputs:
2667 2669
             return
2670
+        if ('', target_name) in self.build.run_target_names:
2671
+            return
2668 2672
         cmd = self.environment.get_build_command() + \
2669 2673
             ['--internal', 'clang' + name, self.environment.source_dir, self.environment.build_dir]
2670 2674
         elem = NinjaBuildElement(self.all_outputs, 'meson-' + target_name, 'CUSTOM_COMMAND', 'PHONY')
@@ -2688,6 +2692,8 @@ https://gcc.gnu.org/bugzilla/show_bug.cgi?id=47485'''))
2688 2692
         import shutil
2689 2693
         if not shutil.which(tool):
2690 2694
             return
2695
+        if ('', target_name) in self.build.run_target_names:
2696
+            return
2691 2697
         if target_name in self.all_outputs:
2692 2698
             return
2693 2699
         cmd = self.environment.get_build_command() + \

+ 1
- 0
mesonbuild/build.py View File

@@ -117,6 +117,7 @@ class Build:
117 117
         self.environment = environment
118 118
         self.projects = {}
119 119
         self.targets = OrderedDict()
120
+        self.run_target_names = set() # type: typing.Set[typing.Tuple[str, str]]
120 121
         self.global_args = PerMachine({}, {})         # type: PerMachine[typing.Dict[str, typing.List[str]]]
121 122
         self.projects_args = PerMachine({}, {})       # type: PerMachine[typing.Dict[str, typing.List[str]]]
122 123
         self.global_link_args = PerMachine({}, {})    # type: PerMachine[typing.Dict[str, typing.List[str]]]

+ 3
- 0
mesonbuild/interpreter.py View File

@@ -3369,6 +3369,9 @@ This will become a hard error in the future.''' % kwargs['input'], location=self
3369 3369
         command, *cmd_args = cleaned_args
3370 3370
         tg = RunTargetHolder(build.RunTarget(name, command, cmd_args, cleaned_deps, self.subdir, self.subproject), self)
3371 3371
         self.add_target(name, tg.held_object)
3372
+        full_name = (self.subproject, name)
3373
+        assert(full_name not in self.build.run_target_names)
3374
+        self.build.run_target_names.add(full_name)
3372 3375
         return tg
3373 3376
 
3374 3377
     @FeatureNew('alias_target', '0.52.0')

+ 7
- 0
test cases/common/54 run target/meson.build View File

@@ -65,3 +65,10 @@ conf = configure_file(
65 65
 run_target('configure_script',
66 66
   command : conf
67 67
 )
68
+
69
+# Target names that clash with potential builtin functionality.
70
+run_target('ctags',
71
+  command : converter)
72
+
73
+run_target('clang-format',
74
+  command : converter)

Loading…
Cancel
Save