mirror of
https://github.com/godotengine/buildroot.git
synced 2026-01-05 14:09:53 +03:00
Move the strip out of leading spaces in defconfig fragments from the BRTest class to the Builder class. It actually postpones the strip out, consequentially allowing test cases to post-process the defconfig in their own __init__ before calling the __init__ method from BRTest. Moving this code to the Builder class also allows any new test class that inherits from BRTest to reuse the same code even if the new class overrides the setUp method. At same time, prepend a newline to the jlevel handling otherwise it would stop working for defconfig fragments that don't end in a newline. Signed-off-by: Ricardo Martincoski <ricardo.martincoski@gmail.com> Cc: Yann E. MORIN <yann.morin.1998@free.fr> Signed-off-by: Arnout Vandecappelle (Essensium/Mind) <arnout@mind.be>
49 lines
1.5 KiB
Python
49 lines
1.5 KiB
Python
import os
|
|
import shutil
|
|
import subprocess
|
|
|
|
import infra
|
|
|
|
class Builder(object):
|
|
def __init__(self, config, builddir, logtofile):
|
|
self.config = '\n'.join([line.lstrip() for line in
|
|
config.splitlines()]) + '\n'
|
|
self.builddir = builddir
|
|
self.logfile = infra.open_log_file(builddir, "build", logtofile)
|
|
|
|
def build(self):
|
|
if not os.path.isdir(self.builddir):
|
|
os.makedirs(self.builddir)
|
|
|
|
config_file = os.path.join(self.builddir, ".config")
|
|
with open(config_file, "w+") as cf:
|
|
cf.write(self.config)
|
|
# dump the defconfig to the logfile for easy debugging
|
|
self.logfile.write("> start defconfig\n" + self.config +
|
|
"> end defconfig\n")
|
|
self.logfile.flush()
|
|
|
|
cmd = ["make",
|
|
"O={}".format(self.builddir),
|
|
"olddefconfig"]
|
|
ret = subprocess.call(cmd, stdout=self.logfile, stderr=self.logfile)
|
|
if ret != 0:
|
|
raise SystemError("Cannot olddefconfig")
|
|
|
|
cmd = ["make", "-C", self.builddir]
|
|
ret = subprocess.call(cmd, stdout=self.logfile, stderr=self.logfile)
|
|
if ret != 0:
|
|
raise SystemError("Build failed")
|
|
|
|
open(self.stamp_path(), 'a').close()
|
|
|
|
def stamp_path(self):
|
|
return os.path.join(self.builddir, "build-done")
|
|
|
|
def is_finished(self):
|
|
return os.path.exists(self.stamp_path())
|
|
|
|
def delete(self):
|
|
if os.path.exists(self.builddir):
|
|
shutil.rmtree(self.builddir)
|