Gentoo Archives: gentoo-dev

From: "Michał Górny" <mgorny@g.o>
To: gentoo-dev@l.g.o
Cc: reavertm@g.o, scarabeus@g.o, "Michał Górny" <mgorny@g.o>
Subject: [gentoo-dev] [PATCH 3/4] cmake-utils: support common BUILD_DIR variable.
Date: Thu, 29 Nov 2012 13:41:47
Message-Id: 1354196458-17485-4-git-send-email-mgorny@gentoo.org
In Reply to: [gentoo-dev] autotools-utils & cmake-utils: use common BUILD_DIR var by "Michał Górny"
1 ---
2 gx86/eclass/cmake-utils.eclass | 33 +++++++++++++++++++--------------
3 1 file changed, 19 insertions(+), 14 deletions(-)
4
5 diff --git a/gx86/eclass/cmake-utils.eclass b/gx86/eclass/cmake-utils.eclass
6 index 2129ebf..26fc1c1 100644
7 --- a/gx86/eclass/cmake-utils.eclass
8 +++ b/gx86/eclass/cmake-utils.eclass
9 @@ -114,12 +114,15 @@ _use_me_now_inverted() {
10 fi
11 }
12
13 -# @ECLASS-VARIABLE: CMAKE_BUILD_DIR
14 +# @ECLASS-VARIABLE: BUILD_DIR
15 # @DESCRIPTION:
16 # Build directory where all cmake processed files should be generated.
17 # For in-source build it's fixed to ${CMAKE_USE_DIR}.
18 # For out-of-source build it can be overriden, by default it uses
19 # ${WORKDIR}/${P}_build.
20 +#
21 +# This variable has been called CMAKE_BUILD_DIR formerly.
22 +# It is set under that name for compatibility.
23
24 # @ECLASS-VARIABLE: CMAKE_BUILD_TYPE
25 # @DESCRIPTION:
26 @@ -163,12 +166,14 @@ _check_build_dir() {
27 : ${CMAKE_USE_DIR:=${S}}
28 if [[ -n ${CMAKE_IN_SOURCE_BUILD} ]]; then
29 # we build in source dir
30 - CMAKE_BUILD_DIR="${CMAKE_USE_DIR}"
31 + BUILD_DIR="${CMAKE_USE_DIR}"
32 else
33 - : ${CMAKE_BUILD_DIR:=${WORKDIR}/${P}_build}
34 + : ${BUILD_DIR:=${CMAKE_BUILD_DIR:-${WORKDIR}/${P}_build}}
35 fi
36 - mkdir -p "${CMAKE_BUILD_DIR}"
37 - echo ">>> Working in BUILD_DIR: \"$CMAKE_BUILD_DIR\""
38 + CMAKE_BUILD_DIR=${BUILD_DIR}
39 +
40 + mkdir -p "${BUILD_DIR}"
41 + echo ">>> Working in BUILD_DIR: \"$BUILD_DIR\""
42 }
43
44 # Determine which generator to use
45 @@ -328,7 +333,7 @@ enable_cmake-utils_src_configure() {
46 fi
47
48 # Prepare Gentoo override rules (set valid compiler, append CPPFLAGS etc.)
49 - local build_rules=${CMAKE_BUILD_DIR}/gentoo_rules.cmake
50 + local build_rules=${BUILD_DIR}/gentoo_rules.cmake
51 cat > "${build_rules}" <<- _EOF_
52 SET (CMAKE_AR $(type -P $(tc-getAR)) CACHE FILEPATH "Archive manager" FORCE)
53 SET (CMAKE_C_COMPILER $(type -P $(tc-getCC)) CACHE FILEPATH "C compiler" FORCE)
54 @@ -364,7 +369,7 @@ enable_cmake-utils_src_configure() {
55 fi
56
57 # Common configure parameters (invariants)
58 - local common_config=${CMAKE_BUILD_DIR}/gentoo_common_config.cmake
59 + local common_config=${BUILD_DIR}/gentoo_common_config.cmake
60 local libdir=$(get_libdir)
61 cat > "${common_config}" <<- _EOF_
62 SET (LIB_SUFFIX ${libdir/lib} CACHE STRING "library path suffix" FORCE)
63 @@ -396,7 +401,7 @@ enable_cmake-utils_src_configure() {
64 "${MYCMAKEARGS}"
65 )
66
67 - pushd "${CMAKE_BUILD_DIR}" > /dev/null
68 + pushd "${BUILD_DIR}" > /dev/null
69 debug-print "${LINENO} ${ECLASS} ${FUNCNAME}: mycmakeargs is ${mycmakeargs_local[*]}"
70 echo "${CMAKE_BINARY}" "${cmakeargs[@]}" "${CMAKE_USE_DIR}"
71 "${CMAKE_BINARY}" "${cmakeargs[@]}" "${CMAKE_USE_DIR}" || die "cmake failed"
72 @@ -418,7 +423,7 @@ cmake-utils_src_make() {
73 debug-print-function ${FUNCNAME} "$@"
74
75 _check_build_dir
76 - pushd "${CMAKE_BUILD_DIR}" > /dev/null
77 + pushd "${BUILD_DIR}" > /dev/null
78 if [[ $(_generator_to_use) = Ninja ]]; then
79 # first check if Makefile exist otherwise die
80 [[ -e build.ninja ]] || die "Makefile not found. Error during configure stage."
81 @@ -444,7 +449,7 @@ enable_cmake-utils_src_install() {
82 debug-print-function ${FUNCNAME} "$@"
83
84 _check_build_dir
85 - pushd "${CMAKE_BUILD_DIR}" > /dev/null
86 + pushd "${BUILD_DIR}" > /dev/null
87 if [[ $(_generator_to_use) = Ninja ]]; then
88 DESTDIR=${D} ninja install "$@" || die "died running ninja install"
89 base_src_install_docs
90 @@ -467,7 +472,7 @@ enable_cmake-utils_src_test() {
91 local ctestargs
92
93 _check_build_dir
94 - pushd "${CMAKE_BUILD_DIR}" > /dev/null
95 + pushd "${BUILD_DIR}" > /dev/null
96 [[ -e CTestTestfile.cmake ]] || { echo "No tests found. Skipping."; return 0 ; }
97
98 [[ -n ${TEST_VERBOSE} ]] && ctestargs="--extra-verbose --output-on-failure"
99 @@ -479,13 +484,13 @@ enable_cmake-utils_src_test() {
100 else
101 if [[ -n "${CMAKE_YES_I_WANT_TO_SEE_THE_TEST_LOG}" ]] ; then
102 # on request from Diego
103 - eerror "Tests failed. Test log ${CMAKE_BUILD_DIR}/Testing/Temporary/LastTest.log follows:"
104 + eerror "Tests failed. Test log ${BUILD_DIR}/Testing/Temporary/LastTest.log follows:"
105 eerror "--START TEST LOG--------------------------------------------------------------"
106 - cat "${CMAKE_BUILD_DIR}/Testing/Temporary/LastTest.log"
107 + cat "${BUILD_DIR}/Testing/Temporary/LastTest.log"
108 eerror "--END TEST LOG----------------------------------------------------------------"
109 die "Tests failed."
110 else
111 - die "Tests failed. When you file a bug, please attach the following file: \n\t${CMAKE_BUILD_DIR}/Testing/Temporary/LastTest.log"
112 + die "Tests failed. When you file a bug, please attach the following file: \n\t${BUILD_DIR}/Testing/Temporary/LastTest.log"
113 fi
114
115 # die might not die due to nonfatal
116 --
117 1.8.0