Bug 1832700 - Set MSVS_VERSION according to the MSVC version. r=firefox-build-system-reviewers,andi

Differential Revision: https://phabricator.services.mozilla.com/D177836
This commit is contained in:
Mike Hommey 2023-05-15 21:56:37 +00:00
parent 830ef79482
commit 71bcf54e47
2 changed files with 27 additions and 14 deletions

View File

@ -664,17 +664,34 @@ def vc_compiler_version(vc_compiler_path):
)
# MSVC path with version 14.x is actually version 19.x
if version.major == 14:
return f"19.{version.minor}"
return Version(f"19.{version.minor}")
@depends_if(vc_compiler_version)
def is_vs2019_or_more(vc_compiler_version):
return Version(vc_compiler_version) >= Version("19.20")
return vc_compiler_version >= Version("19.20")
add_old_configure_assignment("IS_VS2019_OR_MORE", is_vs2019_or_more)
@depends_if(vc_compiler_version)
def msvs_version(vc_compiler_version):
# clang-cl emulates the same version scheme as cl. And MSVS_VERSION needs to
# be set for GYP on Windows.
if vc_compiler_version >= Version("19.30"):
return "2022"
if vc_compiler_version >= Version("19.20"):
return "2019"
if vc_compiler_version >= Version("19.10"):
return "2017"
return ""
set_config("MSVS_VERSION", msvs_version)
clang_search_path = bootstrap_search_path("clang/bin")
@ -1940,18 +1957,6 @@ set_config("GCC_USE_GNU_LD", gcc_use_gnu_ld)
add_old_configure_assignment("GCC_USE_GNU_LD", gcc_use_gnu_ld)
@depends(c_compiler)
def msvs_version(info):
# clang-cl emulates the same version scheme as cl. And MSVS_VERSION needs to
# be set for GYP on Windows.
if info.type == "clang-cl":
return "2017"
return ""
set_config("MSVS_VERSION", msvs_version)
include("compile-checks.configure")
include("arm.configure", when=depends(target.cpu)(lambda cpu: cpu == "arm"))

View File

@ -43,6 +43,10 @@ def get_id(name):
def visual_studio_product_to_solution_version(version):
if version == "2017":
return "12.00", "15"
elif version == "2019":
return "12.00", "16"
elif version == "2022":
return "12.00", "17"
else:
raise Exception("Unknown version seen: %s" % version)
@ -50,6 +54,10 @@ def visual_studio_product_to_solution_version(version):
def visual_studio_product_to_platform_toolset_version(version):
if version == "2017":
return "v141"
elif version == "2019":
return "v142"
elif version == "2022":
return "v143"
else:
raise Exception("Unknown version seen: %s" % version)