Skip to content

Commit 1d65b99

Browse files
Imran Iqbalbnoordhuis
Imran Iqbal
authored andcommitted
tools: update gyp to b3cef02
Includes two patches for AIX. Adds support for both 32-bit and 64-bit files[0] and uses -RPf for cp instead of -af (which is unsupported)[1] [0] https://codereview.chromium.org/1319663007 [1] https://codereview.chromium.org/1368133002 PR-URL: #3487 Reviewed-By: Ben Noordhuis <[email protected]> Reviewed-By: Shigeki Ohtsu <[email protected]>
1 parent cf0130d commit 1d65b99

13 files changed

+103
-44
lines changed

tools/gyp/PRESUBMIT.py

+4-5
Original file line numberDiff line numberDiff line change
@@ -125,14 +125,13 @@ def CheckChangeOnCommit(input_api, output_api):
125125

126126

127127
TRYBOTS = [
128-
'gyp-win32',
129-
'gyp-win64',
130-
'gyp-linux',
131-
'gyp-mac',
128+
'linux_try',
129+
'mac_try',
130+
'win_try',
132131
]
133132

134133

135134
def GetPreferredTryMasters(_, change):
136135
return {
137-
'tryserver.nacl': { t: set(['defaulttests']) for t in TRYBOTS },
136+
'client.gyp': { t: set(['defaulttests']) for t in TRYBOTS },
138137
}

tools/gyp/gyp_main.py

+5-7
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,13 @@
44
# Use of this source code is governed by a BSD-style license that can be
55
# found in the LICENSE file.
66

7+
import os
78
import sys
89

9-
# TODO(mark): sys.path manipulation is some temporary testing stuff.
10-
try:
11-
import gyp
12-
except ImportError, e:
13-
import os.path
14-
sys.path.append(os.path.join(os.path.dirname(sys.argv[0]), 'pylib'))
15-
import gyp
10+
# Make sure we're using the version of pylib in this repo, not one installed
11+
# elsewhere on the system.
12+
sys.path.insert(0, os.path.join(os.path.dirname(sys.argv[0]), 'pylib'))
13+
import gyp
1614

1715
if __name__ == '__main__':
1816
sys.exit(gyp.script_main())

tools/gyp/pylib/gyp/MSVSSettings.py

+1-4
Original file line numberDiff line numberDiff line change
@@ -708,10 +708,7 @@ def _ValidateSettings(validators, settings, stderr):
708708
_MSBuildOnly(_compile, 'BuildingInIDE', _boolean)
709709
_MSBuildOnly(_compile, 'CompileAsManaged',
710710
_Enumeration([], new=['false',
711-
'true', # /clr
712-
'Pure', # /clr:pure
713-
'Safe', # /clr:safe
714-
'OldSyntax'])) # /clr:oldSyntax
711+
'true'])) # /clr
715712
_MSBuildOnly(_compile, 'CreateHotpatchableImage', _boolean) # /hotpatch
716713
_MSBuildOnly(_compile, 'MultiProcessorCompilation', _boolean) # /MP
717714
_MSBuildOnly(_compile, 'PreprocessOutputPath', _string) # /Fi

tools/gyp/pylib/gyp/MSVSSettings_test.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -296,7 +296,7 @@ def testValidateMSBuildSettings_settings(self):
296296
'BuildingInIDE': 'true',
297297
'CallingConvention': 'Cdecl',
298298
'CompileAs': 'CompileAsC',
299-
'CompileAsManaged': 'Pure',
299+
'CompileAsManaged': 'true',
300300
'CreateHotpatchableImage': 'true',
301301
'DebugInformationFormat': 'ProgramDatabase',
302302
'DisableLanguageExtensions': 'true',

tools/gyp/pylib/gyp/common.py

+9-2
Original file line numberDiff line numberDiff line change
@@ -131,13 +131,20 @@ def QualifiedTarget(build_file, target, toolset):
131131

132132

133133
@memoize
134-
def RelativePath(path, relative_to):
134+
def RelativePath(path, relative_to, follow_path_symlink=True):
135135
# Assuming both |path| and |relative_to| are relative to the current
136136
# directory, returns a relative path that identifies path relative to
137137
# relative_to.
138+
# If |follow_symlink_path| is true (default) and |path| is a symlink, then
139+
# this method returns a path to the real file represented by |path|. If it is
140+
# false, this method returns a path to the symlink. If |path| is not a
141+
# symlink, this option has no effect.
138142

