Gentoo Archives: gentoo-commits

From: "George Shapovalov (george)" <george@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] gentoo-x86 commit in eclass: gnat.eclass
Date: Thu, 27 Dec 2007 01:40:55
Message-Id: E1J7hjo-0003Sx-Rp@stork.gentoo.org
1 george 07/12/27 01:40:44
2
3 Modified: gnat.eclass
4 Log:
5 updated gnat.eclass to support primary compilers and versioned Ada sandard dependencies
6
7 Revision Changes Path
8 1.31 eclass/gnat.eclass
9
10 file : http://sources.gentoo.org/viewcvs.py/gentoo-x86/eclass/gnat.eclass?rev=1.31&view=markup
11 plain: http://sources.gentoo.org/viewcvs.py/gentoo-x86/eclass/gnat.eclass?rev=1.31&content-type=text/plain
12 diff : http://sources.gentoo.org/viewcvs.py/gentoo-x86/eclass/gnat.eclass?r1=1.30&r2=1.31
13
14 Index: gnat.eclass
15 ===================================================================
16 RCS file: /var/cvsroot/gentoo-x86/eclass/gnat.eclass,v
17 retrieving revision 1.30
18 retrieving revision 1.31
19 diff -u -r1.30 -r1.31
20 --- gnat.eclass 14 Dec 2007 12:16:56 -0000 1.30
21 +++ gnat.eclass 27 Dec 2007 01:40:44 -0000 1.31
22 @@ -1,6 +1,6 @@
23 # Copyright 1999-2004 Gentoo Foundation
24 # Distributed under the terms of the GNU General Public License v2
25 -# $Header: /var/cvsroot/gentoo-x86/eclass/gnat.eclass,v 1.30 2007/12/14 12:16:56 george Exp $
26 +# $Header: /var/cvsroot/gentoo-x86/eclass/gnat.eclass,v 1.31 2007/12/27 01:40:44 george Exp $
27 #
28 # Author: George Shapovalov <george@g.o>
29 # Belongs to: ada herd <ada@g.o>
30 @@ -35,8 +35,9 @@
31
32 DESCRIPTION="Common procedures for building Ada libs using split gnat compilers"
33
34 -# really need to make sure we have eselect with new eclass version
35 -DEPEND=">=app-admin/eselect-gnat-1.1"
36 +# make sure we have an appropriately recent eselect-gnat installed, as we are
37 +# using some common code here.
38 +DEPEND=">=app-admin/eselect-gnat-1.3"
39
40
41 # ----------------------------------
42 @@ -99,6 +100,61 @@
43
44
45 # ------------------------------------
46 +# Dependency processing related stuff
47 +
48 +# A simple wrapper to get the relevant part of the DEPEND
49 +# params:
50 +# $1 - should contain dependency specification analogous to DEPEND,
51 +# if omitted, DEPEND is processed
52 +get_ada_dep() {
53 + [[ -z "$1" ]] && DEP="${DEPEND}" || DEP="$1"
54 + local TempStr
55 + for fn in $DEP; do # here $DEP should *not* be in ""
56 + [[ $fn =~ "virtual/ada" ]] && TempStr=${fn/*virtual\//}
57 + # above match should be to full virtual/ada, as simply "ada" is a common
58 + # part of ${PN}, even for some packages under dev-ada
59 + done
60 +# debug-print-function $FUNCNAME "TempStr=${TempStr:0:8}"
61 + [[ -n ${TempStr} ]] && echo ${TempStr:0:8}
62 +}
63 +
64 +# This function is used to check whether the requested gnat profile matches the
65 +# requested Ada standard
66 +# !!ATTN!!
67 +# This must match dependencies as specified in vitrual/ada !!!
68 +#
69 +# params:
70 +# $1 - the requested gnat profile in usual form (e.g. x86_64-pc-linux-gnu-gnat-gcc-4.1)
71 +# $2 - Ada standard specification, as would be specified in DEPEND.
72 +# Valid values: ada-1995, ada-2005, ada
73 +# Since standard variants are (mostly) backwards-compatible, ada-1995 and
74 +# simply "ada" produce the same results (at least until ada-1983 is adde,
75 +# which is rather unlikely).
76 +belongs_to_standard() {
77 +# debug-print-function $FUNCNAME $*
78 + . ${GnatCommon} || die "failed to source gnat-common lib"
79 + if [[ $2 == 'ada' ]] || [[ $2 == 'ada-1995' ]]; then
80 +# debug-print-function "ada or ada-1995 match"
81 + return 0 # no restrictions imposed
82 + elif [[ "$2" == 'ada-2005' ]]; then
83 + local GnatSlot=$(get_gnat_SLOT $1)
84 + local ReducedSlot=${GnatSlot//\./}
85 + if [[ $(get_gnat_Pkg $1) == "gcc" ]]; then
86 +# debug-print-function "got gcc profile, GnatSlot=${ReducedSlot}"
87 + [[ ${ReducedSlot} -ge "43" ]] && return 0 || return 1
88 + elif [[ $(get_gnat_Pkg $1) == "gpl" ]]; then
89 +# debug-print-function "got gpl profile, GnatSlot=${ReducedSlot}"
90 + [[ ${ReducedSlot} -ge "41" ]] && return 0 || return 1
91 + else
92 + return 1 # unknown compiler encountered
93 + fi
94 + else
95 + return 1 # unknown standard requested, check spelling!
96 + fi
97 +}
98 +
99 +
100 +# ------------------------------------
101 # Helpers
102 #
103
104 @@ -137,7 +193,7 @@
105 }
106
107
108 -# Returns a name of active gnat profile. Peroroms some validity checks. No input
109 +# Returns a name of active gnat profile. Performs some validity checks. No input
110 # parameters, analyzes the system setup directly.
111 get_active_profile() {
112 # get common code and settings
113 @@ -226,7 +282,7 @@
114 elog "for the installed library. In order to immediately activate these"
115 elog "settings please run:"
116 elog
117 - elog "env-update"
118 + #elog "env-update"
119 elog "source /etc/profile"
120 einfo
121 einfo "Otherwise the settings will become active next time you login"
122 @@ -276,45 +332,56 @@
123 # duplicating code or trying to violate sandbox in some way..
124 . ${GnatCommon} || die "failed to source gnat-common lib"
125
126 - compilers=( $(find_compilers ) )
127 + compilers=( $(find_primary_compilers ) )
128 if [[ -n ${compilers[@]} ]] ; then
129 local i
130 + local AdaDep=$(get_ada_dep)
131 for (( i = 0 ; i < ${#compilers[@]} ; i = i + 1 )) ; do
132 - debug-print-section "compiling for gnat profile ${compilers[${i}]}"
133 + if $(belongs_to_standard ${compilers[${i}]} ${AdaDep}); then
134 + einfo "compiling for gnat profile ${compilers[${i}]}"
135
136 - # copy sources
137 - mkdir "${DL}" "${DLbin}" "${DLgpr}"
138 - cp -dpR "${S}" "${SL}"
139 -
140 - # setup environment
141 - # As eselect-gnat also manages the libs, this will ensure the right
142 - # lib profiles are activated too (in case we depend on some Ada lib)
143 - generate_envFile ${compilers[${i}]} ${BuildEnv} && \
144 - expand_BuildEnv "${BuildEnv}" && \
145 - . "${BuildEnv}" || die "failed to switch to ${compilers[${i}]}"
146 - # many libs (notably xmlada and gtkada) do not like to see
147 - # themselves installed. Need to strip them from ADA_*_PATH
148 - # NOTE: this should not be done in pkg_setup, as we setup
149 - # environment right above
150 - export ADA_INCLUDE_PATH=$(filter_env_var ADA_INCLUDE_PATH)
151 - export ADA_OBJECTS_PATH=$(filter_env_var ADA_OBJECTS_PATH)
152 -
153 - # call compilation callback
154 - cd "${SL}"
155 - gnat_filter_flags ${compilers[${i}]}
156 - lib_compile ${compilers[${i}]} || die "failed compiling for ${compilers[${i}]}"
157 -
158 - # call install callback
159 - cd "${SL}"
160 - lib_install ${compilers[${i}]} || die "failed installing profile-specific part for ${compilers[${i}]}"
161 - # move installed and cleanup
162 - mv "${DL}" "${DL}-${compilers[${i}]}"
163 - mv "${DLbin}" "${DLbin}-${compilers[${i}]}"
164 - mv "${DLgpr}" "${DLgpr}-${compilers[${i}]}"
165 - rm -rf "${SL}"
166 + # copy sources
167 + mkdir "${DL}" "${DLbin}" "${DLgpr}"
168 + cp -dpR "${S}" "${SL}"
169 +
170 + # setup environment
171 + # As eselect-gnat also manages the libs, this will ensure the right
172 + # lib profiles are activated too (in case we depend on some Ada lib)
173 + generate_envFile ${compilers[${i}]} ${BuildEnv} && \
174 + expand_BuildEnv "${BuildEnv}" && \
175 + . "${BuildEnv}" || die "failed to switch to ${compilers[${i}]}"
176 + # many libs (notably xmlada and gtkada) do not like to see
177 + # themselves installed. Need to strip them from ADA_*_PATH
178 + # NOTE: this should not be done in pkg_setup, as we setup
179 + # environment right above
180 + export ADA_INCLUDE_PATH=$(filter_env_var ADA_INCLUDE_PATH)
181 + export ADA_OBJECTS_PATH=$(filter_env_var ADA_OBJECTS_PATH)
182 +
183 + # call compilation callback
184 + cd "${SL}"
185 + gnat_filter_flags ${compilers[${i}]}
186 + lib_compile ${compilers[${i}]} || die "failed compiling for ${compilers[${i}]}"
187 +
188 + # call install callback
189 + cd "${SL}"
190 + lib_install ${compilers[${i}]} || die "failed installing profile-specific part for ${compilers[${i}]}"
191 + # move installed and cleanup
192 + mv "${DL}" "${DL}-${compilers[${i}]}"
193 + mv "${DLbin}" "${DLbin}-${compilers[${i}]}"
194 + mv "${DLgpr}" "${DLgpr}-${compilers[${i}]}"
195 + rm -rf "${SL}"
196 + else
197 + einfo "skipping gnat profile ${compilers[${i}]}"
198 + fi
199 done
200 else
201 - die "please make sure you have at least one gnat compiler installed!"
202 + ewarn "Please note!"
203 + elog "Treatment of installed Ada compilers has recently changed!"
204 + elog "Libs are now being built only for \"primary\" compilers."
205 + elog "Please list gnat profiles (as reported by \"eselect gnat list\")"
206 + elog "that you want to regularly use (i.e., not just for testing)"
207 + elog "in ${PRIMELIST}, one per line."
208 + die "please make sure you have at least one gnat compiler installed and set as primary!"
209 fi
210 }
211
212 @@ -328,22 +395,27 @@
213 . ${GnatCommon} || die "failed to source gnat-common lib"
214 dodir ${SPECSDIR}/${PN}
215
216 - compilers=( $(find_compilers ) )
217 + compilers=( $(find_primary_compilers) )
218 if [[ -n ${compilers[@]} ]] ; then
219 local i
220 + local AdaDep=$(get_ada_dep)
221 for (( i = 0 ; i < ${#compilers[@]} ; i = i + 1 )) ; do
222 - debug-print-section "installing for gnat profile ${compilers[${i}]}"
223 + if $(belongs_to_standard ${compilers[${i}]} ${AdaDep}); then
224 + debug-print-section "installing for gnat profile ${compilers[${i}]}"
225
226 - local DLlocation=${AdalibLibTop}/${compilers[${i}]}
227 - dodir ${DLlocation}
228 - cp -dpR "${DL}-${compilers[${i}]}" "${D}/${DLlocation}/${PN}"
229 - cp -dpR "${DLbin}-${compilers[${i}]}" "${D}/${DLlocation}"/bin
230 - cp -dpR "${DLgpr}-${compilers[${i}]}" "${D}/${DLlocation}"/gpr
231 - # create profile-specific specs file
232 - cp ${LibEnv} ${D}/${SPECSDIR}/${PN}/${compilers[${i}]}
233 - sed -i -e "s:%DL%:${DLlocation}/${PN}:g" ${D}/${SPECSDIR}/${PN}/${compilers[${i}]}
234 - sed -i -e "s:%DLbin%:${DLlocation}/bin:g" ${D}/${SPECSDIR}/${PN}/${compilers[${i}]}
235 - sed -i -e "s:%DLgpr%:${DLlocation}/gpr:g" ${D}/${SPECSDIR}/${PN}/${compilers[${i}]}
236 + local DLlocation=${AdalibLibTop}/${compilers[${i}]}
237 + dodir ${DLlocation}
238 + cp -dpR "${DL}-${compilers[${i}]}" "${D}/${DLlocation}/${PN}"
239 + cp -dpR "${DLbin}-${compilers[${i}]}" "${D}/${DLlocation}"/bin
240 + cp -dpR "${DLgpr}-${compilers[${i}]}" "${D}/${DLlocation}"/gpr
241 + # create profile-specific specs file
242 + cp ${LibEnv} ${D}/${SPECSDIR}/${PN}/${compilers[${i}]}
243 + sed -i -e "s:%DL%:${DLlocation}/${PN}:g" ${D}/${SPECSDIR}/${PN}/${compilers[${i}]}
244 + sed -i -e "s:%DLbin%:${DLlocation}/bin:g" ${D}/${SPECSDIR}/${PN}/${compilers[${i}]}
245 + sed -i -e "s:%DLgpr%:${DLlocation}/gpr:g" ${D}/${SPECSDIR}/${PN}/${compilers[${i}]}
246 + else
247 + einfo "skipping gnat profile ${compilers[${i}]}"
248 + fi
249 done
250 else
251 die || "please make sure you have at least one gnat compiler installed!"
252
253
254
255 --
256 gentoo-commits@g.o mailing list