Skip to content

Commit

Permalink
media-libs/assimp: add 5.2.5-r2, add 5.3.1
Browse files Browse the repository at this point in the history
Rework tests to make use of gtest via ctest.
Some tests generate random input data which might fail on fma-enabled CPUs due to smaller rounding errors on fused operations, so we repeat those
tests until they succeed.

Closes: https://bugs.gentoo.org/908403
Closes: https://bugs.gentoo.org/910362
Signed-off-by: Paul Zander <negril.nx+gentoo@gmail.com>
  • Loading branch information
negril committed Dec 29, 2023
1 parent b3cd406 commit 16d6e70
Show file tree
Hide file tree
Showing 4 changed files with 248 additions and 0 deletions.
1 change: 1 addition & 0 deletions media-libs/assimp/Manifest
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
DIST assimp-5.2.5.tar.gz 49543936 BLAKE2B 77e0eecd1307646211a86244a371e24401dffd03dceb569acdd63751cdb38bd169c8b12c942efd2e77b5f541653f2775739150b9fe352b8c903dcc4fe7bccca8 SHA512 ac0dc4243f9d1ff077966f0037187b4374075ac97e75e1a3cd6bdc1caf5f8e4d40953d9a8a316480969c09524d87daa9d3ed75e6ac6f037dd5b1c5f25fce3afb
DIST assimp-5.3.1.tar.gz 52826870 BLAKE2B 1f3eac17deb6d19777f2a7cdf74e5be9d6df12a70e9b0449a90f3cc6f85b6d4170de2b870c028e2ad9c7f6ac7269daa0cbb3971dd1feb83a5b12a683ff8bb72f SHA512 49963f84ed0a8145f3af249890a533f0b12f5553ae09581289cb1f20cb49cb1a3ed3f3c4c966ceb43aa897b90deca268aa6554066b2bd34f2ac9c15041420ddb
93 changes: 93 additions & 0 deletions media-libs/assimp/assimp-5.2.5-r2.ebuild
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
# Copyright 1999-2023 Gentoo Authors
# Distributed under the terms of the GNU General Public License v2

EAPI=8

inherit cmake

DESCRIPTION="Importer library to import assets from 3D files"
HOMEPAGE="https://github.com/assimp/assimp"
SRC_URI="https://github.com/${PN}/${PN}/archive/v${PV}.tar.gz -> ${P}.tar.gz"

LICENSE="BSD"
SLOT="0/${PV}"
KEYWORDS="~amd64 ~arm ~arm64 ~ppc ~ppc64 ~riscv ~x86"
IUSE="samples test"

RESTRICT="!test? ( test )"

RDEPEND="
sys-libs/zlib[minizip]
samples? (
media-libs/freeglut
media-libs/libglvnd
)
test? (
dev-cpp/gtest
)
"
DEPEND="${RDEPEND}"

PATCHES=(
"${FILESDIR}/${PN}-5.2.5-gtest.patch"
)

DOCS=( CodeConventions.md Readme.md )

src_prepare() {
sed -r \
-e "s#PROJECT\(Assimp VERSION [0-9]+\.[0-9]+\.[0-9]+\)#PROJECT(Assimp VERSION ${PV})#g" \
-i CMakeLists.txt || die
sed -r \
-e "s#EXPECT_EQ\(aiGetVersionPatch\(\), [0-9]+U \);#EXPECT_EQ(aiGetVersionPatch(), $(ver_cut 3)U );#g" \
-e "s#EXPECT_NE\( aiGetVersionRevision#EXPECT_EQ\( aiGetVersionRevision#g" \
-i test/unit/utVersion.cpp || die
sed \
-e "s# -O0 -g # #g" \
-i \
cmake-modules/Coveralls.cmake \
contrib/android-cmake/android.toolchain.cmake \
contrib/openddlparser/CMakeLists.txt \
CMakeLists.txt \
|| die

cmake_src_prepare
}

