blob: aa6541c6f6d694bdf139e5e596e7fdc1095d890a [file] [log] [blame]
Brad Bishopc342db32019-05-15 21:57:59 -04001#
Patrick Williams92b42cb2022-09-03 06:53:57 -05002# Copyright OpenEmbedded Contributors
3#
Brad Bishopc342db32019-05-15 21:57:59 -04004# SPDX-License-Identifier: MIT
5#
6
Brad Bishop19323692019-04-05 15:28:33 -04007import os
8import subprocess
9import tempfile
10import unittest
Brad Bishop1a4b7ee2018-12-16 17:11:34 -080011from oeqa.sdk.case import OESDKTestCase
12
13from oeqa.utils.subprocesstweak import errors_have_output
14errors_have_output()
15
16class BuildAssimp(OESDKTestCase):
17 """
18 Test case to build a project using cmake.
19 """
20
Brad Bishop19323692019-04-05 15:28:33 -040021 def setUp(self):
Brad Bishop1a4b7ee2018-12-16 17:11:34 -080022 if not (self.tc.hasHostPackage("nativesdk-cmake") or
23 self.tc.hasHostPackage("cmake-native")):
24 raise unittest.SkipTest("Needs cmake")
25
Brad Bishop1a4b7ee2018-12-16 17:11:34 -080026 def test_assimp(self):
Brad Bishop1a4b7ee2018-12-16 17:11:34 -080027 with tempfile.TemporaryDirectory(prefix="assimp", dir=self.tc.sdk_dir) as testdir:
Brad Bishop19323692019-04-05 15:28:33 -040028 tarball = self.fetch(testdir, self.td["DL_DIR"], "https://github.com/assimp/assimp/archive/v4.1.0.tar.gz")
29
30 dirs = {}
31 dirs["source"] = os.path.join(testdir, "assimp-4.1.0")
32 dirs["build"] = os.path.join(testdir, "build")
33 dirs["install"] = os.path.join(testdir, "install")
34
Andrew Geisslerc9f78652020-09-18 14:11:35 -050035 subprocess.check_output(["tar", "xf", tarball, "-C", testdir], stderr=subprocess.STDOUT)
Brad Bishop19323692019-04-05 15:28:33 -040036 self.assertTrue(os.path.isdir(dirs["source"]))
37 os.makedirs(dirs["build"])
Brad Bishop1a4b7ee2018-12-16 17:11:34 -080038
Brad Bishop19323692019-04-05 15:28:33 -040039 self._run("cd {build} && cmake -DCMAKE_VERBOSE_MAKEFILE:BOOL=ON {source}".format(**dirs))
40 self._run("cmake --build {build} -- -j".format(**dirs))
41 self._run("cmake --build {build} --target install -- DESTDIR={install}".format(**dirs))
42 self.check_elf(os.path.join(dirs["install"], "usr", "local", "lib", "libassimp.so.4.1.0"))