blob: 6fed73e35051cd18e239367787d72ada53d17e94 [file] [log] [blame]
Brad Bishop6e60e8b2018-02-01 10:27:11 -05001# Copyright (C) 2016 Intel Corporation
2# Released under the MIT license (see COPYING.MIT)
3
4import os
5import subprocess
6
7from oeqa.utils.buildproject import BuildProject
8
9class SDKBuildProject(BuildProject):
10 def __init__(self, testpath, sdkenv, uri, testlogdir, builddatetime,
11 foldername=None, dl_dir=None):
12 self.sdkenv = sdkenv
13 self.testdir = testpath
14 self.targetdir = testpath
15 os.makedirs(testpath, exist_ok=True)
16 self.datetime = builddatetime
17 self.testlogdir = testlogdir
18 os.makedirs(self.testlogdir, exist_ok=True)
19 self.logfile = os.path.join(self.testlogdir, "sdk_target_log.%s" % self.datetime)
20 BuildProject.__init__(self, uri, foldername, tmpdir=testpath, dl_dir=dl_dir)
21
22 def download_archive(self):
Brad Bishop6e60e8b2018-02-01 10:27:11 -050023 self._download_archive()
24
Brad Bishop1a4b7ee2018-12-16 17:11:34 -080025 cmd = 'tar xf %s -C %s' % (os.path.join(self.targetdir, self.archive), self.targetdir)
Brad Bishop6e60e8b2018-02-01 10:27:11 -050026 subprocess.check_output(cmd, shell=True)
27
28 #Change targetdir to project folder
29 self.targetdir = os.path.join(self.targetdir, self.fname)
30
31 def run_configure(self, configure_args='', extra_cmds=''):
32 return super(SDKBuildProject, self).run_configure(configure_args=(configure_args or '$CONFIGURE_FLAGS'), extra_cmds=extra_cmds)
33
34 def run_install(self, install_args=''):
35 return super(SDKBuildProject, self).run_install(install_args=(install_args or "DESTDIR=%s/../install" % self.targetdir))
36
37 def log(self, msg):
38 if self.logfile:
39 with open(self.logfile, "a") as f:
40 f.write("%s\n" % msg)
41
42 def _run(self, cmd):
43 self.log("Running . %s; " % self.sdkenv + cmd)
Brad Bishop1a4b7ee2018-12-16 17:11:34 -080044 try:
45 output = subprocess.check_output(". %s; " % self.sdkenv + cmd, shell=True, stderr=subprocess.STDOUT)
46 except subprocess.CalledProcessError as exc:
47 print(exc.output.decode('utf-8'))
48 return exc.returncode
49 return 0