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