def set_up_landmines(target, new_landmines): """Does the work of setting, planting, and triggering landmines.""" 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) if not os.path.exists(landmines_path): with open(landmines_path, 'w') as f: f.writelines(new_landmines) else: triggered = os.path.join(out_dir, '.landmines_triggered') with open(landmines_path, 'r') as f: old_landmines = f.readlines() if old_landmines != new_landmines: old_date = time.ctime(os.stat(landmines_path).st_ctime) diff = difflib.unified_diff(old_landmines, new_landmines, fromfile='old_landmines', tofile='new_landmines', fromfiledate=old_date, tofiledate=time.ctime(), n=0) with open(triggered, 'w') as f: f.writelines(diff) elif os.path.exists(triggered): # Remove false triggered landmines. os.remove(triggered)
def clobber_if_necessary(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')) try: os.makedirs(out_dir) except OSError as e: if e.errno == errno.EEXIST: pass if os.path.exists(landmines_path): with open(landmines_path, 'r') as f: old_landmines = f.readlines() if old_landmines != new_landmines: old_date = time.ctime(os.stat(landmines_path).st_ctime) 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(landmines_path, 'w') as f: f.writelines(new_landmines)
def clobber_if_necessary(new_landmines, src_dir): """Does the work of setting, planting, and triggering landmines.""" out_dir = get_build_dir(landmine_utils.builder(), src_dir) landmines_path = os.path.normpath(os.path.join(src_dir, '.landmines')) try: os.makedirs(out_dir) except OSError as e: if e.errno == errno.EEXIST: pass if os.path.exists(landmines_path): with open(landmines_path, 'r') as f: old_landmines = f.readlines() if old_landmines != new_landmines: old_date = time.ctime(os.stat(landmines_path).st_ctime) 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.clobber(out_dir) # Save current set of landmines for next time. with open(landmines_path, 'w') as f: f.writelines(new_landmines)
def clobber_if_necessary(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')) try: os.makedirs(out_dir) except OSError as e: if e.errno == errno.EEXIST: pass if os.path.exists(landmines_path): with open(landmines_path, 'r') as f: old_landmines = f.readlines() if old_landmines != new_landmines: old_date = time.ctime(os.stat(landmines_path).st_ctime) 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 contents of build directory but not directory itself: some # checkouts have the build directory mounted. for f in os.listdir(out_dir): path = os.path.join(out_dir, f) if os.path.isfile(path): os.unlink(path) elif os.path.isdir(path): shutil.rmtree(path) # Save current set of landmines for next time. with open(landmines_path, 'w') as f: f.writelines(new_landmines)
def clobber_if_necessary(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')) try: os.makedirs(out_dir) except OSError as e: if e.errno == errno.EEXIST: pass if os.path.exists(landmines_path): with open(landmines_path, 'r') as f: old_landmines = f.readlines() if old_landmines != new_landmines: old_date = time.ctime(os.stat(landmines_path).st_ctime) 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 contents of build directory but not directory itself: some # checkouts have the build directory mounted. for f in os.listdir(out_dir): path = os.path.join(out_dir, f) if os.path.isfile(path): os.unlink(path) elif os.path.isdir(path): delete_build_dir(path) # Save current set of landmines for next time. with open(landmines_path, 'w') as f: f.writelines(new_landmines)
def set_up_landmines(target, new_landmines): """Does the work of setting, planting, and triggering landmines.""" out_dir = get_target_build_dir(landmine_utils.builder(), target) landmines_path = os.path.join(out_dir, '.landmines') if not os.path.exists(out_dir): return # Make sure the landmines tracker exists. open(landmines_path, 'a').close() triggered = os.path.join(out_dir, '.landmines_triggered') with open(landmines_path, 'r') as f: old_landmines = f.readlines() if old_landmines != new_landmines: old_date = time.ctime(os.stat(landmines_path).st_ctime) diff = difflib.unified_diff(old_landmines, new_landmines, fromfile='old_landmines', tofile='new_landmines', fromfiledate=old_date, tofiledate=time.ctime(), n=0) with open(triggered, 'w') as f: f.writelines(diff) print "Setting landmine: %s" % triggered print "Reason:\n%s" % diff elif os.path.exists(triggered): # Remove false triggered landmines. os.remove(triggered) print "Removing landmine: %s" % triggered with open(landmines_path, 'w') as f: f.writelines(new_landmines)
def set_up_landmines(target, new_landmines): """Does the work of setting, planting, and triggering landmines.""" out_dir = get_target_build_dir(landmine_utils.builder(), target) landmines_path = os.path.join(out_dir, '.landmines') if not os.path.exists(out_dir): return if not os.path.exists(landmines_path): print "Landmines tracker didn't exists." # FIXME(machenbach): Clobber deletes the .landmines tracker. Difficult # to know if we are right after a clobber or if it is first-time landmines # deployment. Also, a landmine-triggered clobber right after a clobber is # not possible. Different clobber methods for msvs, xcode and make all # have different blacklists of files that are not deleted. 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: old_date = time.ctime(os.stat(landmines_path).st_ctime) diff = difflib.unified_diff(old_landmines, new_landmines, fromfile='old_landmines', tofile='new_landmines', fromfiledate=old_date, tofiledate=time.ctime(), n=0) with open(triggered, 'w') as f: f.writelines(diff) print "Setting landmine: %s" % triggered elif os.path.exists(triggered): # Remove false triggered landmines. os.remove(triggered) print "Removing landmine: %s" % triggered with open(landmines_path, 'w') as f: f.writelines(new_landmines)
def main(): landmine_scripts = process_options() if landmine_utils.builder() in ('dump_dependency_json', 'eclipse'): return 0 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) return 0
def main(): landmine_scripts = process_options() if landmine_utils.builder() in ('dump_dependency_json', 'eclipse'): return 0 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
def clobber_if_necessary(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')) try: os.makedirs(out_dir) except OSError as e: if e.errno == errno.EEXIST: pass if needs_clobber(landmines_path, new_landmines): # Clobber contents of build directory but not directory itself: some # checkouts have the build directory mounted. for f in os.listdir(out_dir): path = os.path.join(out_dir, f) if os.path.basename(out_dir) == 'build': # Only delete build directories and files for MSVS builds as the folder # shares some checked out files and directories. if (os.path.isdir(path) and re.search(r'(?:[Rr]elease)|(?:[Dd]ebug)', f)): delete_build_dir(path) elif (os.path.isfile(path) and (path.endswith('.sln') or path.endswith('.vcxproj') or path.endswith('.vcxproj.user'))): os.unlink(path) else: if os.path.isfile(path): os.unlink(path) elif os.path.isdir(path): delete_build_dir(path) if os.path.basename(out_dir) == 'xcodebuild': # Xcodebuild puts an additional project file structure into build, # while the output folder is xcodebuild. project_dir = os.path.join(SRC_DIR, 'build', 'all.xcodeproj') if os.path.exists(project_dir) and os.path.isdir(project_dir): delete_build_dir(project_dir) # Save current set of landmines for next time. with open(landmines_path, 'w') as f: f.writelines(new_landmines)