dev-qt/qtpositioning: stable 5.14.2 for ppc, bug #719732
[gentoo.git] / eclass / dotnet.eclass
1 # Copyright 1999-2019 Gentoo Authors
2 # Distributed under the terms of the GNU General Public License v2
3
4 # @ECLASS: dotnet.eclass
5 # @MAINTAINER: dotnet@gentoo.org
6 # @SUPPORTED_EAPIS: 1 2 3 4 5 6 7
7 # @BLURB: common settings and functions for mono and dotnet related packages
8 # @DESCRIPTION:
9 # The dotnet eclass contains common environment settings that are useful for
10 # dotnet packages.  Currently, it provides no functions, just exports
11 # MONO_SHARED_DIR and sets LC_ALL in order to prevent errors during compilation
12 # of dotnet packages.
13
14 case ${EAPI:-0} in
15         0)
16                 die "this eclass doesn't support EAPI 0" ;;
17         [1-6])
18                 inherit eapi7-ver multilib
19                 DEPEND="dev-lang/mono" ;;
20         *)
21                 BDEPEND="dev-lang/mono" ;;
22 esac
23
24 inherit mono-env
25
26 # @ECLASS-VARIABLE: USE_DOTNET
27 # @DESCRIPTION:
28 # Use flags added to IUSE
29
30 # SET default use flags according on DOTNET_TARGETS
31 for x in ${USE_DOTNET}; do
32         case ${x} in
33                 net45) if [[ ${DOTNET_TARGETS} == *net45* ]]; then IUSE+=" +net45"; else IUSE+=" net45"; fi;;
34                 net40) if [[ ${DOTNET_TARGETS} == *net40* ]]; then IUSE+=" +net40"; else IUSE+=" net40"; fi;;
35                 net35) if [[ ${DOTNET_TARGETS} == *net35* ]]; then IUSE+=" +net35"; else IUSE+=" net35"; fi;;
36                 net20) if [[ ${DOTNET_TARGETS} == *net20* ]]; then IUSE+=" +net20"; else IUSE+=" net20"; fi;;
37         esac
38 done
39
40 # @FUNCTION: dotnet_pkg_setup
41 # @DESCRIPTION:
42 # This function set FRAMEWORK.
43 dotnet_pkg_setup() {
44         for x in ${USE_DOTNET} ; do
45                 case ${x} in
46                         net45) if use net45; then F="4.5"; fi;;
47                         net40) if use net40; then F="4.0"; fi;;
48                         net35) if use net35; then F="3.5"; fi;;
49                         net20) if use net20; then F="2.0"; fi;;
50                 esac
51                 if [[ -z ${FRAMEWORK} ]]; then
52                         if [[ ${F} ]]; then
53                                 FRAMEWORK="${F}";
54                         fi
55                 else
56                         ver_test "${F}" -le "${FRAMEWORK}" || FRAMEWORK="${F}"
57                 fi
58         done
59         if [[ -z ${FRAMEWORK} ]]; then
60                 FRAMEWORK="4.0"
61         fi
62         einfo " -- USING .NET ${FRAMEWORK} FRAMEWORK -- "
63 }
64
65 # >=mono-0.92 versions using mcs -pkg:foo-sharp require shared memory, so we set the
66 # shared dir to ${T} so that ${T}/.wapi can be used during the install process.
67 export MONO_SHARED_DIR="${T}"
68
69 # Building mono, nant and many other dotnet packages is known to fail if LC_ALL
70 # variable is not set to C. To prevent this all mono related packages will be
71 # build with LC_ALL=C (see bugs #146424, #149817)
72 export LC_ALL=C
73
74 # Monodevelop-using applications need this to be set or they will try to create config
75 # files in the user's ~ dir.
76
77 export XDG_CONFIG_HOME="${T}"
78
79 # Fix bug 83020:
80 # "Access Violations Arise When Emerging Mono-Related Packages with MONO_AOT_CACHE"
81
82 unset MONO_AOT_CACHE
83
84 # @FUNCTION: exbuild
85 # @DESCRIPTION:
86 # Run xbuild with Release configuration and configurated FRAMEWORK.
87 exbuild() {
88         elog "xbuild ""$@"" /p:Configuration=Release /tv:4.0 /p:TargetFrameworkVersion=v""${FRAMEWORK}"" || die"
89         xbuild "$@" /p:Configuration=Release /tv:4.0 /p:TargetFrameworkVersion=v"${FRAMEWORK}" || die
90 }
91
92 # @FUNCTION: egacinstall
93 # @DESCRIPTION:
94 # Install package to GAC.
95 egacinstall() {
96         use !prefix && has "${EAPI:-0}" 0 1 2 && ED="${D}"
97         gacutil -i "${1}" \
98                 -root "${ED}"/usr/$(get_libdir) \
99                 -gacdir /usr/$(get_libdir) \
100                 -package ${2:-${GACPN:-${PN}}} \
101                 || die "installing ${1} into the Global Assembly Cache failed"
102 }
103
104 # @FUNCTION: dotnet_multilib_comply
105 # @DESCRIPTION:
106 # multilib comply
107 dotnet_multilib_comply() {
108         use !prefix && has "${EAPI:-0}" 0 1 2 && ED="${D}"
109         local dir finddirs=() mv_command=${mv_command:-mv}
110         if [[ -d "${ED}/usr/lib" && "$(get_libdir)" != "lib" ]]
111         then
112                 if ! [[ -d "${ED}"/usr/"$(get_libdir)" ]]
113                 then
114                         mkdir "${ED}"/usr/"$(get_libdir)" || die "Couldn't mkdir ${ED}/usr/$(get_libdir)"
115                 fi
116                 ${mv_command} "${ED}"/usr/lib/* "${ED}"/usr/"$(get_libdir)"/ || die "Moving files into correct libdir failed"
117                 rm -rf "${ED}"/usr/lib
118                 for dir in "${ED}"/usr/"$(get_libdir)"/pkgconfig "${ED}"/usr/share/pkgconfig
119                 do
120
121                         if [[ -d "${dir}" && "$(find "${dir}" -name '*.pc')" != "" ]]
122                         then
123                                 pushd "${dir}" &> /dev/null
124                                 sed  -i -r -e 's:/(lib)([^a-zA-Z0-9]|$):/'"$(get_libdir)"'\2:g' \
125                                         *.pc \
126                                         || die "Sedding some sense into pkgconfig files failed."
127                                 popd "${dir}" &> /dev/null
128                         fi
129                 done
130                 if [[ -d "${ED}/usr/bin" ]]
131                 then
132                         for exe in "${ED}/usr/bin"/*
133                         do
134                                 if [[ "$(file "${exe}")" == *"shell script text"* ]]
135                                 then
136                                         sed -r -i -e ":/lib(/|$): s:/lib(/|$):/$(get_libdir)\1:" \
137                                                 "${exe}" || die "Sedding some sense into ${exe} failed"
138                                 fi
139                         done
140                 fi
141
142         fi
143 }
144
145 EXPORT_FUNCTIONS pkg_setup