diff options
author | Xavier Claessens <xavier.claessens@collabora.com> | 2023-04-30 10:19:06 -0400 |
---|---|---|
committer | Xavier Claessens <xavier.claessens@collabora.com> | 2023-05-01 12:57:45 -0400 |
commit | ff86e799a4d1119f51d7e7715944a2c87eaef509 (patch) | |
tree | e4557e973f81a73baf5a3ae0cbc57b1030978f45 /mesonbuild/backend | |
parent | 25f4f77a3b22630032827b1f29eb353b6ff07507 (diff) | |
download | meson-ff86e799a4d1119f51d7e7715944a2c87eaef509.zip meson-ff86e799a4d1119f51d7e7715944a2c87eaef509.tar.gz meson-ff86e799a4d1119f51d7e7715944a2c87eaef509.tar.bz2 |
extract_all_objects: Include PCH object with MSVC
This changes the object file name with ninja backend to match the
name used by vs backend and add it in outputs of the ninja rule.
Diffstat (limited to 'mesonbuild/backend')
-rw-r--r-- | mesonbuild/backend/backends.py | 18 | ||||
-rw-r--r-- | mesonbuild/backend/ninjabackend.py | 2 |
2 files changed, 17 insertions, 3 deletions
diff --git a/mesonbuild/backend/backends.py b/mesonbuild/backend/backends.py index 4972eab..d17a9a5 100644 --- a/mesonbuild/backend/backends.py +++ b/mesonbuild/backend/backends.py @@ -842,6 +842,8 @@ class Backend: def _determine_ext_objs(self, extobj: 'build.ExtractedObjects', proj_dir_to_build_root: str) -> T.List[str]: result: T.List[str] = [] + targetdir = self.get_target_private_dir(extobj.target) + # Merge sources and generated sources raw_sources = list(extobj.srclist) for gensrc in extobj.genlist: @@ -858,12 +860,18 @@ class Backend: elif self.environment.is_object(s): result.append(s.relative_name()) + # MSVC generate an object file for PCH + if extobj.pch: + for lang, pch in extobj.target.pch.items(): + compiler = extobj.target.compilers[lang] + if compiler.get_argument_syntax() == 'msvc': + objname = self.get_msvc_pch_objname(lang, pch) + result.append(os.path.join(proj_dir_to_build_root, targetdir, objname)) + # extobj could contain only objects and no sources if not sources: return result - targetdir = self.get_target_private_dir(extobj.target) - # With unity builds, sources don't map directly to objects, # we only support extracting all the objects in this mode, # so just return all object files. @@ -898,6 +906,12 @@ class Backend: args += compiler.get_pch_use_args(pchpath, p[0]) return includeargs + args + def get_msvc_pch_objname(self, lang: str, pch: T.List[str]) -> str: + if len(pch) == 1: + # Same name as in create_msvc_pch_implementation() below. + return f'meson_pch-{lang}.obj' + return os.path.splitext(pch[1])[0] + '.obj' + def create_msvc_pch_implementation(self, target: build.BuildTarget, lang: str, pch_header: str) -> str: # We have to include the language in the file name, otherwise # pch.c and pch.cpp will both end up as pch.obj in VS backends. diff --git a/mesonbuild/backend/ninjabackend.py b/mesonbuild/backend/ninjabackend.py index d61c359..8bfe96d 100644 --- a/mesonbuild/backend/ninjabackend.py +++ b/mesonbuild/backend/ninjabackend.py @@ -3066,7 +3066,7 @@ https://gcc.gnu.org/bugzilla/show_bug.cgi?id=47485''')) extradep = None pch_objects += objs rulename = self.compiler_to_pch_rule_name(compiler) - elem = NinjaBuildElement(self.all_outputs, dst, rulename, src) + elem = NinjaBuildElement(self.all_outputs, objs + [dst], rulename, src) if extradep is not None: elem.add_dep(extradep) self.add_header_deps(target, elem, header_deps) |