summaryrefslogtreecommitdiffstats
path: root/chromium/MAKEPKG
blob: 4674fe9fc8d77fb95b06d786e2ebd933e80c921b (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
#!/bin/mkpkg
# description: Open-source web browser
# url: https://www.chromium.org/
#
# Patches:
#   copium     — musl basics (Alpine/selfisekai)
#   gentoo     — system toolchain support (Matt Jolly)
#   patches/   — musl deep fixes (Chimera cports + flux)

name=chromium
version=146.0.7680.164
release=1
_copium=146.4
_gentoo=146-1
depends=(gtk3 nss nspr harfbuzz icu libpng libjpeg-turbo libwebp
  zlib libxml2 fontconfig freetype libffi libxkbcommon alsa-lib
  wayland mesa libdrm dbus)
makedeps=(gn ninja rust rust-bindgen python3 nodejs flatbuffers gperf
  bsd-headers gcc-compat)
source=(https://github.com/chromium-linux-tarballs/chromium-tarballs/releases/download/$version/chromium-$version-linux.tar.xz
  https://registry.npmjs.org/@rollup/wasm-node/-/wasm-node-4.53.3.tgz
  https://codeberg.org/selfisekai/copium/archive/$_copium.tar.gz
  https://gitlab.com/Matt.Jolly/chromium-patches/-/archive/$_gentoo/chromium-patches-$_gentoo.tar.gz)

patch() {
  cd chromium-$version

  # Replace bundled rollup with wasm-node (pure WASM — no native binary needed on musl)
  rm -rf third_party/devtools-frontend/src/node_modules/rollup
  cp -a "$SRC"/package \
    third_party/devtools-frontend/src/node_modules/rollup

  # Copium patches (musl basics)
  for p in "$SRC"/copium/cr*.patch; do
    case "$p" in *rust-pre1.8*|*rust-pre1.90*|*no-unrar*) continue ;; esac
    patch -Np1 -i "$p"
  done

  # Gentoo patches (system toolchain)
  patch -Np1 -i "$SRC"/chromium-patches-$_gentoo/chromium-145-compiler.patch
  patch -Np1 -i "$SRC"/chromium-patches-$_gentoo/chromium-144-bindgen-custom-toolchain.patch
  patch -Np1 -i "$SRC"/chromium-patches-$_gentoo/chromium-117-material-color-include.patch
  patch -Np1 -i "$SRC"/chromium-patches-$_gentoo/chromium-145-revert-rustfmt.patch || true

  # flux musl patches
  for p in \
    008-fstatat64 \
    016-musl-sandbox \
    017-musl-tid-caching \
    019-musl-no-execinfo \
    020-musl-no-mallinfo \
    021-musl-no-res-ninit \
    022-no-sandbox-settls \
    027-temp-failure-retry \
    033-perfetto-get-thread-name \
    035-breakpad-no-getcontext \
    disable-dns_config_service \
    noclanglibs \
    sanitizer-no-death-callback \
    terminal-fdset \
    llvm21-fixes \
  ; do
    patch -Np1 -i "$PKGMK_SOURCE_DIR"/patches/$p.patch
  done

  # Rust target triple
  sed -i 's/unknown-linux-gnu/unknown-linux-musl/g' build/config/rust.gni
  echo 'x86_64-unknown-linux-musl' >> build/rust/known-target-triples.txt

  # Enable nightly Rust features
  sed -i '1a import os; os.environ["RUSTC_BOOTSTRAP"] = "1"' \
    build/rust/gni_impl/rustc_wrapper.py

  # Strip -Werror
  sed -i 's/-Werror//g' build/config/compiler/BUILD.gn

  # musl: libc++ rune table
  sed -i '1i #define _LIBCPP_PROVIDES_DEFAULT_RUNE_TABLE' \
    third_party/libc++/src/include/__config

  # musl: guard glibc-only stack trace helper
  sed -i 's/OutputToStreamWithPrefixImpl(os, prefix_string);/#if defined(__GLIBC__)\n  OutputToStreamWithPrefixImpl(os, prefix_string);\n#endif/' \
    base/debug/stack_trace.cc

  # Fix dbus::Bus incomplete type
  sed -i '/chrome_browser_main_linux.h/a #include "dbus/bus.h"' \
    chrome/browser/chrome_browser_main_linux.cc
}

sha256sums=(
    "ea7350702cb827c94b786fc1fa51c24c0401e782c9c08dd7ca25a676da4a8f8c"
    "04b101456db24503a6facaade777f4bfb58909195208d4dbbf7dc4217bf71289"
    "bd7bd0984d048d6844195f4aa18b24a0f56603814c243ed32190746d8ba8d7c5"
    "96d6562120964b0c9e1a2bedf4335e0bf20f5e7d67a443bb26c651b0167a6a6b"
)

build() {
  cd chromium-$version

  export CC=clang CXX=clang++ AR=llvm-ar NM=llvm-nm RANLIB=llvm-ranlib LD=ld.lld
  export CFLAGS="-O2 -pipe -Wno-unknown-warning-option -Wno-builtin-macro-redefined -Wno-deprecated-declarations"
  export CXXFLAGS="$CFLAGS -Wno-invalid-constexpr"
  export LDFLAGS="-fuse-ld=lld"
  export RUSTC_BOOTSTRAP=1
  export DEPOT_TOOLS_UPDATE=0
  export VPYTHON_BYPASS="manually managed python not supported by chrome operations"
  export PKG_CONFIG_PATH=/lib/pkgconfig:/usr/lib/pkgconfig:/usr/share/pkgconfig
  export HOME="$PWD"/fake-home && mkdir -p "$HOME"

  # System node + toolchain stubs
  mkdir -p third_party/node/linux/node-linux-x64/bin
  ln -sf /usr/bin/node third_party/node/linux/node-linux-x64/bin/node
  mkdir -p third_party/llvm-build/Release+Asserts/bin
  ln -sf /usr/bin/clang   third_party/llvm-build/Release+Asserts/bin/
  ln -sf /usr/bin/clang++ third_party/llvm-build/Release+Asserts/bin/

  # Stub node version check
  printf '#!/usr/bin/env python3\nimport sys; open(sys.argv[sys.argv.index("--out_file")+1], "w").write("ok")\n' \
    > third_party/node/check_version.py

  mkdir -p out/Release
  cat > out/Release/args.gn << EOF
is_clang = true
use_lld = true
is_debug = false
is_official_build = true
symbol_level = 0
is_musl = true
custom_toolchain = "//build/toolchain/linux/unbundle:default"
host_toolchain = "//build/toolchain/linux/unbundle:default"
rust_sysroot_absolute = "$(rustc --print sysroot)"
rust_bindgen_root = "/usr"
bindgen_libclang_path = "/usr/lib"
clang_base_path = "/usr"
rustc_version = "0"
use_sysroot = false
treat_warnings_as_errors = false
fatal_linker_warnings = false
clang_use_chrome_plugins = false
use_custom_libcxx = true
use_safe_libstdcxx = false
chrome_pgo_phase = 0
is_cfi = false
use_thin_lto = false
use_clang_modules = false
blink_enable_generated_code_formatting = false
use_system_harfbuzz = true
use_system_libffi = true
use_bundled_fontconfig = false
use_ozone = true
ozone_platform_wayland = true
ozone_platform_x11 = false
ozone_platform_headless = true
use_xkbcommon = true
use_alsa = true
use_pulseaudio = false
rtc_use_pipewire = false
use_vaapi = true
use_dbus = true
use_cups = false
use_kerberos = false
enable_widevine = false
enable_hangout_services_extension = false
enable_nocompile_tests = false
safe_browsing_use_unrar = false
proprietary_codecs = true
ffmpeg_branding = "Chrome"
enable_ml_internal = false
target_cpu = "x64"
EOF

  gn gen out/Release || return 1

  # Remove bogus -I/include from generated ninja files
  find out/Release -name '*.ninja' -exec sed -i 's| -I/include||g; s| -isystem/include||g' {} +

  # System flatbuffers
  ln -sf /usr/bin/flatc out/Release/flatc

  ulimit -n 4096
  ninja -C out/Release -j8 chrome chrome_crashpad_handler || return 1

  # Install
  d="$PKG/usr/lib/chromium"
  install -d "$d" "$PKG/usr/bin"

  install -m755 out/Release/chrome "$d/"
  install -m755 out/Release/chrome_crashpad_handler "$d/"

  # Data files
  install -m644 out/Release/*.pak "$d/"
  install -m644 out/Release/*.bin "$d/" 2>/dev/null || true
  [ -f out/Release/icudtl.dat ] && install -m644 out/Release/icudtl.dat "$d/"

  # Shared libraries (skip .TOC build artifacts)
  for f in out/Release/*.so out/Release/*.so.*; do
    [ -f "$f" ] && case "$f" in *.TOC) continue ;; esac && install -m644 "$f" "$d/"
  done

  # Vulkan SwiftShader ICD
  [ -f out/Release/vk_swiftshader_icd.json ] && install -m644 out/Release/vk_swiftshader_icd.json "$d/"

  # XDG helpers
  for f in xdg-mime xdg-settings; do
    [ -f out/Release/$f ] && install -m755 out/Release/$f "$d/"
  done

  # Locales — only en-US and el (Greek)
  install -d "$d/locales"
  for loc in en-US el; do
    install -m644 out/Release/locales/${loc}.pak "$d/locales/"
    for v in FEMININE MASCULINE NEUTER; do
      [ -f out/Release/locales/${loc}_${v}.pak ] && \
        install -m644 out/Release/locales/${loc}_${v}.pak "$d/locales/"
    done
  done

  # Wrapper
  printf '#!/bin/sh\nexec /usr/lib/chromium/chrome --ozone-platform-hint=auto "$@"\n' > "$PKG/usr/bin/chromium"
  chmod 755 "$PKG/usr/bin/chromium"
}

signify() {
    untrusted comment: public key
    RWTZ9IduCSQ/mL8337TEUinPwT92xFEUpD92hkS7IxcOnzTt9QdpohT3
}

# vim: filetype=sh