*/*: [QA] Fix trivial cases of MissingTestRestrict
[gentoo.git] / sci-libs / dmlc-core / dmlc-core-0_p20170719.ebuild
1 # Copyright 1999-2019 Gentoo Authors
2 # Distributed under the terms of the GNU General Public License v2
3
4 EAPI=6
5
6 inherit toolchain-funcs cmake-utils
7
8 DESCRIPTION="Common bricks library for building distributed machine learning."
9 HOMEPAGE="https://github.com/dmlc/dmlc-core"
10
11 if [[ ${PV} == *9999* ]] ; then
12         EGIT_REPO_URI="https://github.com/dmlc/${PN}.git"
13         inherit git-r3
14         KEYWORDS=""
15 else
16         EGIT_COMMIT="54db57d5d1b2a7b93319053011802888b827a539"
17         inherit vcs-snapshot
18         KEYWORDS="~amd64 ~x86 ~amd64-linux ~x86-linux"
19         SRC_URI="${HOMEPAGE}/archive/${EGIT_COMMIT}.tar.gz -> ${P}.tar.gz"
20 fi
21
22 LICENSE="Apache-2.0"
23 SLOT="0"
24
25 # hdfs needs big java hdfs not yet in portage
26 # azure not yet in portage
27 IUSE="doc openmp s3 test"
28 RESTRICT="!test? ( test )"
29
30 RDEPEND="net-misc/curl[ssl]"
31 DEPEND="${RDEPEND}
32         doc? ( app-doc/doxygen )
33         test? ( dev-cpp/gtest )
34 "
35
36 PATCHES=( "${FILESDIR}"/${PN}-install-dirs.patch )
37
38 pkg_pretend() {
39         [[ ${MERGE_TYPE} != binary ]] && use openmp && tc-check-openmp
40 }
41
42 pkg_setup() {
43         [[ ${MERGE_TYPE} != binary ]] && use openmp && tc-check-openmp
44 }
45
46 src_prepare() {
47         cmake-utils_src_prepare
48         # respect user flags (SSE2 does nothing more than adding -msse2)
49         # also doc install everything so remove
50         sed -e '/-O3/d' \
51                 -e '/check_cxx.*SSE2/d' \
52                 -i CMakeLists.txt || die
53         # all these hacks below to allow testing
54         sed -e 's|-O3||' -e 's|-lm|-lm -L$(LD_LIBRARY_PATH) -ldmlc|g' -i Makefile || die
55         sed -e "s|libdmlc.a||g" \
56                 -i test/dmlc_test.mk test/unittest/dmlc_unittest.mk || die
57         cat <<-EOF > config.mk
58                 USE_SSE=0
59                 WITH_FPIC=1
60                 USE_OPENMP=$(use openmp && echo 1 || echo 0)
61                 USE_S3=$(use s3 && echo 1 || echo 0)
62                 BUILD_TEST=$(use test && echo 1 || echo 0)
63                 DMLC_CFLAGS=${CXXFLAGS}
64                 DMLC_LDFLAGS=${LDFLAGS}
65         EOF
66 }
67
68 src_configure() {
69         local mycmakeargs=(
70                 -DBUILD_SHARED_LIBS=ON
71                 -DUSE_S3="$(usex s3)"
72                 -DUSE_OPENMP="$(usex openmp)"
73         )
74         cmake-utils_src_configure
75 }
76
77 src_compile() {
78         cmake-utils_src_compile
79         if use doc; then
80                 doxygen doc/Doxyfile || die
81         fi
82 }
83
84 src_test() {
85         tc-export CXX
86         export LD_LIBRARY_PATH="${BUILD_DIR}"
87         emake test
88         test/unittest/dmlc_unittest || die
89 }
90
91 src_install() {
92         cmake-utils_src_install
93         if use doc; then
94                 insinto /usr/share/doc/${PF}
95                 doins -r doc/doxygen/html
96                 docompress -x /usr/share/doc/${PF}/html
97         fi
98 }