1 # Copyright 1999-2016 Gentoo Foundation
2 # Distributed under the terms of the GNU General Public License v2
4 # @ECLASS: chromium-2.eclass
6 # Chromium Herd <chromium@gentoo.org>
8 # Mike Gilbert <floppym@gentoo.org>
9 # @BLURB: Shared functions for chromium and google-chrome
11 inherit eutils linux-info
13 if [[ ${PN} == chromium ]]; then
14 IUSE+=" custom-cflags"
17 # @FUNCTION: chromium_suid_sandbox_check_kernel_config
20 # Ensures the system kernel supports features needed for SUID sandbox to work.
21 chromium_suid_sandbox_check_kernel_config() {
22 has "${EAPI:-0}" 0 1 2 3 && die "EAPI=${EAPI} is not supported"
24 if [[ "${MERGE_TYPE}" == "source" || "${MERGE_TYPE}" == "binary" ]]; then
25 # Warn if the kernel does not support features needed for sandboxing.
27 ERROR_PID_NS="PID_NS is required for sandbox to work"
28 ERROR_NET_NS="NET_NS is required for sandbox to work"
29 ERROR_USER_NS="USER_NS is required for sandbox to work"
30 ERROR_SECCOMP_FILTER="SECCOMP_FILTER is required for sandbox to work"
31 # Warn if the kernel does not support features needed for the browser to work
32 # (bug #552576, bug #556286).
33 ERROR_ADVISE_SYSCALLS="CONFIG_ADVISE_SYSCALLS is required for the renderer (bug #552576)"
34 ERROR_COMPAT_VDSO="CONFIG_COMPAT_VDSO causes segfaults (bug #556286)"
35 ERROR_GRKERNSEC="CONFIG_GRKERNSEC breaks sandbox (bug #613668)"
36 CONFIG_CHECK="~PID_NS ~NET_NS ~SECCOMP_FILTER ~USER_NS ~ADVISE_SYSCALLS ~!COMPAT_VDSO ~!GRKERNSEC"
41 # @ECLASS-VARIABLE: CHROMIUM_LANGS
44 # List of language packs available for this package.
46 _chromium_set_l10n_IUSE() {
47 [[ ${EAPI:-0} == 0 ]] && die "EAPI=${EAPI} is not supported"
50 for lang in ${CHROMIUM_LANGS}; do
51 # Default to enabled since we bundle them anyway.
52 # USE-expansion will take care of disabling the langs the user has not
54 IUSE+=" +l10n_${lang}"
58 if [[ ${CHROMIUM_LANGS} ]]; then
59 _chromium_set_l10n_IUSE
62 # @FUNCTION: chromium_remove_language_paks
65 # Removes pak files from the current directory for languages that the user has
66 # not selected via the L10N variable.
67 # Also performs QA checks to ensure CHROMIUM_LANGS has been set correctly.
68 chromium_remove_language_paks() {
71 # Look for missing pak files.
72 for lang in ${CHROMIUM_LANGS}; do
73 if [[ ! -e ${lang}.pak ]]; then
74 # https://bugs.gentoo.org/583762
75 if [[ ${lang} != sr-ME || ! -e me.pak ]]; then
76 eqawarn "L10N warning: no .pak file for ${lang} (${lang}.pak not found)"
82 rm -f fake-bidi.pak || die
84 # Look for extra pak files.
85 # Remove pak files that the user does not want.
89 if [[ ${lang} == en-US ]]; then
93 # https://bugs.gentoo.org/583762
94 if [[ ${lang} == me ]]; then
95 if ! has sr-ME ${CHROMIUM_LANGS}; then
96 eqawarn "L10N warning: no sr-ME in LANGS"
97 elif ! use l10n_sr-ME; then
103 if ! has ${lang} ${CHROMIUM_LANGS}; then
104 eqawarn "L10N warning: no ${lang} in LANGS"
107 if ! use l10n_${lang}; then
114 if [[ "${EBUILD_PHASE}" != "compile" ]]; then
118 # Prevent user problems like bug #348235.
119 eshopts_push -s extglob
120 if is-flagq '-g?(gdb)?([1-9])'; then
122 ewarn "You have enabled debug info (i.e. -g or -ggdb in your CFLAGS/CXXFLAGS)."
123 ewarn "This produces very large build files causes the linker to consume large"
124 ewarn "amounts of memory."
126 ewarn "Please try removing -g{,gdb} before reporting a bug."
131 # ccache often causes bogus compile failures, especially when the cache gets
133 if has ccache ${FEATURES}; then
135 ewarn "You have enabled ccache. Please try disabling ccache"
136 ewarn "before reporting a bug."
141 if use_if_iuse custom-cflags; then
143 ewarn "You have enabled the custom-cflags USE flag."
144 ewarn "Please disable it before reporting a bug."
148 # If the system doesn't have enough memory, the compilation is known to
149 # fail. Print info about memory to recognize this condition.
151 einfo "$(grep MemTotal /proc/meminfo)"
152 einfo "$(grep SwapTotal /proc/meminfo)"
156 # @VARIABLE: EGYP_CHROMIUM_COMMAND
158 # Path to the gyp_chromium script.
159 : ${EGYP_CHROMIUM_COMMAND:=build/gyp_chromium}
161 # @VARIABLE: EGYP_CHROMIUM_DEPTH
163 # Depth for egyp_chromium.
164 : ${EGYP_CHROMIUM_DEPTH:=.}
166 # @FUNCTION: egyp_chromium
167 # @USAGE: [gyp arguments]
169 # Calls EGYP_CHROMIUM_COMMAND with depth EGYP_CHROMIUM_DEPTH and given
170 # arguments. The full command line is echoed for logging.
172 set -- "${EGYP_CHROMIUM_COMMAND}" --depth="${EGYP_CHROMIUM_DEPTH}" "$@"
178 # @USAGE: <USE flag> [GYP flag] [true suffix] [false suffix]
180 # If USE flag is set, echo -D[GYP flag]=[true suffix].
182 # If USE flag is not set, echo -D[GYP flag]=[false suffix].
184 # [GYP flag] defaults to use_[USE flag] with hyphens converted to underscores.
186 # [true suffix] defaults to 1. [false suffix] defaults to 0.
188 local gypflag="-D${2:-use_${1//-/_}}="
189 usex "$1" "${gypflag}" "${gypflag}" "${3-1}" "${4-0}"