def Main(): starttime = time.time() # Parse the options. parser = BuildOptions() options = parser.parse_args() targets = options.build_targets if len(targets) == 0: targets = ['all'] if not gn_py.ProcessOptions(options): parser.print_help() return 1 # If binaries are built with sanitizers we should use those flags. # If the binaries are not built with sanitizers the flag should have no # effect. env = dict(os.environ) env.update(SanitizerEnvironmentVariables()) # Always run GN before building. gn_py.RunGnOnConfiguredConfigurations(options) # Build all targets for each requested configuration. configs = [] for target_os in options.os: for mode in options.mode: for arch in options.arch: for sanitizer in options.sanitizer: configs.append( BuildOneConfig(options, targets, target_os, mode, arch, sanitizer)) # Build regular configs. goma_builds = [] for (build_config, args, goma) in configs: if args is None: return 1 if goma: goma_builds.append([env, args]) elif RunOneBuildCommand(build_config, args, env=env) != 0: return 1 # Run goma builds in parallel. pool = multiprocessing.Pool(multiprocessing.cpu_count()) results = pool.map(RunOneGomaBuildCommand, goma_builds, chunksize=1) for r in results: if r != 0: return 1 endtime = time.time() print("The build took %.3f seconds" % (endtime - starttime)) return 0
def Main(): starttime = time.time() # Parse the options. parser = BuildOptions() options = parser.parse_args() targets = options.build_targets if len(targets) == 0: targets = ['all'] if not gn_py.ProcessOptions(options): parser.print_help() return 1 # If binaries are built with sanitizers we should use those flags. # If the binaries are not built with sanitizers the flag should have no # effect. env = dict(os.environ) env.update(SanitizerEnvironmentVariables()) # Always run GN before building. gn_py.RunGnOnConfiguredConfigurations(options) # Build all targets for each requested configuration. configs = [] for target_os in options.os: for mode in options.mode: for arch in options.arch: for sanitizer in options.sanitizer: configs.append( BuildOneConfig(options, targets, target_os, mode, arch, sanitizer)) # Build regular configs. goma_builds = [] for (build_config, args, goma) in configs: if args is None: return 1 if goma: goma_builds.append([env, args]) elif RunOneBuildCommand(build_config, args, env=env) != 0: return 1 # Run goma builds in parallel. active_goma_builds = [] for (env, args) in goma_builds: print(' '.join(args)) process = subprocess.Popen(args, env=env) active_goma_builds.append([args, process]) while active_goma_builds: time.sleep(0.1) for goma_build in active_goma_builds: (args, process) = goma_build if process.poll() is not None: print(' '.join(args) + " done.") active_goma_builds.remove(goma_build) if process.returncode != 0: for (_, to_kill) in active_goma_builds: to_kill.terminate() return 1 endtime = time.time() print("The build took %.3f seconds" % (endtime - starttime)) return 0