blob: 32f5e3310dea58202566d6ad7389972909d81c8b [file] [log] [blame]
Brad Bishopc342db32019-05-15 21:57:59 -04001#
Brad Bishop6e60e8b2018-02-01 10:27:11 -05002# Copyright (C) 2016 Intel Corporation
Brad Bishopc342db32019-05-15 21:57:59 -04003#
4# SPDX-License-Identifier: MIT
5#
Brad Bishop6e60e8b2018-02-01 10:27:11 -05006
7import os
8import subprocess
9
10from oeqa.utils.buildproject import BuildProject
11
12class SDKBuildProject(BuildProject):
13 def __init__(self, testpath, sdkenv, uri, testlogdir, builddatetime,
14 foldername=None, dl_dir=None):
15 self.sdkenv = sdkenv
16 self.testdir = testpath
17 self.targetdir = testpath
18 os.makedirs(testpath, exist_ok=True)
19 self.datetime = builddatetime
20 self.testlogdir = testlogdir
21 os.makedirs(self.testlogdir, exist_ok=True)
22 self.logfile = os.path.join(self.testlogdir, "sdk_target_log.%s" % self.datetime)
23 BuildProject.__init__(self, uri, foldername, tmpdir=testpath, dl_dir=dl_dir)
24
25 def download_archive(self):
Brad Bishop6e60e8b2018-02-01 10:27:11 -050026 self._download_archive()
27
Brad Bishop1a4b7ee2018-12-16 17:11:34 -080028 cmd = 'tar xf %s -C %s' % (os.path.join(self.targetdir, self.archive), self.targetdir)
Brad Bishop6e60e8b2018-02-01 10:27:11 -050029 subprocess.check_output(cmd, shell=True)
30
31 #Change targetdir to project folder
32 self.targetdir = os.path.join(self.targetdir, self.fname)
33
34 def run_configure(self, configure_args='', extra_cmds=''):
35 return super(SDKBuildProject, self).run_configure(configure_args=(configure_args or '$CONFIGURE_FLAGS'), extra_cmds=extra_cmds)
36
37 def run_install(self, install_args=''):
38 return super(SDKBuildProject, self).run_install(install_args=(install_args or "DESTDIR=%s/../install" % self.targetdir))
39
40 def log(self, msg):
41 if self.logfile:
42 with open(self.logfile, "a") as f:
43 f.write("%s\n" % msg)
44
45 def _run(self, cmd):
46 self.log("Running . %s; " % self.sdkenv + cmd)
Brad Bishop1a4b7ee2018-12-16 17:11:34 -080047 try:
Brad Bishopc342db32019-05-15 21:57:59 -040048 output = subprocess.check_output(". %s; " % self.sdkenv + cmd, shell=True,
49 executable='/bin/bash', stderr=subprocess.STDOUT)
Brad Bishop1a4b7ee2018-12-16 17:11:34 -080050 except subprocess.CalledProcessError as exc:
51 print(exc.output.decode('utf-8'))
52 return exc.returncode
53 return 0