Import the VS environment when building premake.
This commit is contained in:
parent
aef9f35784
commit
da0a468126
|
@ -11,6 +11,7 @@ __author__ = 'ben.vanik@gmail.com (Ben Vanik)'
|
||||||
import os
|
import os
|
||||||
import subprocess
|
import subprocess
|
||||||
import sys
|
import sys
|
||||||
|
import re
|
||||||
|
|
||||||
|
|
||||||
self_path = os.path.dirname(os.path.abspath(__file__))
|
self_path = os.path.dirname(os.path.abspath(__file__))
|
||||||
|
@ -56,24 +57,31 @@ def build_premake():
|
||||||
try:
|
try:
|
||||||
os.chdir(premake_path)
|
os.chdir(premake_path)
|
||||||
if sys.platform == 'darwin':
|
if sys.platform == 'darwin':
|
||||||
shell_call([
|
subprocess.call([
|
||||||
'make',
|
'make',
|
||||||
'-f', 'Bootstrap.mak',
|
'-f', 'Bootstrap.mak',
|
||||||
'osx',
|
'osx',
|
||||||
])
|
], shell=False)
|
||||||
elif sys.platform == 'win32':
|
elif sys.platform == 'win32':
|
||||||
# TODO(benvanik): import VS environment.
|
# Grab Visual Studio version and execute shell to set up environment.
|
||||||
shell_call([
|
vs_version = import_vs_environment()
|
||||||
|
if vs_version != 2015:
|
||||||
|
print('ERROR: Visual Studio 2015 not found!')
|
||||||
|
print('Ensure you have the VS140COMNTOOLS environment variable!')
|
||||||
|
sys.exit(1)
|
||||||
|
return
|
||||||
|
|
||||||
|
subprocess.call([
|
||||||
'nmake',
|
'nmake',
|
||||||
'-f', 'Bootstrap.mak',
|
'-f', 'Bootstrap.mak',
|
||||||
'windows',
|
'windows',
|
||||||
])
|
], shell=False)
|
||||||
else:
|
else:
|
||||||
shell_call([
|
subprocess.call([
|
||||||
'make',
|
'make',
|
||||||
'-f', 'Bootstrap.mak',
|
'-f', 'Bootstrap.mak',
|
||||||
'linux',
|
'linux',
|
||||||
])
|
], shell=False)
|
||||||
finally:
|
finally:
|
||||||
os.chdir(cwd)
|
os.chdir(cwd)
|
||||||
pass
|
pass
|
||||||
|
@ -121,6 +129,50 @@ def shell_call(command, throw_on_error=True, stdout_path=None):
|
||||||
return result
|
return result
|
||||||
|
|
||||||
|
|
||||||
|
def import_vs_environment():
|
||||||
|
"""Finds the installed Visual Studio version and imports
|
||||||
|
interesting environment variables into os.environ.
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
A version such as 2015 or None if no VS is found.
|
||||||
|
"""
|
||||||
|
version = 0
|
||||||
|
tools_path = ''
|
||||||
|
if 'VS140COMNTOOLS' in os.environ:
|
||||||
|
version = 2015
|
||||||
|
tools_path = os.environ['VS140COMNTOOLS']
|
||||||
|
if version == 0:
|
||||||
|
return None
|
||||||
|
tools_path = os.path.join(tools_path, '..\\..\\vc\\vcvarsall.bat')
|
||||||
|
|
||||||
|
args = [tools_path, '&&', 'set']
|
||||||
|
popen = subprocess.Popen(
|
||||||
|
args, shell=True, stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
|
||||||
|
variables, _ = popen.communicate()
|
||||||
|
envvars_to_save = (
|
||||||
|
'devenvdir',
|
||||||
|
'include',
|
||||||
|
'lib',
|
||||||
|
'libpath',
|
||||||
|
'path',
|
||||||
|
'pathext',
|
||||||
|
'systemroot',
|
||||||
|
'temp',
|
||||||
|
'tmp',
|
||||||
|
'windowssdkdir',
|
||||||
|
)
|
||||||
|
for line in variables.splitlines():
|
||||||
|
for envvar in envvars_to_save:
|
||||||
|
if re.match(envvar + '=', line.lower()):
|
||||||
|
var, setting = line.split('=', 1)
|
||||||
|
if envvar == 'path':
|
||||||
|
setting = os.path.dirname(sys.executable) + os.pathsep + setting
|
||||||
|
os.environ[var.upper()] = setting
|
||||||
|
break
|
||||||
|
|
||||||
|
os.environ['VSVERSION'] = str(version)
|
||||||
|
return version
|
||||||
|
|
||||||
def git_submodule_update():
|
def git_submodule_update():
|
||||||
"""Runs a full recursive git submodule init and update.
|
"""Runs a full recursive git submodule init and update.
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue