dev-ml/llvm-ocaml: Remove broken VE target from 10.0.0rc2
[gentoo.git] / dev-ml / llvm-ocaml / llvm-ocaml-10.0.0_rc2.ebuild
1 # Copyright 1999-2020 Gentoo Authors
2 # Distributed under the terms of the GNU General Public License v2
3
4 EAPI=7
5
6 PYTHON_COMPAT=( python3_{6,7,8} )
7 inherit cmake-utils llvm llvm.org multiprocessing python-any-r1
8
9 DESCRIPTION="OCaml bindings for LLVM"
10 HOMEPAGE="https://llvm.org/"
11 LLVM_COMPONENTS=( llvm )
12 llvm.org_set_globals
13
14 # Keep in sync with sys-devel/llvm
15 ALL_LLVM_EXPERIMENTAL_TARGETS=( ARC AVR )
16 ALL_LLVM_TARGETS=( AArch64 AMDGPU ARM BPF Hexagon Lanai Mips MSP430
17         NVPTX PowerPC RISCV Sparc SystemZ WebAssembly X86 XCore
18         "${ALL_LLVM_EXPERIMENTAL_TARGETS[@]}" )
19 ALL_LLVM_TARGETS=( "${ALL_LLVM_TARGETS[@]/#/llvm_targets_}" )
20 LLVM_TARGET_USEDEPS=${ALL_LLVM_TARGETS[@]/%/?}
21
22 LICENSE="Apache-2.0-with-LLVM-exceptions UoI-NCSA"
23 SLOT="0/${PV}"
24 KEYWORDS=""
25 IUSE="debug test ${ALL_LLVM_TARGETS[*]}"
26 REQUIRED_USE="|| ( ${ALL_LLVM_TARGETS[*]} )"
27 RESTRICT="!test? ( test )"
28
29 RDEPEND="
30         >=dev-lang/ocaml-4.00.0:0=
31         dev-ml/ocaml-ctypes:=
32         ~sys-devel/llvm-${PV}:=[${LLVM_TARGET_USEDEPS// /,},debug?]
33         !sys-devel/llvm[ocaml(-)]"
34 DEPEND="${RDEPEND}"
35 BDEPEND="
36         dev-lang/perl
37         dev-ml/findlib
38         test? ( dev-ml/ounit )
39         ${PYTHON_DEPS}"
40
41 # least intrusive of all
42 CMAKE_BUILD_TYPE=RelWithDebInfo
43
44 pkg_setup() {
45         LLVM_MAX_SLOT=${PV%%.*} llvm_pkg_setup
46         python-any-r1_pkg_setup
47 }
48
49 src_prepare() {
50         # Python is needed to run tests using lit
51         python_setup
52
53         cmake-utils_src_prepare
54 }
55
56 src_configure() {
57         local libdir=$(get_libdir)
58         local mycmakeargs=(
59                 -DLLVM_LIBDIR_SUFFIX=${libdir#lib}
60
61                 -DBUILD_SHARED_LIBS=OFF
62                 -DLLVM_BUILD_LLVM_DYLIB=ON
63                 -DLLVM_LINK_LLVM_DYLIB=ON
64                 -DLLVM_OCAML_OUT_OF_TREE=ON
65
66                 # cheap hack: LLVM combines both anyway, and the only difference
67                 # is that the former list is explicitly verified at cmake time
68                 -DLLVM_TARGETS_TO_BUILD=""
69                 -DLLVM_EXPERIMENTAL_TARGETS_TO_BUILD="${LLVM_TARGETS// /;}"
70                 -DLLVM_BUILD_TESTS=$(usex test)
71
72                 # disable various irrelevant deps and settings
73                 -DLLVM_ENABLE_FFI=OFF
74                 -DLLVM_ENABLE_TERMINFO=OFF
75                 -DHAVE_HISTEDIT_H=NO
76                 -DWITH_POLLY=OFF
77                 -DLLVM_ENABLE_ASSERTIONS=$(usex debug)
78                 -DLLVM_ENABLE_EH=ON
79                 -DLLVM_ENABLE_RTTI=ON
80
81                 -DLLVM_HOST_TRIPLE="${CHOST}"
82
83                 # disable go bindings
84                 -DGO_EXECUTABLE=GO_EXECUTABLE-NOTFOUND
85
86                 # TODO: ocamldoc
87         )
88
89         use test && mycmakeargs+=(
90                 -DLLVM_LIT_ARGS="-vv;-j;${LIT_JOBS:-$(makeopts_jobs "${MAKEOPTS}" "$(get_nproc)")}"
91         )
92
93         # LLVM_ENABLE_ASSERTIONS=NO does not guarantee this for us, #614844
94         # also: custom rules for OCaml do not work for CPPFLAGS
95         use debug || local -x CFLAGS="${CFLAGS} -DNDEBUG"
96         cmake-utils_src_configure
97
98         local llvm_libdir=$(llvm-config --libdir)
99         # an ugly hack; TODO: figure out a way to pass -L to ocaml...
100         cd "${BUILD_DIR}/${libdir}" || die
101         ln -s "${llvm_libdir}"/*.so . || die
102
103         if use test; then
104                 local llvm_bindir=$(llvm-config --bindir)
105                 # Force using system-installed tools.
106                 sed -i -e "/llvm_tools_dir/s@\".*\"@\"${llvm_bindir}\"@" \
107                         "${BUILD_DIR}"/test/lit.site.cfg.py || die
108         fi
109 }
110
111 src_compile() {
112         cmake-utils_src_compile ocaml_all
113 }
114
115 src_test() {
116         # respect TMPDIR!
117         local -x LIT_PRESERVES_TMP=1
118         cmake-utils_src_make check-llvm-bindings-ocaml
119 }
120
121 src_install() {
122         DESTDIR="${D}" \
123         cmake -P "${BUILD_DIR}"/bindings/ocaml/cmake_install.cmake || die
124
125         dodoc bindings/ocaml/README.txt
126 }