1 # Copyright 2009-2020 Gentoo Authors
2 # Distributed under the terms of the GNU General Public License v2
5 PYTHON_COMPAT=( python2_7 )
7 CHROMIUM_LANGS="am ar bg bn ca cs da de el en-GB es es-419 et fa fi fil fr gu he
8 hi hr hu id it ja kn ko lt lv ml mr ms nb nl pl pt-BR pt-PT ro ru sk sl sr
9 sv sw ta te th tr uk vi zh-CN zh-TW"
11 inherit check-reqs chromium-2 desktop flag-o-matic multilib ninja-utils pax-utils portability python-any-r1 readme.gentoo-r1 toolchain-funcs xdg-utils
13 DESCRIPTION="Open-source version of Google Chrome web browser"
14 HOMEPAGE="http://chromium.org/"
15 SRC_URI="https://commondatastorage.googleapis.com/chromium-browser-official/${P}.tar.xz"
19 KEYWORDS="~amd64 ~arm64 ~x86"
20 IUSE="+closure-compile component-build cups cpu_flags_arm_neon gnome-keyring +hangouts kerberos pic +proprietary-codecs pulseaudio selinux +suid +system-ffmpeg +system-icu +system-libvpx +tcmalloc widevine"
21 RESTRICT="!system-ffmpeg? ( proprietary-codecs? ( bindist ) )"
22 REQUIRED_USE="component-build? ( !suid )"
25 >=app-accessibility/at-spi2-atk-2.26:2
27 cups? ( >=net-print/cups-1.3.11:= )
31 system-icu? ( >=dev-libs/icu-65:= )
32 >=dev-libs/libxml2-2.9.4-r3:=[icu]
36 >=dev-libs/re2-0.2019.08.01:=
37 gnome-keyring? ( >=gnome-base/libgnome-keyring-3.12:= )
38 >=media-libs/alsa-lib-1.0.19:=
39 media-libs/fontconfig:=
41 >=media-libs/harfbuzz-2.4.0:0=[icu(-)]
42 media-libs/libjpeg-turbo:=
44 system-libvpx? ( media-libs/libvpx:=[postproc,svc] )
45 >=media-libs/openh264-1.6.0:=
46 pulseaudio? ( media-sound/pulseaudio:= )
48 >=media-video/ffmpeg-4:=
50 media-video/ffmpeg[-samba]
51 >=net-fs/samba-4.5.10-r1[-debug(-)]
53 >=media-libs/opus-1.3.1:=
62 x11-libs/libXcomposite:=
67 >=x11-libs/libXi-1.6.0:=
70 x11-libs/libXScrnSaver:=
75 >=media-libs/libwebp-0.4.0:=
76 sys-libs/zlib:=[minizip]
77 kerberos? ( virtual/krb5 )
79 # For nvidia-drivers blocker, see bug #413637 .
80 RDEPEND="${COMMON_DEPEND}
84 selinux? ( sec-policy/selinux-chromium )
85 tcmalloc? ( !<x11-drivers/nvidia-drivers-331.20 )
87 DEPEND="${COMMON_DEPEND}
89 # dev-vcs/git - https://bugs.gentoo.org/593476
99 >=dev-util/gperf-3.0.3
100 >=dev-util/ninja-1.7.2
101 >=net-libs/nodejs-7.6.0[inspector]
102 sys-apps/hwids[usb(+)]
103 >=sys-devel/bison-2.4.3
105 closure-compile? ( virtual/jre )
109 : ${CHROMIUM_FORCE_CLANG=no}
111 if [[ ${CHROMIUM_FORCE_CLANG} == yes ]]; then
112 BDEPEND+=" >=sys-devel/clang-7"
115 if ! has chromium_pkg_die ${EBUILD_DEATH_HOOKS}; then
116 EBUILD_DEATH_HOOKS+=" chromium_pkg_die";
119 DISABLE_AUTOFORMATTING="yes"
121 Some web pages may require additional fonts to display properly.
122 Try installing some of the following packages if some characters
123 are not displayed properly:
124 - media-fonts/arphicfonts
126 - media-fonts/ipamonafont
128 - media-fonts/ja-ipafonts
129 - media-fonts/takao-fonts
130 - media-fonts/wqy-microhei
131 - media-fonts/wqy-zenhei
133 To fix broken icons on the Downloads page, you should install an icon
134 theme that covers the appropriate MIME types, and configure this as your
137 For native file dialogs in KDE, install kde-apps/kdialog.
141 "${FILESDIR}/chromium-compiler-r11.patch"
142 "${FILESDIR}/chromium-fix-char_traits.patch"
143 "${FILESDIR}/chromium-78-protobuf-export.patch"
144 "${FILESDIR}/chromium-79-gcc-alignas.patch"
145 "${FILESDIR}/chromium-80-gcc-quiche.patch"
146 "${FILESDIR}/chromium-80-gcc-blink.patch"
147 "${FILESDIR}/chromium-81-gcc-noexcept.patch"
148 "${FILESDIR}/chromium-81-gcc-constexpr.patch"
152 if [[ ${MERGE_TYPE} != binary ]]; then
153 local -x CPP="$(tc-getCXX) -E"
154 if tc-is-gcc && ! ver_test "$(gcc-version)" -ge 8.0; then
155 die "At least gcc 8.0 is required"
157 # component build hangs with tcmalloc enabled due to sandbox issue, bug #695976.
158 if has usersandbox ${FEATURES} && use tcmalloc && use component-build; then
159 die "Component build with tcmalloc requires FEATURES=-usersandbox."
161 if [[ ${CHROMIUM_FORCE_CLANG} == yes ]] || tc-is-clang; then
162 if use component-build; then
163 die "Component build with clang requires fuzzer headers."
168 # Check build requirements, bug #541816 and bug #471810 .
169 CHECKREQS_MEMORY="3G"
170 CHECKREQS_DISK_BUILD="7G"
171 if ( shopt -s extglob; is-flagq '-g?(gdb)?([1-9])' ); then
172 CHECKREQS_DISK_BUILD="25G"
173 if ! use component-build; then
174 CHECKREQS_MEMORY="16G"
187 chromium_suid_sandbox_check_kernel_config
191 # Calling this here supports resumption via FEATURES=keepwork
196 mkdir -p third_party/node/linux/node-linux-x64/bin || die
197 ln -s "${EPREFIX}"/usr/bin/node third_party/node/linux/node-linux-x64/bin/node || die
200 base/third_party/cityhash
201 base/third_party/double_conversion
202 base/third_party/dynamic_annotations
204 base/third_party/nspr
205 base/third_party/superfasthash
206 base/third_party/symbolize
207 base/third_party/valgrind
208 base/third_party/xdg_mime
209 base/third_party/xdg_user_dirs
210 buildtools/third_party/libc++
211 buildtools/third_party/libc++abi
212 chrome/third_party/mozilla_security_manager
213 courgette/third_party
214 net/third_party/mozilla_security_manager
217 net/third_party/uri_template
218 third_party/abseil-cpp
220 third_party/angle/src/common/third_party/base
221 third_party/angle/src/common/third_party/smhasher
222 third_party/angle/src/common/third_party/xxhash
223 third_party/angle/src/third_party/compiler
224 third_party/angle/src/third_party/libXNVCtrl
225 third_party/angle/src/third_party/trace_event
226 third_party/angle/src/third_party/volk
227 third_party/angle/third_party/glslang
228 third_party/angle/third_party/spirv-headers
229 third_party/angle/third_party/spirv-tools
230 third_party/angle/third_party/vulkan-headers
231 third_party/angle/third_party/vulkan-loader
232 third_party/angle/third_party/vulkan-tools
233 third_party/angle/third_party/vulkan-validation-layers
234 third_party/apple_apsl
237 third_party/boringssl
238 third_party/boringssl/src/third_party/fiat
240 third_party/breakpad/breakpad/src/third_party/curl
242 third_party/cacheinvalidation
244 third_party/catapult/common/py_vulcanize/third_party/rcssmin
245 third_party/catapult/common/py_vulcanize/third_party/rjsmin
246 third_party/catapult/third_party/beautifulsoup4
247 third_party/catapult/third_party/html5lib-python
248 third_party/catapult/third_party/polymer
249 third_party/catapult/third_party/six
250 third_party/catapult/tracing/third_party/d3
251 third_party/catapult/tracing/third_party/gl-matrix
252 third_party/catapult/tracing/third_party/jpeg-js
253 third_party/catapult/tracing/third_party/jszip
254 third_party/catapult/tracing/third_party/mannwhitneyu
255 third_party/catapult/tracing/third_party/oboe
256 third_party/catapult/tracing/third_party/pako
259 third_party/closure_compiler
261 third_party/crashpad/crashpad/third_party/lss
262 third_party/crashpad/crashpad/third_party/zlib
264 third_party/cros_system_api
267 third_party/depot_tools
268 third_party/devscripts
269 third_party/devtools-frontend
270 third_party/devtools-frontend/src/front_end/third_party/fabricjs
271 third_party/devtools-frontend/src/front_end/third_party/wasmparser
272 third_party/devtools-frontend/src/third_party
273 third_party/dom_distiller_js
274 third_party/emoji-segmenter
275 third_party/flatbuffers
277 third_party/libgifcodec
279 third_party/google_input_tools
280 third_party/google_input_tools/third_party/closure_library
281 third_party/google_input_tools/third_party/closure_library/third_party/closure
282 third_party/googletest
285 third_party/inspector_protocol
288 third_party/jstemplate
290 third_party/leveldatabase
291 third_party/libXNVCtrl
292 third_party/libaddressinput
294 third_party/libaom/source/libaom/third_party/vector
295 third_party/libaom/source/libaom/third_party/x86inc
296 third_party/libjingle
297 third_party/libphonenumber
298 third_party/libsecret
303 third_party/libxml/chromium
308 third_party/markupsafe
310 third_party/metrics_proto
314 third_party/node/node_modules/polymer-bundler/lib/third_party/UglifyJS2
315 third_party/one_euro_filter
316 third_party/openscreen
317 third_party/openscreen/src/third_party/tinycbor/src/src
320 third_party/pdfium/third_party/agg23
321 third_party/pdfium/third_party/base
322 third_party/pdfium/third_party/bigint
323 third_party/pdfium/third_party/freetype
324 third_party/pdfium/third_party/lcms
325 third_party/pdfium/third_party/libopenjpeg20
326 third_party/pdfium/third_party/libpng16
327 third_party/pdfium/third_party/libtiff
328 third_party/pdfium/third_party/skia_shared
333 third_party/private-join-and-compute
335 third_party/protobuf/third_party/six
340 third_party/simplejson
342 third_party/skia/include/third_party/skcms
343 third_party/skia/include/third_party/vulkan
344 third_party/skia/third_party/skcms
345 third_party/skia/third_party/vulkan
347 third_party/spirv-headers
348 third_party/SPIRV-Tools
350 third_party/swiftshader
351 third_party/swiftshader/third_party/llvm-7.0
352 third_party/swiftshader/third_party/llvm-subzero
353 third_party/swiftshader/third_party/marl
354 third_party/swiftshader/third_party/subzero
355 third_party/swiftshader/third_party/SPIRV-Headers/include/spirv/unified1
359 third_party/web-animations-js
360 third_party/webdriver
362 third_party/webrtc/common_audio/third_party/fft4g
363 third_party/webrtc/common_audio/third_party/spl_sqrt_floor
364 third_party/webrtc/modules/third_party/fft
365 third_party/webrtc/modules/third_party/g711
366 third_party/webrtc/modules/third_party/g722
367 third_party/webrtc/rtc_base/third_party/base64
368 third_party/webrtc/rtc_base/third_party/sigslot
372 third_party/zlib/google
373 tools/grit/third_party/six
374 url/third_party/mozilla
375 v8/src/third_party/siphash
376 v8/src/third_party/valgrind
377 v8/src/third_party/utf8-decoder
378 v8/third_party/inspector_protocol
381 # gyp -> gn leftovers
382 base/third_party/libevent
384 third_party/speech-dispatcher
386 third_party/xdg-utils
387 third_party/yasm/run_yasm.py
389 if ! use system-ffmpeg; then
390 keeplibs+=( third_party/ffmpeg third_party/opus )
392 if ! use system-icu; then
393 keeplibs+=( third_party/icu )
395 if ! use system-libvpx; then
396 keeplibs+=( third_party/libvpx )
397 keeplibs+=( third_party/libvpx/source/libvpx/third_party/x86inc )
399 if use tcmalloc; then
400 keeplibs+=( third_party/tcmalloc )
403 # Remove most bundled libraries. Some are still needed.
404 build/linux/unbundle/remove_bundled_libraries.py "${keeplibs[@]}" --do-remove || die
408 # Calling this here supports resumption via FEATURES=keepwork
413 # Make sure the build system will use the right tools, bug #340795.
414 tc-export AR CC CXX NM
416 if [[ ${CHROMIUM_FORCE_CLANG} == yes ]] && ! tc-is-clang; then
417 # Force clang since gcc is pretty broken at the moment.
420 strip-unsupported-flags
424 myconf_gn+=" is_clang=true clang_use_chrome_plugins=false"
426 myconf_gn+=" is_clang=false"
429 # Define a custom toolchain for GN
430 myconf_gn+=" custom_toolchain=\"//build/toolchain/linux/unbundle:default\""
432 if tc-is-cross-compiler; then
433 tc-export BUILD_{AR,CC,CXX,NM}
434 myconf_gn+=" host_toolchain=\"//build/toolchain/linux/unbundle:host\""
435 myconf_gn+=" v8_snapshot_toolchain=\"//build/toolchain/linux/unbundle:host\""
437 myconf_gn+=" host_toolchain=\"//build/toolchain/linux/unbundle:default\""
440 # GN needs explicit config for Debug/Release as opposed to inferring it from build directory.
441 myconf_gn+=" is_debug=false"
443 # Component build isn't generally intended for use by end users. It's mostly useful
444 # for development and debugging.
445 myconf_gn+=" is_component_build=$(usex component-build true false)"
447 myconf_gn+=" use_allocator=$(usex tcmalloc \"tcmalloc\" \"none\")"
449 # Disable nacl, we can't build without pnacl (http://crbug.com/269560).
450 myconf_gn+=" enable_nacl=false"
452 # Use system-provided libraries.
453 # TODO: freetype -- remove sources (https://bugs.chromium.org/p/pdfium/issues/detail?id=733).
454 # TODO: use_system_hunspell (upstream changes needed).
455 # TODO: use_system_libsrtp (bug #459932).
456 # TODO: use_system_protobuf (bug #525560).
457 # TODO: use_system_ssl (http://crbug.com/58087).
458 # TODO: use_system_sqlite (http://crbug.com/22208).
460 # libevent: https://bugs.gentoo.org/593458
461 local gn_system_libraries=(
465 # Need harfbuzz_from_pkgconfig target
479 if use system-ffmpeg; then
480 gn_system_libraries+=( ffmpeg opus )
482 if use system-icu; then
483 gn_system_libraries+=( icu )
485 if use system-libvpx; then
486 gn_system_libraries+=( libvpx )
488 build/linux/unbundle/replace_gn_files.py --system-libraries "${gn_system_libraries[@]}" || die
490 # See dependency logic in third_party/BUILD.gn
491 myconf_gn+=" use_system_harfbuzz=true"
493 # Optional dependencies.
494 myconf_gn+=" closure_compile=$(usex closure-compile true false)"
495 myconf_gn+=" enable_hangout_services_extension=$(usex hangouts true false)"
496 myconf_gn+=" enable_widevine=$(usex widevine true false)"
497 myconf_gn+=" use_cups=$(usex cups true false)"
498 myconf_gn+=" use_gnome_keyring=$(usex gnome-keyring true false)"
499 myconf_gn+=" use_kerberos=$(usex kerberos true false)"
500 myconf_gn+=" use_pulseaudio=$(usex pulseaudio true false)"
502 # TODO: link_pulseaudio=true for GN.
504 myconf_gn+=" fieldtrial_testing_like_official_build=true"
506 # Never use bundled gold binary. Disable gold linker flags for now.
507 # Do not use bundled clang.
508 # Trying to use gold results in linker crash.
509 myconf_gn+=" use_gold=false use_sysroot=false linux_use_bundled_binutils=false use_custom_libcxx=false"
511 # Disable forced lld, bug 641556
512 myconf_gn+=" use_lld=false"
514 ffmpeg_branding="$(usex proprietary-codecs Chrome Chromium)"
515 myconf_gn+=" proprietary_codecs=$(usex proprietary-codecs true false)"
516 myconf_gn+=" ffmpeg_branding=\"${ffmpeg_branding}\""
518 # Set up Google API keys, see http://www.chromium.org/developers/how-tos/api-keys .
519 # Note: these are for Gentoo use ONLY. For your own distribution,
520 # please get your own set of keys. Feel free to contact chromium@gentoo.org
522 local google_api_key="AIzaSyDEAOvatFo0eTgsV_ZlEzx0ObmepsMzfAc"
523 local google_default_client_id="329227923882.apps.googleusercontent.com"
524 local google_default_client_secret="vgKG0NNv7GoDpbtoFNLxCUXu"
525 myconf_gn+=" google_api_key=\"${google_api_key}\""
526 myconf_gn+=" google_default_client_id=\"${google_default_client_id}\""
527 myconf_gn+=" google_default_client_secret=\"${google_default_client_secret}\""
528 local myarch="$(tc-arch)"
530 # Avoid CFLAGS problems, bug #352457, bug #390147.
531 if ! use custom-cflags; then
532 replace-flags "-Os" "-O2"
535 # Prevent linker from running out of address space, bug #471810 .
540 # Prevent libvpx build failures. Bug 530248, 544702, 546984.
541 if [[ ${myarch} == amd64 || ${myarch} == x86 ]]; then
542 filter-flags -mno-mmx -mno-sse2 -mno-ssse3 -mno-sse4.1 -mno-avx -mno-avx2
546 if [[ $myarch = amd64 ]] ; then
547 myconf_gn+=" target_cpu=\"x64\""
548 ffmpeg_target_arch=x64
549 elif [[ $myarch = x86 ]] ; then
550 myconf_gn+=" target_cpu=\"x86\""
551 ffmpeg_target_arch=ia32
553 # This is normally defined by compiler_cpu_abi in
554 # build/config/compiler/BUILD.gn, but we patch that part out.
555 append-flags -msse2 -mfpmath=sse -mmmx
556 elif [[ $myarch = arm64 ]] ; then
557 myconf_gn+=" target_cpu=\"arm64\""
558 ffmpeg_target_arch=arm64
559 elif [[ $myarch = arm ]] ; then
560 myconf_gn+=" target_cpu=\"arm\""
561 ffmpeg_target_arch=$(usex cpu_flags_arm_neon arm-neon arm)
563 die "Failed to determine target arch, got '$myarch'."
566 # Make sure that -Werror doesn't get added to CFLAGS by the build system.
567 # Depending on GCC version the warnings are different and we don't want
568 # the build to fail because of that.
569 myconf_gn+=" treat_warnings_as_errors=false"
571 # Disable fatal linker warnings, bug 506268.
572 myconf_gn+=" fatal_linker_warnings=false"
575 export TMPDIR="${WORKDIR}/temp"
576 mkdir -p -m 755 "${TMPDIR}" || die
578 # https://bugs.gentoo.org/654216
579 addpredict /dev/dri/ #nowarn
581 #if ! use system-ffmpeg; then
583 local build_ffmpeg_args=""
584 if use pic && [[ "${ffmpeg_target_arch}" == "ia32" ]]; then
585 build_ffmpeg_args+=" --disable-asm"
588 # Re-configure bundled ffmpeg. See bug #491378 for example reasons.
589 einfo "Configuring bundled ffmpeg..."
590 pushd third_party/ffmpeg > /dev/null || die
591 chromium/scripts/build_ffmpeg.py linux ${ffmpeg_target_arch} \
592 --branding ${ffmpeg_branding} -- ${build_ffmpeg_args} || die
593 chromium/scripts/copy_config.sh || die
594 chromium/scripts/generate_gn.py || die
595 popd > /dev/null || die
598 # Chromium relies on this, but was disabled in >=clang-10, crbug.com/1042470
599 append-cxxflags $(test-flags-CXX -flax-vector-conversions=all)
601 # Explicitly disable ICU data file support for system-icu builds.
602 if use system-icu; then
603 myconf_gn+=" icu_use_data_file=false"
606 einfo "Configuring Chromium..."
607 set -- gn gen --args="${myconf_gn} ${EXTRA_GN}" out/Release
613 # Final link uses lots of file descriptors.
616 # Calling this here supports resumption via FEATURES=keepwork
619 #"${EPYTHON}" tools/clang/scripts/update.py --force-local-build --gcc-toolchain /usr --skip-checkout --use-system-cmake --without-android || die
621 # Build mksnapshot and pax-mark it.
623 for x in mksnapshot v8_context_snapshot_generator; do
624 if tc-is-cross-compiler; then
625 eninja -C out/Release "host/${x}"
626 pax-mark m "out/Release/host/${x}"
628 eninja -C out/Release "${x}"
629 pax-mark m "out/Release/${x}"
633 # Even though ninja autodetects number of CPUs, we respect
634 # user's options, for debugging with -j 1 or any other reason.
635 eninja -C out/Release chrome chromedriver
636 use suid && eninja -C out/Release chrome_sandbox
638 pax-mark m out/Release/chrome
640 # Build manpage; bug #684550
641 sed -e 's|@@PACKAGE@@|chromium-browser|g;
642 s|@@MENUNAME@@|Chromium|g;' \
643 chrome/app/resources/manpage.1.in > \
644 out/Release/chromium-browser.1 || die
646 # Build desktop file; bug #706786
647 sed -e 's|@@MENUNAME@@|Chromium|g;
648 s|@@USR_BIN_SYMLINK_NAME@@|chromium-browser|g;
649 s|@@PACKAGE@@|chromium-browser|g;
650 s|\(^Exec=\)/usr/bin/|\1|g;' \
651 chrome/installer/linux/common/desktop.template > \
652 out/Release/chromium-browser-chromium.desktop || die
656 local CHROMIUM_HOME="/usr/$(get_libdir)/chromium-browser"
657 exeinto "${CHROMIUM_HOME}"
658 doexe out/Release/chrome
661 newexe out/Release/chrome_sandbox chrome-sandbox
662 fperms 4755 "${CHROMIUM_HOME}/chrome-sandbox"
665 doexe out/Release/chromedriver
667 local sedargs=( -e "s:/usr/lib/:/usr/$(get_libdir)/:g" )
668 sed "${sedargs[@]}" "${FILESDIR}/chromium-launcher-r3.sh" > chromium-launcher.sh || die
669 doexe chromium-launcher.sh
671 # It is important that we name the target "chromium-browser",
672 # xdg-utils expect it; bug #355517.
673 dosym "${CHROMIUM_HOME}/chromium-launcher.sh" /usr/bin/chromium-browser
674 # keep the old symlink around for consistency
675 dosym "${CHROMIUM_HOME}/chromium-launcher.sh" /usr/bin/chromium
677 dosym "${CHROMIUM_HOME}/chromedriver" /usr/bin/chromedriver
679 # Allow users to override command-line options, bug #357629.
680 insinto /etc/chromium
681 newins "${FILESDIR}/chromium.default" "default"
683 pushd out/Release/locales > /dev/null || die
684 chromium_remove_language_paks
687 insinto "${CHROMIUM_HOME}"
688 doins out/Release/*.bin
689 doins out/Release/*.pak
690 doins out/Release/*.so
692 if ! use system-icu; then
693 doins out/Release/icudtl.dat
696 doins -r out/Release/locales
697 doins -r out/Release/resources
699 if [[ -d out/Release/swiftshader ]]; then
700 insinto "${CHROMIUM_HOME}/swiftshader"
701 doins out/Release/swiftshader/*.so
706 for size in 16 24 32 48 64 128 256 ; do
708 16|32) branding="chrome/app/theme/default_100_percent/chromium" ;;
709 *) branding="chrome/app/theme/chromium" ;;
711 newicon -s ${size} "${branding}/product_logo_${size}.png" \
715 # Install desktop entry
716 domenu out/Release/chromium-browser-chromium.desktop
718 # Install GNOME default application entry (bug #303100).
719 insinto /usr/share/gnome-control-center/default-apps
720 newins "${FILESDIR}"/chromium-browser.xml chromium-browser.xml
722 # Install manpage; bug #684550
723 doman out/Release/chromium-browser.1
724 dosym chromium-browser.1 /usr/share/man/man1/chromium.1
726 readme.gentoo_create_doc
730 xdg_icon_cache_update
731 xdg_desktop_database_update
735 xdg_icon_cache_update
736 xdg_desktop_database_update
737 readme.gentoo_print_elog