Brad Bishop | c342db3 | 2019-05-15 21:57:59 -0400 | [diff] [blame] | 1 | # |
Patrick Williams | 92b42cb | 2022-09-03 06:53:57 -0500 | [diff] [blame] | 2 | # Copyright OpenEmbedded Contributors |
| 3 | # |
Brad Bishop | c342db3 | 2019-05-15 21:57:59 -0400 | [diff] [blame] | 4 | # SPDX-License-Identifier: MIT |
| 5 | # |
| 6 | |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 7 | import os |
| 8 | import subprocess |
| 9 | import tempfile |
| 10 | import unittest |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 11 | from oeqa.sdk.case import OESDKTestCase |
| 12 | |
| 13 | from oeqa.utils.subprocesstweak import errors_have_output |
| 14 | errors_have_output() |
| 15 | |
| 16 | class BuildAssimp(OESDKTestCase): |
| 17 | """ |
| 18 | Test case to build a project using cmake. |
| 19 | """ |
| 20 | |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 21 | def setUp(self): |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 22 | if not (self.tc.hasHostPackage("nativesdk-cmake") or |
| 23 | self.tc.hasHostPackage("cmake-native")): |
| 24 | raise unittest.SkipTest("Needs cmake") |
| 25 | |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 26 | def test_assimp(self): |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 27 | with tempfile.TemporaryDirectory(prefix="assimp", dir=self.tc.sdk_dir) as testdir: |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 28 | 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 Geissler | c9f7865 | 2020-09-18 14:11:35 -0500 | [diff] [blame] | 35 | subprocess.check_output(["tar", "xf", tarball, "-C", testdir], stderr=subprocess.STDOUT) |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 36 | self.assertTrue(os.path.isdir(dirs["source"])) |
| 37 | os.makedirs(dirs["build"]) |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 38 | |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 39 | 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")) |