Commit 0071999c authored by Nirbheek Chauhan's avatar Nirbheek Chauhan 🐜
Browse files

cerbero/genlib: Reuse msvc env found at startup

Since Visual Studio is optional now, this patch is non-trivial.

Part-of: <gstreamer/cerbero!480>
parent 576ddac5
...@@ -116,13 +116,10 @@ class GenLib(object): ...@@ -116,13 +116,10 @@ class GenLib(object):
# No Visual Studio tools while cross-compiling # No Visual Studio tools while cross-compiling
if platform != Platform.WINDOWS: if platform != Platform.WINDOWS:
return None, None return None, None
try: # Visual Studio not installed
from cerbero.ide.vs.env import get_msvc_env if 'PATH' not in self.config.msvc_env_for_toolchain:
msvc_env = get_msvc_env('x86', target_arch, False, self.config.vs_install_version,
self.config.vs_install_path)[0]
except FatalError:
return None, None return None, None
paths = msvc_env['PATH'] paths = self.config.msvc_env_for_toolchain['PATH'].get()
return shutil.which('lib', path=paths), paths return shutil.which('lib', path=paths), paths
class GenGnuLib(GenLib): class GenGnuLib(GenLib):
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
# shouldn't be modified unless you now what you are doing. # shouldn't be modified unless you now what you are doing.
# PLEASE, DO NOT EDIT THIS FILE # PLEASE, DO NOT EDIT THIS FILE
from cerbero.config import Architecture, Platform from cerbero.config import Architecture, Platform, FatalError
from cerbero.utils import EnvValue, EnvValueArg, EnvValueCmd, EnvValuePath from cerbero.utils import EnvValue, EnvValueArg, EnvValueCmd, EnvValuePath
# We don't want anything from mingw or msys detected in configure and # We don't want anything from mingw or msys detected in configure and
...@@ -174,22 +174,33 @@ if platform == Platform.WINDOWS: ...@@ -174,22 +174,33 @@ if platform == Platform.WINDOWS:
# Only use one process to make the build more reliable. # Only use one process to make the build more reliable.
allow_parallel_build = False allow_parallel_build = False
if platform == Platform.WINDOWS and variants.visualstudio:
from cerbero.ide.vs.env import get_msvc_env, append_path from cerbero.ide.vs.env import get_msvc_env, append_path
# Contains only the env vars that MSVC needs, including any existing vars # Always try to fetch msvc env vars on Windows, since we optionally use it
# that were appended/prepended and have new values # for finding `lib.exe`
msvc_env, msvc_version = get_msvc_env(arch, target_arch, variants.uwp, have_visualstudio = False
vs_install_version, vs_install_path) try:
for key, value in msvc_env.items(): # Contains only the env vars that MSVC needs, including any existing vars
msvc_env_for_toolchain[key] = EnvValue.from_key(key, value) # that were appended/prepended and have new values
# We want the MSVC compiler and linker to find the headers and libraries msvc_env, msvc_version = get_msvc_env(arch, target_arch, variants.uwp,
# provided by recipes built by us, so append to INCLUDE and LIB. vs_install_version, vs_install_path)
# NOTE: We do not want to add the MinGW toolchain paths here have_visualstudio = True
msvc_env_for_toolchain['INCLUDE'] += [os.path.join(prefix, 'include')] except FatalError as e:
msvc_env_for_toolchain['LIB'] += [os.path.join(prefix, 'lib' + lib_suffix)] if variants.visualstudio:
msvc_env_for_toolchain['WINDRES'] = EnvValueCmd('rc') raise e
if variants.uwp: print('Could not find Visual Studio; will only use MinGW')
meson_properties['needs_exe_wrapper'] = 'true'
if have_visualstudio:
for key, value in msvc_env.items():
msvc_env_for_toolchain[key] = EnvValue.from_key(key, value)
# We want the MSVC compiler and linker to find the headers and libraries
# provided by recipes built by us, so append to INCLUDE and LIB.
# NOTE: We do not want to add the MinGW toolchain paths here
msvc_env_for_toolchain['INCLUDE'] += [os.path.join(prefix, 'include')]
msvc_env_for_toolchain['LIB'] += [os.path.join(prefix, 'lib' + lib_suffix)]
msvc_env_for_toolchain['WINDRES'] = EnvValueCmd('rc')
if variants.uwp:
meson_properties['needs_exe_wrapper'] = 'true'
# Export the env for a shell # Export the env for a shell
if for_shell: if for_shell:
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment