summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--mesonbuild/backend/ninjabackend.py10
-rw-r--r--test cases/common/259 preprocess/meson.build6
2 files changed, 11 insertions, 5 deletions
diff --git a/mesonbuild/backend/ninjabackend.py b/mesonbuild/backend/ninjabackend.py
index 19da2499a..5aeaa4803 100644
--- a/mesonbuild/backend/ninjabackend.py
+++ b/mesonbuild/backend/ninjabackend.py
@@ -856,6 +856,10 @@ class NinjaBackend(backends.Backend):
self.generate_swift_target(target)
return
+ # CompileTarget compiles all its sources and does not do a final link.
+ # This is, for example, a preprocessor.
+ is_compile_target = isinstance(target, build.CompileTarget)
+
# Preexisting target C/C++ sources to be built; dict of full path to
# source relative to build root and the original File object.
target_sources: T.MutableMapping[str, File]
@@ -922,6 +926,8 @@ class NinjaBackend(backends.Backend):
obj_list.append(rel_src)
elif self.environment.is_library(rel_src) or modules.is_module_library(rel_src):
pass
+ elif is_compile_target:
+ generated_source_files.append(raw_src)
else:
# Assume anything not specifically a source file is a header. This is because
# people generate files with weird suffixes (.inc, .fh) that they then include
@@ -992,7 +998,7 @@ class NinjaBackend(backends.Backend):
# Generate compile targets for all the preexisting sources for this target
for src in target_sources.values():
- if not self.environment.is_header(src):
+ if not self.environment.is_header(src) or is_compile_target:
if self.environment.is_llvm_ir(src):
o, s = self.generate_llvm_ir_compile(target, src)
obj_list.append(o)
@@ -1015,7 +1021,7 @@ class NinjaBackend(backends.Backend):
obj_list.append(o)
compiled_sources.append(s)
source2object[s] = o
- if isinstance(target, build.CompileTarget):
+ if is_compile_target:
# Skip the link stage for this special type of target
return
linker, stdlib_args = self.determine_linker_and_stdlib_args(target)
diff --git a/test cases/common/259 preprocess/meson.build b/test cases/common/259 preprocess/meson.build
index 2650166b2..5107427c1 100644
--- a/test cases/common/259 preprocess/meson.build
+++ b/test cases/common/259 preprocess/meson.build
@@ -6,16 +6,16 @@ add_project_arguments(['-DFOO=0', '-DBAR=0'], language: 'c')
fs = import('fs')
bar_content = fs.read('bar.c')
-bar_c = custom_target(
+bar_x = custom_target(
input: 'bar.c',
- output: 'bar.c',
+ output: 'bar.x',
command: ['python3', '-c', '''import sys;print(sys.argv[1].replace('@BAR@', 'bar'))''', bar_content],
capture: true,
)
dep = declare_dependency(compile_args: '-DPLOP=0')
-pp_files = cc.preprocess('foo.c', bar_c, output: '@PLAINNAME@', dependencies: dep)
+pp_files = cc.preprocess('foo.c', bar_x, output: '@PLAINNAME@.c', dependencies: dep)
foreach f : pp_files
message(f.full_path())