def archive_build(target='Debug', name='archive.zip', location='out', files=None, ignore_subfolder_names=False): out_dir = 'out' target_dir = os.path.join(out_dir, target) zip_file = os.path.join(location, name) expanded_files = [] if files: for f in files: expanded_files.append(os.path.join(target_dir, f)) else: expanded_files = [target_dir] saved_dir = os.getcwd() os.chdir(os.path.dirname(os.path.join(saved_dir, out_dir))) # Delete the zip file so we don't accidentally add to an existing archive. chromium_utils.RemoveFile(zip_file) zip_args = '-yr1' if ignore_subfolder_names: zip_args += 'j' command = ['zip', zip_args, zip_file] command.extend(expanded_files) subprocess.call(' '.join(command), shell=True) os.chdir(saved_dir)
def PruneOldArchives(staging_dir, zip_base, zip_ext): """Removes old archives so that we don't exceed disk space.""" zip_list = glob.glob(os.path.join(staging_dir, zip_base + '_*' + zip_ext)) saved_zip_list = GetRecentBuildsByBuildNumber(zip_list, zip_base, zip_ext) saved_mtime_list = GetRecentBuildsByModificationTime(zip_list) # Prune zip files not matched by the whitelists above. for zip_file in zip_list: if zip_file not in saved_zip_list and zip_file not in saved_mtime_list: print 'Pruning zip %s.' % zip_file chromium_utils.RemoveFile(staging_dir, zip_file)
def main_win(options, args): """Interprets options, clobbers object files, and calls the build tool. """ # Prefer the version specified in the .sln. When devenv.com is used at the # command line to start a build, it doesn't accept sln file from a different # version. if not options.msvs_version: sln = open(os.path.join(options.build_dir, options.solution), 'rU') header = sln.readline().strip() sln.close() if header.endswith('11.00'): options.msvs_version = '10' elif header.endswith('10.00'): options.msvs_version = '9' elif header.endswith('9.00'): options.msvs_version = '8' else: print >> sys.stderr, "Unknown sln header:\n" + header return 1 REG_ROOT = 'SOFTWARE\\Microsoft\\VisualStudio\\' devenv = ReadHKLMValue(REG_ROOT + options.msvs_version + '.0', 'InstallDir') if devenv: devenv = os.path.join(devenv, 'devenv.com') else: print >> sys.stderr, ("MSVS %s was requested but is not installed." % options.msvs_version) return 1 ib = ReadHKLMValue('SOFTWARE\\Xoreax\\IncrediBuild\\Builder', 'Folder') if ib: ib = os.path.join(ib, 'BuildConsole.exe') if ib and os.path.exists(ib) and not options.no_ib: tool = ib if options.arch == 'x64': tool_options = ['/Cfg=%s|x64' % options.target] else: tool_options = ['/Cfg=%s|Win32' % options.target] if options.project: tool_options.extend(['/Prj=%s' % options.project]) else: tool = devenv if options.arch == 'x64': tool_options = ['/Build', '%s|x64' % options.target] else: tool_options = ['/Build', options.target] if options.project: tool_options.extend(['/Project', options.project]) options.build_dir = os.path.abspath(options.build_dir) build_output_dir = os.path.join(options.build_dir, options.target) def clobber(): print('Removing %s' % build_output_dir) chromium_utils.RemoveDirectory(build_output_dir) if options.clobber: clobber() else: # Remove the log file so it doesn't grow without limit, chromium_utils.RemoveFile(build_output_dir, 'debug.log') # Remove the chrome.dll version resource so it picks up the new svn # revision, unless user explicitly asked not to remove it. See # Bug 1064677 for more details. if not options.keep_version_file: chromium_utils.RemoveFile(build_output_dir, 'obj', 'chrome_dll', 'chrome_dll_version.rc') env = EchoDict(os.environ) if options.compiler == 'goma': env['CC'] = 'gomacc.exe cl' env['CXX'] = 'gomacc.exe cl' env['PATH'] = ';'.join([options.goma_dir, env['PATH']]) if options.mode == 'google_chrome' or options.mode == 'official': env['CHROMIUM_BUILD'] = '_google_chrome' if options.mode == 'official': # Official builds are always Google Chrome. env['OFFICIAL_BUILD'] = '1' env['CHROME_BUILD_TYPE'] = '_official' if not options.solution: options.solution = 'all.sln' result = -1 solution = os.path.join(options.build_dir, options.solution) command = [tool, solution] + tool_options + args errors = [] # Examples: # midl : command line error MIDL1003 : error returned by the C # preprocessor (-1073741431) # # Error executing C:\PROGRA~2\MICROS~1\Common7\Tools\Bin\Midl.Exe (tool # returned code: 1282) # # --- # # cl : Command line error D8027 : cannot execute 'C:\Program Files # (x86)\Microsoft Visual Studio 8\VC\bin\c2.dll' # # --- # # Warning: Could not delete file "c:\b\slave\win\build\src\build\Debug\ # chrome.dll" : Access is denied # --------------------Build System Warning-------------------------------- # ------- # Could not delete file: # Could not delete file "c:\b\slave\win\build\src\build\Debug\ # chrome.dll" : Access is denied # (Automatically running xgHandle on first 10 files that could not be # deleted) # Searching for '\Device\HarddiskVolume1\b\slave\win\build\src\build\ # Debug\chrome.dll': # No handles found. # (xgHandle utility returned code: 0x00000000) # # --- # # webkit.lib(WebGeolocationError.obj) : fatal error LNK1318: Unexpected PDB # error; OK (0) '' # # Error executing link.exe (tool returned code: 1318) # # --- # # browser.lib(background_application_list_model.obj) : fatal error LNK1000: # Internal error during IMAGE::Pass2 # (along with a register dump) # # --- # # ...\browser\history\download_create_info.cc : fatal error C1033: cannot open # program database '...\src\build\debug\obj\browser\browser\vc80_ib_2.idb' known_toolset_bugs = [ '\\c2.dll', 'Midl.Exe (tool returned code: 1282)', 'LINK : fatal error LNK1102: out of memory', 'fatal error LNK1318: Unexpected PDB error', 'fatal error LNK1000: Internal error during IMAGE::Pass2', 'fatal error C1033', ] def scan(line): for known_line in known_toolset_bugs: if known_line in line: errors.append(line) break env.print_overrides() result = chromium_utils.RunCommand(command, parser_func=scan, env=env, universal_newlines=True) if errors: print('\n\nRetrying a clobber build because of:') print('\n'.join((' ' + l for l in errors))) print('Removing %s' % build_output_dir) for _ in range(3): try: chromium_utils.RemoveDirectory(build_output_dir) break except OSError, e: print(e) print('\nSleeping 15 seconds. Lovely windows file locks.') time.sleep(15) else: print('Failed to delete a file 3 times in a row, aborting.') return 1 result = chromium_utils.RunCommand(command, env=env)
build_list = [] for x in zip_list: regexp_match = regexp.match(os.path.basename(x)) if regexp_match: build_list.append(int(regexp_match.group(1))) # Since we match both ###.zip and ###_old.zip, bounce through a set and back # to a list to get an order list of build numbers. build_list = list(set(build_list)) build_list.sort() # Only keep the last 15 number (that means we could have 30 due to _old files # if someone forced a respin of every single one) trim_build_list = build_list[:-15] for x in trim_build_list: prune_name = zip_template.replace('.zip', '_%d.zip' % x) print 'Pruning build %d' % x chromium_utils.RemoveFile(stage_dir, prune_name) chromium_utils.RemoveFile(stage_dir, prune_name.replace('.zip', '_old.zip')) www_dir = config.Archive.www_dir_base + 'v8_archive/' + build_version archive_host = 'master3.golo.chromium.org' print 'SshMakeDirectory(%s, %s)' % (archive_host, www_dir) print 'SshCopyFiles(%s, %s, %s)' % (versioned_file, archive_host, www_dir) chromium_utils.SshMakeDirectory(archive_host, www_dir) MakeWorldReadable(versioned_file) chromium_utils.SshCopyFiles(versioned_file, archive_host, www_dir) # os.unlink(versioned_file) # Files are created umask 077 by default, so make it world-readable # before pushing to web server. return 0