dev-util/lldb: amd64 stable wrt bug #705530
[gentoo.git] / dev-util / lldb / lldb-7.1.0.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 : ${CMAKE_MAKEFILE_GENERATOR:=ninja}
7 # (needed due to CMAKE_BUILD_TYPE != Gentoo)
8 CMAKE_MIN_VERSION=3.7.0-r1
9 PYTHON_COMPAT=( python2_7 )
10
11 inherit cmake-utils llvm multiprocessing python-single-r1 \
12         toolchain-funcs
13
14 MY_P=${P/_/}.src
15 LLVM_P=llvm-${PV/_/}.src
16
17 DESCRIPTION="The LLVM debugger"
18 HOMEPAGE="https://llvm.org/"
19 SRC_URI="https://releases.llvm.org/${PV/_//}/${MY_P}.tar.xz
20         test? ( https://releases.llvm.org/${PV/_//}/${LLVM_P}.tar.xz )"
21
22 LICENSE="UoI-NCSA"
23 SLOT="0"
24 KEYWORDS="amd64 arm64 x86"
25 IUSE="libedit ncurses +python test"
26 # Tests are known to fail, and we are not going to address the failures
27 # in this version.
28 RESTRICT="test"
29
30 RDEPEND="
31         libedit? ( dev-libs/libedit:0= )
32         ncurses? ( >=sys-libs/ncurses-5.9-r3:0= )
33         python? ( dev-python/six[${PYTHON_USEDEP}]
34                 ${PYTHON_DEPS} )
35         ~sys-devel/clang-${PV}[xml]
36         ~sys-devel/llvm-${PV}
37         !<sys-devel/llvm-4.0"
38 DEPEND="${RDEPEND}
39         python? ( >=dev-lang/swig-3.0.11 )
40         test? ( ~dev-python/lit-${PV}[${PYTHON_USEDEP}] )
41         ${PYTHON_DEPS}"
42
43 REQUIRED_USE=${PYTHON_REQUIRED_USE}
44
45 S=${WORKDIR}/${MY_P}
46
47 # least intrusive of all
48 CMAKE_BUILD_TYPE=RelWithDebInfo
49
50 pkg_setup() {
51         LLVM_MAX_SLOT=${PV%%.*} llvm_pkg_setup
52         python-single-r1_pkg_setup
53 }
54
55 src_unpack() {
56         einfo "Unpacking ${MY_P}.tar.xz ..."
57         tar -xf "${DISTDIR}/${MY_P}.tar.xz" || die
58
59         if use test; then
60                 einfo "Unpacking parts of ${LLVM_P}.tar.xz ..."
61                 tar -xf "${DISTDIR}/${LLVM_P}.tar.xz" \
62                         "${LLVM_P}"/{lib/Testing/Support,utils/unittest} || die
63                 mv "${LLVM_P}" llvm || die
64         fi
65 }
66
67 src_configure() {
68         local mycmakeargs=(
69                 -DLLDB_DISABLE_CURSES=$(usex !ncurses)
70                 -DLLDB_DISABLE_LIBEDIT=$(usex !libedit)
71                 -DLLDB_DISABLE_PYTHON=$(usex !python)
72                 -DLLDB_USE_SYSTEM_SIX=1
73                 -DLLVM_ENABLE_TERMINFO=$(usex ncurses)
74
75                 -DLLDB_INCLUDE_TESTS=$(usex test)
76
77                 # TODO: fix upstream to detect this properly
78                 -DHAVE_LIBDL=ON
79                 -DHAVE_LIBPTHREAD=ON
80
81                 # normally we'd have to set LLVM_ENABLE_TERMINFO, HAVE_TERMINFO
82                 # and TERMINFO_LIBS... so just force FindCurses.cmake to use
83                 # ncurses with complete library set (including autodetection
84                 # of -ltinfo)
85                 -DCURSES_NEED_NCURSES=ON
86         )
87         use test && mycmakeargs+=(
88                 -DLLVM_BUILD_TESTS=$(usex test)
89                 # compilers for lit tests
90                 -DLLDB_TEST_C_COMPILER="$(type -P clang)"
91                 -DLLDB_TEST_CXX_COMPILER="$(type -P clang++)"
92
93                 -DLLVM_MAIN_SRC_DIR="${WORKDIR}/llvm"
94                 -DLLVM_EXTERNAL_LIT="${EPREFIX}/usr/bin/lit"
95                 -DLLVM_LIT_ARGS="-vv;-j;${LIT_JOBS:-$(makeopts_jobs "${MAKEOPTS}" "$(get_nproc)")}"
96         )
97
98         cmake-utils_src_configure
99 }
100
101 src_test() {
102         cmake-utils_src_make check-lldb-lit
103         use python && cmake-utils_src_make check-lldb
104 }
105
106 src_install() {
107         cmake-utils_src_install
108
109         # oh my...
110         if use python; then
111                 # remove custom readline.so for now
112                 # TODO: figure out how to deal with it
113                 # upstream is basically building a custom readline.so with -ledit
114                 # to avoid symbol collisions between readline and libedit...
115                 rm "${D}$(python_get_sitedir)/readline.so" || die
116
117                 # byte-compile the modules
118                 python_optimize
119         fi
120 }