Skip to content

Commit

Permalink
tools: update gyp to eb296f6
Browse files Browse the repository at this point in the history
* [win] Add support for MS VS2017 (via Registry)

REF: https://chromium.googlesource.com/external/gyp/+/eb296f67da078ec01f5e3a9ea9cdc6d26d680161
PR-URL: #12450
Reviewed-By: João Reis <reis@janeasystems.com>
  • Loading branch information
refack committed Apr 18, 2017
1 parent 1e7f6b1 commit 3a334b1
Show file tree
Hide file tree
Showing 25 changed files with 1,131 additions and 452 deletions.
3 changes: 3 additions & 0 deletions tools/gyp/AUTHORS
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,6 @@ Steven Knight <knight@baldmt.com>
Ryan Norton <rnorton10@gmail.com>
David J. Sankel <david@sankelsoftware.com>
Eric N. Vander Weele <ericvw@gmail.com>
Tom Freudenberg <th.freudenberg@gmail.com>
Julien Brianceau <jbriance@cisco.com>
Refael Ackermann <refack@gmail.com>
9 changes: 4 additions & 5 deletions tools/gyp/DEPS
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@
# (You don't need to use gclient for normal GYP development work.)

vars = {
"chrome_trunk": "http://src.chromium.org/svn/trunk",
"googlecode_url": "http://%s.googlecode.com/svn",
"chromium_git": "https://chromium.googlesource.com/",
}

