From 533973671b4de1b9ff9a41dc631b626c11f58fdf Mon Sep 17 00:00:00 2001 From: Massimiliano Culpo Date: Wed, 27 Nov 2024 11:33:57 +0100 Subject: [PATCH] builtin: fix for Windows pipelines --- .../builtin/packages/libtheora/package.py | 2 +- .../repos/builtin/packages/msvc/package.py | 64 +++++++++++++++++++ 2 files changed, 65 insertions(+), 1 deletion(-) diff --git a/var/spack/repos/builtin/packages/libtheora/package.py b/var/spack/repos/builtin/packages/libtheora/package.py index f835016467c..457c611f5bb 100644 --- a/var/spack/repos/builtin/packages/libtheora/package.py +++ b/var/spack/repos/builtin/packages/libtheora/package.py @@ -88,7 +88,7 @@ def setup_build_environment(self, env): # devenv is needed to convert ancient MSbuild project to modern # msbuild project so MSBuild versions older than 2010 can build this # project - devenv_path = os.path.join(self.pkg.compiler.vs_root, "Common7", "IDE") + devenv_path = os.path.join(self.spec["msvc"].package.vs_root, "Common7", "IDE") env.prepend_path("PATH", devenv_path) @property diff --git a/var/spack/repos/builtin/packages/msvc/package.py b/var/spack/repos/builtin/packages/msvc/package.py index f6677829627..0f5cd750ef8 100644 --- a/var/spack/repos/builtin/packages/msvc/package.py +++ b/var/spack/repos/builtin/packages/msvc/package.py @@ -143,6 +143,70 @@ def _standard_flag(self, *, language: str, standard: str) -> str: } return flags[language][standard] + @property + def short_msvc_version(self): + """This is the shorthand VCToolset version of form + MSVC + """ + return "MSVC" + self.vc_toolset_ver + + @property + def vc_toolset_ver(self): + """ + The toolset version is the version of the combined set of cl and link + This typically relates directly to VS version i.e. VS 2022 is v143 + VS 19 is v142, etc. + This value is defined by the first three digits of the major + minor + version of the VS toolset (143 for 14.3x.bbbbb). Traditionally the + minor version has remained a static two digit number for a VS release + series, however, as of VS22, this is no longer true, both + 14.4x.bbbbb and 14.3x.bbbbb are considered valid VS22 VC toolset + versions due to a change in toolset minor version sentiment. + + This is *NOT* the full version, for that see + Msvc.msvc_version or MSVC.platform_toolset_ver for the + raw platform toolset version + + """ + ver = self.msvc_version[:2].joined.string[:3] + return ver + + @property + def msvc_version(self): + """This is the VCToolset version *NOT* the actual version of the cl compiler""" + return spack.version.Version(re.search(Msvc.compiler_version_regex, self.cc).group(1)) + + @property + def vs_root(self): + # The MSVC install root is located at a fix level above the compiler + # and is referenceable idiomatically via the pattern below + # this should be consistent accross versions + return os.path.abspath(os.path.join(self.cc, "../../../../../../../..")) + + @property + def platform_toolset_ver(self): + """ + This is the platform toolset version of current MSVC compiler + i.e. 142. The platform toolset is the targeted MSVC library/compiler + versions by compilation (this is different from the VC Toolset) + + + This is different from the VC toolset version as established + by `short_msvc_version`, but typically are represented by the same + three digit value + """ + # Typically VS toolset version and platform toolset versions match + # VS22 introduces the first divergence of VS toolset version + # (144 for "recent" releases) and platform toolset version (143) + # so it needs additional handling until MS releases v144 + # (assuming v144 is also for VS22) + # or adds better support for detection + # TODO: (johnwparent) Update this logic for the next platform toolset + # or VC toolset version update + toolset_ver = self.vc_toolset_ver + vs22_toolset = spack.version.Version(toolset_ver) > Version("142") + return toolset_ver if not vs22_toolset else "143" + class CmdCall: """Compose a call to `cmd` for an ordered series of cmd commands/scripts"""