dotnet.eclass 4.4 KB

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