Skip to content

Commit 99cbbc0

Browse files
committed
tools: update gyp to 25ed9ac
Includes improved support for VS 2015[0] and makes it possible to build with ninja again[1]. [0] https://codereview.chromium.org/1112753003 [1] https://codereview.chromium.org/1209553002 Fixes: #2065 PR-URL: #2074 Reviewed-By: Johan Bergström <[email protected]> Reviewed-By: Shigeki Ohtsu <[email protected]>
1 parent 05a73c0 commit 99cbbc0

16 files changed

+399
-1887
lines changed

tools/gyp/PRESUBMIT.py

-1
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,6 @@ def CheckChangeOnCommit(input_api, output_api):
129129
'gyp-win64',
130130
'gyp-linux',
131131
'gyp-mac',
132-
'gyp-android'
133132
]
134133

135134

tools/gyp/buildbot/aosp_manifest.xml

-466
This file was deleted.

tools/gyp/buildbot/buildbot_run.py

+2-117
Original file line numberDiff line numberDiff line change
@@ -3,27 +3,17 @@
33
# Use of this source code is governed by a BSD-style license that can be
44
# found in the LICENSE file.
55

6-
76
"""Argument-less script to select what to run on the buildbots."""
87

9-
10-
import filecmp
118
import os
129
import shutil
1310
import subprocess
1411
import sys
1512

1613

17-
if sys.platform in ['win32', 'cygwin']:
18-
EXE_SUFFIX = '.exe'
19-
else:
20-
EXE_SUFFIX = ''
21-
22-
2314
BUILDBOT_DIR = os.path.dirname(os.path.abspath(__file__))
2415
TRUNK_DIR = os.path.dirname(BUILDBOT_DIR)
2516
ROOT_DIR = os.path.dirname(TRUNK_DIR)
26-
ANDROID_DIR = os.path.join(ROOT_DIR, 'android')
2717
CMAKE_DIR = os.path.join(ROOT_DIR, 'cmake')
2818
CMAKE_BIN_DIR = os.path.join(CMAKE_DIR, 'bin')
2919
OUT_DIR = os.path.join(TRUNK_DIR, 'out')
@@ -71,95 +61,6 @@ def PrepareCmake():
7161
CallSubProcess( ['make', 'cmake'], cwd=CMAKE_DIR)
7262

7363

