summaryrefslogtreecommitdiffstats
path: root/build/landmines.py
diff options
context:
space:
mode:
authoriannucci@chromium.org <iannucci@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-08-13 02:07:35 +0000
committeriannucci@chromium.org <iannucci@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-08-13 02:08:38 +0000
commit5a9e71778a0357194e33d27c9802a6979dddbe4d (patch)
tree82cd3541c6494db1278bb1473439eb11d845d17b /build/landmines.py
parent02a7f63626a073fb9018f0cd4126df3fcfba0fd3 (diff)
downloadchromium_src-5a9e71778a0357194e33d27c9802a6979dddbe4d.zip
chromium_src-5a9e71778a0357194e33d27c9802a6979dddbe4d.tar.gz
chromium_src-5a9e71778a0357194e33d27c9802a6979dddbe4d.tar.bz2
Revert of Make landmines work on local builds too (patchset #3 of https://codereview.chromium.org/457003004/)
Reason for revert: Apparently this requires win_toolchain.json to exist, but I'm not sure how it's supposed to get there (as seen on a clobber build): Traceback (most recent call last): File "src/build/landmines.py", line 132, in <module> sys.exit(main()) File "src/build/landmines.py", line 119, in main gyp_environment.SetEnvironment() File "C:\b\build\slave\win_trunk\build\src\build\gyp_environment.py", line 33, in SetEnvironment vs_toolchain.SetEnvironmentAndGetRuntimeDllDirs() File "C:\b\build\slave\win_trunk\build\src\build\vs_toolchain.py", line 33, in SetEnvironmentAndGetRuntimeDllDirs with open(json_data_file, 'r') as tempf: IOError: [Errno 2] No such file or directory: 'C:\\b\\build\\slave\\win_trunk\\build\\src\\build\\win_toolchain.json' Original issue's description: > Make landmines work on local builds too > > Moves (some of) gyp environment setup out of gyp_chromium into separate > module, and shares that between gyp_chromium and landmines.py. > > landmines.py is added as the first entry in DEPS hooks so that it can > clobber the entire build directory before running other hooks that > extract/generate into the build dir. > > R=iannucci@chromium.org > BUG=400011 > > Committed: https://src.chromium.org/viewvc/chrome?view=rev&revision=289099 TBR=scottmg@chromium.org NOTREECHECKS=true NOTRY=true BUG=400011 Review URL: https://codereview.chromium.org/469623002 Cr-Commit-Position: refs/heads/master@{#289158} git-svn-id: svn://svn.chromium.org/chrome/trunk/src@289158 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'build/landmines.py')
-rwxr-xr-xbuild/landmines.py59
1 files changed, 31 insertions, 28 deletions
diff --git a/build/landmines.py b/build/landmines.py
index c31bac7..220b8a7 100755
--- a/build/landmines.py
+++ b/build/landmines.py
@@ -4,8 +4,10 @@
# found in the LICENSE file.
"""
-This script runs every build as the first hook (See DEPS). If it detects that
-the build should be clobbered, it will remove the build directory.
+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
+accordingly. The script will also emit the reasons for the clobber to stdout.
A landmine is tripped when a builder checks out a different revision, and the
diff between the new landmines and the old ones is non-null. At this point, the
@@ -14,11 +16,9 @@ build is clobbered.
import difflib
import errno
-import gyp_environment
import logging
import optparse
import os
-import shutil
import sys
import subprocess
import time
@@ -29,32 +29,35 @@ import landmine_utils
SRC_DIR = os.path.dirname(os.path.dirname(os.path.realpath(__file__)))
-def get_build_dir(build_tool, is_iphone=False):
+def get_target_build_dir(build_tool, target, is_iphone=False):
"""
Returns output directory absolute path dependent on build and targets.
Examples:
- r'c:\b\build\slave\win\build\src\out'
- '/mnt/data/b/build/slave/linux/build/src/out'
- '/b/build/slave/ios_rel_device/build/src/xcodebuild'
+ r'c:\b\build\slave\win\build\src\out\Release'
+ '/mnt/data/b/build/slave/linux/build/src/out/Debug'
+ '/b/build/slave/ios_rel_device/build/src/xcodebuild/Release-iphoneos'
Keep this function in sync with tools/build/scripts/slave/compile.py
"""
ret = None
if build_tool == 'xcode':
- ret = os.path.join(SRC_DIR, 'xcodebuild')
+ ret = os.path.join(SRC_DIR, 'xcodebuild',
+ target + ('-iphoneos' if is_iphone else ''))
elif build_tool in ['make', 'ninja', 'ninja-ios']: # TODO: Remove ninja-ios.
- ret = os.path.join(SRC_DIR, 'out')
+ ret = os.path.join(SRC_DIR, 'out', target)
elif build_tool in ['msvs', 'vs', 'ib']:
- ret = os.path.join(SRC_DIR, 'build')
+ ret = os.path.join(SRC_DIR, 'build', target)
else:
raise NotImplementedError('Unexpected GYP_GENERATORS (%s)' % build_tool)
return os.path.abspath(ret)
-def clobber_if_necessary(new_landmines):
+def set_up_landmines(target, new_landmines):
"""Does the work of setting, planting, and triggering landmines."""
- out_dir = get_build_dir(landmine_utils.builder())
- landmines_path = os.path.normpath(os.path.join(out_dir, '..', '.landmines'))
+ out_dir = get_target_build_dir(landmine_utils.builder(), target,
+ landmine_utils.platform() == 'ios')
+
+ landmines_path = os.path.join(out_dir, '.landmines')
try:
os.makedirs(out_dir)
except OSError as e:
@@ -62,6 +65,7 @@ def clobber_if_necessary(new_landmines):
pass
if os.path.exists(landmines_path):
+ triggered = os.path.join(out_dir, '.landmines_triggered')
with open(landmines_path, 'r') as f:
old_landmines = f.readlines()
if old_landmines != new_landmines:
@@ -69,13 +73,12 @@ def clobber_if_necessary(new_landmines):
diff = difflib.unified_diff(old_landmines, new_landmines,
fromfile='old_landmines', tofile='new_landmines',
fromfiledate=old_date, tofiledate=time.ctime(), n=0)
- sys.stdout.write('Clobbering due to:\n')
- sys.stdout.writelines(diff)
-
- # Clobber.
- shutil.rmtree(out_dir)
- # Save current set of landmines for next time.
+ with open(triggered, 'w') as f:
+ f.writelines(diff)
+ elif os.path.exists(triggered):
+ # Remove false triggered landmines.
+ os.remove(triggered)
with open(landmines_path, 'w') as f:
f.writelines(new_landmines)
@@ -116,14 +119,14 @@ def main():
if landmine_utils.builder() in ('dump_dependency_json', 'eclipse'):
return 0
- gyp_environment.SetEnvironment()
-
- landmines = []
- for s in landmine_scripts:
- proc = subprocess.Popen([sys.executable, s], stdout=subprocess.PIPE)
- output, _ = proc.communicate()
- landmines.extend([('%s\n' % l.strip()) for l in output.splitlines()])
- clobber_if_necessary(landmines)
+ for target in ('Debug', 'Release', 'Debug_x64', 'Release_x64'):
+ landmines = []
+ for s in landmine_scripts:
+ 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