9 def __init__(self, config, builddir, logtofile):
10 self.config = '\n'.join([line.lstrip() for line in
11 config.splitlines()]) + '\n'
12 self.builddir = builddir
13 self.logfile = infra.open_log_file(builddir, "build", logtofile)
16 if not os.path.isdir(self.builddir):
17 os.makedirs(self.builddir)
19 config_file = os.path.join(self.builddir, ".config")
20 with open(config_file, "w+") as cf:
22 # dump the defconfig to the logfile for easy debugging
23 self.logfile.write("> start defconfig\n" + self.config +
27 env = {"PATH": os.environ["PATH"]}
29 "O={}".format(self.builddir),
31 ret = subprocess.call(cmd, stdout=self.logfile, stderr=self.logfile,
34 raise SystemError("Cannot olddefconfig")
36 cmd = ["make", "-C", self.builddir]
37 ret = subprocess.call(cmd, stdout=self.logfile, stderr=self.logfile,
40 raise SystemError("Build failed")
42 open(self.stamp_path(), 'a').close()
45 return os.path.join(self.builddir, "build-done")
47 def is_finished(self):
48 return os.path.exists(self.stamp_path())
51 if os.path.exists(self.builddir):
52 shutil.rmtree(self.builddir)