src_configure() {
local mycmakeargs=(
-DASSIMP_ASAN=OFF
-DASSIMP_BUILD_ASSIMP_TOOLS=ON
-DASSIMP_BUILD_DOCS=OFF
-DASSIMP_BUILD_SAMPLES=$(usex samples)
-DASSIMP_BUILD_TESTS=$(usex test)
-DASSIMP_BUILD_ZLIB=OFF
-DASSIMP_DOUBLE_PRECISION=OFF
-DASSIMP_INJECT_DEBUG_POSTFIX=OFF
-DASSIMP_IGNORE_GIT_HASH=ON
-DASSIMP_UBSAN=OFF
-DASSIMP_WARNINGS_AS_ERRORS=OFF
# bug #891787 (CVE-2022-45748), intentionally not in alphabetic ordering
-DASSIMP_BUILD_COLLADA_IMPORTER=OFF
-DASSIMP_BUILD_COLLADA_EXPORTER=OFF
)

if use samples; then
mycmakeargs+=( -DOpenGL_GL_PREFERENCE="GLVND" )
fi

cmake_src_configure
}

src_test() {
local CMAKE_SKIP_TESTS=(
# ( Failed )
"^utCollada.*"
"^utIssues.OpacityBugWhenExporting_727$"
)
myctestargs=(
--repeat until-pass:100
)

cmake_src_test
}
124 changes: 124 additions & 0 deletions media-libs/assimp/assimp-5.3.1.ebuild
Original file line number Diff line number Diff line change
@@ -0,0 +1,124 @@
# Copyright 1999-2023 Gentoo Authors
# Distributed under the terms of the GNU General Public License v2

EAPI=8

inherit cmake

DESCRIPTION="Importer library to import assets from 3D files"
HOMEPAGE="https://github.com/assimp/assimp"
SRC_URI="https://github.com/${PN}/${PN}/archive/v${PV}.tar.gz -> ${P}.tar.gz"

LICENSE="BSD"
SLOT="0/${PV}"
KEYWORDS="~amd64 ~arm ~arm64 ~ppc ~ppc64 ~riscv ~x86"
IUSE="doc samples test"

RESTRICT="!test? ( test )"

RDEPEND="
sys-libs/zlib[minizip]
doc? ( app-doc/doxygen )
samples? (
media-libs/freeglut
media-libs/libglvnd
)
test? (
dev-cpp/gtest
)
"
DEPEND="${RDEPEND}"

PATCHES=(
"${FILESDIR}/${PN}-5.2.5-gtest.patch"
)

DOCS=( CodeConventions.md Readme.md )

src_prepare() {
sed -r \
-e "s#PROJECT\(Assimp VERSION [0-9]+\.[0-9]+\.[0-9]+\)#PROJECT(Assimp VERSION ${PV})#g" \
-i CMakeLists.txt || die
sed -r \
-e "s#EXPECT_EQ\(aiGetVersionPatch\(\), [0-9]+U \);#EXPECT_EQ(aiGetVersionPatch(), $(ver_cut 3)U );#g" \
-e "s#EXPECT_NE\( aiGetVersionRevision#EXPECT_EQ\( aiGetVersionRevision#g" \
-i test/unit/utVersion.cpp || die
sed \
-e "s# -g -O0 # #g" \
-i \
cmake-modules/Coveralls.cmake \
contrib/android-cmake/android.toolchain.cmake \
contrib/openddlparser/CMakeLists.txt \
CMakeLists.txt \
|| die
sed -r \
-e "s#(PROJECT_NUMBER *= \").*\"#\1v${PV}\"#g" \
-e "s#(GENERATE_XML *= )(YES|NO)#\1NO#g" \
-e "s#(GENERATE_HTML *= )(YES|NO)#\1YES#g" \
-i doc/Doxyfile.in || die
sed -r \
-e "s#AssimpDoc_Html(/AnimationOverview)#architecture\1#g" \
-e "s#AssimpDoc_Html(/dragonsplash)#images\1#g" \
-i doc/CMakeLists.txt || die

cmake_src_prepare
}

