1 # Copyright 1999-2015 Gentoo Foundation
2 # Distributed under the terms of the GNU General Public License v2
5 # @ECLASS: chromium-2.eclass
7 # Chromium Herd <chromium@gentoo.org>
9 # Mike Gilbert <floppym@gentoo.org>
10 # @BLURB: Shared functions for chromium and google-chrome
12 inherit eutils linux-info
14 if [[ ${PN} == chromium ]]; then
15 IUSE+=" custom-cflags"
18 # @FUNCTION: chromium_suid_sandbox_check_kernel_config
21 # Ensures the system kernel supports features needed for SUID sandbox to work.
22 chromium_suid_sandbox_check_kernel_config() {
23 has "${EAPI:-0}" 0 1 2 3 && die "EAPI=${EAPI} is not supported"
25 if [[ "${MERGE_TYPE}" == "source" || "${MERGE_TYPE}" == "binary" ]]; then
26 # Warn if the kernel does not support features needed for sandboxing.
28 ERROR_PID_NS="PID_NS is required for sandbox to work"
29 ERROR_NET_NS="NET_NS is required for sandbox to work"
30 ERROR_USER_NS="USER_NS is required for sandbox to work"
31 ERROR_SECCOMP_FILTER="SECCOMP_FILTER is required for sandbox to work"
32 # Warn if the kernel does not support features needed for the browser to work
33 # (bug #552576, bug #556286).
34 ERROR_ADVISE_SYSCALLS="CONFIG_ADVISE_SYSCALLS is required for the renderer (bug #552576)"
35 ERROR_COMPAT_VDSO="CONFIG_COMPAT_VDSO causes segfaults (bug #556286)"
36 CONFIG_CHECK="~PID_NS ~NET_NS ~SECCOMP_FILTER ~USER_NS ~ADVISE_SYSCALLS ~!COMPAT_VDSO"
41 # @ECLASS-VARIABLE: CHROMIUM_LANGS
44 # List of language packs available for this package.
46 _chromium_set_linguas_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
53 # selected via LINGUAS.
54 IUSE+=" +linguas_${lang}"
58 if [[ ${CHROMIUM_LANGS} ]]; then
59 _chromium_set_linguas_IUSE
70 _chromium_strip_pak() {
77 # @FUNCTION: chromium_remove_language_paks
80 # Removes pak files from the current directory for languages that the user has
81 # not selected via the LINGUAS variable.
82 # Also performs QA checks to ensure CHROMIUM_LANGS has been set correctly.
83 chromium_remove_language_paks() {
84 local crlangs=$(_chromium_crlang ${CHROMIUM_LANGS})
85 local present_crlangs=$(_chromium_strip_pak *.pak)
86 local present_langs=$(_chromium_syslang ${present_crlangs})
89 # Look for missing pak files.
90 for lang in ${crlangs}; do
91 if ! has ${lang} ${present_crlangs}; then
92 eqawarn "LINGUAS warning: no .pak file for ${lang} (${lang}.pak not found)"
96 # Look for extra pak files.
97 # Remove pak files that the user does not want.
98 for lang in ${present_langs}; do
99 if [[ ${lang} == en_US ]]; then
102 if ! has ${lang} ${CHROMIUM_LANGS}; then
103 eqawarn "LINGUAS warning: no ${lang} in LANGS"
106 if ! use linguas_${lang}; then
107 rm "$(_chromium_crlang ${lang}).pak" || die
113 if [[ "${EBUILD_PHASE}" != "compile" ]]; then
117 # Prevent user problems like bug #348235.
118 eshopts_push -s extglob
119 if is-flagq '-g?(gdb)?([1-9])'; then
121 ewarn "You have enabled debug info (i.e. -g or -ggdb in your CFLAGS/CXXFLAGS)."
122 ewarn "This produces very large build files causes the linker to consume large"
123 ewarn "amounts of memory."
125 ewarn "Please try removing -g{,gdb} before reporting a bug."
130 # ccache often causes bogus compile failures, especially when the cache gets
132 if has ccache ${FEATURES}; then
134 ewarn "You have enabled ccache. Please try disabling ccache"
135 ewarn "before reporting a bug."
140 if use_if_iuse custom-cflags; then
142 ewarn "You have enabled the custom-cflags USE flag."
143 ewarn "Please disable it before reporting a bug."
147 # If the system doesn't have enough memory, the compilation is known to
148 # fail. Print info about memory to recognize this condition.
150 einfo "$(grep MemTotal /proc/meminfo)"
151 einfo "$(grep SwapTotal /proc/meminfo)"
155 # @VARIABLE: EGYP_CHROMIUM_COMMAND
157 # Path to the gyp_chromium script.
158 : ${EGYP_CHROMIUM_COMMAND:=build/gyp_chromium}
160 # @VARIABLE: EGYP_CHROMIUM_DEPTH
162 # Depth for egyp_chromium.
163 : ${EGYP_CHROMIUM_DEPTH:=.}
165 # @FUNCTION: egyp_chromium
166 # @USAGE: [gyp arguments]
168 # Calls EGYP_CHROMIUM_COMMAND with depth EGYP_CHROMIUM_DEPTH and given
169 # arguments. The full command line is echoed for logging.
171 set -- "${EGYP_CHROMIUM_COMMAND}" --depth="${EGYP_CHROMIUM_DEPTH}" "$@"
177 # @USAGE: <USE flag> [GYP flag] [true suffix] [false suffix]
179 # If USE flag is set, echo -D[GYP flag]=[true suffix].
181 # If USE flag is not set, echo -D[GYP flag]=[false suffix].
183 # [GYP flag] defaults to use_[USE flag] with hyphens converted to underscores.
185 # [true suffix] defaults to 1. [false suffix] defaults to 0.
187 local gypflag="-D${2:-use_${1//-/_}}="
188 usex "$1" "${gypflag}" "${gypflag}" "${3-1}" "${4-0}"