def docmderrout(cmd, outfile): """Execute a command to an output file capturing stderr.""" if flag_echo: sys.stderr.write("executing: " + cmd + "\n") if flag_dryrun: return u.docmderrout(cmd, outfile)
def docmderrout(cmd, outfile): """Execute a command.""" if flag_echo: sys.stderr.write("executing: " + cmd + "\n") if flag_dryrun: return u.docmderrout(cmd, outfile)
def perform_build(abuild): """Run a single specified build.""" u.verbose(1, "running build: %s" % abuild) lunched_env = simulate_lunch(abuild) outfile = "build-err.%s.txt" % abuild cbf = "-t" if flag_checkbuild: cbf = "-T" if flag_mmma_target: bcmd = "mmm.py -k -j %d -a %s" % (flag_parfactor, flag_mmma_target) else: bcmd = "mmm.py -k -j %d %s" % (flag_parfactor, cbf) if flag_dryrun: bcmd = "echo %s" % bcmd rc = 0 if flag_do_build: u.verbose(1, "kicking off build cmd %s for %s" % (bcmd, abuild)) rc = u.docmderrout(bcmd, outfile, nf=True) result = "PASS" if rc != 0: result = "FAIL" u.verbose(0, "result for build '%s': %s" % (abuild, result)) if rc != 0: u.verbose(0, ">> build log for failure: %s" % outfile) # Collect dwarf info summarize_dwarf(abuild) else: u.verbose(1, "not performing build (stubbed out)") if flag_do_clean: apo = os.environ["ANDROID_PRODUCT_OUT"] if not apo: u.error("internal error -- no ANDROID_PRODUCT_OUT env setting") u.verbose(1, "cleaning %s" % apo) if not flag_dryrun: shutil.rmtree(apo, ignore_errors=True) else: u.verbose(0, "rm -rf %s" % apo) else: u.verbose(1, "not performing post-build clean") # flash if rc == 0 and flag_do_flash: serial = perform_flash(abuild) if serial and flag_do_flashverify: perform_verify(abuild, serial) # restore env load_environment(lunched_env, saved_env) return rc
def undolink(link): """Undo a symbolic link.""" try: _ = os.readlink(link) except OSError as ose: u.warning("warning: %s not a link (%s), " "skipping" % (link, ose)) return docmd("rm %s" % link) # Hack: sometimes gofrontend can get ahead of gcc trunk, in which case # we may try to check out something that does not exist. Check for this # case and work around it. # rev = "HEAD~1" rev = "HEAD" st = u.docmderrout("git show %s:%s" % (rev, link), "/dev/null", True) if st != 0: u.warning("skipping %s, does not exist in trunk yet" % link) else: docmd("git checkout %s" % link)
def undolink(link): """Undo a symbolic link.""" try: _ = os.readlink(link) except OSError as ose: u.warning("warning: %s not a link (%s), " "skipping" % (link, ose)) return docmd("rm %s" % link) # Hack: sometimes gofrontend can get ahead of gcc trunk, in which case # we may try to check out something that does not exist. Check for this # case and work around it. # rev = "HEAD~1" rev = "HEAD" st = u.docmderrout("git show %s:%s" % (rev, link), "/dev/null", True) if st != 0: u.warning("skipping %s, does not exist in trunk yet" % link) else: docmd("git checkout %s" % link)
def dotestaction(action, githash, outf, idx, summaryf): """Perform a test action, writing results to outf.""" global num_failures u.verbose(0, "starting %s run for %s" % (action, githash)) tf = tempfile.NamedTemporaryFile(mode="w", delete=True) status = u.docmderrout(action, tf.name, True) if status != 0: u.verbose(0, "warning: '%s' run failed for commit %s" % (action, githash)) summaryf.write("%d: failed action: %s\n" % (idx, action)) num_failures += 1 try: with open(tf.name, "r") as rf: lines = rf.readlines() for line in lines: outf.write(line) u.verbose( 1, "wrote %d test output lines to %s" % (len(lines), outf.name)) except IOError: u.error("open failed for %s temp output %s" % (action, tf.name))
def setup_gccgo_gdb(): """Set up for gccgo debugging.""" if not gccgo_location: u.warning("failed to locate gccgo compilation " "of %s" % flag_gccgo_gdb) return outfile = ".gccgo.err.txt" here = os.getcwd() gloc = gccgo_location if here != gloc: u.warning("gccgo compile takes place in %s, " "not here (%s)" % (gccgo_location, here)) regloc = re.compile(r"\$WORK/(\S+)$") m = regloc.match(gccgo_location) if m: if flag_relocate: gloc = os.path.join(flag_relocate, m.group(1)) else: gloc = os.path.join(workdir, m.group(1)) u.verbose(1, "revised gloc dir is %s" % gloc) os.chdir(gloc) driver = gccgo_invocation[0] args = gccgo_invocation[1:] for idx in range(0, len(args)): if args[idx] == "$WORK": if flag_relocate: args[idx] = flag_relocate else: args[idx] = workdir cmd = ("%s -v %s" % (driver, " ".join(args))) u.verbose(1, "in %s, executing gdb setup cmd: %s" % (os.getcwd(), cmd)) rc = u.docmderrout(cmd, outfile, True) if rc != 0: u.warning("cmd failed: %s" % cmd) try: inf = open(outfile, "rb") except IOError as e: u.error("internal error: unable to consume tmp " "file %s? error %s" % (outfile, e.strerror)) lines = inf.readlines() inf.close() found = False reg1 = re.compile(r"^\s*(\S+/go1)\s+(\S.+)$") for line in lines: u.verbose(2, "gccgo -v line is %s" % line.strip()) m = reg1.match(line) if m: go1exe = m.group(1) u.verbose(1, "go1 driver is %s" % go1exe) go1args = m.group(2) u.verbose(1, "go1 args: %s" % go1args) # Create symlink if not os.path.exists("go1"): u.verbose(0, "symlinking to %s" % go1exe) os.symlink(go1exe, "go1") # Dump args u.verbose(0, "writing args to .gdbinit") try: outf = open(".gdbinit", "w") except IOError as e: u.error("unable to open %s: " "%s" % (".gdbinit", e.strerror)) outf.write("# gud-gdb --fullname ./go1\n") outf.write("set args %s" % go1args) outf.close() u.verbose(0, "starting emacs") subprocess.Popen(["emacs", ".gdbinit"]) return if not found: u.error("unable to locate go1 invocation in gccgo -v output") os.chdir(here)