139143
# Convert to normalized (and therefore absolute paths).
140-
path = os.path.realpath(path)
144+
if follow_path_symlink:
145+
path = os.path.realpath(path)
146+
else:
147+
path = os.path.abspath(path)
141148
relative_to = os.path.realpath(relative_to)
142149

143150
# On Windows, we can't create a relative path to a different drive, so just

tools/gyp/pylib/gyp/generator/analyzer.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -338,7 +338,7 @@ def _GenerateTargets(data, target_list, target_dicts, toplevel_dir, files,
338338
sources = _ExtractSources(target_name, target_dicts[target_name],
339339
toplevel_dir)
340340
for source in sources:
341-
if source in files:
341+
if _ToGypPath(os.path.normpath(source)) in files:
342342
print 'target', target_name, 'matches', source
343343
target.match_status = MATCH_STATUS_MATCHES
344344
matching_targets.append(target)
@@ -498,7 +498,7 @@ def _WasGypIncludeFileModified(params, files):
498498
files."""
499499
if params['options'].includes:
500500
for include in params['options'].includes:
501-
if _ToGypPath(include) in files:
501+
if _ToGypPath(os.path.normpath(include)) in files:
502502
print 'Include file modified, assuming all changed', include
503503
return True
504504
return False

tools/gyp/pylib/gyp/generator/make.py

+11-7
Original file line numberDiff line numberDiff line change
@@ -211,10 +211,10 @@ def CalculateGeneratorInputInfo(params):
211211

212212
LINK_COMMANDS_AIX = """\
213213
quiet_cmd_alink = AR($(TOOLSET)) $@
214-
cmd_alink = rm -f $@ && $(AR.$(TOOLSET)) crs $@ $(filter %.o,$^)
214+
cmd_alink = rm -f $@ && $(AR.$(TOOLSET)) -X32_64 crs $@ $(filter %.o,$^)
215215
216216
quiet_cmd_alink_thin = AR($(TOOLSET)) $@
217-
cmd_alink_thin = rm -f $@ && $(AR.$(TOOLSET)) crs $@ $(filter %.o,$^)
217+
cmd_alink_thin = rm -f $@ && $(AR.$(TOOLSET)) -X32_64 crs $@ $(filter %.o,$^)
218218
219219
quiet_cmd_link = LINK($(TOOLSET)) $@
220220
cmd_link = $(LINK.$(TOOLSET)) $(GYP_LDFLAGS) $(LDFLAGS.$(TOOLSET)) -o $@ $(LD_INPUTS) $(LIBS)
@@ -273,9 +273,9 @@ def CalculateGeneratorInputInfo(params):
273273
%(make_global_settings)s
274274
275275
CC.target ?= %(CC.target)s
276-
CFLAGS.target ?= $(CFLAGS)
276+
CFLAGS.target ?= $(CPPFLAGS) $(CFLAGS)
277277
CXX.target ?= %(CXX.target)s
278-
CXXFLAGS.target ?= $(CXXFLAGS)
278+
CXXFLAGS.target ?= $(CPPFLAGS) $(CXXFLAGS)
279279
LINK.target ?= %(LINK.target)s
280280
LDFLAGS.target ?= $(LDFLAGS)
281281
AR.target ?= $(AR)
@@ -286,9 +286,9 @@ def CalculateGeneratorInputInfo(params):
286286
# TODO(evan): move all cross-compilation logic to gyp-time so we don't need
287287
# to replicate this environment fallback in make as well.
288288
CC.host ?= %(CC.host)s
289-
CFLAGS.host ?=
289+
CFLAGS.host ?= $(CPPFLAGS_host) $(CFLAGS_host)
290290
CXX.host ?= %(CXX.host)s
291-
CXXFLAGS.host ?=
291+
CXXFLAGS.host ?= $(CPPFLAGS_host) $(CXXFLAGS_host)
292292
LINK.host ?= %(LINK.host)s
293293
LDFLAGS.host ?=
294294
AR.host ?= %(AR.host)s
@@ -365,7 +365,7 @@ def CalculateGeneratorInputInfo(params):
365365
366366
quiet_cmd_copy = COPY $@
367367
# send stderr to /dev/null to ignore messages when linking directories.
368-
cmd_copy = ln -f "$<" "$@" 2>/dev/null || (rm -rf "$@" && cp -af "$<" "$@")
368+
cmd_copy = ln -f "$<" "$@" 2>/dev/null || (rm -rf "$@" && cp %(copy_archive_args)s "$<" "$@")
369369
370370
%(link_commands)s
371371
"""
@@ -2010,6 +2010,7 @@ def CalculateMakefilePath(build_file, base_name):
20102010
srcdir_prefix = '$(srcdir)/'
20112011

20122012
flock_command= 'flock'
2013+
copy_archive_arguments = '-af'
20132014
header_params = {
20142015
'default_target': default_target,
20152016
'builddir': builddir_name,
@@ -2019,6 +2020,7 @@ def CalculateMakefilePath(build_file, base_name):
20192020
'link_commands': LINK_COMMANDS_LINUX,
20202021
'extra_commands': '',
20212022
'srcdir': srcdir,
2023+
'copy_archive_args': copy_archive_arguments,
20222024
}
20232025
if flavor == 'mac':
20242026
flock_command = './gyp-mac-tool flock'
@@ -2043,7 +2045,9 @@ def CalculateMakefilePath(build_file, base_name):
20432045
'flock': 'lockf',
20442046
})
20452047
elif flavor == 'aix':
2048+
copy_archive_arguments = '-pPRf'
20462049
header_params.update({
2050+
'copy_archive_args': copy_archive_arguments,
20472051
'link_commands': LINK_COMMANDS_AIX,
20482052
'flock': './gyp-flock-tool flock',
20492053
'flock_index': 2,

tools/gyp/pylib/gyp/generator/msvs.py

+13
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,8 @@ def _import_OrderedDict():
8787
'msvs_requires_importlibrary',
8888
'msvs_enable_winphone',
8989
'msvs_application_type_revision',
90+
'msvs_target_platform_version',
91+
'msvs_target_platform_minversion',
9092
]
9193

9294

@@ -2644,6 +2646,17 @@ def _GetMSBuildGlobalProperties(spec, guid, gyp_file_name):
26442646
else:
26452647
properties[0].append(['ApplicationTypeRevision', '8.1'])
26462648

2649+
if spec.get('msvs_target_platform_version'):
2650+
target_platform_version = spec.get('msvs_target_platform_version')
2651+
properties[0].append(['WindowsTargetPlatformVersion',
2652+
target_platform_version])
2653+
if spec.get('msvs_target_platform_minversion'):
2654+
target_platform_minversion = spec.get('msvs_target_platform_minversion')
2655+
properties[0].append(['WindowsTargetPlatformMinVersion',
2656+
target_platform_minversion])
2657+
else:
2658+
properties[0].append(['WindowsTargetPlatformMinVersion',
2659+
target_platform_version])
26472660
if spec.get('msvs_enable_winphone'):
26482661
properties[0].append(['ApplicationType', 'Windows Phone'])
26492662
else:

tools/gyp/pylib/gyp/generator/ninja.py

+15-4
Original file line numberDiff line numberDiff line change
@@ -921,6 +921,11 @@ def WriteSourcesForArch(self, ninja_file, config_name, config, sources,
921921
os.environ.get('CFLAGS', '').split() + cflags_c)
922922
cflags_cc = (os.environ.get('CPPFLAGS', '').split() +
923923
os.environ.get('CXXFLAGS', '').split() + cflags_cc)
924+
elif self.toolset == 'host':
925+
cflags_c = (os.environ.get('CPPFLAGS_host', '').split() +
926+
os.environ.get('CFLAGS_host', '').split() + cflags_c)
927+
cflags_cc = (os.environ.get('CPPFLAGS_host', '').split() +
928+
os.environ.get('CXXFLAGS_host', '').split() + cflags_cc)
924929

925930
defines = config.get('defines', []) + extra_defines
926931
self.WriteVariableList(ninja_file, 'defines',
@@ -1672,7 +1677,7 @@ def CommandWithWrapper(cmd, wrappers, prog):
16721677

16731678
def GetDefaultConcurrentLinks():
16741679
"""Returns a best-guess for a number of concurrent links."""
1675-
pool_size = int(os.getenv('GYP_LINK_CONCURRENCY', 0))
1680+
pool_size = int(os.environ.get('GYP_LINK_CONCURRENCY', 0))
16761681
if pool_size:
16771682
return pool_size
16781683

@@ -1696,8 +1701,10 @@ class MEMORYSTATUSEX(ctypes.Structure):
16961701
stat.dwLength = ctypes.sizeof(stat)
16971702
ctypes.windll.kernel32.GlobalMemoryStatusEx(ctypes.byref(stat))
16981703

1699-
mem_limit = max(1, stat.ullTotalPhys / (4 * (2 ** 30))) # total / 4GB
1700-
hard_cap = max(1, int(os.getenv('GYP_LINK_CONCURRENCY_MAX', 2**32)))
1704+
# VS 2015 uses 20% more working set than VS 2013 and can consume all RAM
1705+
# on a 64 GB machine.
1706+
mem_limit = max(1, stat.ullTotalPhys / (5 * (2 ** 30))) # total / 5GB
1707+
hard_cap = max(1, int(os.environ.get('GYP_LINK_CONCURRENCY_MAX', 2**32)))
17011708
return min(mem_limit, hard_cap)
17021709
elif sys.platform.startswith('linux'):
17031710
if os.path.exists("/proc/meminfo"):
@@ -2275,7 +2282,11 @@ def GenerateOutputForConfig(target_list, target_dicts, data, params,
22752282
if flavor == 'mac':
22762283
gyp.xcode_emulation.MergeGlobalXcodeSettingsToSpec(data[build_file], spec)
22772284

2278-
build_file = gyp.common.RelativePath(build_file, options.toplevel_dir)
2285+
# If build_file is a symlink, we must not follow it because there's a chance
2286+
# it could point to a path above toplevel_dir, and we cannot correctly deal
2287+
# with that case at the moment.
2288+
build_file = gyp.common.RelativePath(build_file, options.toplevel_dir,
2289+
False)
22792290

22802291
qualified_target_for_hash = gyp.common.QualifiedTarget(build_file, name,
22812292
toolset)

tools/gyp/pylib/gyp/input.py

+12-8
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ def IsPathSection(section):
5757
# If section ends in one of the '=+?!' characters, it's applied to a section
5858
# without the trailing characters. '/' is notably absent from this list,
5959
# because there's no way for a regular expression to be treated as a path.
60-
while section[-1:] in '=+?!':
60+
while section and section[-1:] in '=+?!':
6161
section = section[:-1]
6262

6363
if section in path_sections:
@@ -893,20 +893,24 @@ def ExpandVariables(input, phase, variables, build_file):
893893
else:
894894
# Fix up command with platform specific workarounds.
895895
contents = FixupPlatformCommand(contents)
896-
p = subprocess.Popen(contents, shell=use_shell,
897-
stdout=subprocess.PIPE,
898-
stderr=subprocess.PIPE,
899-
stdin=subprocess.PIPE,
900-
cwd=build_file_dir)
896+
try:
897+
p = subprocess.Popen(contents, shell=use_shell,
898+
stdout=subprocess.PIPE,
899+
stderr=subprocess.PIPE,
900+
stdin=subprocess.PIPE,
901+
cwd=build_file_dir)
902+
except Exception, e:
903+
raise GypError("%s while executing command '%s' in %s" %
904+
(e, contents, build_file))
901905

902906
p_stdout, p_stderr = p.communicate('')
903907

904908
if p.wait() != 0 or p_stderr:
905909
sys.stderr.write(p_stderr)
906910
# Simulate check_call behavior, since check_call only exists
907911
# in python 2.5 and later.
908-
raise GypError("Call to '%s' returned exit status %d." %
909-
(contents, p.returncode))
912+
raise GypError("Call to '%s' returned exit status %d while in %s." %
913+
(contents, p.returncode, build_file))
910914
replacement = p_stdout.rstrip()
911915

912916
cached_command_results[cache_key] = replacement

tools/gyp/pylib/gyp/msvs_emulation.py

+10
Original file line numberDiff line numberDiff line change
@@ -442,6 +442,7 @@ def GetCflags(self, config):
442442
cl('FloatingPointModel',
443443
map={'0': 'precise', '1': 'strict', '2': 'fast'}, prefix='/fp:',
444444
default='0')
445+
cl('CompileAsManaged', map={'false': '', 'true': '/clr'})
445446
cl('WholeProgramOptimization', map={'true': '/GL'})
446447
cl('WarningLevel', prefix='/W')
447448
cl('WarnAsError', map={'true': '/WX'})
@@ -593,6 +594,15 @@ def GetLdflags(self, config, gyp_to_build_path, expand_special,
593594
'2': 'WINDOWS%s' % minimum_required_version},
594595
prefix='/SUBSYSTEM:')
595596

597+
stack_reserve_size = self._Setting(
598+
('VCLinkerTool', 'StackReserveSize'), config, default='')
599+
if stack_reserve_size:
600+
stack_commit_size = self._Setting(
601+
('VCLinkerTool', 'StackCommitSize'), config, default='')
602+
if stack_commit_size:
603+
stack_commit_size = ',' + stack_commit_size
604+
ldflags.append('/STACK:%s%s' % (stack_reserve_size, stack_commit_size))
605+
596606
ld('TerminalServerAware', map={'1': ':NO', '2': ''}, prefix='/TSAWARE')
597607
ld('LinkIncremental', map={'1': ':NO', '2': ''}, prefix='/INCREMENTAL')
598608
ld('BaseAddress', prefix='/BASE:')

tools/gyp/pylib/gyp/win_tool.py

+3-1
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,9 @@ def ExecLinkWrapper(self, arch, use_separate_mspdbsrv, *args):
123123
stderr=subprocess.STDOUT)
124124
out, _ = link.communicate()
125125
for line in out.splitlines():
126-
if not line.startswith(' Creating library '):
126+
if (not line.startswith(' Creating library ') and
127+
not line.startswith('Generating code') and
128+
not line.startswith('Finished generating code')):
127129
print line
128130
return link.returncode
129131

tools/gyp/pylib/gyp/xcode_emulation.py

+17-3
Original file line numberDiff line numberDiff line change
@@ -1032,7 +1032,23 @@ def _AdjustLibrary(self, library, config_name=None):
10321032
sdk_root = self._SdkPath(config_name)
10331033
if not sdk_root:
10341034
sdk_root = ''
1035-
return l.replace('$(SDKROOT)', sdk_root)
1035+
# Xcode 7 started shipping with ".tbd" (text based stubs) files instead of
1036+
# ".dylib" without providing a real support for them. What it does, for
1037+
# "/usr/lib" libraries, is do "-L/usr/lib -lname" which is dependent on the
1038+
# library order and cause collision when building Chrome.
1039+
#
1040+
# Instead substitude ".tbd" to ".dylib" in the generated project when the
1041+
# following conditions are both true:
1042+
# - library is referenced in the gyp file as "$(SDKROOT)/**/*.dylib",
1043+
# - the ".dylib" file does not exists but a ".tbd" file do.
1044+
library = l.replace('$(SDKROOT)', sdk_root)
1045+
if l.startswith('$(SDKROOT)'):
1046+
basename, ext = os.path.splitext(library)
1047+
if ext == '.dylib' and not os.path.exists(library):
1048+
tbd_library = basename + '.tbd'
1049+
if os.path.exists(tbd_library):
1050+
library = tbd_library
1051+
return library
10361052

10371053
def AdjustLibraries(self, libraries, config_name=None):
10381054
"""Transforms entries like 'Cocoa.framework' in libraries into entries like
@@ -1479,8 +1495,6 @@ def _GetXcodeEnv(xcode_settings, built_products_dir, srcroot, configuration,
14791495
sdk_root = xcode_settings._SdkRoot(configuration)
14801496
if not sdk_root:
14811497
sdk_root = xcode_settings._XcodeSdkPath('')
1482-
if sdk_root is None:
1483-
sdk_root = ''
14841498
env['SDKROOT'] = sdk_root
14851499

14861500
if not additional_settings:

0 commit comments

Comments
 (0)