diff options
author | Friedemann Kleint <Friedemann.Kleint@qt.io> | 2022-12-08 14:54:22 +0100 |
---|---|---|
committer | Friedemann Kleint <Friedemann.Kleint@qt.io> | 2022-12-08 19:17:56 +0100 |
commit | 7fcf5d83d7035fdcdf9d60670cd0bce64ae32e64 (patch) | |
tree | 2079692682df338b174e6c2dea33925ab0ca2bd7 /build_scripts/utils.py | |
parent | 9ef643830072c5138c459f79127df33ecbb56ecc (diff) |
build_system: Remove code trying to find the MSVC installation
The code was not triggered since the build system tries to compile
a small test project with Ninja before even reaching it.
It was also using code for MSVC 9 (2008) which does not work anymore
and causes deprecation warnings:
setuptools\_distutils\msvc9compiler.py:34: DeprecationWarning:
msvc9compiler is deprecated and slated to be removed in the future.
Please discontinue use or file an issue with pypa/distutils describing
your use case.
Change-Id: I95a6b7700c13873884deb6186e78d6c520c592de
Reviewed-by: Cristian Maureira-Fredes <cristian.maureira-fredes@qt.io>
Reviewed-by: Adrian Herrmann <adrian.herrmann@qt.io>
Reviewed-by: Shyamnath Premnadh <Shyamnath.Premnadh@qt.io>
Diffstat (limited to 'build_scripts/utils.py')
-rw-r--r-- | build_scripts/utils.py | 151 |
1 files changed, 0 insertions, 151 deletions
diff --git a/build_scripts/utils.py b/build_scripts/utils.py index 8cd947b32..bc31c29fc 100644 --- a/build_scripts/utils.py +++ b/build_scripts/utils.py @@ -85,157 +85,6 @@ def get_numpy_location(): return None -def winsdk_setenv(platform_arch, build_type): - from setuptools._distutils import msvc9compiler as msvc9 - - sdk_version_map = { - "v6.0a": 9.0, - "v6.1": 9.0, - "v7.0": 9.0, - "v7.0a": 10.0, - "v7.1": 10.0 - } - - log.info(f"Searching Windows SDK with MSVC compiler version {msvc9.VERSION}") - setenv_paths = [] - for base in msvc9.HKEYS: - sdk_versions = msvc9.Reg.read_keys(base, msvc9.WINSDK_BASE) - if sdk_versions: - for sdk_version in sdk_versions: - installationfolder = Path(msvc9.Reg.get_value(f"{msvc9.WINSDK_BASE}\\{sdk_version}", - "installationfolder")) - # productversion = msvc9.Reg.get_value( - # "{}\\{}".format(msvc9.WINSDK_BASE, sdk_version), - # "productversion") - setenv_path = installationfolder / 'bin' / 'SetEnv.cmd' - if setenv_path.exists(): - continue - if sdk_version not in sdk_version_map: - continue - if sdk_version_map[sdk_version] != msvc9.VERSION: - continue - setenv_paths.append(setenv_path) - if len(setenv_paths) == 0: - raise SetupError("Failed to find the Windows SDK with MSVC " - f"compiler version {msvc9.VERSION}") - for setenv_path in setenv_paths: - log.info(f"Found {setenv_path}") - - # Get SDK env (use latest SDK version installed on system) - setenv_path = setenv_paths[-1] - log.info(f"Using {setenv_path} ") - build_arch = "/x86" if platform_arch.startswith("32") else "/x64" - build_type = "/Debug" if build_type.lower() == "debug" else "/Release" - setenv_cmd = [setenv_path, build_arch, build_type] - setenv_env = get_environment_from_batch_command(setenv_cmd) - _setenv_paths = [setenv_env[k] for k in setenv_env if k.upper() == 'PATH'] - setenv_env_paths = os.pathsep.join(_setenv_paths).split(os.pathsep) - setenv_env_without_paths = {k: setenv_env[k] for k in setenv_env if k.upper() != 'PATH'} - - # Extend os.environ with SDK env - log.info("Initializing Windows SDK env...") - update_env_path(setenv_env_paths) - for k in sorted(setenv_env_without_paths): - v = setenv_env_without_paths[k] - log.info(f"Inserting '{k} = {v}' to environment") - os.environ[k] = v - log.info("Done initializing Windows SDK env") - - -def find_vcdir(version): - """ - This is the customized version of - setuptools._distutils.msvc9compiler.find_vcvarsall method - """ - from setuptools._distutils import msvc9compiler as msvc9 - vsbase = msvc9.VS_BASE % version - try: - productdir = Path(msvc9.Reg.get_value(rf"{vsbase}\Setup\VC", "productdir")) - except KeyError: - productdir = None - - # trying Express edition - if productdir is None: - try: - hasattr(msvc9, VSEXPRESS_BASE) # noqa: VSEXPRESS_BASE get defined with msvc9 - except AttributeError: - pass - else: - vsbase = VSEXPRESS_BASE % version # noqa: VSEXPRESS_BASE get defined with msvc9 - try: - productdir = msvc9.Reg.get_value(rf"{vsbase}\Setup\VC", "productdir") - except KeyError: - productdir = None - log.debug("Unable to find productdir in registry") - - if not productdir or not productdir.is_dir(): - toolskey = f"VS{version:0.0f}0COMNTOOLS" - toolsdir = Path(os.environ.get(toolskey, None)) - - if toolsdir and toolsdir.is_dir(): - productdir = toolsdir / os.pardir / os.pardir / "VC" - productdir = productdir.resolve() - if not productdir.is_dir(): - log.debug(f"{productdir} is not a valid directory") - return None - else: - log.debug(f"Env var {toolskey} is not set or invalid") - if not productdir: - log.debug("No productdir found") - return None - return productdir - - -def init_msvc_env(platform_arch, build_type): - from setuptools._distutils import msvc9compiler as msvc9 - - log.info(f"Searching MSVC compiler version {msvc9.VERSION}") - vcdir_path = Path(find_vcdir(msvc9.VERSION)) - if not vcdir_path: - raise SetupError(f"Failed to find the MSVC compiler version {msvc9.VERSION} on " - "your system.") - else: - log.info(f"Found {vcdir_path}") - - log.info(f"Searching MSVC compiler {msvc9.VERSION} environment init script") - if platform_arch.startswith("32"): - vcvars_path = vcdir_path / "bin" / "vcvars32.bat" - else: - vcvars_path = vcdir_path / "bin" / "vcvars64.bat" - if not vcvars_path.exists(): - vcvars_path = vcdir_path / "bin" / "amd64" / "vcvars64.bat" - if not vcvars_path.exists(): - vcvars_path = vcdir_path / "bin" / "amd64" / "vcvarsamd64.bat" - - if not vcvars_path.exists(): - # MSVC init script not found, try to find and init Windows SDK env - log.error("Failed to find the MSVC compiler environment init script " - "(vcvars.bat) on your system.") - winsdk_setenv(platform_arch, build_type) - return - else: - log.info(f"Found {vcvars_path}") - - # Get MSVC env - log.info(f"Using MSVC {msvc9.VERSION} in {vcvars_path}") - msvc_arch = "x86" if platform_arch.startswith("32") else "amd64" - log.info(f"Getting MSVC env for {msvc_arch} architecture") - vcvars_cmd = [vcvars_path, msvc_arch] - msvc_env = get_environment_from_batch_command(vcvars_cmd) - _msvc_paths = [msvc_env[k] for k in msvc_env if k.upper() == 'PATH'] - msvc_env_paths = os.pathsep.join(_msvc_paths).split(os.pathsep) - msvc_env_without_paths = {k: msvc_env[k] for k in msvc_env if k.upper() != 'PATH'} - - # Extend os.environ with MSVC env - log.info("Initializing MSVC env...") - update_env_path(msvc_env_paths) - for k in sorted(msvc_env_without_paths): - v = msvc_env_without_paths[k] - log.info(f"Inserting '{k} = {v}' to environment") - os.environ[k] = v - log.info("Done initializing MSVC env") - - def platform_cmake_options(as_tuple_list=False): result = [] if sys.platform == 'win32': |