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):
# No Visual Studio tools while cross-compiling
if platform != Platform.WINDOWS:
return None, None
from cerbero.ide.vs.env import get_msvc_env
msvc_env = get_msvc_env('x86', target_arch, False, self.config.vs_install_version,
except FatalError:
# Visual Studio not installed
if 'PATH' not in self.config.msvc_env_for_toolchain:
return None, None
paths = msvc_env['PATH']
paths = self.config.msvc_env_for_toolchain['PATH'].get()
return shutil.which('lib', path=paths), paths
class GenGnuLib(GenLib):
......@@ -3,7 +3,7 @@
# shouldn't be modified unless you now what you are doing.
from cerbero.config import Architecture, Platform
from cerbero.config import Architecture, Platform, FatalError
from cerbero.utils import EnvValue, EnvValueArg, EnvValueCmd, EnvValuePath
# We don't want anything from mingw or msys detected in configure and
......@@ -174,12 +174,23 @@ if platform == Platform.WINDOWS:
# Only use one process to make the build more reliable.
allow_parallel_build = False
if platform == Platform.WINDOWS and variants.visualstudio:
from cerbero.ide.vs.env import get_msvc_env, append_path
# Always try to fetch msvc env vars on Windows, since we optionally use it
# for finding `lib.exe`
have_visualstudio = False
# Contains only the env vars that MSVC needs, including any existing vars
# that were appended/prepended and have new values
msvc_env, msvc_version = get_msvc_env(arch, target_arch, variants.uwp,
vs_install_version, vs_install_path)
have_visualstudio = True
except FatalError as e:
if variants.visualstudio:
raise e
print('Could not find Visual Studio; will only use MinGW')
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
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