Use vswhere to detect Visual Studio 2017.
This commit is contained in:
parent
1a3c4187d8
commit
d2c84e37ee
19
xenia-build
19
xenia-build
|
@ -48,8 +48,9 @@ def main():
|
|||
# Grab Visual Studio version and execute shell to set up environment.
|
||||
if sys.platform == 'win32':
|
||||
vs_version = import_vs_environment()
|
||||
if vs_version != 2015:
|
||||
print('ERROR: Visual Studio 2015 not found!')
|
||||
if vs_version == 0:
|
||||
print('ERROR: Visual Studio not found!')
|
||||
print('Visual Studio 2015 is the recommended version.')
|
||||
print('Ensure you have the VS140COMNTOOLS environment variable!')
|
||||
sys.exit(1)
|
||||
return
|
||||
|
@ -98,15 +99,23 @@ def import_vs_environment():
|
|||
A version such as 2015 or None if no VS is found.
|
||||
"""
|
||||
version = 0
|
||||
|
||||
candidate_path = subprocess.check_output('third_party/vswhere/vswhere.exe -version "[15,)" -latest -format value -property installationPath', shell=False);
|
||||
candidate_path = candidate_path.strip()
|
||||
|
||||
tools_path = ''
|
||||
if 'VS140COMNTOOLS' in os.environ:
|
||||
if candidate_path:
|
||||
tools_path = os.path.join(candidate_path, 'vc\\auxiliary\\build\\vcvarsall.bat')
|
||||
if os.path.isfile(tools_path) and os.access(tools_path, os.X_OK):
|
||||
version = 2017
|
||||
if version == 0 and 'VS140COMNTOOLS' in os.environ:
|
||||
version = 2015
|
||||
tools_path = os.environ['VS140COMNTOOLS']
|
||||
tools_path = os.path.join(tools_path, '..\\..\\vc\\vcvarsall.bat')
|
||||
if version == 0:
|
||||
return None
|
||||
tools_path = os.path.join(tools_path, '..\\..\\vc\\vcvarsall.bat')
|
||||
|
||||
args = [tools_path, '&&', 'set']
|
||||
args = [tools_path, 'x64', '&&', 'set']
|
||||
popen = subprocess.Popen(
|
||||
args, shell=True, stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
|
||||
variables, _ = popen.communicate()
|
||||
|
|
Loading…
Reference in New Issue