aboutsummaryrefslogtreecommitdiffstats
path: root/community/chromium/APKBUILD
blob: 8dbf95fecb20a27d3c832848509a41aeb380c7e2 (plain)
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
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
# Contributor: Carlo Landmeter 
# Contributor: Natanael Copa 
# Maintainer: psykose 
pkgname=chromium
pkgver=117.0.5938.62
pkgrel=0
_extra_patches=chromium-115-patchset-2
# https://source.chromium.org/chromium/chromium/src/+/main:third_party/test_fonts/test_fonts.tar.gz.sha1
# (for the given version, when it changes)
_testfonts=336e775eec536b2d785cc80eff6ac39051931286
pkgdesc="Chromium web browser"
url="https://www.chromium.org/Home"
arch="aarch64 armv7 x86_64"
license="BSD-3-Clause"
# explicit depends for --headless
# XXX: eudev-libs replaced by so:libudev.so.1 to allow installation with libudev-zero
# take care if libudev.so ever updates somajor..
depends="
	font-opensans
	gtk+3.0
	icu-data-full
	mesa-dri-gallium
	musl>=1.2.3_git20230322-r0
	so:libudev.so.1
	xdg-utils
	"
makedepends="
	alsa-lib-dev
	aom-dev
	bash
	bison
	bsd-compat-headers
	bzip2-dev
	cairo-dev
	clang-dev
	compiler-rt
	cups-dev
	curl-dev
	dav1d-dev
	dbus-glib-dev
	elfutils
	elfutils-dev
	eudev-dev
	ffmpeg-dev
	findutils
	flac-dev
	flex
	freetype-dev
	gn
	gperf
	gtk+3.0-dev
	gzip
	harfbuzz-dev
	hunspell-dev
	hwdata-dev
	jpeg-dev
	jsoncpp-dev
	krb5-dev
	lcms2-dev
	libavif-dev
	libbsd-dev
	libcap-dev
	libevdev-dev
	libevent-dev
	libexif-dev
	libffi-dev
	libgcrypt-dev
	libjpeg-turbo-dev
	libusb-dev
	libva-dev
	libwebp-dev
	libxcomposite-dev
	libxcursor-dev
	libxinerama-dev
	libxml2-dev
	libxrandr-dev
	libxscrnsaver-dev
	libxslt-dev
	linux-headers
	lld
	llvm
	mesa-dev
	minizip-dev
	nodejs-current
	nss-dev
	opus-dev
	pciutils-dev
	perl
	pipewire-dev
	pulseaudio-dev
	py3-setuptools
	python3
	qt5-qtbase-dev
	rust
	samurai
	snappy-dev
	speex-dev
	sqlite-dev
	woff2-dev
	xcb-proto
	zlib-dev
	"
checkdepends="py3-six"
subpackages="
	$pkgname-qt5
	$pkgname-chromedriver
	$pkgname-doc
	$pkgname-lang
	$pkgname-swiftshader
	"
source="https://commondatastorage.googleapis.com/chromium-browser-official/chromium-$pkgver.tar.xz
	https://commondatastorage.googleapis.com/chromium-browser-official/chromium-$pkgver-testdata.tar.xz
	test_fonts-$_testfonts.tar.gz::https://chromium-fonts.storage.googleapis.com/$_testfonts
	chromium-patches-$_extra_patches.tar.gz::https://github.com/stha09/chromium-patches/archive/refs/tags/$_extra_patches.tar.gz
	chromium-launcher.sh
	chromium.conf
	google-api.keys

	chromium-117-old-gn-no-mnemonic.patch
	chromium-revert-drop-of-system-java.patch
	chromium-use-alpine-target.patch
	clang-runtime-path.patch
	disable-failing-tests.patch
	fc-cache-version.patch
	fix-missing-cstdint-include-musl.patch
	fstatat-32bit.patch
	gcc12-fixes.patch
	gdbinit.patch
	import-version.patch
	ipcz-missing-include.patch
	libstdc++13.patch
	material-color-stdround.patch
	mman.patch
	musl-sandbox.patch
	musl-tid-caching.patch
	musl-v8-monotonic-pthread-cont_timedwait.patch
	no-execinfo.patch
	no-mallinfo.patch
	no-mte.patch
	no-res-ninit-nclose.patch
	pvalloc.patch
	revert-llvm16-linker-flag.patch
	quiche-array.patch
	temp-failure-retry.patch
	"
