Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Visual Studio 2019 patch #15

Merged
merged 6 commits into from Apr 7, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
44 changes: 44 additions & 0 deletions hererocks.py
Expand Up @@ -2341,7 +2341,51 @@ def setup_vs_and_rerun(vs_version, arch):
remove_dir(temp_dir)
sys.exit(exit_code)

def setup_vs_by_vswhere(target):
'''
vswhere: https://github.com/Microsoft/vswhere
detect Visual Studio 2017 versin 15.2 or later
'''
if target != "vs":
return

if program_exists("cl"):
# already setup
return

vswhere = os.environ[
'ProgramFiles(x86)'] + '\\Microsoft Visual Studio\\Installer\\vswhere.exe'
if not os.path.exists(vswhere):
return

install_dir = run(vswhere, '-latest', '-products', '*', '-requires', 'Microsoft.VisualStudio.Component.VC.Tools.x86.x64', '-property', 'installationPath', get_output=True)
vcvars = install_dir + '\\VC\\Auxiliary\\Build\\vcvars64.bat'
if not os.path.exists(vcvars):
return

for line in run(os.environ['COMSPEC'], '/C', vcvars, '&', 'set', get_output=True).splitlines():
try:
k, v = line.split('=', maxsplit=1)
k = k.upper()
if k == 'PATH':
path = os.environ['PATH']
for p in v.split(';'):
if p not in path:
path = p + ';' + path
os.environ['PATH'] = path
elif k == 'INCLUDE':
os.environ['INCLUDE'] = v
elif k == 'LIB':
os.environ['LIB'] = v
except ValueError:
pass

def setup_vs(target):
try:
setup_vs_by_vswhere(target)
except Exception:
pass

# If using vsXX_YY or vs_XX target, set VS up by writing a .bat file calling corresponding vcvarsall.bat
# before recursively calling hererocks, passing arguments through a temporary file using
# --actual-argv-file because passing special characters like '^' as an argument to a batch file is not fun.
Expand Down