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