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 +
28 "O={}".format(self.builddir),
30 ret = subprocess.call(cmd, stdout=self.logfile, stderr=self.logfile)
32 raise SystemError("Cannot olddefconfig")
34 cmd = ["make", "-C", self.builddir]
35 ret = subprocess.call(cmd, stdout=self.logfile, stderr=self.logfile)
37 raise SystemError("Build failed")
39 open(self.stamp_path(), 'a').close()
42 return os.path.join(self.builddir, "build-done")
44 def is_finished(self):
45 return os.path.exists(self.stamp_path())
48 if os.path.exists(self.builddir):
49 shutil.rmtree(self.builddir)