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: |
Patrick Williams | 73bd93f | 2024-02-20 08:07:48 -0600 | [diff] [blame^] | 28 | tarball = self.fetch(testdir, self.td["DL_DIR"], "https://github.com/assimp/assimp/archive/v5.3.1.tar.gz") |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 29 | |
| 30 | dirs = {} |
Patrick Williams | 73bd93f | 2024-02-20 08:07:48 -0600 | [diff] [blame^] | 31 | dirs["source"] = os.path.join(testdir, "assimp-5.3.1") |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 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"])) |
Patrick Williams | 73bd93f | 2024-02-20 08:07:48 -0600 | [diff] [blame^] | 37 | # Apply the zlib patch https://github.com/madler/zlib/commit/a566e156b3fa07b566ddbf6801b517a9dba04fa3 |
| 38 | # this sed wont be needed once assimp moves its zlib copy to v1.3.1+ |
| 39 | self._run("sed -i '/# ifdef _FILE_OFFSET_BITS/I,+2 d' {source}/contrib/zlib/gzguts.h".format(**dirs)) |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 40 | os.makedirs(dirs["build"]) |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 41 | |
Patrick Williams | 73bd93f | 2024-02-20 08:07:48 -0600 | [diff] [blame^] | 42 | self._run("cd {build} && cmake -DCMAKE_VERBOSE_MAKEFILE:BOOL=ON -DASSIMP_BUILD_ZLIB=ON {source}".format(**dirs)) |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 43 | self._run("cmake --build {build} -- -j".format(**dirs)) |
| 44 | self._run("cmake --build {build} --target install -- DESTDIR={install}".format(**dirs)) |
Patrick Williams | 73bd93f | 2024-02-20 08:07:48 -0600 | [diff] [blame^] | 45 | self.check_elf(os.path.join(dirs["install"], "usr", "local", "lib", "libassimp.so.5.3.0")) |