summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rwxr-xr-xbuild/get_landmines.py63
-rw-r--r--build/landmine_utils.py114
-rwxr-xr-xbuild/landmines.py161
3 files changed, 197 insertions, 141 deletions
diff --git a/build/get_landmines.py b/build/get_landmines.py
new file mode 100755
index 0000000..05c9de6
--- /dev/null
+++ b/build/get_landmines.py
@@ -0,0 +1,63 @@
+#!/usr/bin/env python
+# Copyright 2013 The Chromium Authors. All rights reserved.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+"""
+This file emits the list of reasons why a particular build needs to be clobbered
+(or a list of 'landmines').
+"""
+
+import optparse
+import sys
+
+import landmine_utils
+
+
+builder = landmine_utils.platform
+distributor = landmine_utils.distributor
+gyp_defines = landmine_utils.gyp_defines
+gyp_msvs_version = landmine_utils.gyp_msvs_version
+platform = landmine_utils.platform
+
+
+def print_landmines(target):
+ """
+ ALL LANDMINES ARE EMITTED FROM HERE.
+ target can be one of {'Release', 'Debug', 'Debug_x64', 'Release_x64'}.
+ """
+ if (distributor() == 'goma' and platform() == 'win32' and
+ builder() == 'ninja'):
+ print 'Need to clobber winja goma due to backend cwd cache fix.'
+ if platform() == 'android':
+ print 'Clobber: Resources removed in r195014 require clobber.'
+ if platform() == 'win' and builder() == 'ninja':
+ print 'Compile on cc_unittests fails due to symbols removed in r185063.'
+ if platform() == 'linux' and builder() == 'ninja':
+ print 'Builders switching from make to ninja will clobber on this.'
+ if platform() == 'mac':
+ print 'Switching from bundle to unbundled dylib (issue 14743002).'
+ if (platform() == 'win' and builder() == 'ninja' and
+ gyp_msvs_version() == '2012' and
+ gyp_defines().get('target_arch') == 'x64' and
+ gyp_defines().get('dcheck_always_on') == '1'):
+ print "Switched win x64 trybots from VS2010 to VS2012."
+ print 'Need to clobber everything due to an IDL change in r154579 (blink)'
+
+
+def main():
+ parser = optparse.OptionParser()
+ parser.add_option('-t', '--target',
+ help=='Target for which the landmines have to be emitted')
+
+ options, args = parser.parse_args()
+
+ if args:
+ parser.error('Unknown arguments %s' % args)
+
+ print_landmines(options.target)
+ return 0
+
+
+if __name__ == '__main__':
+ sys.exit(main())
diff --git a/build/landmine_utils.py b/build/landmine_utils.py
new file mode 100644
index 0000000..021fc9b
--- /dev/null
+++ b/build/landmine_utils.py
@@ -0,0 +1,114 @@
+# Copyright 2013 The Chromium Authors. All rights reserved.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+
+import functools
+import logging
+import os
+import shlex
+import sys
+
+
+def memoize(default=None):
+ """This decorator caches the return value of a parameterless pure function"""
+ def memoizer(func):
+ val = []
+ @functools.wraps(func)
+ def inner():
+ if not val:
+ ret = func()
+ val.append(ret if ret is not None else default)
+ if logging.getLogger().isEnabledFor(logging.INFO):
+ print '%s -> %r' % (func.__name__, val[0])
+ return val[0]
+ return inner
+ return memoizer
+
+
+@memoize()
+def IsWindows():
+ return sys.platform in ['win32', 'cygwin']
+
+
+@memoize()
+def IsLinux():
+ return sys.platform.startswith('linux')
+
+
+@memoize()
+def IsMac():
+ return sys.platform == 'darwin'
+
+
+@memoize()
+def gyp_defines():
+ """Parses and returns GYP_DEFINES env var as a dictionary."""
+ return dict(arg.split('=', 1)
+ for arg in shlex.split(os.environ.get('GYP_DEFINES', '')))
+
+@memoize()
+def gyp_msvs_version():
+ return os.environ.get('GYP_MSVS_VERSION', '')
+
+@memoize()
+def distributor():
+ """
+ Returns a string which is the distributed build engine in use (if any).
+ Possible values: 'goma', 'ib', ''
+ """
+ if 'goma' in gyp_defines():
+ return 'goma'
+ elif IsWindows():
+ if 'CHROME_HEADLESS' in os.environ:
+ return 'ib' # use (win and !goma and headless) as approximation of ib
+
+
+@memoize()
+def platform():
+ """
+ Returns a string representing the platform this build is targetted for.
+ Possible values: 'win', 'mac', 'linux', 'ios', 'android'
+ """
+ if 'OS' in gyp_defines():
+ if 'android' in gyp_defines()['OS']:
+ return 'android'
+ else:
+ return gyp_defines()['OS']
+ elif IsWindows():
+ return 'win'
+ elif IsLinux():
+ return 'linux'
+ else:
+ return 'mac'
+
+
+@memoize()
+def builder():
+ """
+ Returns a string representing the build engine (not compiler) to use.
+ Possible values: 'make', 'ninja', 'xcode', 'msvs', 'scons'
+ """
+ if 'GYP_GENERATORS' in os.environ:
+ # for simplicity, only support the first explicit generator
+ generator = os.environ['GYP_GENERATORS'].split(',')[0]
+ if generator.endswith('-android'):
+ return generator.split('-')[0]
+ elif generator.endswith('-ninja'):
+ return 'ninja'
+ else:
+ return generator
+ else:
+ if platform() == 'android':
+ # Good enough for now? Do any android bots use make?
+ return 'ninja'
+ elif platform() == 'ios':
+ return 'xcode'
+ elif IsWindows():
+ return 'msvs'
+ elif IsLinux():
+ return 'ninja'
+ elif IsMac():
+ return 'xcode'
+ else:
+ assert False, 'Don\'t know what builder we\'re using!'
diff --git a/build/landmines.py b/build/landmines.py
index c09ffb8..edf0405 100755
--- a/build/landmines.py
+++ b/build/landmines.py
@@ -4,9 +4,6 @@
# found in the LICENSE file.
"""
-This file holds a list of reasons why a particular build needs to be clobbered
-(or a list of 'landmines').
-
This script runs every build as a hook. If it detects that the build should
be clobbered, it will touch the file <build_dir>/.landmine_triggered. The
various build scripts will then check for the presence of this file and clobber
@@ -18,148 +15,18 @@ build is clobbered.
"""
import difflib
-import functools
import gyp_helper
import logging
import optparse
import os
-import shlex
import sys
+import subprocess
import time
-SRC_DIR = os.path.dirname(os.path.dirname(os.path.realpath(__file__)))
-
-def memoize(default=None):
- """This decorator caches the return value of a parameterless pure function"""
- def memoizer(func):
- val = []
- @functools.wraps(func)
- def inner():
- if not val:
- ret = func()
- val.append(ret if ret is not None else default)
- if logging.getLogger().isEnabledFor(logging.INFO):
- print '%s -> %r' % (func.__name__, val[0])
- return val[0]
- return inner
- return memoizer
-
-
-@memoize()
-def IsWindows():
- return sys.platform in ['win32', 'cygwin']
-
-
-@memoize()
-def IsLinux():
- return sys.platform.startswith('linux')
-
-
-@memoize()
-def IsMac():
- return sys.platform == 'darwin'
-
-
-@memoize()
-def gyp_defines():
- """Parses and returns GYP_DEFINES env var as a dictionary."""
- return dict(arg.split('=', 1)
- for arg in shlex.split(os.environ.get('GYP_DEFINES', '')))
-
-@memoize()
-def gyp_msvs_version():
- return os.environ.get('GYP_MSVS_VERSION', '')
-
-@memoize()
-def distributor():
- """
- Returns a string which is the distributed build engine in use (if any).
- Possible values: 'goma', 'ib', ''
- """
- if 'goma' in gyp_defines():
- return 'goma'
- elif IsWindows():
- if 'CHROME_HEADLESS' in os.environ:
- return 'ib' # use (win and !goma and headless) as approximation of ib
-
-
-@memoize()
-def platform():
- """
- Returns a string representing the platform this build is targetted for.
- Possible values: 'win', 'mac', 'linux', 'ios', 'android'
- """
- if 'OS' in gyp_defines():
- if 'android' in gyp_defines()['OS']:
- return 'android'
- else:
- return gyp_defines()['OS']
- elif IsWindows():
- return 'win'
- elif IsLinux():
- return 'linux'
- else:
- return 'mac'
+import landmine_utils
-@memoize()
-def builder():
- """
- Returns a string representing the build engine (not compiler) to use.
- Possible values: 'make', 'ninja', 'xcode', 'msvs', 'scons'
- """
- if 'GYP_GENERATORS' in os.environ:
- # for simplicity, only support the first explicit generator
- generator = os.environ['GYP_GENERATORS'].split(',')[0]
- if generator.endswith('-android'):
- return generator.split('-')[0]
- elif generator.endswith('-ninja'):
- return 'ninja'
- else:
- return generator
- else:
- if platform() == 'android':
- # Good enough for now? Do any android bots use make?
- return 'ninja'
- elif platform() == 'ios':
- return 'xcode'
- elif IsWindows():
- return 'msvs'
- elif IsLinux():
- return 'ninja'
- elif IsMac():
- return 'xcode'
- else:
- assert False, 'Don\'t know what builder we\'re using!'
-
-
-def get_landmines(target):
- """
- ALL LANDMINES ARE DEFINED HERE.
- target is 'Release' or 'Debug'
- """
- landmines = []
- add = lambda item: landmines.append(item + '\n')
-
- if (distributor() == 'goma' and platform() == 'win32' and
- builder() == 'ninja'):
- add('Need to clobber winja goma due to backend cwd cache fix.')
- if platform() == 'android':
- add('Clobber: Resources removed in r195014 require clobber.')
- if platform() == 'win' and builder() == 'ninja':
- add('Compile on cc_unittests fails due to symbols removed in r185063.')
- if platform() == 'linux' and builder() == 'ninja':
- add('Builders switching from make to ninja will clobber on this.')
- if platform() == 'mac':
- add('Switching from bundle to unbundled dylib (issue 14743002).')
- if (platform() == 'win' and builder() == 'ninja' and
- gyp_msvs_version() == '2012' and
- gyp_defines().get('target_arch') == 'x64' and
- gyp_defines().get('dcheck_always_on') == '1'):
- add("Switched win x64 trybots from VS2010 to VS2012.")
- add('Need to clobber everything due to an IDL change in r154579 (blink)')
-
- return landmines
+SRC_DIR = os.path.dirname(os.path.dirname(os.path.realpath(__file__)))
def get_target_build_dir(build_tool, target, is_iphone=False):
@@ -187,16 +54,15 @@ def get_target_build_dir(build_tool, target, is_iphone=False):
return os.path.abspath(ret)
-def set_up_landmines(target):
+def set_up_landmines(target, new_landmines):
"""Does the work of setting, planting, and triggering landmines."""
- out_dir = get_target_build_dir(builder(), target, platform() == 'ios')
+ out_dir = get_target_build_dir(landmine_utils.builder(), target,
+ landmine_utils.platform() == 'ios')
landmines_path = os.path.join(out_dir, '.landmines')
if not os.path.exists(out_dir):
os.makedirs(out_dir)
- new_landmines = get_landmines(target)
-
if not os.path.exists(landmines_path):
with open(landmines_path, 'w') as f:
f.writelines(new_landmines)
@@ -219,11 +85,17 @@ def set_up_landmines(target):
def main():
parser = optparse.OptionParser()
+ parser.add_option(
+ '-s', '--landmine-scripts', action='append',
+ default=[os.path.join(SRC_DIR, 'build', 'get_landmines.py')],
+ help='Path to the script which emits landmines to stdout. The target '
+ 'is passed to this script via option -t.')
parser.add_option('-v', '--verbose', action='store_true',
default=('LANDMINES_VERBOSE' in os.environ),
help=('Emit some extra debugging information (default off). This option '
'is also enabled by the presence of a LANDMINES_VERBOSE environment '
'variable.'))
+
options, args = parser.parse_args()
if args:
@@ -235,7 +107,14 @@ def main():
gyp_helper.apply_chromium_gyp_env()
for target in ('Debug', 'Release', 'Debug_x64', 'Release_x64'):
- set_up_landmines(target)
+ landmines = []
+ for s in options.landmine_scripts:
+ print 'Getting landmines from `%s -t %s`' % (s, target)
+ proc = subprocess.Popen([sys.executable, s, '-t', target],
+ stdout=subprocess.PIPE)
+ output, _ = proc.communicate()
+ landmines.extend([('%s\n' % l.strip()) for l in output.splitlines()])
+ set_up_landmines(target, landmines)
return 0