# chrome-sandbox can use suid when user namespaces aren't available, but uses only userns and drops privileges normally
# tests stopped building with 115 with clang16
options="suid !check"

# backwards compat (merged into primary)
provides="$pkgname-angle=$pkgver-r$pkgrel"

case "$CARCH" in
riscv64)
	;;
*)
	# dbg outside riscv only
	subpackages="$pkgname-dbg $subpackages"
	;;
esac

case "$CARCH" in
x86_64)
	;;
*)
	# 32-bit fails a bunch of tests for various size-related reasons
	# aarch64 gets timeout related failures due to builder setup, no easy way to
	# raise timeouts
	options="$options !check"
	;;
esac

# secfixes:
#   103.0.5060.134-r0:
#     - CVE-2022-2163
#     - CVE-2022-2477
#     - CVE-2022-2478
#     - CVE-2022-2479
#     - CVE-2022-2480
#     - CVE-2022-2481
#   103.0.5060.114-r0:
#     - CVE-2022-2294
#     - CVE-2022-2295
#     - CVE-2022-2296
#   103.0.5060.53-r0:
#     - CVE-2022-2156
#     - CVE-2022-2157
#     - CVE-2022-2158
#     - CVE-2022-2160
#     - CVE-2022-2161
#     - CVE-2022-2162
#     - CVE-2022-2163
#     - CVE-2022-2164
#     - CVE-2022-2165
#   102.0.5005.61-r0:
#     - CVE-2022-1853
#     - CVE-2022-1854
#     - CVE-2022-1855
#     - CVE-2022-1856
#     - CVE-2022-1857
#     - CVE-2022-1858
#     - CVE-2022-1859
#     - CVE-2022-1860
#     - CVE-2022-1861
#     - CVE-2022-1862
#     - CVE-2022-1863
#     - CVE-2022-1864
#     - CVE-2022-1865
#     - CVE-2022-1866
#     - CVE-2022-1867
#     - CVE-2022-1868
#     - CVE-2022-1869
#     - CVE-2022-1870
#     - CVE-2022-1871
#     - CVE-2022-1872
#     - CVE-2022-1873
#     - CVE-2022-1874
#     - CVE-2022-1875
#     - CVE-2022-1876
#   101.0.4951.64-r0:
#     - CVE-2022-1633
#     - CVE-2022-1634
#     - CVE-2022-1635
#     - CVE-2022-1636
#     - CVE-2022-1637
#     - CVE-2022-1638
#     - CVE-2022-1639
#     - CVE-2022-1640
#     - CVE-2022-1641
#   101.0.4951.54-r0:
#     - CVE-2022-1477
#     - CVE-2022-1478
#     - CVE-2022-1479
#     - CVE-2022-1481
#     - CVE-2022-1482
#     - CVE-2022-1483
#     - CVE-2022-1484
#     - CVE-2022-1485
#     - CVE-2022-1486
#     - CVE-2022-1487
#     - CVE-2022-1488
#     - CVE-2022-1489
#     - CVE-2022-1490
#     - CVE-2022-1491
#     - CVE-2022-1492
#     - CVE-2022-1493
#     - CVE-2022-1494
#     - CVE-2022-1495
#     - CVE-2022-1496
#     - CVE-2022-1497
#     - CVE-2022-1498
#     - CVE-2022-1499
#     - CVE-2022-1500
#     - CVE-2022-1501
#   100.0.4896.127-r0:
#     - CVE-2022-1364
#   99.0.4844.84-r0:
#     - CVE-2022-1096
#   98.0.4758.102-r0:
#     - CVE-2022-0452
#     - CVE-2022-0453
#     - CVE-2022-0454
#     - CVE-2022-0455
#     - CVE-2022-0456
#     - CVE-2022-0457
#     - CVE-2022-0458
#     - CVE-2022-0459
#     - CVE-2022-0460
#     - CVE-2022-0461
#     - CVE-2022-0462
#     - CVE-2022-0463
#     - CVE-2022-0464
#     - CVE-2022-0465
#     - CVE-2022-0466
#     - CVE-2022-0467
#     - CVE-2022-0468
#     - CVE-2022-0469
#     - CVE-2022-0470
#     - CVE-2022-0603
#     - CVE-2022-0604
#     - CVE-2022-0605
#     - CVE-2022-0606
#     - CVE-2022-0607
#     - CVE-2022-0608
#     - CVE-2022-0609
#     - CVE-2022-0610
#   93.0.4577.82-r0:
#     - CVE-2021-30625
#     - CVE-2021-30626
#     - CVE-2021-30627
#     - CVE-2021-30628
#     - CVE-2021-30629
#     - CVE-2021-30630
#     - CVE-2021-30631
#     - CVE-2021-30632
#     - CVE-2021-30633
#   93.0.4577.63-r0:
#     - CVE-2021-30606
#     - CVE-2021-30607
#     - CVE-2021-30608
#     - CVE-2021-30609
#     - CVE-2021-30610
#     - CVE-2021-30611
#     - CVE-2021-30612
#     - CVE-2021-30613
#     - CVE-2021-30614
#     - CVE-2021-30615
#     - CVE-2021-30616
#     - CVE-2021-30617
#     - CVE-2021-30618
#     - CVE-2021-30619
#     - CVE-2021-30620
#     - CVE-2021-30621
#     - CVE-2021-30622
#     - CVE-2021-30623
#     - CVE-2021-30624
#   92.0.4515.159-r0:
#     - CVE-2021-30598
#     - CVE-2021-30599
#     - CVE-2021-30600
#     - CVE-2021-30601
#     - CVE-2021-30602
#     - CVE-2021-30603
#     - CVE-2021-30604
#     - CVE-2021-30590
#     - CVE-2021-30591
#     - CVE-2021-30592
#     - CVE-2021-30593
#     - CVE-2021-30594
#     - CVE-2021-30596
#     - CVE-2021-30597
#   92.0.4515.107-r0:
#     - CVE-2021-30565
#     - CVE-2021-30566
#     - CVE-2021-30567
#     - CVE-2021-30568
#     - CVE-2021-30569
#     - CVE-2021-30571
#     - CVE-2021-30572
#     - CVE-2021-30573
#     - CVE-2021-30574
#     - CVE-2021-30575
#     - CVE-2021-30576
#     - CVE-2021-30577
#     - CVE-2021-30578
#     - CVE-2021-30579
#     - CVE-2021-30580
#     - CVE-2021-30581
#     - CVE-2021-30582
#     - CVE-2021-30583
#     - CVE-2021-30584
#     - CVE-2021-30585
#     - CVE-2021-30586
#     - CVE-2021-30587
#     - CVE-2021-30588
#     - CVE-2021-30589
#   91.0.4472.164-r0:
#     - CVE-2021-30559
#     - CVE-2021-30541
#     - CVE-2021-30560
#     - CVE-2021-30561
#     - CVE-2021-30562
#     - CVE-2021-30563
#     - CVE-2021-30564
#   91.0.4472.114-r0:
#     - CVE-2021-30554
#     - CVE-2021-30555
#     - CVE-2021-30556
#     - CVE-2021-30557
#   91.0.4472.101-r0:
#     - CVE-2021-30544
#     - CVE-2021-30545
#     - CVE-2021-30546
#     - CVE-2021-30547
#     - CVE-2021-30548
#     - CVE-2021-30549
#     - CVE-2021-30550
#     - CVE-2021-30551
#     - CVE-2021-30552
#     - CVE-2021-30553
#   91.0.4472.77-r0:
#     - CVE-2021-30521
#     - CVE-2021-30522
#     - CVE-2021-30523
#     - CVE-2021-30524
#     - CVE-2021-30525
#     - CVE-2021-30526
#     - CVE-2021-30527
#     - CVE-2021-30528
#     - CVE-2021-30529
#     - CVE-2021-30530
#     - CVE-2021-30531
#     - CVE-2021-30532
#     - CVE-2021-30533
#     - CVE-2021-30534
#     - CVE-2021-30535
#     - CVE-2021-30536
#     - CVE-2021-30537
#     - CVE-2021-30538
#     - CVE-2021-30539
#     - CVE-2021-30540
#   90.0.4430.72-r0:
#     - CVE-2021-21201
#     - CVE-2021-21202
#     - CVE-2021-21203
#     - CVE-2021-21204
#     - CVE-2021-21205
#     - CVE-2021-21221
#     - CVE-2021-21207
#     - CVE-2021-21208
#     - CVE-2021-21209
#     - CVE-2021-21210
#     - CVE-2021-21211
#     - CVE-2021-21212
#     - CVE-2021-21213
#     - CVE-2021-21214
#     - CVE-2021-21215
#     - CVE-2021-21216
#     - CVE-2021-21217
#     - CVE-2021-21218
#     - CVE-2021-21219
#   89.0.4389.128-r0:
#     - CVE-2021-21206
#     - CVE-2021-21220
#   89.0.4389.114-r0:
#     - CVE-2021-21194
#     - CVE-2021-21195
#     - CVE-2021-21196
#     - CVE-2021-21197
#     - CVE-2021-21198
#     - CVE-2021-21199
#   89.0.4389.90-r0:
#     - CVE-2021-21191
#     - CVE-2021-21192
#     - CVE-2021-21193
#   89.0.4389.72-r0:
#     - CVE-2021-21158
#     - CVE-2021-21159
#     - CVE-2021-21160
#     - CVE-2021-21161
#     - CVE-2021-21162
#     - CVE-2021-21163
#     - CVE-2021-21164
#     - CVE-2021-21165
#     - CVE-2021-21166
#     - CVE-2021-21167
#     - CVE-2021-21168
#     - CVE-2021-21169
#     - CVE-2021-21170
#     - CVE-2021-21171
#     - CVE-2021-21172
#     - CVE-2021-21173
#     - CVE-2021-21174
#     - CVE-2021-21175
#     - CVE-2021-21176
#     - CVE-2021-21177
#     - CVE-2021-21178
#     - CVE-2021-21179
#     - CVE-2021-21180
#     - CVE-2020-27844
#     - CVE-2021-21181
#     - CVE-2021-21182
#     - CVE-2021-21183
#     - CVE-2021-21184
#     - CVE-2021-21185
#     - CVE-2021-21186
#     - CVE-2021-21187
#     - CVE-2021-21188
#     - CVE-2021-21189
#     - CVE-2021-21190
#   83.0.4103.116-r0:
#     - CVE-2020-6505
#     - CVE-2020-6506
#     - CVE-2020-6507
#     - CVE-2020-6509
#   72.0.3626.121-r0:
#     - CVE-2019-5786

