chromium-2.eclass 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190
  1. # Copyright 1999-2016 Gentoo Foundation
  2. # Distributed under the terms of the GNU General Public License v2
  3. # @ECLASS: chromium-2.eclass
  4. # @MAINTAINER:
  5. # Chromium Herd <chromium@gentoo.org>
  6. # @AUTHOR:
  7. # Mike Gilbert <floppym@gentoo.org>
  8. # @BLURB: Shared functions for chromium and google-chrome
  9. inherit eutils linux-info
  10. if [[ ${PN} == chromium ]]; then
  11. IUSE+=" custom-cflags"
  12. fi
  13. # @FUNCTION: chromium_suid_sandbox_check_kernel_config
  14. # @USAGE:
  15. # @DESCRIPTION:
  16. # Ensures the system kernel supports features needed for SUID sandbox to work.
  17. chromium_suid_sandbox_check_kernel_config() {
  18. has "${EAPI:-0}" 0 1 2 3 && die "EAPI=${EAPI} is not supported"
  19. if [[ "${MERGE_TYPE}" == "source" || "${MERGE_TYPE}" == "binary" ]]; then
  20. # Warn if the kernel does not support features needed for sandboxing.
  21. # Bug #363987.
  22. ERROR_PID_NS="PID_NS is required for sandbox to work"
  23. ERROR_NET_NS="NET_NS is required for sandbox to work"
  24. ERROR_USER_NS="USER_NS is required for sandbox to work"
  25. ERROR_SECCOMP_FILTER="SECCOMP_FILTER is required for sandbox to work"
  26. # Warn if the kernel does not support features needed for the browser to work
  27. # (bug #552576, bug #556286).
  28. ERROR_ADVISE_SYSCALLS="CONFIG_ADVISE_SYSCALLS is required for the renderer (bug #552576)"
  29. ERROR_COMPAT_VDSO="CONFIG_COMPAT_VDSO causes segfaults (bug #556286)"
  30. CONFIG_CHECK="~PID_NS ~NET_NS ~SECCOMP_FILTER ~USER_NS ~ADVISE_SYSCALLS ~!COMPAT_VDSO"
  31. check_extra_config
  32. fi
  33. }
  34. # @ECLASS-VARIABLE: CHROMIUM_LANGS
  35. # @DEFAULT_UNSET
  36. # @DESCRIPTION:
  37. # List of language packs available for this package.
  38. _chromium_set_l10n_IUSE() {
  39. [[ ${EAPI:-0} == 0 ]] && die "EAPI=${EAPI} is not supported"
  40. local lang
  41. for lang in ${CHROMIUM_LANGS}; do
  42. # Default to enabled since we bundle them anyway.
  43. # USE-expansion will take care of disabling the langs the user has not
  44. # selected via L10N.
  45. IUSE+=" +l10n_${lang}"
  46. done
  47. }
  48. if [[ ${CHROMIUM_LANGS} ]]; then
  49. _chromium_set_l10n_IUSE
  50. fi
  51. # @FUNCTION: chromium_remove_language_paks
  52. # @USAGE:
  53. # @DESCRIPTION:
  54. # Removes pak files from the current directory for languages that the user has
  55. # not selected via the L10N variable.
  56. # Also performs QA checks to ensure CHROMIUM_LANGS has been set correctly.
  57. chromium_remove_language_paks() {
  58. local lang pak
  59. # Look for missing pak files.
  60. for lang in ${CHROMIUM_LANGS}; do
  61. if [[ ! -e ${lang}.pak ]]; then
  62. # https://bugs.gentoo.org/583762
  63. if [[ ${lang} != sr-ME || ! -e me.pak ]]; then
  64. eqawarn "L10N warning: no .pak file for ${lang} (${lang}.pak not found)"
  65. fi
  66. fi
  67. done
  68. # Bug 588198
  69. rm -f fake-bidi.pak || die
  70. # Look for extra pak files.
  71. # Remove pak files that the user does not want.
  72. for pak in *.pak; do
  73. lang=${pak%.pak}
  74. if [[ ${lang} == en-US ]]; then
  75. continue
  76. fi
  77. # https://bugs.gentoo.org/583762
  78. if [[ ${lang} == me ]]; then
  79. if ! has sr-ME ${CHROMIUM_LANGS}; then
  80. eqawarn "L10N warning: no sr-ME in LANGS"
  81. elif ! use l10n_sr-ME; then
  82. rm "${pak}" || die
  83. fi
  84. continue
  85. fi
  86. if ! has ${lang} ${CHROMIUM_LANGS}; then
  87. eqawarn "L10N warning: no ${lang} in LANGS"
  88. continue
  89. fi
  90. if ! use l10n_${lang}; then
  91. rm "${pak}" || die
  92. fi
  93. done
  94. }
  95. chromium_pkg_die() {
  96. if [[ "${EBUILD_PHASE}" != "compile" ]]; then
  97. return
  98. fi
  99. # Prevent user problems like bug #348235.
  100. eshopts_push -s extglob
  101. if is-flagq '-g?(gdb)?([1-9])'; then
  102. ewarn
  103. ewarn "You have enabled debug info (i.e. -g or -ggdb in your CFLAGS/CXXFLAGS)."
  104. ewarn "This produces very large build files causes the linker to consume large"
  105. ewarn "amounts of memory."
  106. ewarn
  107. ewarn "Please try removing -g{,gdb} before reporting a bug."
  108. ewarn
  109. fi
  110. eshopts_pop
  111. # ccache often causes bogus compile failures, especially when the cache gets
  112. # corrupted.
  113. if has ccache ${FEATURES}; then
  114. ewarn
  115. ewarn "You have enabled ccache. Please try disabling ccache"
  116. ewarn "before reporting a bug."
  117. ewarn
  118. fi
  119. # No ricer bugs.
  120. if use_if_iuse custom-cflags; then
  121. ewarn
  122. ewarn "You have enabled the custom-cflags USE flag."
  123. ewarn "Please disable it before reporting a bug."
  124. ewarn
  125. fi
  126. # If the system doesn't have enough memory, the compilation is known to
  127. # fail. Print info about memory to recognize this condition.
  128. einfo
  129. einfo "$(grep MemTotal /proc/meminfo)"
  130. einfo "$(grep SwapTotal /proc/meminfo)"
  131. einfo
  132. }
  133. # @VARIABLE: EGYP_CHROMIUM_COMMAND
  134. # @DESCRIPTION:
  135. # Path to the gyp_chromium script.
  136. : ${EGYP_CHROMIUM_COMMAND:=build/gyp_chromium}
  137. # @VARIABLE: EGYP_CHROMIUM_DEPTH
  138. # @DESCRIPTION:
  139. # Depth for egyp_chromium.
  140. : ${EGYP_CHROMIUM_DEPTH:=.}
  141. # @FUNCTION: egyp_chromium
  142. # @USAGE: [gyp arguments]
  143. # @DESCRIPTION:
  144. # Calls EGYP_CHROMIUM_COMMAND with depth EGYP_CHROMIUM_DEPTH and given
  145. # arguments. The full command line is echoed for logging.
  146. egyp_chromium() {
  147. set -- "${EGYP_CHROMIUM_COMMAND}" --depth="${EGYP_CHROMIUM_DEPTH}" "$@"
  148. echo "$@"
  149. "$@"
  150. }
  151. # @FUNCTION: gyp_use
  152. # @USAGE: <USE flag> [GYP flag] [true suffix] [false suffix]
  153. # @DESCRIPTION:
  154. # If USE flag is set, echo -D[GYP flag]=[true suffix].
  155. #
  156. # If USE flag is not set, echo -D[GYP flag]=[false suffix].
  157. #
  158. # [GYP flag] defaults to use_[USE flag] with hyphens converted to underscores.
  159. #
  160. # [true suffix] defaults to 1. [false suffix] defaults to 0.
  161. gyp_use() {
  162. local gypflag="-D${2:-use_${1//-/_}}="
  163. usex "$1" "${gypflag}" "${gypflag}" "${3-1}" "${4-0}"
  164. }