1#
2# SPDX-License-Identifier: MIT
3#
4
5import os
6import subprocess
7import tempfile
8import unittest
9from oeqa.sdk.case import OESDKTestCase
10
11from oeqa.utils.subprocesstweak import errors_have_output
12errors_have_output()
13
14class BuildAssimp(OESDKTestCase):
15    """
16    Test case to build a project using cmake.
17    """
18
19    def setUp(self):
20        if not (self.tc.hasHostPackage("nativesdk-cmake") or
21                self.tc.hasHostPackage("cmake-native")):
22            raise unittest.SkipTest("Needs cmake")
23
24    def test_assimp(self):
25        with tempfile.TemporaryDirectory(prefix="assimp", dir=self.tc.sdk_dir) as testdir:
26            tarball = self.fetch(testdir, self.td["DL_DIR"], "https://github.com/assimp/assimp/archive/v4.1.0.tar.gz")
27
28            dirs = {}
29            dirs["source"] = os.path.join(testdir, "assimp-4.1.0")
30            dirs["build"] = os.path.join(testdir, "build")
31            dirs["install"] = os.path.join(testdir, "install")
32
33            subprocess.check_output(["tar", "xf", tarball, "-C", testdir])
34            self.assertTrue(os.path.isdir(dirs["source"]))
35            os.makedirs(dirs["build"])
36
37            self._run("cd {build} && cmake -DCMAKE_VERBOSE_MAKEFILE:BOOL=ON {source}".format(**dirs))
38            self._run("cmake --build {build} -- -j".format(**dirs))
39            self._run("cmake --build {build} --target install -- DESTDIR={install}".format(**dirs))
40            self.check_elf(os.path.join(dirs["install"], "usr", "local", "lib", "libassimp.so.4.1.0"))
41