Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(30)

Side by Side Diff: build/landmines.py

Issue 2071463002: Simplify landmines code a bit now that all branches of all platforms are on ninja (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix for reland Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « build/landmine_utils.py ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 #!/usr/bin/env python 1 #!/usr/bin/env python
2 # Copyright (c) 2012 The Chromium Authors. All rights reserved. 2 # Copyright (c) 2012 The Chromium Authors. All rights reserved.
3 # Use of this source code is governed by a BSD-style license that can be 3 # Use of this source code is governed by a BSD-style license that can be
4 # found in the LICENSE file. 4 # found in the LICENSE file.
5 5
6 """ 6 """
7 This script runs every build as the first hook (See DEPS). If it detects that 7 This script runs every build as the first hook (See DEPS). If it detects that
8 the build should be clobbered, it will delete the contents of the build 8 the build should be clobbered, it will delete the contents of the build
9 directory. 9 directory.
10 10
11 A landmine is tripped when a builder checks out a different revision, and the 11 A landmine is tripped when a builder checks out a different revision, and the
12 diff between the new landmines and the old ones is non-null. At this point, the 12 diff between the new landmines and the old ones is non-null. At this point, the
13 build is clobbered. 13 build is clobbered.
14 """ 14 """
15 15
16 import difflib 16 import difflib
17 import errno 17 import errno
18 import gyp_environment 18 import gyp_environment
19 import logging 19 import logging
20 import optparse 20 import optparse
21 import os 21 import os
22 import sys 22 import sys
23 import subprocess 23 import subprocess
24 import time 24 import time
25 25
26 import clobber 26 import clobber
27 import landmine_utils 27 import landmine_utils
28 28
29 29
30 def get_build_dir(build_tool, src_dir, is_iphone=False): 30 def get_build_dir(src_dir):
31 """ 31 """
32 Returns output directory absolute path dependent on build and targets. 32 Returns output directory absolute path dependent on build and targets.
33 Examples: 33 Examples:
34 r'c:\b\build\slave\win\build\src\out' 34 r'c:\b\build\slave\win\build\src\out'
35 '/mnt/data/b/build/slave/linux/build/src/out' 35 '/mnt/data/b/build/slave/linux/build/src/out'
36 '/b/build/slave/ios_rel_device/build/src/xcodebuild' 36 '/b/build/slave/ios_rel_device/build/src/out'
37 37
38 Keep this function in sync with tools/build/scripts/slave/compile.py 38 Keep this function in sync with tools/build/scripts/slave/compile.py
39 """ 39 """
40 ret = None 40 if 'CHROMIUM_OUT_DIR' in os.environ:
41 if build_tool == 'xcode': 41 output_dir = os.environ.get('CHROMIUM_OUT_DIR').strip()
42 ret = os.path.join(src_dir, 'xcodebuild') 42 if not output_dir:
43 elif build_tool in ['make', 'ninja', 'ninja-ios']: # TODO: Remove ninja-ios. 43 raise Error('CHROMIUM_OUT_DIR environment variable is set but blank!')
44 if 'CHROMIUM_OUT_DIR' in os.environ:
45 output_dir = os.environ.get('CHROMIUM_OUT_DIR').strip()
46 if not output_dir:
47 raise Error('CHROMIUM_OUT_DIR environment variable is set but blank!')
48 else:
49 output_dir = landmine_utils.gyp_generator_flags().get('output_dir', 'out')
50 ret = os.path.join(src_dir, output_dir)
51 else: 44 else:
52 raise NotImplementedError('Unexpected GYP_GENERATORS (%s)' % build_tool) 45 output_dir = landmine_utils.gyp_generator_flags().get('output_dir', 'out')
53 return os.path.abspath(ret) 46 return os.path.abspath(os.path.join(src_dir, output_dir))
54 47
55 48
56 def clobber_if_necessary(new_landmines, src_dir): 49 def clobber_if_necessary(new_landmines, src_dir):
57 """Does the work of setting, planting, and triggering landmines.""" 50 """Does the work of setting, planting, and triggering landmines."""
58 out_dir = get_build_dir(landmine_utils.builder(), src_dir) 51 out_dir = get_build_dir(src_dir)
59 landmines_path = os.path.normpath(os.path.join(src_dir, '.landmines')) 52 landmines_path = os.path.normpath(os.path.join(src_dir, '.landmines'))
60 try: 53 try:
61 os.makedirs(out_dir) 54 os.makedirs(out_dir)
62 except OSError as e: 55 except OSError as e:
63 if e.errno == errno.EEXIST: 56 if e.errno == errno.EEXIST:
64 pass 57 pass
65 58
66 if os.path.exists(landmines_path): 59 if os.path.exists(landmines_path):
67 with open(landmines_path, 'r') as f: 60 with open(landmines_path, 'r') as f:
68 old_landmines = f.readlines() 61 old_landmines = f.readlines()
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
122 extra_script = os.environ.get('EXTRA_LANDMINES_SCRIPT') 115 extra_script = os.environ.get('EXTRA_LANDMINES_SCRIPT')
123 if extra_script: 116 if extra_script:
124 options.landmine_scripts += [extra_script] 117 options.landmine_scripts += [extra_script]
125 118
126 return options 119 return options
127 120
128 121
129 def main(): 122 def main():
130 options = process_options() 123 options = process_options()
131 124
132 if landmine_utils.builder() in ('dump_dependency_json', 'eclipse'):
133 return 0
134
135 gyp_environment.SetEnvironment() 125 gyp_environment.SetEnvironment()
136 126
137 landmines = [] 127 landmines = []
138 for s in options.landmine_scripts: 128 for s in options.landmine_scripts:
139 proc = subprocess.Popen([sys.executable, s], stdout=subprocess.PIPE) 129 proc = subprocess.Popen([sys.executable, s], stdout=subprocess.PIPE)
140 output, _ = proc.communicate() 130 output, _ = proc.communicate()
141 landmines.extend([('%s\n' % l.strip()) for l in output.splitlines()]) 131 landmines.extend([('%s\n' % l.strip()) for l in output.splitlines()])
142 clobber_if_necessary(landmines, options.src_dir) 132 clobber_if_necessary(landmines, options.src_dir)
143 133
144 return 0 134 return 0
145 135
146 136
147 if __name__ == '__main__': 137 if __name__ == '__main__':
148 sys.exit(main()) 138 sys.exit(main())
OLDNEW
« no previous file with comments | « build/landmine_utils.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698