cef: use vpython3 for commands called by gclient
[AGL/meta-agl-demo.git] / recipes-wam / cef / cef_git.bb
1 require gn-utils.inc
2
3 inherit qemu python3native
4
5 LICENSE = "Apache-2.0 & BSD-3-Clause & LGPL-2.0-only & LGPL-2.1-only"
6
7 LIC_FILES_CHKSUM = "\
8     file://LICENSE;md5=c408a301e3407c3803499ce9290515d6 \
9     file://third_party/blink/renderer/core/LICENSE-LGPL-2;md5=36357ffde2b64ae177b2494445b79d21 \
10     file://third_party/blink/renderer/core/LICENSE-LGPL-2.1;md5=a778a33ef338abbaf8b8a7c36b6eec80 \
11 "
12
13 CHROMIUM_VERSION = "118.0.5993.80"
14 BRANCH = "5993"
15 SRCREV = "3cffa575446727e2fe1f6499efa21f8e096e8ca0"
16
17 PV = "${CHROMIUM_VERSION}.${BRANCH}+git"
18
19 FILESEXTRAPATHS:prepend := "${THISDIR}/files/cef:"
20 FILESEXTRAPATHS:prepend := "${THISDIR}/files/chromium:"
21
22 # The [agl]-prefixed patches are the changes needed to make WAM work with
23 # agl-compositor. The [meta-browser] patches comes from the https://github.com/OSSystems/meta-browser
24 # project that does similar work on keeping up to the new chromium milestones
25 # and the [MXX-Fix] patches are the fixes done by us to fix build issues for
26 # the current chromium milestone. 
27 # For more information about the current milestones: https://chromiumdash.appspot.com/releases?platform=Linux
28 SRC_URI = "\
29     https://commondatastorage.googleapis.com/chromium-browser-official/chromium-${CHROMIUM_VERSION}.tar.xz \
30     file://0001-agl-compositor-Add-agl_shell_wrapper-AGL-wayland-ext.patch \
31     file://0002-agl-Add-waylandwindow-window-tree-host-essential-par.patch \
32     file://0003-agl-Only-bind-to-agl_shell-if-it-s-the-browser-proce.patch \
33     file://0004-agl-Add-a-method-to-check-if-the-agl-window-is-confi.patch \
34     file://0005-agl-Start-using-agl-shell-version-4.patch \
35     file://0006-agl-Don-t-use-DRI-for-renesas.patch \
36     file://0007-meta-browser-Remove-the-GN-settings-done-for-clang-t.patch \
37     file://0008-meta-browser-Pass-no-static-libstdc-to-gen.py.patch \
38     file://0009-meta-browser-IWYU-Add-includes-for-size_t-and-int64_.patch \
39     file://0010-meta-browser-BUILD-do-not-specify-march-on-arm.patch \
40     file://0011-meta-browser-Avoid-parenthesized-initialization-of-a.patch \
41     file://0012-meta-browser-Fix-constexpr-variable-cannot-have-non-.patch \
42     file://0013-meta-browser-Add-missing-typename-s.patch \
43     file://0014-meta-browser-Avoid-std-ranges-find_if.patch \
44     file://0015-meta-browser-Avoid-capturing-structured-bindings.patch \
45     file://0016-meta-browser-Delete-compiler-options-not-available-i.patch \
46     file://0017-meta-browser-Don-t-pass-disable-auto-upgrade-debug-i.patch \
47     file://0018-meta-browser-Fix-undefined-symbol-PaintOpWriter-Seri.patch \
48     file://0019-upstream-Initialize-ServerCvc-with-designated-initia.patch \
49     file://0020-M118-fix-Don-t-look-for-depot_tools-in-chrommium-s-t.patch \
50     file://0021-M118-fix-Add-multiple-missing-includes.patch \
51     file://0022-M118-fix-Fix-aggregate-initialization-in-trace_log.patch \
52     file://0023-M118-fix-Add-missing-typename-keyword-in-multiple-st.patch \
53     file://0024-M118-fix-Fix-comparison-in-HostResolverCache.patch \
54     file://0025-M118-fix-Avoid-using-std-ranges-any_of-find_if-none_.patch \
55     file://0026-M118-fix-Add-deleted-constructors-operators.patch \
56     file://0027-M118-fix-Initialize-percentages-member-on-blink-Font.patch \
57     file://0028-M118-fix-Don-t-delete-ZstdSourceStream-copy-move-cto.patch \
58     file://0029-M118-fix-Fix-issue-with-structured-bindinds-captured.patch \
59     file://0030-M118-fix-Only-default-arm_use_neon-to-true-if-its-va.patch \
60     file://0031-M118-fix-Add-a-way-to-set-different-lib-paths-host-a.patch \
61     file://0032-M118-fix-zlib-Fix-arm-build.patch \
62     file://0033-M118-fix-Fix-skia-linker-issues-for-arm-neon.patch \
63     file://0034-v8-qemu-wrapper.patch \
64     \
65     git://bitbucket.org/chromiumembedded/cef.git;branch=${BRANCH};protocol=https;rev=${SRCREV};name=cef;destsuffix=chromium-${CHROMIUM_VERSION}/cef \
66     file://0001-Add-an-option-to-use-an-output-directory-outside-src.patch;patchdir=cef \
67     file://0002-Add-an-option-to-override-the-default-distrib-direct.patch;patchdir=cef \
68     file://0003-Add-an-option-to-use-an-alternative-base-output-dire.patch;patchdir=cef \
69     file://0004-Add-an-option-to-bypass-sysroot-checking-and-force.patch;patchdir=cef \
70     file://0005-Add-AGL-wayland-window-related-calls.patch;patchdir=cef \
71     file://0006-Add-a-method-to-check-if-the-agl-window-is-configure.patch;patchdir=cef \
72     file://0007-Add-the-SetActivateRegion-method.patch;patchdir=cef \
73     file://0008-Allow-passing-the-app_id-on-widget-creation.patch;patchdir=cef \
74     file://0009-Update-generated-api.patch;patchdir=cef \
75     file://0010-Make-patcher-work-outside-a-git-checkout.patch;patchdir=cef \ 
76     file://0011-Avoid-the-RuntimeError-dictionary-changed-size-durin.patch;patchdir=cef \
77 "
78
79 SRC_URI[sha256sum] = "741c5528a151bc364999969077a13d7a283cfd0eaf34adf47de667a34e5e58ff"
80
81 CHROMIUM_DIR = "${WORKDIR}/chromium-${CHROMIUM_VERSION}"
82 CEF_DIR = "${CHROMIUM_DIR}/cef"
83 DEPOT_TOOLS_DIR="${STAGING_DIR_NATIVE}${datadir}/depot_tools"
84 S = "${CHROMIUM_DIR}"
85 B = "${WORKDIR}/build"
86
87 OUT_PATH = "${B}/out/Release_GN_${GN_TARGET_ARCH_NAME}"
88 DIST_PATH = "${OUT_PATH}/dist/cef-minimal_${GN_TARGET_ARCH_NAME}"
89 CEF_DATA_PATH = "${datadir}/cef"
90
91 DEPENDS:append = " ca-certificates-native curl clang clang-native gperf-native dbus libcxx libcxx-native libpng libxslt jpeg jpeg-native compiler-rt libxkbcommon nss nss-native atk at-spi2-atk libdrm pango cairo virtual/egl qemu-native pciutils glib-2.0 pkgconfig-native pulseaudio xz-native compiler-rt compiler-rt-native expat-native"
92
93 do_sync[depends] += "depot-tools-wam-native:do_populate_sysroot"
94 do_configure[depends] += "depot-tools-wam-native:do_populate_sysroot"
95 do_compile[depends] += "depot-tools-wam-native:do_populate_sysroot"
96
97 # needs to fetch a font package
98 do_configure[network] = "1"
99
100 GN_UNBUNDLE_LIBS = " libjpeg libpng libxslt"
101
102 # gn defaults from CEF wiki, except for use_sysroot
103 GN_DEFINES = "use_sysroot=false \
104               symbol_level=0 \
105               is_cfi=false \
106               use_thin_lto=false \
107 "
108
109 # Disable GTK and prevent cef from
110 # building its gtk demos
111 GN_DEFINES:append = " \
112               use_gtk=false \
113               cef_use_gtk=false \
114 "
115
116 GN_DEFINES:append = " \
117               treat_warnings_as_errors=false \
118               is_component_build=false \
119               use_cups=false \
120               use_kerberos=false \
121               use_ozone=true \
122               use_xkbcommon=true \
123               use_wayland_gbm=true \
124               use_gnome_keyring=false \
125               enable_remoting=false \
126               enable_js_type_check=false \
127 "
128
129 # ozone options
130 GN_DEFINES:append = " \
131               use_ozone=true \
132               ozone_auto_platforms=false \
133               ozone_platform_headless=true \
134               ozone_platform_wayland=true \
135               ozone_platform_x11=false \
136               use_system_minigbm=true \
137               use_system_libdrm=true \
138               use_system_libwayland=false \
139               use_system_libffi=true \
140 "
141
142 GN_DEFINES:append = " \
143               dcheck_always_on=false \
144               is_debug=false \
145               is_official_build=true \
146 "
147
148 GN_DEFINES:append = " \
149               use_egl=true \
150               use_glib=true \
151               use_dri=false \
152 "
153
154 RUNTIME = "llvm"
155 TOOLCHAIN = "clang"
156 TOOLCHAIN:class-native = "clang"
157 LIBCPLUSPLUS = "-stdlib=libc++"
158
159 BUILD_CPPFLAGS:append:runtime-llvm = " -isysroot=${STAGING_DIR_NATIVE} -stdlib=libc++"
160 BUILD_LDFLAGS:append:runtime-llvm = " -rtlib=libgcc -unwindlib=libgcc -stdlib=libc++ -lc++abi -rpath ${STAGING_LIBDIR_NATIVE}"
161 CXXFLAGS:append:runtime-llvm = " -isysroot=${STAGING_DIR_NATIVE} -stdlib=libc++"
162
163 BUILD_AR:toolchain-clang = "llvm-ar"
164 BUILD_CC:toolchain-clang = "clang"
165 BUILD_CXX:toolchain-clang = "clang++"
166 BUILD_LD:toolchain-clang = "clang"
167
168 COMPATIBLE_MACHINE = "(-)"
169 COMPATIBLE_MACHINE:aarch64 = "(.*)"
170 COMPATIBLE_MACHINE:armv6 = "(.*)"
171 COMPATIBLE_MACHINE:armv7a = "(.*)"
172 COMPATIBLE_MACHINE:armv7ve = "(.*)"
173 COMPATIBLE_MACHINE:x86 = "(.*)"
174 COMPATIBLE_MACHINE:x86-64 = "(.*)"
175
176 # ARM builds need special additional flags (see ${S}/build/config/arm.gni).
177 # If we do not pass |arm_arch| and friends to GN, it will deduce a value that
178 # will then conflict with TUNE_CCARGS and CC.
179 # Note that as of M61 in some corner cases parts of the build system disable
180 # the "compiler_arm_fpu" GN config, whereas -mfpu is always passed via ${CC}.
181 # We might want to rework that if there are issues in the future.
182 def get_compiler_flag(params, param_name, d):
183     """Given a sequence of compiler arguments in |params|, returns the value of
184     an option |param_name| or an empty string if the option is not present."""
185     for param in params:
186       if param.startswith(param_name):
187         return param.split('=')[1]
188     return ''
189
190 ARM_FLOAT_ABI = "${@bb.utils.contains('TUNE_FEATURES', 'callconvention-hard', 'hard', 'softfp', d)}"
191 ARM_FPU = "${@get_compiler_flag(d.getVar('TUNE_CCARGS').split(), '-mfpu', d)}"
192 ARM_TUNE = "${@get_compiler_flag(d.getVar('TUNE_CCARGS').split(), '-mcpu', d)}"
193 ARM_VERSION:aarch64 = "8"
194 ARM_VERSION:armv7a = "7"
195 ARM_VERSION:armv7ve = "7"
196 ARM_VERSION:armv6 = "6"
197
198 # GN computes and defaults to it automatically where needed
199 # forcing it from cmdline breaks build on places where it ends up
200 # overriding what GN wants
201 TUNE_CCARGS:remove = "-mthumb"
202
203 GN_DEFINES:append:arm = " \
204         arm_float_abi=\"${ARM_FLOAT_ABI}\" \
205         arm_fpu=\"${ARM_FPU}\" \
206         arm_tune=\"${ARM_TUNE}\" \
207         arm_version=${ARM_VERSION} \
208 "
209 # tcmalloc's atomicops-internals-arm-v6plus.h uses the "dmb" instruction that
210 # is not available on (some?) ARMv6 models, which causes the build to fail.
211 GN_DEFINES:append:armv6 = ' use_allocator="none"'
212 # The WebRTC code fails to build on ARMv6 when NEON is enabled.
213 # https://bugs.chromium.org/p/webrtc/issues/detail?id=6574
214
215 # Disable unknown attribute warnings that are generating tons of logs
216 # TODO(rzanoni): check if https://chromium-review.googlesource.com/c/chromium/src/+/4322480
217 # needs to be reverted
218 BUILD_CXXFLAGS:remove = '-Wunknown-attributes'
219 BUILD_CXXFLAGS:append = ' -Wno-unknown-attributes'
220 BUILD_CPPFLAGS:remove = '-Wunknown-attributes'
221 BUILD_CPPFLAGS:append = ' -Wno-unknown-attributes'
222 CXXFLAGS:remove = '-Wunknown-attributes'
223 CXXFLAGS:append = ' -Wno-unknown-attributes'
224 CPPFLAGS:remove = '-Wunknown-attributes'
225 CPPFLAGS:append = ' -Wno-unknown-attributes'
226
227 GN_DEFINES:append = ' \
228               arm_use_neon=false \
229               use_lld=true \
230               use_gold=false \
231               use_custom_libcxx_for_host=false \
232               use_custom_libcxx=false \
233               chrome_pgo_phase=0 \
234               gold_path="" \
235               is_clang=true \
236               current_os="linux" \
237               clang_use_chrome_plugins=false \
238               clang_base_path="${STAGING_DIR_NATIVE}/usr" \
239               clang_version="14.0.6" \
240               clang_base_path_target="${STAGING_DIR_TARGET}/usr" \
241               custom_toolchain="//build/toolchain/cros:target" \
242               host_toolchain="//build/toolchain/cros:host" \
243               v8_snapshot_toolchain="//build/toolchain/cros:v8_snapshot" \
244               target_cpu="${@gn_target_arch_name(d)}" \
245               use_v8_context_snapshot=false \
246               custom_toolchain="//build/toolchain/yocto:yocto_target" \
247               host_toolchain="//build/toolchain/yocto:yocto_native" \
248               v8_snapshot_toolchain="//build/toolchain/yocto:yocto_target" \
249 '
250
251 PACKAGECONFIG ??= "upower use-egl"
252 PACKAGECONFIG[use-egl] = ",,virtual/egl virtual/libgles2"
253 PACKAGECONFIG[upower] = ",,,upower"
254
255 GN_DEFINES:append = ' \
256               ${PACKAGECONFIG_CONFARGS} \
257 '
258
259 python do_write_toolchain_file () {
260     """Writes a BUILD.gn file for Yocto detailing its toolchains."""
261     toolchain_dir = d.expand("${S}/build/toolchain/yocto")
262     bb.utils.mkdirhier(toolchain_dir)
263     toolchain_file = os.path.join(toolchain_dir, "BUILD.gn")
264     write_toolchain_file(d, toolchain_file)
265 }
266 addtask write_toolchain_file after do_patch before do_configure
267
268 # V8's JIT infrastructure requires binaries such as mksnapshot and
269 # mkpeephole to be run in the host during the build. However, these
270 # binaries must have the same bit-width as the target (e.g. a x86_64
271 # host targeting ARMv6 needs to produce a 32-bit binary). Instead of
272 # depending on a third Yocto toolchain, we just build those binaries
273 # for the target and run them on the host with QEMU.
274 python do_create_v8_qemu_wrapper () {
275     """Creates a small wrapper that invokes QEMU to run some target V8 binaries
276     on the host."""
277     qemu_libdirs = [d.expand('${STAGING_DIR_HOST}${libdir}'),
278                     d.expand('${STAGING_DIR_HOST}${base_libdir}')]
279     qemu_cmd = qemu_wrapper_cmdline(d, d.getVar('STAGING_DIR_HOST', True),
280                                     qemu_libdirs)
281     wrapper_path = d.expand('${OUT_PATH}/v8-qemu-wrapper.sh')
282     with open(wrapper_path, 'w') as wrapper_file:
283         wrapper_file.write("""#!/bin/sh
284
285 # This file has been generated automatically.
286 # It invokes QEMU to run binaries built for the target in the host during the
287 # build process.
288
289 %s "$@"
290 """ % qemu_cmd)
291     os.chmod(wrapper_path, 0o755)
292 }
293 do_create_v8_qemu_wrapper[dirs] = "${OUT_PATH}"
294 addtask create_v8_qemu_wrapper after do_patch before do_configure
295
296 do_configure () {
297     bbnote "do_configure:"
298     bbnote "Base out path: ${B}"
299
300     export DEPOT_TOOLS_UPDATE=0
301     export GCLIENT_PY3=1
302     export PATH="${DEPOT_TOOLS_DIR}:$PATH"
303     export GN_DEFINES="${GN_DEFINES}"
304     export SSL_CERT_DIR="$OECORE_NATIVE_SYSROOT/etc/ssl/certs/"
305     cd ${S}
306     python3 ./build/linux/unbundle/replace_gn_files.py --system-libraries ${GN_UNBUNDLE_LIBS}
307
308     # Download a few dependencies.  Check the current chromium DEPS file when
309     # upgrading to a new milestone.
310     vpython3 third_party/depot_tools/download_from_google_storage.py --no_resume --extract --no_auth --bucket chromium-fonts -s third_party/test_fonts/test_fonts.tar.gz.sha1
311     vpython3 third_party/depot_tools/download_from_google_storage.py --no_resume --extract --no_auth --bucket chromium-nodejs/16.13.0 -s third_party/node/linux/node-linux-x64.tar.gz.sha1
312     vpython3 tools/rust/update_rust.py
313
314     cd ${S}/cef
315     python3 tools/gclient_hook.py --base-out-path ${B} --bypass-sysroot-check
316 }
317
318 do_compile[progress] = "outof:^\[(\d+)/(\d+)\]\s+"
319 do_compile () {
320     if [ ! -f ${OUT_PATH}/build.ninja ]; then
321          do_configure
322     fi
323
324     export PATH="${DEPOT_TOOLS_DIR}:$PATH"
325     export PATH="$PATH:${S}/third_party/ninja"
326     ninja ${PARALLEL_MAKE} -C ${OUT_PATH} libcef chrome_sandbox
327 }
328
329 do_install () {
330     cd ${S}/cef
331     python3 tools/make_distrib.py --output-dir ${OUT_PATH}/dist \
332                                   --dist-path-name cef-minimal \
333                                   --base-out-path ${B} \
334                                   --no-docs \
335                                   --no-symbols \
336                                   --no-archive \
337                                   --ninja-build \
338                                   --minimal \
339                                   --${GN_TARGET_ARCH_NAME}-build \
340                                   --ozone
341
342     install -d ${D}${CEF_DATA_PATH}
343
344     cp -R --no-dereference --preserve=mode,links -v ${DIST_PATH}/* ${D}${CEF_DATA_PATH}
345     # TODO(rzanoni): Follow the wiki instructions to install the sandbox
346 }
347
348 # TODO: fix QA issues, libraries in the wrong location
349 FILES:${PN} += " \
350     ${CEF_DATA_PATH} \
351 "
352
353 INSANE_SKIP:${PN} += "libdir"
354
355 PROVIDES:${PN} += "cef"