Commit 157a4b6a authored by thakis@chromium.org's avatar thakis@chromium.org

Let package_from_installed write the build env into json files in addition to SetEnv.cmd

BUG=495204

Review URL: https://codereview.chromium.org/1706423002

git-svn-id: svn://svn.chromium.org/chrome/trunk/tools/depot_tools@298862 0039d316-1c4b-4281-b951-d872f2087c98
parent e187be98
......@@ -21,7 +21,9 @@ useful as the resulting zip can't be redistributed, and most will presumably
have a Pro license anyway).
"""
import collections
import glob
import json
import optparse
import os
import platform
......@@ -214,15 +216,15 @@ def GenerateSetEnvCmd(target_dir):
['..', '..', 'VC', 'atlmfc', 'include'],
])
# Common to x86 and x64
env = [
env = collections.OrderedDict([
# Yuck: These two have a trailing \ character. No good way to represent this
# in an OS-independent way.
('VSINSTALLDIR', [['..', '..\\']]),
('VCINSTALLDIR', [['..', '..', 'VC\\']]),
('INCLUDE', include_dirs),
]
])
# x86. Always use amd64_x86 cross, not x86 on x86.
env_x86 = [
env_x86 = collections.OrderedDict([
('PATH', [
['..', '..', 'win_sdk', 'bin', 'x86'],
['..', '..', 'VC', 'bin', 'amd64_x86'],
......@@ -234,9 +236,9 @@ def GenerateSetEnvCmd(target_dir):
['..', '..', 'win_sdk', 'Lib', WIN_VERSION, 'ucrt', 'x86'], # VS 2015
['..', '..', 'VC', 'atlmfc', 'lib'],
]),
]
])
# x64.
env_x64 = [
env_x64 = collections.OrderedDict([
('PATH', [
['..', '..', 'win_sdk', 'bin', 'x64'],
['..', '..', 'VC', 'bin', 'amd64'],
......@@ -247,25 +249,32 @@ def GenerateSetEnvCmd(target_dir):
['..', '..', 'win_sdk', 'Lib', WIN_VERSION, 'ucrt', 'x64'], # VS 2015
['..', '..', 'VC', 'atlmfc', 'lib', 'amd64'],
]),
]
])
def BatDirs(dirs):
return ';'.join(['%~dp0' + os.path.join(*d) for d in dirs])
with open(os.path.join(target_dir, r'win_sdk\bin\SetEnv.cmd'), 'w') as f:
set_env_prefix = os.path.join(target_dir, r'win_sdk\bin\SetEnv')
with open(set_env_prefix + '.cmd', 'w') as f:
f.write('@echo off\n'
':: Generated by win_toolchain\\package_from_installed.py.\n')
for var, dirs in env:
for var, dirs in env.iteritems():
f.write('set %s=%s\n' % (var, BatDirs(dirs)))
f.write('if "%1"=="/x64" goto x64\n')
for var, dirs in env_x86:
for var, dirs in env_x86.iteritems():
f.write('set %s=%s%s\n' % (
var, BatDirs(dirs), ';%PATH%' if var == 'PATH' else ''))
f.write('goto :EOF\n')
f.write(':x64\n')
for var, dirs in env_x64:
for var, dirs in env_x64.iteritems():
f.write('set %s=%s%s\n' % (
var, BatDirs(dirs), ';%PATH%' if var == 'PATH' else ''))
with open(set_env_prefix + '.x86.json', 'wb') as f:
assert not set(env.keys()) & set(env_x86.keys()), 'dupe keys'
json.dump(collections.OrderedDict(env.items() + env_x86.items()), f)
with open(set_env_prefix + '.x64.json', 'wb') as f:
assert not set(env.keys()) & set(env_x64.keys()), 'dupe keys'
json.dump(collections.OrderedDict(env.items() + env_x64.items()), f)
def AddEnvSetup(files):
......
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