63897f3e4f294d7356bee49ebfd6f229932d8c0e
[AGL/meta-agl-demo.git] / recipes-wam / cef / cef_git.bb
1 require gn-utils.inc
2
3 LICENSE = "Apache-2.0 & BSD-3-Clause & LGPL-2.0-only & LGPL-2.1-only"
4
5 LIC_FILES_CHKSUM = "\
6     file://LICENSE;md5=c408a301e3407c3803499ce9290515d6 \
7     file://third_party/blink/renderer/core/LICENSE-LGPL-2;md5=36357ffde2b64ae177b2494445b79d21 \
8     file://third_party/blink/renderer/core/LICENSE-LGPL-2.1;md5=a778a33ef338abbaf8b8a7c36b6eec80 \
9 "
10
11 CHROMIUM_VERSION = "118.0.5993.80"
12 BRANCH = "5993"
13 SRCREV = "3cffa575446727e2fe1f6499efa21f8e096e8ca0"
14
15 GN_TARGET_CPU = "${@gn_arch_name('${TUNE_ARCH}')}"
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     \
64     git://bitbucket.org/chromiumembedded/cef.git;branch=${BRANCH};protocol=https;rev=${SRCREV};name=cef;destsuffix=chromium-${CHROMIUM_VERSION}/cef \
65     file://0001-Add-an-option-to-use-an-output-directory-outside-src.patch;patchdir=cef \
66     file://0002-Add-an-option-to-override-the-default-distrib-direct.patch;patchdir=cef \
67     file://0003-Add-an-option-to-use-an-alternative-base-output-dire.patch;patchdir=cef \
68     file://0004-Add-an-option-to-bypass-sysroot-checking-and-force.patch;patchdir=cef \
69     file://0005-Add-AGL-wayland-window-related-calls.patch;patchdir=cef \
70     file://0006-Add-a-method-to-check-if-the-agl-window-is-configure.patch;patchdir=cef \
71     file://0007-Add-the-SetActivateRegion-method.patch;patchdir=cef \
72     file://0008-Allow-passing-the-app_id-on-widget-creation.patch;patchdir=cef \
73     file://0009-Update-generated-api.patch;patchdir=cef \
74     file://0010-Make-patcher-work-outside-a-git-checkout.patch;patchdir=cef \ 
75     file://0011-Avoid-the-RuntimeError-dictionary-changed-size-durin.patch;patchdir=cef \
76 "
77
78 SRC_URI[sha256sum] = "741c5528a151bc364999969077a13d7a283cfd0eaf34adf47de667a34e5e58ff"
79
80 CHROMIUM_DIR = "${WORKDIR}/chromium-${CHROMIUM_VERSION}"
81 CEF_DIR = "${CHROMIUM_DIR}/cef"
82 DEPOT_TOOLS_DIR="${STAGING_DIR_NATIVE}${datadir}/depot_tools"
83 S = "${CHROMIUM_DIR}"
84 B = "${WORKDIR}/build"
85
86 OUT_PATH = "${B}/out/Release_GN_${GN_TARGET_CPU}"
87 DIST_PATH = "${OUT_PATH}/dist/cef-minimal_${GN_TARGET_CPU}"
88 CEF_DATA_PATH = "${datadir}/cef"
89
90 DEPENDS:append = " curl clang clang-native gperf-native gn-native dbus libcxx libcxx-native libpng libxslt jpeg 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"
91
92 do_sync[depends] += "depot-tools-wam-native:do_populate_sysroot"
93 do_configure[depends] += "depot-tools-wam-native:do_populate_sysroot"
94 do_compile[depends] += "depot-tools-wam-native:do_populate_sysroot"
95
96 GN_UNBUNDLE_LIBS = " libjpeg libpng libxslt"
97
98 # gn defaults from CEF wiki, except for use_sysroot
99 GN_DEFINES = "use_sysroot=false \
100               symbol_level=0 \
101               is_cfi=false \
102               use_thin_lto=false \
103 "
104
105 # Disable GTK and prevent cef from
106 # building its gtk demos
107 GN_DEFINES:append = " \
108               use_gtk=false \
109               cef_use_gtk=false \
110 "
111
112 GN_DEFINES:append = " \
113               treat_warnings_as_errors=false \
114               is_component_build=false \
115               use_cups=false \
116               use_kerberos=false \
117               use_ozone=true \
118               use_xkbcommon=true \
119               use_wayland_gbm=true \
120               use_gnome_keyring=false \
121               enable_remoting=false \
122               enable_js_type_check=false \
123 "
124
125 # ozone options
126 GN_DEFINES:append = " \
127               use_ozone=true \
128               ozone_auto_platforms=false \
129               ozone_platform_headless=true \
130               ozone_platform_wayland=true \
131               ozone_platform_x11=false \
132               use_system_minigbm=true \
133               use_system_libdrm=true \
134               use_system_libwayland=false \
135               use_system_libffi=true \
136 "
137
138 GN_DEFINES:append = " \
139               dcheck_always_on=false \
140               is_debug=false \
141               is_official_build=true \
142 "
143
144 GN_DEFINES:append = " \
145               use_egl=true \
146               use_glib=true \
147               use_dri=false \
148 "
149
150 RUNTIME = "llvm"
151 TOOLCHAIN = "clang"
152 TOOLCHAIN:class-native = "clang"
153 LIBCPLUSPLUS = "-stdlib=libc++"
154
155 BUILD_CPPFLAGS:append:runtime-llvm = " -isysroot=${STAGING_DIR_NATIVE} -stdlib=libc++"
156 BUILD_LDFLAGS:append:runtime-llvm = " -rtlib=libgcc -unwindlib=libgcc -stdlib=libc++ -lc++abi -rpath ${STAGING_LIBDIR_NATIVE}"
157 CXXFLAGS:append:runtime-llvm = " -isysroot=${STAGING_DIR_NATIVE} -stdlib=libc++"
158
159 BUILD_AR:toolchain-clang = "llvm-ar"
160 BUILD_CC:toolchain-clang = "clang"
161 BUILD_CXX:toolchain-clang = "clang++"
162 BUILD_LD:toolchain-clang = "clang"
163
164 COMPATIBLE_MACHINE = "(-)"
165 COMPATIBLE_MACHINE:aarch64 = "(.*)"
166 COMPATIBLE_MACHINE:armv6 = "(.*)"
167 COMPATIBLE_MACHINE:armv7a = "(.*)"
168 COMPATIBLE_MACHINE:armv7ve = "(.*)"
169 COMPATIBLE_MACHINE:x86 = "(.*)"
170 COMPATIBLE_MACHINE:x86-64 = "(.*)"
171
172 # ARM builds need special additional flags (see ${S}/build/config/arm.gni).
173 # If we do not pass |arm_arch| and friends to GN, it will deduce a value that
174 # will then conflict with TUNE_CCARGS and CC.
175 # Note that as of M61 in some corner cases parts of the build system disable
176 # the "compiler_arm_fpu" GN config, whereas -mfpu is always passed via ${CC}.
177 # We might want to rework that if there are issues in the future.
178 def get_compiler_flag(params, param_name, d):
179     """Given a sequence of compiler arguments in |params|, returns the value of
180     an option |param_name| or an empty string if the option is not present."""
181     for param in params:
182       if param.startswith(param_name):
183         return param.split('=')[1]
184     return ''
185
186 ARM_FLOAT_ABI = "${@bb.utils.contains('TUNE_FEATURES', 'callconvention-hard', 'hard', 'softfp', d)}"
187 ARM_FPU = "${@get_compiler_flag(d.getVar('TUNE_CCARGS').split(), '-mfpu', d)}"
188 ARM_TUNE = "${@get_compiler_flag(d.getVar('TUNE_CCARGS').split(), '-mcpu', d)}"
189 ARM_VERSION:aarch64 = "8"
190 ARM_VERSION:armv7a = "7"
191 ARM_VERSION:armv7ve = "7"
192 ARM_VERSION:armv6 = "6"
193
194 # GN computes and defaults to it automatically where needed
195 # forcing it from cmdline breaks build on places where it ends up
196 # overriding what GN wants
197 TUNE_CCARGS:remove = "-mthumb"
198
199 GN_DEFINES:append:arm = " \
200         arm_float_abi=\"${ARM_FLOAT_ABI}\" \
201         arm_fpu=\"${ARM_FPU}\" \
202         arm_tune=\"${ARM_TUNE}\" \
203         arm_version=${ARM_VERSION} \
204 "
205 # tcmalloc's atomicops-internals-arm-v6plus.h uses the "dmb" instruction that
206 # is not available on (some?) ARMv6 models, which causes the build to fail.
207 GN_DEFINES:append:armv6 = ' use_allocator="none"'
208 # The WebRTC code fails to build on ARMv6 when NEON is enabled.
209 # https://bugs.chromium.org/p/webrtc/issues/detail?id=6574
210
211 # Disable unknown attribute warnings that are generating tons of logs
212 # TODO(rzanoni): check if https://chromium-review.googlesource.com/c/chromium/src/+/4322480
213 # needs to be reverted
214 BUILD_CXXFLAGS:remove = '-Wunknown-attributes'
215 BUILD_CXXFLAGS:append = ' -Wno-unknown-attributes'
216 BUILD_CPPFLAGS:remove = '-Wunknown-attributes'
217 BUILD_CPPFLAGS:append = ' -Wno-unknown-attributes'
218 CXXFLAGS:remove = '-Wunknown-attributes'
219 CXXFLAGS:append = ' -Wno-unknown-attributes'
220 CPPFLAGS:remove = '-Wunknown-attributes'
221 CPPFLAGS:append = ' -Wno-unknown-attributes'
222
223 GN_DEFINES:append = ' \
224               arm_use_neon=false \
225               use_lld=true \
226               use_gold=false \
227               use_custom_libcxx_for_host=false \
228               use_custom_libcxx=false \
229               chrome_pgo_phase=0 \
230               gold_path="" \
231               is_clang=true \
232               current_os="linux" \
233               clang_use_chrome_plugins=false \
234               clang_base_path="${STAGING_DIR_NATIVE}/usr" \
235               clang_base_path_target="${STAGING_DIR_TARGET}/usr" \
236               clang_version="14.0.6" \
237               custom_toolchain="//build/toolchain/cros:target" \
238               host_toolchain="//build/toolchain/cros:host" \
239               v8_snapshot_toolchain="//build/toolchain/cros:v8_snapshot" \
240               target_cpu="${GN_TARGET_CPU}" \
241               use_v8_context_snapshot=false \
242               cros_host_ar=\"${BUILD_AR}\" \
243               cros_host_cc=\"${BUILD_CC}\" \
244               cros_host_cxx=\"${BUILD_CXX}\" \
245               cros_host_ld=\"${BUILD_CXX}\" \
246               cros_host_extra_cppflags=\"${BUILD_CPPFLAGS}\" \
247               cros_host_extra_cxxflags=\"${BUILD_CXXFLAGS}\" \
248               cros_host_extra_ldflags=\"${BUILD_LDFLAGS}\" \
249               cros_target_ar=\"${AR}\" \
250               cros_target_cc=\"${CC}\" \
251               cros_target_cxx=\"${CXX}\" \
252               cros_target_ld=\"${CXX}\" \
253               cros_target_extra_cppflags=\"${CPPFLAGS}\" \
254               cros_target_extra_cxxflags=\"${CXXFLAGS}\" \
255               cros_target_extra_ldflags=\"${LDFLAGS}\" \
256               cros_v8_snapshot_ar=\"${BUILD_AR}\" \
257               cros_v8_snapshot_cc=\"${BUILD_CC}\" \
258               cros_v8_snapshot_cxx=\"${BUILD_CXX}\" \
259               cros_v8_snapshot_ld=\"${BUILD_CXX}\" \
260               cros_v8_snapshot_cppflags=\"${BUILD_CXXFLAGS}\" \
261               cros_v8_snapshot_cxxflags=\"${BUILD_CXXFLAGS}\" \
262               cros_v8_snapshot_ldflags=\"${BUILD_LDFLAGS}\" \
263 '
264
265 PACKAGECONFIG ??= "upower use-egl"
266 PACKAGECONFIG[use-egl] = ",,virtual/egl virtual/libgles2"
267 PACKAGECONFIG[upower] = ",,,upower"
268
269 GN_DEFINES:append = ' \
270               ${PACKAGECONFIG_CONFARGS} \
271 '
272
273 do_configure () {
274     bbnote "do_configure:"
275     bbnote "Base out path: ${B}"
276
277     export DEPOT_TOOLS_UPDATE=0
278     export GCLIENT_PY3=1
279     export PATH="${DEPOT_TOOLS_DIR}:$PATH"
280     export GN_DEFINES="${GN_DEFINES}"
281
282     cd ${S}
283     python3 ./build/linux/unbundle/replace_gn_files.py --system-libraries ${GN_UNBUNDLE_LIBS}
284
285     # Download a few dependencies.  Check the current chromium DEPS file when
286     # upgrading to a new milestone.
287     python3 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
288     python3 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
289     python3 tools/rust/update_rust.py
290
291     cd ${S}/cef
292     python3 tools/gclient_hook.py --base-out-path ${B} --bypass-sysroot-check
293 }
294
295 do_compile[progress] = "outof:^\[(\d+)/(\d+)\]\s+"
296 do_compile () {
297     if [ ! -f ${OUT_PATH}/build.ninja ]; then
298          do_configure
299     fi
300
301     export PATH="${DEPOT_TOOLS_DIR}:$PATH"
302     export PATH="$PATH:${S}/third_party/ninja"
303     ninja ${PARALLEL_MAKE} -C ${OUT_PATH} libcef chrome_sandbox
304 }
305
306 do_install () {
307     cd ${S}/cef
308     python3 tools/make_distrib.py --output-dir ${OUT_PATH}/dist \
309                                   --dist-path-name cef-minimal \
310                                   --base-out-path ${B} \
311                                   --no-docs \
312                                   --no-symbols \
313                                   --no-archive \
314                                   --ninja-build \
315                                   --minimal \
316                                   --${GN_TARGET_CPU}-build \
317                                   --ozone
318
319     install -d ${D}${CEF_DATA_PATH}
320
321     cp -R --no-dereference --preserve=mode,links -v ${DIST_PATH}/* ${D}${CEF_DATA_PATH}
322     # TODO(rzanoni): Follow the wiki instructions to install the sandbox
323 }
324
325 # TODO: fix QA issues, libraries in the wrong location
326 FILES:${PN} += " \
327     ${CEF_DATA_PATH} \
328 "
329
330 INSANE_SKIP:${PN} += "libdir"
331
332 PROVIDES:${PN} += "cef"