_chromium_testsuites="
	base_unittests
	net_unittests
	"

upstream_version() {
	curl --silent https://omahaproxy.appspot.com/all \
		| awk -F, '$1 == "linux" && $2 == "stable" {print $3}'
}

prepare() {
	default_prepare

	patch -Np1 < "$srcdir"/chromium-patches-$_extra_patches/chromium-114-maldoca-include.patch

	mv ../test_fonts/ ./third_party/test_fonts/

	# https://groups.google.com/a/chromium.org/d/topic/chromium-packagers/9JX1N2nf4PU/discussion
	touch chrome/test/data/webui/i18n_process_css_test.html
	# Use the file at run time instead of effectively compiling it in
	sed 's|//third_party/usb_ids/usb.ids|/usr/share/hwdata/usb.ids|g' \
		-i services/device/public/cpp/usb/BUILD.gn

	mkdir -p third_party/node/linux/node-linux-x64/bin
	ln -s /usr/bin/node third_party/node/linux/node-linux-x64/bin/

	# reusable system library settings
	# libavif - https://github.com/AOMediaCodec/libavif/commit/4d2776a3
	# libaom - https://aomedia.googlesource.com/aom/+/706ee36dcc82%5E%21/
	local use_system="
		dav1d
		ffmpeg
		flac
		fontconfig
		freetype
		harfbuzz-ng
		icu
		jsoncpp
		libdrm
		libevent
		libjpeg
		libwebp
		libxml
		libxslt
		opus
		snappy
		woff2
		zlib
		"

	for _lib in $use_system libjpeg_turbo; do
		msg "Removing buildscripts for system provided $_lib"
			find . -type f -path "*third_party/$_lib/*" \
			\! -path "*third_party/$_lib/chromium/*" \
			\! -path "*third_party/$_lib/google/*" \
			\! -path './base/third_party/icu/*' \
			\! -path './third_party/libxml/*' \
			\! -path './third_party/pdfium/third_party/freetype/include/pstables.h' \
			\! -path './third_party/harfbuzz-ng/utils/hb_scoped.h' \
			\! -path './third_party/crashpad/crashpad/third_party/zlib/zlib_crashpad.h' \
			\! -regex '.*\.\(gn\|gni\|isolate\|py\)' \
			-delete
	done

	msg "Replacing gn files"
	python3 build/linux/unbundle/replace_gn_files.py --system-libraries \
		$use_system
	python3 third_party/libaddressinput/chromium/tools/update-strings.py

	# prevent annoying errors when regenerating gni
	sed -i 's,^update_readme$,#update_readme,' \
		third_party/libvpx/generate_gni.sh

	# allow system dependencies in "official builds"
	sed -i 's/OFFICIAL_BUILD/GOOGLE_CHROME_BUILD/' \
		tools/generate_shim_headers/generate_shim_headers.py

	# https://crbug.com/893950
	sed -i -e 's/\/malloc/' -e 's/\/free/' \
		third_party/blink/renderer/core/xml/*.cc \
		third_party/blink/renderer/core/xml/parser/xml_document_parser.cc \
		third_party/libxml/chromium/*.cc \
		third_party/maldoca/src/maldoca/ole/oss_utils.h

	_configure
}

_configure() {
	cd "$builddir"

	##############################################################
	# Please dont use these keys outside of Alpine Linux project #
	# You can create your own at:                                #
	# http://www.chromium.org/developers/how-tos/api-keys        #
	##############################################################
	local _google_api_key _google_default_client_id _google_default_client_secret
	eval "$(base64 -d < $srcdir/google-api.keys)"

	export CFLAGS="${CFLAGS/-g/} -O2 -Wno-unknown-warning-option -Wno-builtin-macro-redefined -Wno-deprecated-declarations"
	export CXXFLAGS="${CXXFLAGS/-g/} -O2 -Wno-unknown-warning-option -Wno-builtin-macro-redefined -Wno-deprecated-declarations"
	export CPPFLAGS="${CPPFLAGS/-g/} -D__DATE__=  -D__TIME__=  -D__TIMESTAMP__="

	export AR="llvm-ar"
	export CC="clang"
	export CXX="clang++"
	export NM="llvm-nm"

	msg "Configuring build"

	# this should be at 0 for -dbg too. change it for local debugging only
	local symbol_level=0

	case "$CARCH" in
	armv7|riscv64)
		# fails, due to oversized alloc
		# riscv doesn't support this yet
		local lto="false"
		;;
	*)
		local lto="true"
		;;
	esac

	case "$CARCH" in
	riscv64)
		# no vaapi on riscv support
		local vaapi=false
		;;
	*)
		local vaapi=true
		;;
	esac

	# maglev does not compile on arches without pointer compression
	case "$CARCH" in
	armv7)
		local maglev=false
		;;
	*)
		local maglev=true
		;;
	esac

	# rust is disabled pending fixing the build scripts for it - see failed
	# pipeline runs on https://gitlab.alpinelinux.org/alpine/aports/-/merge_requests/51557
	# shellcheck disable=2089
	local gn_config="
		blink_enable_generated_code_formatting=false
		chrome_pgo_phase=0
		clang_base_path=\"/usr\"
		clang_use_chrome_plugins=false
		clang_version=16
		custom_toolchain=\"//build/toolchain/linux/unbundle:default\"
		disable_fieldtrial_testing_config=true
		enable_hangout_services_extension=true
		enable_nacl=false
		enable_stripping=false
		enable_rust=false
		enable_vr=false
		fatal_linker_warnings=false
		ffmpeg_branding=\"Chrome\"
		google_api_key=\"$_google_api_key\"
		google_default_client_id=\"$_google_default_client_id\"
		google_default_client_secret=\"$_google_default_client_secret\"
		host_toolchain=\"//build/toolchain/linux/unbundle:default\"
		icu_use_data_file=false
		is_cfi=false
		is_component_ffmpeg=true
		is_debug=false
		is_official_build=true
		link_pulseaudio=true
		proprietary_codecs=true
		rtc_link_pipewire=true
		rtc_use_pipewire=true
		rust_sysroot_absolute=\"/usr\"
		symbol_level=$symbol_level
		treat_warnings_as_errors=false
		use_custom_libcxx=false
		use_lld=true
		use_pulseaudio=true
		use_sysroot=false
		use_system_freetype=true
		use_system_harfbuzz=true
		use_system_lcms2=true
		use_system_libdrm=true
		use_system_libffi=true
		use_system_libjpeg=true
		use_system_zlib=true
		use_thin_lto=$lto
		use_vaapi=$vaapi
		v8_enable_maglev=$maglev
		"

	# shellcheck disable=2090,2116
	gn gen out/bld --args="$(echo $gn_config)"
}

build() {
	msg "Ninja turtles GO!"

	# final link needs lots of file descriptors
	ulimit -n 4096

	# moc and friends not in path by default
	export PATH="$PATH:/usr/lib/qt5/bin"

	# shellcheck disable=2046
	ninja -C out/bld \
		chrome \
		chrome_sandbox \
		chromedriver.unstripped \
		chrome_crashpad_handler \
		$(want_check && echo $_chromium_testsuites)

}

check() {
	# vpython3 execs system python3 with this set
	export VPYTHON_BYPASS="manually managed python not supported by chrome operations"
	# for vpython3 in cwd
	export PATH="$PATH:$PWD/third_party/depot_tools"

	for testsuite in $_chromium_testsuites; do
		msg "running testsuite $testsuite"
		./out/bld/$testsuite
	done
}

package() {
	cd ./out/bld

	mkdir -p "$pkgdir"/usr/bin

	# binaries
	install -Dm755 chrome "$pkgdir"/usr/lib/$pkgname/chromium
	# backward compat symlink
	ln -sfv chromium "$pkgdir"/usr/lib/$pkgname/chrome
	install -Dm4755 chrome_sandbox "$pkgdir"/usr/lib/$pkgname/chrome-sandbox
	install -Dm755 chrome_crashpad_handler -t "$pkgdir"/usr/lib/$pkgname/

	# qt5
	install -Dm755 libqt5_shim.so -t "$pkgdir"/usr/lib/$pkgname/

	# chromedriver
	install -Dm755 chromedriver.unstripped "$pkgdir"/usr/lib/$pkgname/chromedriver
	ln -sfv ../lib/$pkgname/chromedriver "$pkgdir"/usr/bin/chromedriver

	# resources
	install -Dm644 snapshot_blob.bin -t "$pkgdir"/usr/lib/$pkgname/
	install -Dm644 v8_context_snapshot.bin -t "$pkgdir"/usr/lib/$pkgname/
	if [ -f icudtl.dat ]; then
		install -Dm644 icudtl.dat -t "$pkgdir"/usr/lib/$pkgname/
	fi

	install -Dm755 xdg-mime -t "$pkgdir"/usr/lib/$pkgname/
	install -Dm755 xdg-settings -t "$pkgdir"/usr/lib/$pkgname/

	# Vulkan
	install -Dm755 libvulkan.so.1 -t "$pkgdir"/usr/lib/$pkgname/

	# Angle
	install -Dm755 libEGL.so -t "$pkgdir"/usr/lib/$pkgname/
	install -Dm755 libGLESv2.so -t "$pkgdir"/usr/lib/$pkgname/

	install -Dm755 "$srcdir"/chromium-launcher.sh \
		-t "$pkgdir"/usr/lib/$pkgname/

	cp -a MEIPreload "$pkgdir"/usr/lib/$pkgname/

	# It is important that we name the target "chromium-browser",
	# xdg-utils expect it; bug https://bugs.gentoo.org/355517
	ln -sfv ../lib/$pkgname/chromium-launcher.sh "$pkgdir"/usr/bin/chromium-browser
	ln -sfv chromium-browser "$pkgdir"/usr/bin/chromium

	install -Dm644 "$srcdir"/chromium.conf \
		-t "$pkgdir"/etc/chromium/

	for pak in locales/*.pak *.pak; do
		install -Dm644 "$pak" "$pkgdir"/usr/lib/$pkgname/"$pak"
	done

	install -Dm755 libvk_swiftshader.so \
		-t "$pkgdir"/usr/lib/$pkgname/
	install -Dm755 vk_swiftshader_icd.json \
		-t "$pkgdir"/usr/lib/$pkgname/

	cd "$builddir"

	for size in 24 48 64 128 256; do
		install -Dm644 "chrome/app/theme/chromium/product_logo_$size.png" \
			"$pkgdir/usr/share/icons/hicolor/${size}x$size/apps/chromium.png"
	done

	for size in 16 32; do
		install -Dm644 "chrome/app/theme/default_100_percent/chromium/product_logo_$size.png" \
			"$pkgdir/usr/share/icons/hicolor/${size}x$size/apps/chromium.png"
	done

	sed -i \
		-e 's/@@MENUNAME@@/Chromium/g' \
		-e 's/@@PACKAGE@@/chromium/g' \
		-e 's/@@USR_BIN_SYMLINK_NAME@@/chromium-browser/g' \
		chrome/app/resources/manpage.1.in \
		chrome/installer/linux/common/desktop.template

	sed -ni \
		-e 's/chromium-browser\.desktop/chromium.desktop/' \
		-e '//d' \
		-e '/

/N;/

\n.*\(We invite\|Chromium supports Vorbis\)/,/<\/p>/d' \ -e '/^