74-
_ANDROID_SETUP = 'source build/envsetup.sh && lunch full-eng'
75-
76-
77-
def PrepareAndroidTree():
78-
"""Prepare an Android tree to run 'android' format tests."""
79-
if os.environ['BUILDBOT_CLOBBER'] == '1':
80-
print '@@@BUILD_STEP Clobber Android checkout@@@'
81-
shutil.rmtree(ANDROID_DIR)
82-
83-
# (Re)create the directory so that the following steps will succeed.
84-
if not os.path.isdir(ANDROID_DIR):
85-
os.mkdir(ANDROID_DIR)
86-
87-
# We use a manifest from the gyp project listing pinned revisions of AOSP to
88-
# use, to ensure that we test against a stable target. This needs to be
89-
# updated to pick up new build system changes sometimes, so we must test if
90-
# it has changed.
91-
manifest_filename = 'aosp_manifest.xml'
92-
gyp_manifest = os.path.join(BUILDBOT_DIR, manifest_filename)
93-
android_manifest = os.path.join(ANDROID_DIR, '.repo', 'manifests',
94-
manifest_filename)
95-
manifest_is_current = (os.path.isfile(android_manifest) and
96-
filecmp.cmp(gyp_manifest, android_manifest))
97-
if not manifest_is_current:
98-
# It's safe to repeat these steps, so just do them again to make sure we are
99-
# in a good state.
100-
print '@@@BUILD_STEP Initialize Android checkout@@@'
101-
CallSubProcess(
102-
['repo', 'init',
103-
'-u', 'https://android.googlesource.com/platform/manifest',
104-
'-b', 'master',
105-
'-g', 'all,-notdefault,-device,-darwin,-mips,-x86'],
106-
cwd=ANDROID_DIR)
107-
shutil.copy(gyp_manifest, android_manifest)
108-
109-
print '@@@BUILD_STEP Sync Android@@@'
110-
CallSubProcess(['repo', 'sync', '-j4', '-m', manifest_filename],
111-
cwd=ANDROID_DIR)
112-
113-
# If we already built the system image successfully and didn't sync to a new
114-
# version of the source, skip running the build again as it's expensive even
115-
# when there's nothing to do.
116-
system_img = os.path.join(ANDROID_DIR, 'out', 'target', 'product', 'generic',
117-
'system.img')
118-
if manifest_is_current and os.path.isfile(system_img):
119-
return
120-
121-
print '@@@BUILD_STEP Build Android@@@'
122-
CallSubProcess(
123-
['/bin/bash',
124-
'-c', '%s && make -j4' % _ANDROID_SETUP],
125-
cwd=ANDROID_DIR)
126-
127-
128-
def StartAndroidEmulator():
129-
"""Start an android emulator from the built android tree."""
130-
print '@@@BUILD_STEP Start Android emulator@@@'
131-
132-
CallSubProcess(['/bin/bash', '-c',
133-
'%s && adb kill-server ' % _ANDROID_SETUP],
134-
cwd=ANDROID_DIR)
135-
136-
# If taskset is available, use it to force adbd to run only on one core, as,
137-
# sadly, it improves its reliability (see crbug.com/268450).
138-
adbd_wrapper = ''
139-
with open(os.devnull, 'w') as devnull_fd:
140-
if subprocess.call(['which', 'taskset'], stdout=devnull_fd) == 0:
141-
adbd_wrapper = 'taskset -c 0'
142-
CallSubProcess(['/bin/bash', '-c',
143-
'%s && %s adb start-server ' % (_ANDROID_SETUP, adbd_wrapper)],
144-
cwd=ANDROID_DIR)
145-
146-
subprocess.Popen(
147-
['/bin/bash', '-c',
148-
'%s && emulator -no-window' % _ANDROID_SETUP],
149-
cwd=ANDROID_DIR)
150-
CallSubProcess(
151-
['/bin/bash', '-c',
152-
'%s && adb wait-for-device' % _ANDROID_SETUP],
153-
cwd=ANDROID_DIR)
154-
155-
156-
def StopAndroidEmulator():
157-
"""Stop all android emulators."""
158-
print '@@@BUILD_STEP Stop Android emulator@@@'
159-
# If this fails, it's because there is no emulator running.
160-
subprocess.call(['pkill', 'emulator.*'])
161-
162-
16364
def GypTestFormat(title, format=None, msvs_version=None, tests=[]):
16465
"""Run the gyp tests for a given format, emitting annotator tags.
16566
@@ -185,15 +86,7 @@ def GypTestFormat(title, format=None, msvs_version=None, tests=[]):
18586
'--format', format,
18687
'--path', CMAKE_BIN_DIR,
18788
'--chdir', 'gyp'] + tests)
188-
if format == 'android':
189-
# gyptest needs the environment setup from envsetup/lunch in order to build
190-
# using the 'android' backend, so this is done in a single shell.
191-
retcode = subprocess.call(
192-
['/bin/bash',
193-
'-c', '%s && cd %s && %s' % (_ANDROID_SETUP, ROOT_DIR, command)],
194-
cwd=ANDROID_DIR, env=env)
195-
else:
196-
retcode = subprocess.call(command, cwd=ROOT_DIR, env=env, shell=True)
89+
retcode = subprocess.call(command, cwd=ROOT_DIR, env=env, shell=True)
19790
if retcode:
19891
# Emit failure tag, and keep going.
19992
print '@@@STEP_FAILURE@@@'
@@ -209,15 +102,7 @@ def GypBuild():
209102
print 'Done.'
210103

211104
retcode = 0
212-
# The Android gyp bot runs on linux so this must be tested first.
213-
if os.environ['BUILDBOT_BUILDERNAME'] == 'gyp-android':
214-
PrepareAndroidTree()
215-
StartAndroidEmulator()
216-
try:
217-
retcode += GypTestFormat('android')
218-
finally:
219-
StopAndroidEmulator()
220-
elif sys.platform.startswith('linux'):
105+
if sys.platform.startswith('linux'):
221106
retcode += GypTestFormat('ninja')
222107
retcode += GypTestFormat('make')
223108
PrepareCmake()

tools/gyp/buildbot/commit_queue/cq_config.json

-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
"launched": {
44
"tryserver.nacl": {
55
"gyp-presubmit": ["defaulttests"],
6-
"gyp-android": ["defaulttests"],
76
"gyp-linux": ["defaulttests"],
87
"gyp-mac": ["defaulttests"],
98
"gyp-win32": ["defaulttests"],

tools/gyp/pylib/gyp/MSVSVersion.py

+3-2
Original file line numberDiff line numberDiff line change
@@ -84,10 +84,11 @@ def SetupScript(self, target_arch):
8484
# vcvars32, which it can only find if VS??COMNTOOLS is set, which it
8585
# isn't always.
8686
if target_arch == 'x86':
87-
if self.short_name == '2013' and (
87+
if self.short_name >= '2013' and self.short_name[-1] != 'e' and (
8888
os.environ.get('PROCESSOR_ARCHITECTURE') == 'AMD64' or
8989
os.environ.get('PROCESSOR_ARCHITEW6432') == 'AMD64'):
90-
# VS2013 non-Express has a x64-x86 cross that we want to prefer.
90+
# VS2013 and later, non-Express have a x64-x86 cross that we want
91+
# to prefer.
9192
return [os.path.normpath(
9293
os.path.join(self.path, 'VC/vcvarsall.bat')), 'amd64_x86']
9394
# Otherwise, the standard x86 compiler.

tools/gyp/pylib/gyp/__init__.py

+14-2
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ def FindBuildFiles():
4949

5050
def Load(build_files, format, default_variables={},
5151
includes=[], depth='.', params=None, check=False,
52-
circular_check=True):
52+
circular_check=True, duplicate_basename_check=True):
5353
"""
5454
Loads one or more specified build files.
5555
default_variables and includes will be copied before use.
@@ -126,6 +126,7 @@ def Load(build_files, format, default_variables={},
126126
# Process the input specific to this generator.
127127
result = gyp.input.Load(build_files, default_variables, includes[:],
128128
depth, generator_input_info, check, circular_check,
129+
duplicate_basename_check,
129130
params['parallel'], params['root_targets'])
130131
return [generator] + result
131132

@@ -324,6 +325,16 @@ def gyp_main(args):
324325
parser.add_option('--no-circular-check', dest='circular_check',
325326
action='store_false', default=True, regenerate=False,
326327
help="don't check for circular relationships between files")
328+
# --no-duplicate-basename-check disables the check for duplicate basenames
329+
# in a static_library/shared_library project. Visual C++ 2008 generator
330+
# doesn't support this configuration. Libtool on Mac also generates warnings
331+
# when duplicate basenames are passed into Make generator on Mac.
332+
# TODO(yukawa): Remove this option when these legacy generators are
333+
# deprecated.
334+
parser.add_option('--no-duplicate-basename-check',
335+
dest='duplicate_basename_check', action='store_false',
336+
default=True, regenerate=False,
337+
help="don't check for duplicate basenames")
327338
parser.add_option('--no-parallel', action='store_true', default=False,
328339
help='Disable multiprocessing')
329340
parser.add_option('-S', '--suffix', dest='suffix', default='',
@@ -499,7 +510,8 @@ def gyp_main(args):
499510
# Start with the default variables from the command line.
500511
[generator, flat_list, targets, data] = Load(
501512
build_files, format, cmdline_default_variables, includes, options.depth,
502-
params, options.check, options.circular_check)
513+
params, options.check, options.circular_check,
514+
options.duplicate_basename_check)
503515

504516
# TODO(mark): Pass |data| for now because the generator needs a list of
505517
# build files that came in. In the future, maybe it should just accept

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

+44-5
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,10 @@ class Target(object):
183183
added_to_compile_targets: used when determining if the target was added to the
184184
set of targets that needs to be built.
185185
in_roots: true if this target is a descendant of one of the root nodes.
186-
is_executable: true if the type of target is executable."""
186+
is_executable: true if the type of target is executable.
187+
is_static_library: true if the type of target is static_library.
188+
is_or_has_linked_ancestor: true if the target does a link (eg executable), or
189+
if there is a target in back_deps that does a link."""
187190
def __init__(self, name):
188191
self.deps = set()
189192
self.match_status = MATCH_STATUS_TBD
@@ -196,6 +199,8 @@ def __init__(self, name):
196199
self.added_to_compile_targets = False
197200
self.in_roots = False
198201
self.is_executable = False
202+
self.is_static_library = False
203+
self.is_or_has_linked_ancestor = False
199204

200205

201206
class Config(object):
@@ -266,8 +271,8 @@ def _GetOrCreateTargetByName(targets, target_name):
266271
def _DoesTargetTypeRequireBuild(target_dict):
267272
"""Returns true if the target type is such that it needs to be built."""
268273
# If a 'none' target has rules or actions we assume it requires a build.
269-
return target_dict['type'] != 'none' or \
270-
target_dict.get('actions') or target_dict.get('rules')
274+
return bool(target_dict['type'] != 'none' or
275+
target_dict.get('actions') or target_dict.get('rules'))
271276

272277

273278
def _GenerateTargets(data, target_list, target_dicts, toplevel_dir, files,
@@ -309,7 +314,11 @@ def _GenerateTargets(data, target_list, target_dicts, toplevel_dir, files,
309314
target.visited = True
310315
target.requires_build = _DoesTargetTypeRequireBuild(
311316
target_dicts[target_name])
312-
target.is_executable = target_dicts[target_name]['type'] == 'executable'
317+
target_type = target_dicts[target_name]['type']
318+
target.is_executable = target_type == 'executable'
319+
target.is_static_library = target_type == 'static_library'
320+
target.is_or_has_linked_ancestor = (target_type == 'executable' or
321+
target_type == 'shared_library')
313322

314323
build_file = gyp.common.ParseQualifiedTarget(target_name)[0]
315324
if not build_file in build_file_in_files:
@@ -378,6 +387,7 @@ def _DoesTargetDependOn(target):
378387
for dep in target.deps:
379388
if _DoesTargetDependOn(dep):
380389
target.match_status = MATCH_STATUS_MATCHES_BY_DEPENDENCY
390+
print '\t', target.name, 'matches by dep', dep.name
381391
return True
382392
target.match_status = MATCH_STATUS_DOESNT_MATCH
383393
return False
@@ -388,6 +398,7 @@ def _GetTargetsDependingOn(possible_targets):
388398
directly on indirectly) on the matched targets.
389399
possible_targets: targets to search from."""
390400
found = []
401+
print 'Targets that matched by dependency:'
391402
for target in possible_targets:
392403
if _DoesTargetDependOn(target):
393404
found.append(target)
@@ -411,14 +422,27 @@ def _AddBuildTargets(target, roots, add_if_no_ancestor, result):
411422
_AddBuildTargets(back_dep_target, roots, False, result)
412423
target.added_to_compile_targets |= back_dep_target.added_to_compile_targets
413424
target.in_roots |= back_dep_target.in_roots
425+
target.is_or_has_linked_ancestor |= (
426+
back_dep_target.is_or_has_linked_ancestor)
414427

415428
# Always add 'executable' targets. Even though they may be built by other
416429
# targets that depend upon them it makes detection of what is going to be
417430
# built easier.
431+
# And always add static_libraries that have no dependencies on them from
432+
# linkables. This is necessary as the other dependencies on them may be
433+
# static libraries themselves, which are not compile time dependencies.
418434
if target.in_roots and \
419435
(target.is_executable or
420436
(not target.added_to_compile_targets and
421-
(add_if_no_ancestor or target.requires_build))):
437+
(add_if_no_ancestor or target.requires_build)) or
438+
(target.is_static_library and add_if_no_ancestor and
439+
not target.is_or_has_linked_ancestor)):
440+
print '\t\tadding to build targets', target.name, 'executable', \
441+
target.is_executable, 'added_to_compile_targets', \
442+
target.added_to_compile_targets, 'add_if_no_ancestor', \
443+
add_if_no_ancestor, 'requires_build', target.requires_build, \
444+
'is_static_library', target.is_static_library, \
445+
'is_or_has_linked_ancestor', target.is_or_has_linked_ancestor
422446
result.add(target)
423447
target.added_to_compile_targets = True
424448

@@ -429,6 +453,7 @@ def _GetBuildTargets(matching_targets, roots):
429453
roots: set of root targets in the build files to search from."""
430454
result = set()
431455
for target in matching_targets:
456+
print '\tfinding build targets for match', target.name
432457
_AddBuildTargets(target, roots, True, result)
433458
return result
434459

@@ -536,6 +561,10 @@ def GenerateOutput(target_list, target_dicts, data, params):
536561
data, target_list, target_dicts, toplevel_dir, frozenset(config.files),
537562
params['build_files'])
538563

564+
print 'roots:'
565+
for root in roots:
566+
print '\t', root.name
567+
539568
unqualified_mapping = _GetUnqualifiedToTargetMapping(all_targets,
540569
config.targets)
541570
invalid_targets = None
@@ -544,10 +573,20 @@ def GenerateOutput(target_list, target_dicts, data, params):
544573

545574
if matching_targets:
546575
search_targets = _LookupTargets(config.targets, unqualified_mapping)
576+
print 'supplied targets'
577+
for target in config.targets:
578+
print '\t', target
579+
print 'expanded supplied targets'
580+
for target in search_targets:
581+
print '\t', target.name
547582
matched_search_targets = _GetTargetsDependingOn(search_targets)
583+
print 'raw matched search targets:'
584+
for target in matched_search_targets:
585+
print '\t', target.name
548586
# Reset the visited status for _GetBuildTargets.
549587
for target in all_targets.itervalues():
550588
target.visited = False
589+
print 'Finding build targets'
551590
build_targets = _GetBuildTargets(matching_targets, roots)
552591
matched_search_targets = [gyp.common.ParseQualifiedTarget(target.name)[1]
553592
for target in matched_search_targets]

0 commit comments

Comments
 (0)