diff options
author | Xavier Claessens <xavier.claessens@collabora.com> | 2022-10-13 14:09:40 -0400 |
---|---|---|
committer | Xavier Claessens <xavier.claessens@collabora.com> | 2022-10-23 12:21:46 +0200 |
commit | 42a7f8e8efe1753bafe535a0be9acb7ed93a4dbb (patch) | |
tree | fe4b57f81d4444c4720c80531e1289ad5abdddb2 /mesonbuild/backend/backends.py | |
parent | 65590e6e4b59e08d0c1a16067524479ed822ad27 (diff) | |
download | meson-42a7f8e8efe1753bafe535a0be9acb7ed93a4dbb.zip meson-42a7f8e8efe1753bafe535a0be9acb7ed93a4dbb.tar.gz meson-42a7f8e8efe1753bafe535a0be9acb7ed93a4dbb.tar.bz2 |
vs backend: Add support for CompileTarget
Since vs backend only support the C compiler, everything else are custom
targets. Convert CompileTarget into a Generator to reuse existing code.
This will be useful in the future to support transpilers, and
assemblers.
Diffstat (limited to 'mesonbuild/backend/backends.py')
-rw-r--r-- | mesonbuild/backend/backends.py | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/mesonbuild/backend/backends.py b/mesonbuild/backend/backends.py index 9776642..32f24e9 100644 --- a/mesonbuild/backend/backends.py +++ b/mesonbuild/backend/backends.py @@ -50,6 +50,8 @@ if T.TYPE_CHECKING: from typing_extensions import TypedDict + _ALL_SOURCES_TYPE = T.List[T.Union[File, build.CustomTarget, build.CustomTargetIndex, build.GeneratedList]] + class TargetIntrospectionData(TypedDict): language: str @@ -1864,3 +1866,28 @@ class Backend: else: env.prepend('PATH', list(extra_paths)) return env + + def compiler_to_generator(self, target: build.BuildTarget, + compiler: 'Compiler', + sources: _ALL_SOURCES_TYPE, + output_templ: str) -> build.GeneratedList: + ''' + Some backends don't support custom compilers. This is a convenience + method to convert a Compiler to a Generator. + ''' + exelist = compiler.get_exelist() + exe = programs.ExternalProgram(exelist[0]) + args = exelist[1:] + # FIXME: There are many other args missing + commands = self.generate_basic_compiler_args(target, compiler) + commands += compiler.get_dependency_gen_args('@OUTPUT@', '@DEPFILE@') + commands += compiler.get_output_args('@OUTPUT@') + commands += compiler.get_compile_only_args() + ['@INPUT@'] + commands += self.get_source_dir_include_args(target, compiler) + commands += self.get_build_dir_include_args(target, compiler) + generator = build.Generator(exe, args + commands.to_native(), [output_templ], depfile='@PLAINNAME@.d') + return generator.process_files(sources, self.interpreter) + + def compile_target_to_generator(self, target: build.CompileTarget) -> build.GeneratedList: + all_sources = T.cast('_ALL_SOURCES_TYPE', target.sources) + T.cast('_ALL_SOURCES_TYPE', target.generated) + return self.compiler_to_generator(target, target.compiler, all_sources, target.output_templ) |