# Copyright 2009-2025 Gentoo Authors
# Distributed under the terms of the GNU General Public License v2
EAPI=8
# PACKAGING NOTES
# Upstream roll their bundled Clang every two weeks, and the bundled Rust
# is rolled regularly and depends on that. While we do our best to build
# with system Clang, we may eventually hit the point where we need to use
# the bundled Clang due to the use of prerelease features.
# USE=bundled-toolchain is intended for users who want to use the same toolchain
# as the upstream releases. It's also a good fallback in case we fall behind
# and need to get a release out quickly (less likely with `dev` in-tree).
# We can't rely on it as a default since the toolchain is only shipped for x86-64;
# other architectures will need to use system toolchain.
# Since m133 we are using CI-generated tarballs from
# https://github.com/chromium-linux-tarballs/chromium-tarballs/
# These are bit-for-bit identical to the official releases, but are built
# using an external CI system that we have some control over, in case
# issues pop up again with official tarball generation.
GN_MIN_VER=0.2235
# chromium-tools/get-chromium-toolchain-strings.py
TEST_FONT=a28b222b79851716f8358d2800157d9ffe117b3545031ae51f69b7e1e1b9a969
BUNDLED_CLANG_VER=llvmorg-22-init-8940-g4d4cb757-4
BUNDLED_RUST_VER=15283f6fe95e5b604273d13a428bab5fc0788f5a-1
RUST_SHORT_HASH=${BUNDLED_RUST_VER:0:10}-${BUNDLED_RUST_VER##*-}
NODE_VER=22.11.0
VIRTUALX_REQUIRED="pgo"
CHROMIUM_LANGS="af am ar bg bn ca cs da de el en-GB es es-419 et fa fi fil fr gu he
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
sv sw ta te th tr uk ur vi zh-CN zh-TW"
LLVM_COMPAT=( 20 )
PYTHON_COMPAT=( python3_{11..13} )
PYTHON_REQ_USE="xml(+)"
RUST_MIN_VER=1.78.0
RUST_NEEDS_LLVM="yes please"
RUST_OPTIONAL="yes" # Not actually optional, but we don't need system Rust (or LLVM) with USE=bundled-toolchain
inherit check-reqs chromium-2 desktop flag-o-matic llvm-r1 multiprocessing ninja-utils pax-utils
inherit python-any-r1 readme.gentoo-r1 rust systemd toolchain-funcs virtualx xdg-utils
DESCRIPTION="Open-source version of Google Chrome web browser"
HOMEPAGE="https://www.chromium.org/"
PPC64_HASH="a85b64f07b489b8c6fdb13ecf79c16c56c560fc6"
PATCH_V="${PV%%\.*}"
COPIUM_COMMIT="46d68912da04d9ed14856c50db986d5c8e786a4b"
SRC_URI="https://github.com/chromium-linux-tarballs/chromium-tarballs/releases/download/${PV}/chromium-${PV}-linux.tar.xz
!bundled-toolchain? (
https://gitlab.com/Matt.Jolly/chromium-patches/-/archive/${PATCH_V}/chromium-patches-${PATCH_V}.tar.bz2
https://codeberg.org/selfisekai/copium/archive/${COPIUM_COMMIT}.tar.gz
-> chromium-patches-copium-${COPIUM_COMMIT:0:10}.tar.gz
)
bundled-toolchain? (
https://gsdview.appspot.com/chromium-browser-clang/Linux_x64/clang-${BUNDLED_CLANG_VER}.tar.xz
-> chromium-clang-${BUNDLED_CLANG_VER}.tar.xz
https://commondatastorage.googleapis.com/chromium-browser-clang/Linux_x64/rust-toolchain-${BUNDLED_RUST_VER}-${BUNDLED_CLANG_VER%-*}.tar.xz
-> chromium-rust-toolchain-${RUST_SHORT_HASH}-${BUNDLED_CLANG_VER%-*}.tar.xz
)
test? (
https://github.com/chromium-linux-tarballs/chromium-tarballs/releases/download/${PV}/chromium-${PV}-linux-testdata.tar.xz
https://chromium-fonts.storage.googleapis.com/${TEST_FONT} -> c