]> git.armaanb.net Git - asd-repo.git/blob - extra/chromium/build
d21e63c4934a39c6b00ae064f5d1cda4377b49b5
[asd-repo.git] / extra / chromium / build
1 #!/bin/sh -e
2
3 # Musl patches
4 for patch in musl-*.patch; do
5     patch -p1 < "$patch"
6 done
7
8 # Patches specifically for my messed up system
9 # no libatomic/clang plugins (wyverkiss), no gzip (me)
10 for patch in wyverkiss-*.patch; do
11     patch -p1 < "$patch"
12 done
13
14 # Ungoogled Chromium patches
15 for patch in chromium-*.patch; do
16     patch -p1 < "$patch"
17 done
18
19 python ungoogled-chromium/utils/prune_binaries.py \
20     ./ ungoogled-chromium/pruning.list
21
22 # Bypass the Python script and apply patches ourselves to avoid GNU patch
23 while read -r patch; do
24     [ "$patch" ] || continue
25     patch -p1 < "ungoogled-chromium/patches/$patch"
26 done < ungoogled-chromium/patches/series
27
28 python ungoogled-chromium/utils/domain_substitution.py apply \
29     -r ungoogled-chromium/domain_regex.list \
30     -f ungoogled-chromium/domain_substitution.list \
31     -c domainsubcache.tar.gz ./
32
33 # Avoid falling back to preprocessor mode when sources contain time macros
34 kiss list ccache && export CCACHE_SLOPPINESS=time_macros
35
36 # Force script incompatible with Python 3 to use /usr/bin/python2
37 # Remove in next release. How exciting.
38 sed -i "1s|python$|&2|" third_party/dom_distiller_js/protoc_plugins/*.py
39
40 mkdir -p third_party/node/linux/node-linux-x64/bin
41 ln -s /usr/bin/node third_party/node/linux/node-linux-x64/bin/
42
43 export CC="${CC:-cc}"
44 export CXX="${CXX:-c++}"
45 export AR="${AR:-ar}"
46 export NM="${NM:-nm}"
47
48 # Allow building against system libraries in official builds
49 sed -i 's/OFFICIAL_BUILD/GOOGLE_CHROME_BUILD/' \
50     tools/generate_shim_headers/generate_shim_headers.py
51
52 # compile gn early, so it can be used to generate gni stuff
53 LDFLAGS="$LDFLAGS -lc++ -lc++abi -lunwind" \
54     ./tools/gn/bootstrap/bootstrap.py --skip-generate-buildfiles
55
56 system="
57     fontconfig
58     freetype
59     harfbuzz-ng
60     libdrm
61     libwebp
62     libxml
63     opus
64 "
65
66 # remove build scripts for system provided dependencies - basically does the
67 # same as the bundled script to remove bundled libs, but this way we don't
68 # have to list the remaining libs
69 for lib in $system; do
70     find . -type f -path "*third_party/$lib/*" \
71         \! -path "*third_party/$lib/chromium/*" \
72         \! -path "*third_party/$lib/google/*" \
73         \! -path "./base/third_party/icu/*" \
74         \! -path "./third_party/pdfium/third_party/freetype/include/pstables.h" \
75         \! -path "./third_party/harfbuzz-ng/utils/hb_scoped.h" \
76         \! -name "*.gn" \
77         \! -name "*.gni" \
78         \! -name "*.isolate" \
79         \! -name "*.py" \
80         -exec rm -rf {} +
81 done
82
83 # switch to system provided dependencies
84 # shellcheck disable=2086
85 ./build/linux/unbundle/replace_gn_files.py --system-libraries $system
86
87 ./third_party/libaddressinput/chromium/tools/update-strings.py
88
89 conf="
90     google_api_key=\"\"
91     google_default_client_id=\"\"
92     google_default_client_secret=\"\"
93     use_official_google_api_keys=false
94     use_unofficial_version_number=false
95     blink_symbol_level=0
96     safe_browsing_mode=0
97     exclude_unwind_tables=true
98     build_with_tflite_lib=false
99     fatal_linker_warnings=false
100     clang_use_chrome_plugins=false
101     treat_warnings_as_errors=false
102     fieldtrial_testing_like_official_build=true
103     custom_toolchain=\"//build/toolchain/linux/unbundle:default\"
104     host_toolchain=\"//build/toolchain/linux/unbundle:default\"
105     enable_vr=false
106     enable_widevine=false
107     enable_swiftshader=false
108     is_cfi=false
109     is_clang=true
110     is_debug=false
111     use_thin_lto=false
112     is_official_build=true
113     rtc_use_pipewire=false
114     proprietary_codecs=true
115     rtc_build_examples=false
116     ffmpeg_branding=\"Chrome\"
117     link_pulseaudio=false
118     ozone_platform_x11=true
119     ozone_platform_wayland=false
120     symbol_level=0
121     use_allocator=\"none\"
122     use_allocator_shim=false
123     use_atk=false
124     use_gio=false
125     use_gtk=false
126     use_lld=true
127     use_x11=true
128     use_cups=false
129     use_dbus=false
130     use_glib=false
131     use_gold=false
132     use_libpci=false
133     use_sysroot=false
134     use_kerberos=false
135     use_pangocairo=false
136     use_pulseaudio=false
137     use_system_zlib=true
138     use_custom_libcxx=false
139     use_gnome_keyring=false
140     use_system_harfbuzz=true
141     use_vaapi=false
142     chrome_pgo_phase=0
143     enable_mdns=false
144     enable_nacl=false
145     enable_remoting=false
146     enable_reporting=false
147     enable_nacl_nonsfi=false
148     enable_reading_list=false
149     enable_js_type_check=false
150     enable_one_click_signin=false
151     enable_service_discovery=false
152     enable_mse_mpeg2ts_stream_parser=true
153     enable_hangout_services_extension=false
154 "
155
156 out/Release/gn gen out/Release --args="$conf"
157
158 # final link needs lots of file descriptors, almost all shells support the -n flag.
159 # shellcheck disable=2039,3045
160 ulimit -n 4096
161
162 ninja -C out/Release chrome
163
164 # Package the monster.
165 install -Dm755 chromium.sh                         "$1/usr/bin/chromium"
166 install -Dm755 out/Release/chrome                  "$1/usr/lib/chromium/chromium"
167 install -Dm644 out/Release/icudtl.dat              "$1/usr/lib/chromium"
168 install -Dm644 out/Release/resources.pak           "$1/usr/lib/chromium/resources.pak"
169 install -Dm644 out/Release/locales/en-US.pak       "$1/usr/lib/chromium/locales/en-US.pak"
170 install -Dm644 out/Release/chrome_100_percent.pak  "$1/usr/lib/chromium/chrome_100_percent.pak"
171 install -Dm644 out/Release/chrome_200_percent.pak  "$1/usr/lib/chromium/chrome_200_percent.pak"
172 install -Dm644 out/Release/v8_context_snapshot.bin "$1/usr/lib/chromium/v8_context_snapshot.bin"