xref: /OK3568_Linux_fs/yocto/meta-browser/meta-chromium/recipes-browser/chromium/chromium-gn.inc (revision 4882a59341e53eb6f0b4789bf948001014eff981)
1require chromium.inc
2require chromium-unbundle.inc
3require gn-utils.inc
4
5GTKIC_VERSION = "${@bb.utils.contains('PACKAGECONFIG', 'gtk4', '4', '3',d)}"
6
7inherit features_check gtk-icon-cache qemu
8
9# The actual directory name in out/ is irrelevant for GN.
10OUTPUT_DIR = "out/Release"
11B = "${S}/${OUTPUT_DIR}"
12
13SRC_URI += " \
14    file://0001-limit-number-of-LTO-jobs.patch \
15    file://0002-Remove-the-GN-settings-done-for-clang-that-conflict-.patch \
16    file://0003-v8-qemu-wrapper.patch \
17    file://0004-wrapper-extra-flags.patch \
18    file://0005-BUILD-do-not-specify-march-on-arm.patch \
19    file://0007-Delete-compiler-options-not-available-in-release-ver.patch \
20    file://0008-avoid-link-latomic-failure-on-CentOS-8-host.patch \
21    file://0009-nomerge-attribute-on-declaration-is-only-available-s.patch \
22    file://0011-Revert-Use-ffile-compilation-dir-instead-of-fdebug-c.patch \
23    file://0013-Fix-html_minifier-script-for-node-v12.patch \
24    file://0015-drop-gsimple-template-names.patch \
25    file://0016-cast-to-bool-to-avoid-constexpr-error.patch \
26"
27
28SRC_URI:append:libc-musl = "\
29    file://musl/0001-mallinfo-implementation-is-glibc-specific.patch \
30    file://musl/0002-execinfo-implementation-is-glibc-specific.patch \
31    file://musl/0003-Define-TEMP_FAILURE_RETRY-and-__si_fields.patch \
32    file://musl/0004-blink-Fix-build-with-musl.patch \
33    file://musl/0005-breakpad-Fix-build-with-musl.patch \
34    file://musl/0006-fontconfig-Musl-does-not-have-rand_r-API.patch \
35    file://musl/0007-__libc_malloc-is-internal-to-glibc.patch \
36    file://musl/0008-gnu_libc_version-API-is-glibc-specific.patch \
37    file://musl/0009-provide-res_ninit-and-nclose-APIs-on-non-glibc-linux.patch \
38    file://musl/0011-crashpad-Fix-build-with-musl.patch \
39    file://musl/0012-debug-Fix-build-with-musl.patch \
40    file://musl/0015-mallopt-is-glibc-specific-API.patch \
41    file://musl/0018--Use-monotonic-clock-for-pthread_cond_timedwait-with-.patch \
42    file://musl/0020-Fix-tab-crashes-on-musl.patch \
43    file://musl/0021-pthread_getname_np.patch \
44    file://musl/0022-sys-stat.patch \
45    file://musl/scoped-file.patch \
46    file://musl/fix-narrowing-cast.patch \
47    file://musl/credentials-header.patch \
48    file://musl/fstatat64.patch \
49"
50
51ANY_OF_DISTRO_FEATURES = "opengl vulkan"
52
53# Append instead of assigning; the gtk-icon-cache class inherited above also
54# adds packages to DEPENDS.
55DEPENDS += " \
56    alsa-lib \
57    ${@bb.utils.contains('DISTRO_FEATURES', 'x11', 'at-spi2-core', '', d)} \
58    atk \
59    bison-native \
60    cairo \
61    curl \
62    expat \
63    flac \
64    glib-2.0 \
65    gn-native \
66    gperf-native \
67    gtk+3 \
68    jpeg \
69    libdrm \
70    libffi \
71    libwebp \
72    libxkbcommon \
73    libxslt \
74    ninja-native \
75    nodejs-native \
76    nspr \
77    nspr-native \
78    nss \
79    nss-native \
80    pango \
81    pciutils \
82    pkgconfig-native \
83    ${@bb.utils.contains('DISTRO_FEATURES', 'pulseaudio', 'pulseaudio', '', d)} \
84    qemu-native \
85    virtual/libgl \
86"
87DEPEND:append:runtime-llvm = " compiler-rt-native libcxx-native"
88
89# The wrapper script we use from upstream requires bash.
90RDEPENDS:${PN} = "bash"
91
92COMPATIBLE_MACHINE = "(-)"
93COMPATIBLE_MACHINE:aarch64 = "(.*)"
94COMPATIBLE_MACHINE:armv6 = "(.*)"
95COMPATIBLE_MACHINE:armv7a = "(.*)"
96COMPATIBLE_MACHINE:armv7ve = "(.*)"
97COMPATIBLE_MACHINE:x86-64 = "(.*)"
98
99# Also build the parts that are run on the host with clang.
100BUILD_AR:toolchain-clang = "llvm-ar"
101BUILD_CC:toolchain-clang = "clang"
102BUILD_CXX:toolchain-clang = "clang++"
103BUILD_LD:toolchain-clang = "clang"
104
105PACKAGECONFIG ??= "upower use-egl"
106
107# this makes sure the dependencies for the EGL mode are present; otherwise, the configure scripts
108# automatically and silently fall back to GLX
109PACKAGECONFIG[use-egl] = ",,virtual/egl virtual/libgles2"
110
111# Empty PACKAGECONFIG options listed here to avoid warnings.
112# The .bb file should use these to conditionally add patches
113# and command-line switches (extra dependencies should not
114# be necessary but are OK to add).
115PACKAGECONFIG[component-build] = ""
116
117# Starting with M61, Chromium defaults to building with its own copy of libc++
118# instead of the system's libstdc++. Add a knob to control this behavior
119# https://groups.google.com/a/chromium.org/d/msg/chromium-packagers/8aYO3me2SCE/SZ8pJXhZAwAJ
120PACKAGECONFIG[custom-libcxx] = "use_custom_libcxx=true,use_custom_libcxx=false,,"
121
122PACKAGECONFIG[cups] = "use_cups=true,use_cups=false,cups"
123PACKAGECONFIG[gtk4] = ""
124PACKAGECONFIG[kiosk-mode] = ""
125PACKAGECONFIG[proprietary-codecs] = ' \
126        ffmpeg_branding="Chrome" proprietary_codecs=true, \
127        ffmpeg_branding="Chromium" proprietary_codecs=false \
128'
129# Enable UPower by default.
130# Chromium expects to be able to query battery status through D-Bus.
131PACKAGECONFIG[upower] = ",,,upower"
132
133# Disable VA-API by default. It is compile time enabled since M88, but it's not
134# desired to make all the users of the Chromium meta-browser recipe depend on
135# libva without a real need. Both X11 (non-Ozone) and Wayland (Ozone) can use it,
136# but remember to also use proprietary codecs so that H.264 is supported. Also note
137# that not all the hardware configs might be supported.
138PACKAGECONFIG[use-vaapi] = "use_vaapi=true use_libgav1_parser=true,use_vaapi=false,libva"
139
140# Base GN arguments, mostly related to features we want to enable or disable.
141GN_ARGS = " \
142        ${PACKAGECONFIG_CONFARGS} \
143        is_component_build=${@bb.utils.contains('PACKAGECONFIG', 'component-build', 'true', 'false', d)} \
144        use_gnome_keyring=false \
145        use_kerberos=false \
146        use_pulseaudio=${@bb.utils.contains('DISTRO_FEATURES', 'pulseaudio', 'true', 'false', d)} \
147        use_system_libjpeg=true \
148"
149# Not enabled by default, because the freetype version from oe-core
150# often isn't compatible, e.g. freetype-2.11 isn't compatible with
151# chromium-94
152GN_ARGS += "use_system_freetype=false"
153
154# Qt support appears to be underdevelopment in Nov 2022 so disable now
155# but a PACKAGECONFIG option should be added when the feature is ready.
156GN_ARGS += "use_qt=false"
157
158# Closure_compile needs to be disabled to avoid pulling in java dependencies,
159# which are typicaly not wanted. It started to happen after https://crrev.com/c/1278470
160# This argument was renamed to enable_js_type_check after https://crrev.com/c/2248564
161GN_ARGS += "enable_js_type_check=false"
162
163# Make sure pkg-config, when used with the host's toolchain to build the
164# binaries we need to run on the host, uses the right pkg-config to avoid
165# passing include directories belonging to the target.
166GN_ARGS += 'host_pkg_config="pkg-config-native"'
167
168# From Chromium's BUILDCONFIG.gn:
169# Set to enable the official build level of optimization. This has nothing
170# to do with branding, but enables an additional level of optimization above
171# release (!is_debug). This might be better expressed as a tri-state
172# (debug, release, official) but for historical reasons there are two
173# separate flags.
174# See also: https://groups.google.com/a/chromium.org/d/msg/chromium-dev/hkcb6AOX5gE/PPT1ukWoBwAJ
175GN_ARGS += "is_debug=false is_official_build=true"
176
177# Use lld linker its quicker see https://lld.llvm.org/#performance
178GN_ARGS += "use_lld=true use_gold=false"
179
180# By default, passing is_official_build=true to GN causes its symbol_level
181# variable to be set to "2". This means the compiler will be passed "-g2" and
182# we will end up with a very large chrome binary (around 5Gb as of M58)
183# regardless of whether DEBUG_BUILD has been set or not. In addition, binutils,
184# file and other utilities are unable to read a 32-bit binary this size, which
185# causes it not to be stripped.
186# The solution is two-fold:
187# 1. Make sure -g is not passed on 32-bit architectures via DEBUG_FLAGS. -g is
188#    the same as -g2. -g1 generates an 800MB binary, which is a lot more
189#    manageable.
190# 2. Explicitly pass symbol_level=0 to GN. This causes -g0 to be passed
191#    instead, so that if DEBUG_BUILD is not set GN will not create a huge debug
192#    binary anyway. Since our compiler flags are passed after GN's, -g0 does
193#    not cause any issues if DEBUG_BUILD is set, as -g1 will be passed later.
194DEBUG_FLAGS:remove:arm = "-g"
195DEBUG_FLAGS:append:arm = "-g1"
196DEBUG_FLAGS:remove:x86 = "-g"
197DEBUG_FLAGS:append:x86 = "-g1"
198GN_ARGS += "symbol_level=0"
199
200# As of Chromium 62.0.3202.94 and Yocto Rocko (GCC 7, binutils 2.29), passing
201# -g to the compiler results in many linker errors on aarch64, such as:
202# obj/third_party/WebKit/Source/modules/payments/libpayments.a(PaymentEventDataConversion.o)(.debug_loc+0x4e25): error: relocation overflow in R_AARCH64_ABS32
203DEBUG_FLAGS:remove:aarch64 = "-g"
204DEBUG_FLAGS:append:aarch64 = "-g1"
205
206# As of Chromium 60.0.3112.101 and Yocto Pyro (GCC 6, binutils 2.28), passing
207# -g to the compiler results in many linker errors on x86_64, such as:
208# obj/third_party/WebKit/Source/core/loader/libloader.a(ModuleTreeLinker.o)(.debug_loc+0x1e9a5): error: relocation overflow: reference to local symbol 82 in obj/third_party/WebKit/Source/core/loader/libloader.a(ModuleTreeLinker.o)
209# obj/third_party/WebKit/Source/core/libcore_generated.a(ScriptModule.o)(.debug_loc+0x253c): error: relocation overflow: reference to local symbol 31 in obj/third_party/WebKit/Source/core/libcore_generated.a(ScriptModule.o)
210# so we have to use the same hack described above.
211DEBUG_FLAGS:remove:x86-64 = "-g"
212DEBUG_FLAGS:append:x86-64 = "-g1"
213
214# Disable Chrome Remote Desktop (aka Chromoting) support. Building host support
215# (so that the machine running this recipe can be controlled remotely from
216# another machine) requires additional effort to build some extra binaries,
217# whereas connecting to other machines requires building and installing a
218# Chrome extension (it is not clear how to do that automatically).
219GN_ARGS += "enable_remoting=false"
220
221# NaCl support depends on the NaCl toolchain that needs to be built before NaCl
222# itself. The whole process is quite cumbersome so we just disable the whole
223# thing for now.
224GN_ARGS += "enable_nacl=false"
225
226# We do not want to use Chromium's own Debian-based sysroots, it is easier to
227# just let Chromium's build system assume we are not using a sysroot at all and
228# let Yocto handle everything.
229GN_ARGS += "use_sysroot=false"
230
231# The clang version used to build this recipe may be older than upstream
232# Chromium's, which can cause unexpected warnings to show up. They should not
233# cause the build to fail.
234GN_ARGS += "treat_warnings_as_errors=false"
235
236# Enabling Control Flow Integrity requires more research (i.e. we need to
237# figure out when it was first deemed stable by Chromium). Upstream only
238# enables this for x86-64 right now.
239GN_ARGS += "is_cfi=false"
240
241# Disable activation of field trial tests that can cause problems in
242# production.
243# See https://groups.google.com/a/chromium.org/d/msg/chromium-packagers/ECWC57W7E0k/9Kc5UAmyDAAJ
244GN_ARGS += "disable_fieldtrial_testing_config=true"
245
246# Disable PGO optimization as generated profdata requires the same version of
247# clang that upstream uses. Otherwise, clang-llvm produces the following error:
248# Unsupported instrumentation profile format version.
249# See https://crrev.com/c/2424669
250GN_ARGS += "chrome_pgo_phase=0"
251
252# API keys for accessing Google services. By default, we use an invalid key
253# only to prevent the "you are missing an API key" infobar from being shown on
254# startup.
255# See https://dev.chromium.org/developers/how-tos/api-keys for more information
256# on how to obtain your own keys. You can then set the variables below in
257# local.conf or a .bbappend file.
258GOOGLE_API_KEY ??= "invalid-api-key"
259GOOGLE_DEFAULT_CLIENT_ID ??= "invalid-client-id"
260GOOGLE_DEFAULT_CLIENT_SECRET ??= "invalid-client-secret"
261GN_ARGS += ' \
262        google_api_key="${GOOGLE_API_KEY}" \
263        google_default_client_id="${GOOGLE_DEFAULT_CLIENT_ID}" \
264        google_default_client_secret="${GOOGLE_DEFAULT_CLIENT_SECRET}" \
265'
266
267# Use libcxx headers for native parts
268BUILD_CPPFLAGS:append:runtime-llvm = " -isysroot=${STAGING_DIR_NATIVE} -stdlib=libc++"
269# Use libgcc for native parts
270BUILD_LDFLAGS:append:runtime-llvm = " -rtlib=libgcc -unwindlib=libgcc -stdlib=libc++ -lc++abi -rpath ${STAGING_LIBDIR_NATIVE}"
271
272# Toolchains we will use for the build. We need to point to the toolchain file
273# we've created, set the right target architecture and make sure we are not
274# using Chromium's toolchain (bundled clang, bundled binutils etc).
275GN_ARGS += ' \
276        custom_toolchain="//build/toolchain/yocto:yocto_target" \
277        gold_path="" \
278        host_toolchain="//build/toolchain/yocto:yocto_native" \
279        is_clang=true \
280        clang_base_path="${@clang_install_path(d)}" \
281        clang_use_chrome_plugins=false \
282        target_cpu="${@gn_target_arch_name(d)}" \
283        v8_snapshot_toolchain="//build/toolchain/yocto:yocto_target" \
284'
285
286# This parameter is added by limit-number-of-LTO-jobs.patch with the default value of 8,
287# but we can use whatever user configured in PARALLEL_MAKE
288GN_ARGS += 'max_jobs_per_link="${@oe.utils.parallel_make_argument(d, '%d')}"'
289
290# ARM builds need special additional flags (see ${S}/build/config/arm.gni).
291# If we do not pass |arm_arch| and friends to GN, it will deduce a value that
292# will then conflict with TUNE_CCARGS and CC.
293# Note that as of M61 in some corner cases parts of the build system disable
294# the "compiler:arm_fpu" GN config, whereas -mfpu is always passed via ${CC}.
295# We might want to rework that if there are issues in the future.
296def get_compiler_flag(params, param_name, d):
297    """Given a sequence of compiler arguments in |params|, returns the value of
298    an option |param_name| or an empty string if the option is not present."""
299    for param in params:
300      if param.startswith(param_name):
301        return param.split('=')[1]
302    return ''
303
304ARM_FLOAT_ABI = "${@bb.utils.contains('TUNE_FEATURES', 'callconvention-hard', 'hard', 'softfp', d)}"
305ARM_FPU = "${@get_compiler_flag(d.getVar('TUNE_CCARGS').split(), '-mfpu', d)}"
306ARM_TUNE = "${@get_compiler_flag(d.getVar('TUNE_CCARGS').split(), '-mcpu', d)}"
307ARM_VERSION:aarch64 = "8"
308ARM_VERSION:armv7a = "7"
309ARM_VERSION:armv7ve = "7"
310ARM_VERSION:armv6 = "6"
311
312# GN computes and defaults to it automatically where needed
313# forcing it from cmdline breaks build on places where it ends up
314# overriding what GN wants
315TUNE_CCARGS:remove = "-mthumb"
316
317GN_ARGS:append:arm = ' \
318        arm_float_abi="${ARM_FLOAT_ABI}" \
319        arm_fpu="${ARM_FPU}" \
320        arm_tune="${ARM_TUNE}" \
321        arm_version=${ARM_VERSION} \
322'
323# tcmalloc's atomicops-internals-arm-v6plus.h uses the "dmb" instruction that
324# is not available on (some?) ARMv6 models, which causes the build to fail.
325GN_ARGS:append:armv6 = ' use_partition_alloc_as_malloc=false enable_backup_ref_ptr_support=false'
326# The WebRTC code fails to build on ARMv6 when NEON is enabled.
327# https://bugs.chromium.org/p/webrtc/issues/detail?id=6574
328GN_ARGS:append:armv6 = ' arm_use_neon=false'
329
330# Disable glibc shims on musl
331# tcmalloc does not play well with musl as of M62 (and possibly earlier).
332# https://github.com/gperftools/gperftools/issues/693
333GN_ARGS:append:libc-musl = ' use_allocator_shim=false use_partition_alloc_as_malloc=false enable_backup_ref_ptr_support=false'
334
335CHROMIUM_EXTRA_ARGS ?= " \
336        ${@bb.utils.contains('PACKAGECONFIG', 'use-egl', '--use-gl=egl', '', d)} \
337        ${@bb.utils.contains('PACKAGECONFIG', 'kiosk-mode', '--kiosk --no-first-run --incognito', '', d)} \
338        ${@bb.utils.contains('PACKAGECONFIG', 'gtk4', '--gtk-version=4', '', d)} \
339"
340
341# V8's JIT infrastructure requires binaries such as mksnapshot and
342# mkpeephole to be run in the host during the build. However, these
343# binaries must have the same bit-width as the target (e.g. a x86_64
344# host targeting ARMv6 needs to produce a 32-bit binary). Instead of
345# depending on a third Yocto toolchain, we just build those binaries
346# for the target and run them on the host with QEMU.
347python do_create_v8_qemu_wrapper () {
348    """Creates a small wrapper that invokes QEMU to run some target V8 binaries
349    on the host."""
350    qemu_libdirs = [d.expand('${STAGING_DIR_HOST}${libdir}'),
351                    d.expand('${STAGING_DIR_HOST}${base_libdir}')]
352    qemu_cmd = qemu_wrapper_cmdline(d, d.getVar('STAGING_DIR_HOST', True),
353                                    qemu_libdirs)
354    wrapper_path = d.expand('${B}/v8-qemu-wrapper.sh')
355    with open(wrapper_path, 'w') as wrapper_file:
356        wrapper_file.write("""#!/bin/sh
357
358# This file has been generated automatically.
359# It invokes QEMU to run binaries built for the target in the host during the
360# build process.
361
362%s "$@"
363""" % qemu_cmd)
364    os.chmod(wrapper_path, 0o755)
365}
366do_create_v8_qemu_wrapper[dirs] = "${B}"
367addtask create_v8_qemu_wrapper after do_patch before do_configure
368
369# Check the LLVMVERSION defined in the meta-clang layer. Given Chromium is
370# developed using new C++ features, the LLVMVERSION has to be >= 12. Otherwise,
371# it is not guaranteed that Chromium will compile.
372python do_check_llvm_version () {
373  from distutils.version import LooseVersion
374
375  min_llvm_version = "12.0.0"
376  llvm_version = d.getVar('LLVMVERSION', False)
377  if not llvm_version:
378    bb.warn("Unable to determine LLVM version. Chromium may not be compiled "
379            "successfully if the LLVM version is below %s." % min_llvm_version)
380    return
381
382  if LooseVersion(llvm_version) < LooseVersion(min_llvm_version):
383    bb.fatal("Your LLVMVERSION (%s) is lower than the minimum required "
384             "LLVMVERSION (%s). If you are using dunfell, make sure you "
385             "use clang12 branch." % (llvm_version, min_llvm_version))
386}
387addtask check_llvm_version before do_configure
388
389python do_write_toolchain_file () {
390    """Writes a BUILD.gn file for Yocto detailing its toolchains."""
391    toolchain_dir = d.expand("${S}/build/toolchain/yocto")
392    bb.utils.mkdirhier(toolchain_dir)
393    toolchain_file = os.path.join(toolchain_dir, "BUILD.gn")
394    write_toolchain_file(d, toolchain_file)
395}
396addtask write_toolchain_file after do_patch before do_configure
397
398do_add_nodejs_symlink () {
399	# Adds a symlink to the node binary to the location expected by
400	# Chromium's build system.
401	chromium_node_dir="${S}/third_party/node/linux/node-linux-x64/bin"
402	nodejs_native_path="${STAGING_BINDIR_NATIVE}/node"
403	mkdir -p "${chromium_node_dir}"
404	if [ ! -f "${nodejs_native_path}" ]; then
405		echo "${nodejs_native_path} does not exist."
406		exit 1
407	fi
408	ln -sf "${nodejs_native_path}" "${chromium_node_dir}/node"
409}
410addtask add_nodejs_symlink after do_configure before do_compile
411
412do_configure() {
413	cd ${S}
414	python3 ./build/linux/unbundle/replace_gn_files.py --system-libraries ${GN_UNBUNDLE_LIBS}
415	gn gen --args='${GN_ARGS}' "${OUTPUT_DIR}"
416}
417
418do_compile() {
419	ninja -v ${PARALLEL_MAKE} chrome chrome_sandbox chromedriver.unstripped
420}
421do_compile[progress] = "outof:^\[(\d+)/(\d+)\]\s+"
422
423do_install() {
424	install -d ${D}${bindir}
425	install -d ${D}${datadir}
426	install -d ${D}${datadir}/applications
427	install -d ${D}${datadir}/icons
428	install -d ${D}${datadir}/icons/hicolor
429	install -d ${D}${libdir}/chromium
430	install -d ${D}${libdir}/chromium/locales
431
432	install -m 4755 chrome_sandbox ${D}${libdir}/chromium/chrome-sandbox
433	install -m 0755 chrome ${D}${libdir}/chromium/chromium-bin
434	install -m 0644 *.bin ${D}${libdir}/chromium/
435	install -m 0644 icudtl.dat ${D}${libdir}/chromium/icudtl.dat
436
437	# Process and install Chromium's template .desktop file.
438	sed -e "s,@@MENUNAME@@,Chromium Browser,g" \
439	    -e "s,@@PACKAGE@@,chromium,g" \
440	    -e "s,@@USR_BIN_SYMLINK_NAME@@,chromium,g" \
441	    ${S}/chrome/installer/linux/common/desktop.template > chromium.desktop
442	install -m 0644 chromium.desktop ${D}${datadir}/applications/chromium.desktop
443
444	# Install icons.
445	for size in 16 24 32 48 64 128 256; do
446		install -d ${D}${datadir}/icons/hicolor/${size}x${size}
447		install -d ${D}${datadir}/icons/hicolor/${size}x${size}/apps
448		for dirname in "chromium" "default_100_percent/chromium"; do
449			icon="${S}/chrome/app/theme/${dirname}/product_logo_${size}.png"
450			if [ -f "${icon}" ]; then
451				install -m 0644 "${icon}" \
452					${D}${datadir}/icons/hicolor/${size}x${size}/apps/chromium.png
453			fi
454		done
455	done
456
457	# A wrapper for the proprietary Google Chrome version already exists.
458	# We can just use that one instead of reinventing the wheel.
459	WRAPPER_FILE=${S}/chrome/installer/linux/common/wrapper
460	sed -e "s,@@CHANNEL@@,stable,g" \
461		-e "s,@@PROGNAME@@,chromium-bin,g" \
462		${WRAPPER_FILE} > chromium-wrapper
463	install -m 0755 chromium-wrapper ${D}${libdir}/chromium/chromium-wrapper
464	ln -s ${libdir}/chromium/chromium-wrapper ${D}${bindir}/chromium
465
466	# Chromium *.pak files
467	install -m 0644 chrome_*.pak ${D}${libdir}/chromium/
468	install -m 0644 resources.pak ${D}${libdir}/chromium/resources.pak
469
470	# Locales.
471	install -m 0644 locales/*.pak ${D}${libdir}/chromium/locales/
472
473	# Add extra command line arguments to the chromium-wrapper script by
474	# modifying the dummy "CHROME_EXTRA_ARGS" line
475	sed -i "s/^CHROME_EXTRA_ARGS=\"\"/CHROME_EXTRA_ARGS=\"${CHROMIUM_EXTRA_ARGS}\"/" ${D}${libdir}/chromium/chromium-wrapper
476
477	# ANGLE.
478	if [ -e libEGL.so ]; then
479		install -m 0644 libEGL.so ${D}${libdir}/chromium/
480		install -m 0644 libGLESv2.so ${D}${libdir}/chromium/
481	fi
482
483	# libvulkan (for ANGLE).
484	if [ -e libvulkan.so.1 ]; then
485		install -m 0644 libvulkan.so.1 ${D}${libdir}/chromium/
486	fi
487
488	# Swiftshader VK.
489	if [ -e libvk_swiftshader.so ]; then
490		install -m 0644 libvk_swiftshader.so ${D}${libdir}/chromium/
491		# This is needed for ANGLE to find libvk_swiftshader.so.
492		install -m 0644 vk_swiftshader_icd.json ${D}${libdir}/chromium/
493	fi
494
495	if [ -n "${@bb.utils.contains('PACKAGECONFIG', 'component-build', 'component-build', '', d)}" ]; then
496		install -m 0755 *.so ${D}${libdir}/chromium/
497	fi
498
499	# When building chromium with use_system_minigbm=false,
500	# libminigbm.so does not seem to get linked in statically.
501	# So we simply check whether it exists in all cases and ship it.
502	if [ -e libminigbm.so ]; then
503		install -m 0755 libminigbm.so ${D}${libdir}/chromium/
504	fi
505
506	# ChromeDriver.
507	install -m 0755 chromedriver.unstripped ${D}${bindir}/chromedriver
508
509	# Install chrome_crashpad_handler.
510	install -m 0755 chrome_crashpad_handler ${D}${libdir}/chromium/
511}
512
513PACKAGES =+ "${PN}-chromedriver"
514
515FILES:${PN}-chromedriver = "${bindir}/chromedriver"
516
517FILES:${PN} = " \
518        ${bindir}/chromium \
519        ${datadir}/applications/chromium.desktop \
520        ${datadir}/icons/hicolor/*x*/apps/chromium.png \
521        ${libdir}/chromium/* \
522"
523
524PACKAGE_DEBUG_SPLIT_STYLE = "debug-without-src"
525
526# There is no need to ship empty -dev packages.
527ALLOW_EMPTY:${PN}-dev = "0"
528
529# ERROR: QA Issue: lib32-chromium-ozone-wayland: ELF binary /usr/bin/chromium has relocations in .text [textrel]
530INSANE_SKIP:${PN}:append:x86 = "textrel"
531
532