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 eqawarn "L10N warning: no .pak file for ${lang} (${lang}.pak not found)"
79 rm -f fake-bidi.pak || die
80 rm -f fake-bidi.pak.info || die
82 # Look for extra pak files.
83 # Remove pak files that the user does not want.
87 if [[ ${lang} == en-US ]]; then
91 if ! has ${lang} ${CHROMIUM_LANGS}; then
92 eqawarn "L10N warning: no ${lang} in LANGS"
96 if ! use l10n_${lang}; then
98 rm -f "${pak}.info" || die
104 if [[ "${EBUILD_PHASE}" != "compile" ]]; then
108 # Prevent user problems like bug #348235.
109 if ( shopt -s extglob; is-flagq '-g?(gdb)?([1-9])' ); then
111 ewarn "You have enabled debug info (i.e. -g or -ggdb in your CFLAGS/CXXFLAGS)."
112 ewarn "This produces very large build files causes the linker to consume large"
113 ewarn "amounts of memory."
115 ewarn "Please try removing -g{,gdb} before reporting a bug."
119 # ccache often causes bogus compile failures, especially when the cache gets
121 if has ccache ${FEATURES}; then
123 ewarn "You have enabled ccache. Please try disabling ccache"
124 ewarn "before reporting a bug."
129 if use_if_iuse custom-cflags; then
131 ewarn "You have enabled the custom-cflags USE flag."
132 ewarn "Please disable it before reporting a bug."
136 # If the system doesn't have enough memory, the compilation is known to
137 # fail. Print info about memory to recognize this condition.
139 einfo "$(grep MemTotal /proc/meminfo)"
140 einfo "$(grep SwapTotal /proc/meminfo)"
144 # @VARIABLE: EGYP_CHROMIUM_COMMAND
146 # Path to the gyp_chromium script.
147 : ${EGYP_CHROMIUM_COMMAND:=build/gyp_chromium}
149 # @VARIABLE: EGYP_CHROMIUM_DEPTH
151 # Depth for egyp_chromium.
152 : ${EGYP_CHROMIUM_DEPTH:=.}
154 # @FUNCTION: egyp_chromium
155 # @USAGE: [gyp arguments]
157 # Calls EGYP_CHROMIUM_COMMAND with depth EGYP_CHROMIUM_DEPTH and given
158 # arguments. The full command line is echoed for logging.
160 set -- "${EGYP_CHROMIUM_COMMAND}" --depth="${EGYP_CHROMIUM_DEPTH}" "$@"
166 # @USAGE: <USE flag> [GYP flag] [true suffix] [false suffix]
168 # If USE flag is set, echo -D[GYP flag]=[true suffix].
170 # If USE flag is not set, echo -D[GYP flag]=[false suffix].
172 # [GYP flag] defaults to use_[USE flag] with hyphens converted to underscores.
174 # [true suffix] defaults to 1. [false suffix] defaults to 0.
176 local gypflag="-D${2:-use_${1//-/_}}="
177 usex "$1" "${gypflag}" "${gypflag}" "${3-1}" "${4-0}"