blob: 4e251142d7ca42aa68e44c42b8131763563e9699 [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):
23
24 self._download_archive()
25
26 cmd = 'tar xf %s%s -C %s' % (self.targetdir, self.archive, self.targetdir)
27 subprocess.check_output(cmd, shell=True)
28
29 #Change targetdir to project folder
30 self.targetdir = os.path.join(self.targetdir, self.fname)
31
32 def run_configure(self, configure_args='', extra_cmds=''):
33 return super(SDKBuildProject, self).run_configure(configure_args=(configure_args or '$CONFIGURE_FLAGS'), extra_cmds=extra_cmds)
34
35 def run_install(self, install_args=''):
36 return super(SDKBuildProject, self).run_install(install_args=(install_args or "DESTDIR=%s/../install" % self.targetdir))
37
38 def log(self, msg):
39 if self.logfile:
40 with open(self.logfile, "a") as f:
41 f.write("%s\n" % msg)
42
43 def _run(self, cmd):
44 self.log("Running . %s; " % self.sdkenv + cmd)
45 return subprocess.call(". %s; " % self.sdkenv + cmd, shell=True)