src_configure() {
local mycmakeargs=(
# -DASSIMP_ASAN=yes # Enable AddressSanitizer.
-DASSIMP_BUILD_ASSIMP_TOOLS=yes # If the supplementary tools for Assimp are built in addition to the library.
-DASSIMP_BUILD_DOCS=$(usex doc) # Build documentation using Doxygen.
# -DASSIMP_BUILD_DRACO=no # If the Draco libraries are to be built. Primarily for glTF
# -DASSIMP_BUILD_NONFREE_C4D_IMPORTER=no # Build the C4D importer, which relies on the non-free Cineware SDK.
-DASSIMP_BUILD_SAMPLES=$(usex samples) # If the official samples are built as well (needs Glut).
-DASSIMP_BUILD_TESTS=$(usex test) # If the test suite for Assimp is built in addition to the library.
-DASSIMP_BUILD_ZLIB=no # Build your own zlib
-DASSIMP_COVERALLS=$(usex test) # Enable this to measure test coverage.
# breaks tests
# -DASSIMP_DOUBLE_PRECISION=no # Set to yes to enable double precision processing
# -DASSIMP_HUNTER_ENABLED=no # Enable Hunter package manager support
-DASSIMP_IGNORE_GIT_HASH=yes # Don't call git to get the hash.
-DASSIMP_INJECT_DEBUG_POSTFIX=no # Inject debug postfix in .a/.so/.dll lib names
# -DASSIMP_INSTALL=yes # Disable this if you want to use assimp as a submodule.
# -DASSIMP_LIBRARY_SUFFIX= # Suffix to append to library names
# -DASSIMP_NO_EXPORT=no # Disable Assimp's export functionality.
# -DASSIMP_OPT_BUILD_PACKAGES=no # Set to yes to generate CPack configuration files and packaging targets
-DASSIMP_RAPIDJSON_NO_MEMBER_ITERATOR=no # Suppress rapidjson warning on MSVC (NOTE: breaks android build)
# -DASSIMP_UBSAN=yes # Enable Undefined Behavior sanitizer.
-DASSIMP_WARNINGS_AS_ERRORS=no # Treat all warnings as errors.
# -DBUILD_SHARED_LIBS=yes # Build package with shared libraries.
# bug #891787 (CVE-2022-45748), intentionally not in alphabetic ordering
-DASSIMP_BUILD_COLLADA_IMPORTER=OFF
-DASSIMP_BUILD_COLLADA_EXPORTER=OFF
)

if use doc; then
mycmakeargs+=(
-DHTML_OUTPUT="html"
)
fi
if use samples; then
mycmakeargs+=(
-DOpenGL_GL_PREFERENCE="GLVND"
)
fi
if use test; then
# adds the target headercheck which compiles every header file, default disabled because it adds many targets
-DASSIMP_HEADERCHECK=$(usex test)
fi

cmake_src_configure
}

src_test() {
local CMAKE_SKIP_TESTS=(
# ( Failed )
"^utCollada.*"
"^utIssues.OpacityBugWhenExporting_727$"
)
myctestargs=(
--repeat until-pass:100
)
cmake_src_test
}
30 changes: 30 additions & 0 deletions media-libs/assimp/files/assimp-5.2.5-gtest.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt
index afe4874..5a87cc2 100644
--- a/test/CMakeLists.txt
+++ b/test/CMakeLists.txt
@@ -191,7 +191,6 @@ SET( POST_PROCESSES
unit/utRemoveComments.cpp
unit/utRemoveComponent.cpp
unit/utVertexTriangleAdjacency.cpp
- unit/utJoinVertices.cpp
unit/utSplitLargeMeshes.cpp
unit/utFindDegenerates.cpp
unit/utFindInvalidData.cpp
@@ -281,4 +281,6 @@ target_link_libraries( unit assimp ${platform_libs} )

add_subdirectory(headercheck)

-add_test( unittests unit )
+get_target_property(unit_SOURCES unit SOURCES)
+find_package(GTest REQUIRED)
+gtest_add_tests(TARGET unit ${unit_SOURCES})
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -725,6 +725,7 @@ IF ( ASSIMP_BUILD_SAMPLES )
ENDIF ()

IF ( ASSIMP_BUILD_TESTS )
+ enable_testing()
ADD_SUBDIRECTORY( test/ )
ENDIF ()

0 comments on commit 16d6e70

Please sign in to comment.