Gentoo Archives: gentoo-commits

From: "Michał Górny" <mgorny@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] repo/gentoo:master commit in: dev-ml/llvm-ocaml/
Date: Thu, 28 Jan 2021 09:04:08
Message-Id: 1611824546.31e13574ec5a53878331d0ebabcd6f7a4128dcfb.mgorny@gentoo
1 commit: 31e13574ec5a53878331d0ebabcd6f7a4128dcfb
2 Author: Michał Górny <mgorny <AT> gentoo <DOT> org>
3 AuthorDate: Thu Jan 28 09:00:51 2021 +0000
4 Commit: Michał Górny <mgorny <AT> gentoo <DOT> org>
5 CommitDate: Thu Jan 28 09:02:26 2021 +0000
6 URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=31e13574
7
8 dev-ml/llvm-ocaml: Add 13.x live ebuild
9
10 Signed-off-by: Michał Górny <mgorny <AT> gentoo.org>
11
12 dev-ml/llvm-ocaml/llvm-ocaml-13.0.0.9999.ebuild | 124 ++++++++++++++++++++++++
13 1 file changed, 124 insertions(+)
14
15 diff --git a/dev-ml/llvm-ocaml/llvm-ocaml-13.0.0.9999.ebuild b/dev-ml/llvm-ocaml/llvm-ocaml-13.0.0.9999.ebuild
16 new file mode 100644
17 index 00000000000..1e25f7546b8
18 --- /dev/null
19 +++ b/dev-ml/llvm-ocaml/llvm-ocaml-13.0.0.9999.ebuild
20 @@ -0,0 +1,124 @@
21 +# Copyright 1999-2021 Gentoo Authors
22 +# Distributed under the terms of the GNU General Public License v2
23 +
24 +EAPI=7
25 +
26 +PYTHON_COMPAT=( python3_{6..9} )
27 +inherit cmake llvm llvm.org python-any-r1
28 +
29 +DESCRIPTION="OCaml bindings for LLVM"
30 +HOMEPAGE="https://llvm.org/"
31 +
32 +# Keep in sync with sys-devel/llvm
33 +ALL_LLVM_EXPERIMENTAL_TARGETS=( ARC CSKY VE )
34 +ALL_LLVM_TARGETS=( AArch64 AMDGPU ARM AVR BPF Hexagon Lanai Mips MSP430
35 + NVPTX PowerPC RISCV Sparc SystemZ WebAssembly X86 XCore
36 + "${ALL_LLVM_EXPERIMENTAL_TARGETS[@]}" )
37 +ALL_LLVM_TARGETS=( "${ALL_LLVM_TARGETS[@]/#/llvm_targets_}" )
38 +
39 +LICENSE="Apache-2.0-with-LLVM-exceptions UoI-NCSA"
40 +SLOT="0/${PV}"
41 +KEYWORDS=""
42 +IUSE="debug test ${ALL_LLVM_TARGETS[*]}"
43 +REQUIRED_USE="|| ( ${ALL_LLVM_TARGETS[*]} )"
44 +RESTRICT="!test? ( test )"
45 +
46 +RDEPEND="
47 + >=dev-lang/ocaml-4.00.0:0=
48 + dev-ml/ocaml-ctypes:=
49 + ~sys-devel/llvm-${PV}:=[debug?]
50 + !sys-devel/llvm[ocaml(-)]"
51 +for x in "${ALL_LLVM_TARGETS[@]}"; do
52 + RDEPEND+="
53 + ${x}? ( ~sys-devel/llvm-${PV}[${x}] )"
54 +done
55 +unset x
56 +
57 +DEPEND="${RDEPEND}"
58 +BDEPEND="
59 + dev-lang/perl
60 + dev-ml/findlib
61 + >=dev-util/cmake-3.16
62 + test? ( dev-ml/ounit )
63 + ${PYTHON_DEPS}"
64 +
65 +LLVM_COMPONENTS=( llvm )
66 +llvm.org_set_globals
67 +
68 +pkg_setup() {
69 + LLVM_MAX_SLOT=${PV%%.*} llvm_pkg_setup
70 + python-any-r1_pkg_setup
71 +}
72 +
73 +src_configure() {
74 + local libdir=$(get_libdir)
75 + local mycmakeargs=(
76 + -DLLVM_LIBDIR_SUFFIX=${libdir#lib}
77 +
78 + -DBUILD_SHARED_LIBS=OFF
79 + -DLLVM_BUILD_LLVM_DYLIB=ON
80 + -DLLVM_LINK_LLVM_DYLIB=ON
81 + -DLLVM_OCAML_OUT_OF_TREE=ON
82 +
83 + # cheap hack: LLVM combines both anyway, and the only difference
84 + # is that the former list is explicitly verified at cmake time
85 + -DLLVM_TARGETS_TO_BUILD=""
86 + -DLLVM_EXPERIMENTAL_TARGETS_TO_BUILD="${LLVM_TARGETS// /;}"
87 + -DLLVM_BUILD_TESTS=$(usex test)
88 +
89 + # disable various irrelevant deps and settings
90 + -DLLVM_ENABLE_FFI=OFF
91 + -DLLVM_ENABLE_TERMINFO=OFF
92 + -DHAVE_HISTEDIT_H=NO
93 + -DLLVM_ENABLE_ASSERTIONS=$(usex debug)
94 + -DLLVM_ENABLE_EH=ON
95 + -DLLVM_ENABLE_RTTI=ON
96 +
97 + -DLLVM_HOST_TRIPLE="${CHOST}"
98 +
99 + -DPython3_EXECUTABLE="${PYTHON}"
100 +
101 + # disable go bindings
102 + -DGO_EXECUTABLE=GO_EXECUTABLE-NOTFOUND
103 +
104 + # TODO: ocamldoc
105 + )
106 +
107 + use test && mycmakeargs+=(
108 + -DLLVM_LIT_ARGS="$(get_lit_flags)"
109 + )
110 +
111 + # LLVM_ENABLE_ASSERTIONS=NO does not guarantee this for us, #614844
112 + # also: custom rules for OCaml do not work for CPPFLAGS
113 + use debug || local -x CFLAGS="${CFLAGS} -DNDEBUG"
114 + cmake_src_configure
115 +
116 + local llvm_libdir=$(llvm-config --libdir)
117 + # an ugly hack; TODO: figure out a way to pass -L to ocaml...
118 + cd "${BUILD_DIR}/${libdir}" || die
119 + ln -s "${llvm_libdir}"/*.so . || die
120 +
121 + if use test; then
122 + local llvm_bindir=$(llvm-config --bindir)
123 + # Force using system-installed tools.
124 + sed -i -e "/llvm_tools_dir/s@\".*\"@\"${llvm_bindir}\"@" \
125 + "${BUILD_DIR}"/test/lit.site.cfg.py || die
126 + fi
127 +}
128 +
129 +src_compile() {
130 + cmake_build ocaml_all
131 +}
132 +
133 +src_test() {
134 + # respect TMPDIR!
135 + local -x LIT_PRESERVES_TMP=1
136 + cmake_build check-llvm-bindings-ocaml
137 +}
138 +
139 +src_install() {
140 + DESTDIR="${D}" \
141 + cmake -P "${BUILD_DIR}"/bindings/ocaml/cmake_install.cmake || die
142 +
143 + dodoc bindings/ocaml/README.txt
144 +}