Mike Gilbert avatar Mike Gilbert committed d165c3e

Add functions to chromium.eclass.

Comments (0)

Files changed (1)

eclass/chromium.eclass

 # @MAINTAINER:
 # Chromium Herd <chromium@gentoo.org>
 # @AUTHOR:
-# Mike Gilbert <floppym@gentoo.org
+# Mike Gilbert <floppym@gentoo.org>
 # @BLURB: Shared functions for chromium and google-chrome
 
 inherit eutils fdo-mime gnome2-utils linux-info
 # @DESCRIPTION:
 # Ensures the system kernel is configured for full Chromium functionality.
 chromium_check_kernel_config() {
+	has "${EAPI:-0}" 0 1 2 3 && die "EAPI=${EAPI} is not supported"
+
 	if [[ "${MERGE_TYPE}" == "source" || "${MERGE_TYPE}" == "binary" ]]; then
 		# Warn if the kernel does not support features needed for sandboxing.
 		# Bug #363987.
 	fi
 }
 
+# @ECLASS-VARIABLE: CHROMIUM_LANGS
+# @DEFAULT_UNSET
+# @DESCRIPTION:
+# List of language packs available for this package.
+
+_chromium_set_linguas_IUSE() {
+	[[ ${EAPI:-0} == 0 ]] && die "EAPI=${EAPI} is not supported"
+
+	local lang
+	for lang in ${CHROMIUM_LANGS}; do
+		# Default to enabled since we bundle them anyway.
+		# USE-expansion will take care of disabling the langs the user has not
+		# selected via LINGUAS.
+		IUSE+=" +linguas_${lang}"
+	done
+}
+
+if [[ ${CHROMIUM_LANGS} ]]; then
+	_chromium_set_linguas_IUSE
+fi
+
 _chromium_crlang() {
 	local x
 	for x in "$@"; do
 # @FUNCTION: chromium_remove_language_paks
 # @USAGE:
 # @DESCRIPTION:
-# Remove pak files from the current directory for languages that the user has
+# Removes pak files from the current directory for languages that the user has
 # not selected via the LINGUAS variable.
+# Also performs QA checks to ensure CHROMIUM_LANGS has been set correctly.
 chromium_remove_language_paks() {
-	local crlangs=$(_chromium_crlang ${LANGS})
+	local crlangs=$(_chromium_crlang ${CHROMIUM_LANGS})
 	local present_crlangs=$(_chromium_strip_pak *.pak)
 	local present_langs=$(_chromium_syslang ${present_crlangs})
 	local lang
 		if [[ ${lang} == en_US ]]; then
 			continue
 		fi
-		if ! has ${lang} ${LANGS}; then
+		if ! has ${lang} ${CHROMIUM_LANGS}; then
 			eqawarn "LINGUAS warning: no ${lang} in LANGS"
 			continue
 		fi
 chromium_pkg_postrm() {
 	gnome2_icon_cache_update
 }
+
+chromium_pkg_die() {
+	if [[ "${EBUILD_PHASE}" != "compile" ]]; then
+		return
+	fi
+
+	# Prevent user problems like bug #348235.
+	eshopts_push -s extglob
+	if is-flagq '-g?(gdb)?([1-9])'; then
+		ewarn
+		ewarn "You have enabled debug info (i.e. -g or -ggdb in your CFLAGS/CXXFLAGS)."
+		ewarn "Please try removing -g{,gdb} before reporting a bug."
+		ewarn
+	fi
+	eshopts_pop
+
+	# ccache often causes bogus compile failures, especially when the cache gets
+	# corrupted.
+	if has ccache ${FEATURES}; then
+		ewarn
+		ewarn "You have enabled ccache. Please try disabling ccache"
+		ewarn "before reporting a bug."
+		ewarn
+	fi
+
+	# No ricer bugs.
+	if use_if_iuse custom-cflags; then
+		ewarn
+		ewarn "You have enabled the custom-cflags USE flag."
+		ewarn "Please disable it before reporting a bug."
+		ewarn
+	fi
+
+	# If the system doesn't have enough memory, the compilation is known to
+	# fail. Print info about memory to recognize this condition.
+	einfo
+	einfo "$(grep MemTotal /proc/meminfo)"
+	einfo "$(grep SwapTotal /proc/meminfo)"
+	einfo
+}
+
+# @VARIABLE: EGYP_CHROMIUM_COMMAND
+# @DESCRIPTION:
+# Path to the gyp_chromium script.
+: ${EGYP_CHROMIUM_COMMAND:=build/gyp_chromium}
+
+# @VARIABLE: EGYP_CHROMIUM_DEPTH
+# @DESCRIPTION:
+# Depth for egyp_chromium.
+: ${EGYP_CHROMIUM_DEPTH:=.}
+
+# @FUNCTION: egyp_chromium
+# @USAGE: [gyp arguments]
+# @DESCRIPTION:
+# Calls EGYP_CHROMIUM_COMMAND with depth EGYP_CHROMIUM_DEPTH and given
+# arguments. The full command line is echoed for logging.
+egyp_chromium() {
+	set -- "${EGYP_CHROMIUM_COMMAND}" --depth="${EGYP_CHROMIUM_DEPTH}" "$@"
+	echo "$@"
+	"$@"
+}
+
+# @FUNCTION: gyp_use
+# @USAGE: <USE flag> [GYP flag] [true suffix] [false suffix]
+# @DESCRIPTION:
+# If USE flag is set, echo -D[GYP flag]=[true suffix].
+#
+# If USE flag is not set, echo -D[GYP flag]=[false suffix].
+#
+# [GYP flag] defaults to use_[USE flag] with underscores converted to hyphens.
+#
+# [true suffix] defaults to 1. [false suffix] defaults to 0.
+gyp_use() {
+	local gypflag="-D${2:-use_${1//-/_}}="
+	usex "$1" "${gypflag}" "${gypflag}"  "${3-1}" "${4-0}"
+}
+
+# @FUNCTION: get_bundled_v8_version
+# @USAGE: [path to version.cc]
+# @DESCRIPTION:
+# Outputs the version of v8 parsed from a (bundled) copy of the source code.
+chromium_bundled_v8_version() {
+	local vf=${1:-v8/src/version.cc}
+	local major minor build patch
+	major=$(sed -ne 's/#define MAJOR_VERSION *\([0-9]*\)/\1/p' "${vf}")
+	minor=$(sed -ne 's/#define MINOR_VERSION *\([0-9]*\)/\1/p' "${vf}")
+	build=$(sed -ne 's/#define BUILD_NUMBER *\([0-9]*\)/\1/p' "${vf}")
+	patch=$(sed -ne 's/#define PATCH_LEVEL *\([0-9]*\)/\1/p' "${vf}")
+	echo "${major}.${minor}.${build}.${patch}"
+}
+
+# @FUNCTION: get_installed_v8_version
+# @USAGE:
+# @DESCRIPTION
+# Outputs the version of dev-lang/v8 currently installed on the host system.
+chromium_installed_v8_version() {
+	local cpf=$(best_version dev-lang/v8)
+	local pvr=${cpf#dev-lang/v8-}
+	echo "${pvr%-r*}"
+}
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.