deps = {
Expand All @@ -13,12 +12,12 @@ deps = {
deps_os = {
"win": {
"third_party/cygwin":
Var("chrome_trunk") + "/deps/third_party/cygwin@66844",
Var("chromium_git") + "chromium/deps/cygwin@4fbd5b9",

"third_party/python_26":
Var("chrome_trunk") + "/tools/third_party/python_26@89111",
Var("chromium_git") + "chromium/deps/python_26@5bb4080",

"src/third_party/pefile":
(Var("googlecode_url") % "pefile") + "/trunk@63",
Var("chromium_git") + "external/pefile@72c6ae4",
},
}
13 changes: 0 additions & 13 deletions tools/gyp/PRESUBMIT.py
Original file line number Diff line number Diff line change
Expand Up @@ -124,16 +124,3 @@ def CheckChangeOnCommit(input_api, output_api):
finally:
sys.path = old_sys_path
return report


TRYBOTS = [
'linux_try',
'mac_try',
'win_try',
]


def GetPreferredTryMasters(_, change):
return {
'client.gyp': { t: set(['defaulttests']) for t in TRYBOTS },
}
4 changes: 4 additions & 0 deletions tools/gyp/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
GYP can Generate Your Projects.
===================================

Documents are available at [gyp.gsrc.io](https://gyp.gsrc.io), or you can check out ```md-pages``` branch to read those documents offline.
12 changes: 4 additions & 8 deletions tools/gyp/codereview.settings
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
# This file is used by gcl to get repository specific information.
CODE_REVIEW_SERVER: codereview.chromium.org
# This file is used by git cl to get repository specific information.
CC_LIST: gyp-developer@googlegroups.com
VIEW_VC: https://chromium.googlesource.com/external/gyp/+/
TRY_ON_UPLOAD: False
TRYSERVER_PROJECT: gyp
TRYSERVER_PATCHLEVEL: 1
TRYSERVER_ROOT: gyp
TRYSERVER_SVN_URL: svn://svn.chromium.org/chrome-try/try-nacl
CODE_REVIEW_SERVER: codereview.chromium.org
GERRIT_HOST: True
PROJECT: gyp
VIEW_VC: https://chromium.googlesource.com/external/gyp/+/
1 change: 1 addition & 0 deletions tools/gyp/gyptest.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

import os
import optparse
import shlex
import subprocess
import sys

Expand Down
1 change: 1 addition & 0 deletions tools/gyp/pylib/gyp/MSVSSettings.py
Original file line number Diff line number Diff line change
Expand Up @@ -592,6 +592,7 @@ def _ValidateSettings(validators, settings, stderr):
_Same(_compile, 'UseFullPaths', _boolean) # /FC
_Same(_compile, 'WholeProgramOptimization', _boolean) # /GL
_Same(_compile, 'XMLDocumentationFileName', _file_name)
_Same(_compile, 'CompileAsWinRT', _boolean) # /ZW

_Same(_compile, 'AssemblerOutput',
_Enumeration(['NoListing',
Expand Down
3 changes: 2 additions & 1 deletion tools/gyp/pylib/gyp/MSVSUtil.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
'loadable_module': 'dll',
'shared_library': 'dll',
'static_library': 'lib',
'windows_driver': 'sys',
}


Expand Down Expand Up @@ -110,7 +111,7 @@ def ShardTargets(target_list, target_dicts):
else:
new_target_dicts[t] = target_dicts[t]
# Shard dependencies.
for t in new_target_dicts:
for t in sorted(new_target_dicts):
for deptype in ('dependencies', 'dependencies_original'):
dependencies = copy.copy(new_target_dicts[t].get(deptype, []))
new_dependencies = []
Expand Down
54 changes: 42 additions & 12 deletions tools/gyp/pylib/gyp/MSVSVersion.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class VisualStudioVersion(object):

def __init__(self, short_name, description,
solution_version, project_version, flat_sln, uses_vcxproj,
path, sdk_based, default_toolset=None):
path, sdk_based, default_toolset=None, compatible_sdks=None):
self.short_name = short_name
self.description = description
self.solution_version = solution_version
Expand All @@ -28,6 +28,9 @@ def __init__(self, short_name, description,
self.path = path
self.sdk_based = sdk_based
self.default_toolset = default_toolset
compatible_sdks = compatible_sdks or []
compatible_sdks.sort(key=lambda v: float(v.replace('v', '')), reverse=True)
self.compatible_sdks = compatible_sdks

def ShortName(self):
return self.short_name
Expand Down Expand Up @@ -68,17 +71,19 @@ def DefaultToolset(self):
of a user override."""
return self.default_toolset

def SetupScript(self, target_arch):
def _SetupScriptInternal(self, target_arch):
"""Returns a command (with arguments) to be used to set up the
environment."""
# Check if we are running in the SDK command line environment and use
# the setup script from the SDK if so. |target_arch| should be either
# 'x86' or 'x64'.
# If WindowsSDKDir is set and SetEnv.Cmd exists then we are using the
# depot_tools build tools and should run SetEnv.Cmd to set up the
# environment. The check for WindowsSDKDir alone is not sufficient because
# this is set by running vcvarsall.bat.
assert target_arch in ('x86', 'x64')
sdk_dir = os.environ.get('WindowsSDKDir')
if self.sdk_based and sdk_dir:
return [os.path.normpath(os.path.join(sdk_dir, 'Bin/SetEnv.Cmd')),
'/' + target_arch]
if sdk_dir:
setup_path = os.path.normpath(os.path.join(sdk_dir, 'Bin/SetEnv.Cmd'))
if self.sdk_based and sdk_dir and os.path.exists(setup_path):
return [setup_path, '/' + target_arch]
else:
# We don't use VC/vcvarsall.bat for x86 because vcvarsall calls
# vcvars32, which it can only find if VS??COMNTOOLS is set, which it
Expand Down Expand Up @@ -106,6 +111,14 @@ def SetupScript(self, target_arch):
return [os.path.normpath(
os.path.join(self.path, 'VC/vcvarsall.bat')), arg]

def SetupScript(self, target_arch):
script_data = self._SetupScriptInternal(target_arch)
script_path = script_data[0]
if not os.path.exists(script_path):
raise Exception('%s is missing - make sure VC++ tools are installed.' %
script_path)
return script_data


def _RegistryQueryBase(sysdir, key, value):
"""Use reg.exe to read a particular key.
Expand Down Expand Up @@ -226,6 +239,16 @@ def _CreateVersion(name, path, sdk_based=False):
if path:
path = os.path.normpath(path)
versions = {
'2017': VisualStudioVersion('2017',
'Visual Studio 2017',
solution_version='12.00',
project_version='15.0',
flat_sln=False,
uses_vcxproj=True,
path=path,
sdk_based=sdk_based,
default_toolset='v141',
compatible_sdks=['v8.1', 'v10.0']),
'2015': VisualStudioVersion('2015',
'Visual Studio 2015',
solution_version='12.00',
Expand Down Expand Up @@ -338,14 +361,14 @@ def _DetectVisualStudioVersions(versions_to_check, force_express):
A list of visual studio versions installed in descending order of
usage preference.
Base this on the registry and a quick check if devenv.exe exists.
Only versions 8-10 are considered.
Possibilities are:
2005(e) - Visual Studio 2005 (8)
2008(e) - Visual Studio 2008 (9)
2010(e) - Visual Studio 2010 (10)
2012(e) - Visual Studio 2012 (11)
2013(e) - Visual Studio 2013 (12)
2015 - Visual Studio 2015 (14)
2017 - Visual Studio 2017 (15)
Where (e) is e for express editions of MSVS and blank otherwise.
"""
version_to_year = {
Expand All @@ -355,6 +378,7 @@ def _DetectVisualStudioVersions(versions_to_check, force_express):
'11.0': '2012',
'12.0': '2013',
'14.0': '2015',
'15.0': '2017'
}
versions = []
for version in versions_to_check:
Expand Down Expand Up @@ -385,13 +409,18 @@ def _DetectVisualStudioVersions(versions_to_check, force_express):

# The old method above does not work when only SDK is installed.
keys = [r'HKLM\Software\Microsoft\VisualStudio\SxS\VC7',
r'HKLM\Software\Wow6432Node\Microsoft\VisualStudio\SxS\VC7']
r'HKLM\Software\Wow6432Node\Microsoft\VisualStudio\SxS\VC7',
r'HKLM\Software\Microsoft\VisualStudio\SxS\VS7',
r'HKLM\Software\Wow6432Node\Microsoft\VisualStudio\SxS\VS7']
for index in range(len(keys)):
path = _RegistryGetValue(keys[index], version)
if not path:
continue
path = _ConvertToCygpath(path)
if version != '14.0': # There is no Express edition for 2015.
if version == '15.0':
if os.path.exists(path):
versions.append(_CreateVersion('2017', path))
elif version != '14.0': # There is no Express edition for 2015.
versions.append(_CreateVersion(version_to_year[version] + 'e',
os.path.join(path, '..'), sdk_based=True))

Expand All @@ -410,7 +439,7 @@ def SelectVisualStudioVersion(version='auto', allow_fallback=True):
if version == 'auto':
version = os.environ.get('GYP_MSVS_VERSION', 'auto')
version_map = {
'auto': ('14.0', '12.0', '10.0', '9.0', '8.0', '11.0'),
'auto': ('15.0', '14.0', '12.0', '10.0', '9.0', '8.0', '11.0'),
'2005': ('8.0',),
'2005e': ('8.0',),
'2008': ('9.0',),
Expand All @@ -422,6 +451,7 @@ def SelectVisualStudioVersion(version='auto', allow_fallback=True):
'2013': ('12.0',),
'2013e': ('12.0',),
'2015': ('14.0',),
'2017': ('15.0',),
}
override_path = os.environ.get('GYP_MSVS_OVERRIDE_PATH')
if override_path:
Expand Down
13 changes: 11 additions & 2 deletions tools/gyp/pylib/gyp/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -425,13 +425,15 @@ def GetFlavor(params):
return 'freebsd'
if sys.platform.startswith('openbsd'):
return 'openbsd'
if sys.platform.startswith('netbsd'):
return 'netbsd'
if sys.platform.startswith('aix'):
return 'aix'

return 'linux'


def CopyTool(flavor, out_path):
def CopyTool(flavor, out_path, generator_flags={}):
"""Finds (flock|mac|win)_tool.gyp in the gyp directory and copies it
to |out_path|."""
# aix and solaris just need flock emulation. mac and win use more complicated
Expand All @@ -451,11 +453,18 @@ def CopyTool(flavor, out_path):
with open(source_path) as source_file:
source = source_file.readlines()

# Set custom header flags.
header = '# Generated by gyp. Do not edit.\n'
mac_toolchain_dir = generator_flags.get('mac_toolchain_dir', None)
if flavor == 'mac' and mac_toolchain_dir:
header += "import os;\nos.environ['DEVELOPER_DIR']='%s'\n" \
% mac_toolchain_dir

# Add header and write it out.
tool_path = os.path.join(out_path, 'gyp-%s-tool' % prefix)
with open(tool_path, 'w') as tool_file:
tool_file.write(
''.join([source[0], '# Generated by gyp. Do not edit.\n'] + source[1:]))
''.join([source[0], header] + source[1:]))

# Make file executable.
os.chmod(tool_path, 0755)
Expand Down
Loading

0 comments on commit 3a334b1

Please sign in to comment.