Gentoo Archives: gentoo-dev

From: Justin Lecher <jlec@g.o>
To: gentoo-dev@l.g.o
Cc: kde@g.o, Justin Lecher <jlec@g.o>
Subject: [gentoo-dev] [PATCH 1/3] cmake-utils.eclass: Use bash internal testing instead of has()
Date: Mon, 25 Jan 2016 20:30:27
Message-Id: 1453753781-9305-2-git-send-email-jlec@gentoo.org
In Reply to: [gentoo-dev] [PATCH 0/3] RFC: cmake-utils.eclass minor updates by Justin Lecher
1 Signed-off-by: Justin Lecher <jlec@g.o>
2 ---
3 eclass/cmake-utils.eclass | 18 +++++++++---------
4 1 file changed, 9 insertions(+), 9 deletions(-)
5
6 diff --git a/eclass/cmake-utils.eclass b/eclass/cmake-utils.eclass
7 index 9e8e71e..fb7f5ca 100644
8 --- a/eclass/cmake-utils.eclass
9 +++ b/eclass/cmake-utils.eclass
10 @@ -127,7 +127,7 @@ case ${WANT_CMAKE} in
11 always)
12 ;;
13 *)
14 - has "${EAPI:-0}" 2 3 4 5 || die "WANT_CMAKE is banned in EAPI 6 and later"
15 + [[ ${EAPI} == [2345] ]] || die "WANT_CMAKE is banned in EAPI 6 and later"
16 IUSE+=" ${WANT_CMAKE}"
17 CMAKEDEPEND+="${WANT_CMAKE}? ( "
18 ;;
19 @@ -164,7 +164,7 @@ _cmake_use_me_now() {
20 local arg=$2
21 [[ ! -z $3 ]] && arg=$3
22
23 - has "${EAPI:-0}" 2 3 4 5 || die "${FUNCNAME[1]} is banned in EAPI 6 and later: use -D$1${arg}=\"\$(usex $2)\" instead"
24 + [[ ${EAPI} == [2345] ]] || die "${FUNCNAME[1]} is banned in EAPI 6 and later: use -D$1${arg}=\"\$(usex $2)\" instead"
25
26 local uper capitalised x
27 [[ -z $2 ]] && die "cmake-utils_use-$1 <USE flag> [<flag name>]"
28 @@ -186,7 +186,7 @@ _cmake_use_me_now_inverted() {
29 local arg=$2
30 [[ ! -z $3 ]] && arg=$3
31
32 - if ! has "${EAPI:-0}" 2 3 4 5 && [[ "${FUNCNAME[1]}" != cmake-utils_use_find_package ]] ; then
33 + if [[ ${EAPI} != [2345] ]] && [[ "${FUNCNAME[1]}" != cmake-utils_use_find_package ]] ; then
34 die "${FUNCNAME[1]} is banned in EAPI 6 and later: use -D$1${arg}=\"\$(usex $2)\" insteadss"
35 fi
36
37 @@ -283,7 +283,7 @@ cmake_comment_add_subdirectory() {
38 # Comment out an add_subdirectory call in CMakeLists.txt in the current directory
39 # Banned in EAPI 6 and later - use cmake_comment_add_subdirectory instead.
40 comment_add_subdirectory() {
41 - has "${EAPI:-0}" 2 3 4 5 || die "comment_add_subdirectory is banned in EAPI 6 and later - use cmake_comment_add_subdirectory instead"
42 + [[ ${EAPI} == [2345] ]] || die "comment_add_subdirectory is banned in EAPI 6 and later - use cmake_comment_add_subdirectory instead"
43
44 cmake_comment_add_subdirectory "$@"
45 }
46 @@ -315,7 +315,7 @@ cmake-utils_use_enable() { _cmake_use_me_now ENABLE_ "$@" ; }
47 # if foo is enabled and -DCMAKE_DISABLE_FIND_PACKAGE_LibFoo=ON if it is disabled.
48 # This can be used to make find_package optional.
49 cmake-utils_use_find_package() {
50 - if ! has "${EAPI:-0}" 2 3 4 5 && [[ "$#" != 2 ]] ; then
51 + if [[ ${EAPI} != [2345] ]] && [[ "$#" != 2 ]] ; then
52 die "Usage: cmake-utils_use_find_package <USE flag> <package name>"
53 fi
54
55 @@ -456,7 +456,7 @@ enable_cmake-utils_src_prepare() {
56
57 pushd "${S}" > /dev/null || die
58
59 - if ! has "${EAPI:-0}" 2 3 4 5 ; then
60 + if [[ ${EAPI} != [2345] ]]; then
61 default_src_prepare
62 _cmake_cleanup_cmake
63 else
64 @@ -488,7 +488,7 @@ enable_cmake-utils_src_prepare() {
65 enable_cmake-utils_src_configure() {
66 debug-print-function ${FUNCNAME} "$@"
67
68 - has "${EAPI:-0}" 2 3 4 5 && _cmake_cleanup_cmake
69 + [[ ${EAPI} == [2345] ]] && _cmake_cleanup_cmake
70
71 _cmake_check_build_dir
72
73 @@ -564,7 +564,7 @@ enable_cmake-utils_src_configure() {
74 fi
75 fi
76
77 - has "${EAPI:-0}" 0 1 2 && ! use prefix && local EPREFIX=
78 + [[ ${EAPI} == 2 ]] && ! use prefix && local EPREFIX=
79
80 if [[ ${EPREFIX} ]]; then
81 cat >> "${build_rules}" <<- _EOF_ || die
82 @@ -604,7 +604,7 @@ enable_cmake-utils_src_configure() {
83 local mycmakeargstype=$(declare -p mycmakeargs 2>&-)
84 if [[ "${mycmakeargstype}" != "declare -a mycmakeargs="* ]]; then
85 if [[ -n "${mycmakeargstype}" ]] ; then
86 - if has "${EAPI:-0}" 2 3 4 5 ; then
87 + if [[ ${EAPI} != [2345] ]]; then
88 eqawarn "Declaring mycmakeargs as a variable is deprecated. Please use an array instead."
89 else
90 die "Declaring mycmakeargs as a variable is banned in EAPI=${EAPI}. Please use an array instead."
91 --
92 2.7.0