pipewire: add patch to fix non-S16 negotiation issue
[AGL/meta-agl-devel.git] / meta-html5-framework / recipes-wam / chromium / chromium68_git.bb
1 # Copyright (c) 2018 LG Electronics, Inc.
2
3 SUMMARY = "Chromium webruntime for webOS"
4 AUTHOR = "Lokesh Kumar Goel <lokeshkumar.goel@lge.com>"
5 SECTION = "webos/apps"
6 LICENSE = "Apache-2.0 & BSD-3-Clause & LGPL-2.0 & LGPL-2.1"
7 LIC_FILES_CHKSUM = "\
8     file://src/LICENSE;md5=0fca02217a5d49a14dfe2d11837bb34d \
9     file://src/third_party/blink/renderer/core/LICENSE-LGPL-2;md5=36357ffde2b64ae177b2494445b79d21 \
10     file://src/third_party/blink/renderer/core/LICENSE-LGPL-2.1;md5=a778a33ef338abbaf8b8a7c36b6eec80 \
11 "
12
13 require gn-utils.inc
14
15 inherit gettext qemu
16
17 DEPENDS = "virtual/gettext wayland wayland-native pixman freetype glib-2.0 fontconfig openssl pango cairo icu libxkbcommon libexif dbus pciutils udev libcap alsa-lib virtual/egl elfutils-native libdrm atk gperf-native gconf nss nss-native nspr nspr-native bison-native qemu-native"
18
19 PROVIDES = "${BROWSER_APPLICATION}"
20
21 SRC_URI = "\
22     git://github.com/webosose/${PN};branch=@39.agl.guppy;protocol=https;rev=${SRCREV_chromium68} \
23     git://github.com/webosose/v8;destsuffix=git/src/v8;rev=${SRCREV_v8} \
24     file://v8-qemu-wrapper.patch \
25 "
26 SRCREV_chromium68 = "259a8b56bc833956f3acd318b7f19b028277beda"
27 SRCREV_v8 = "1e3af71f1ff3735e8a5b639c48dfca63a7b8a647"
28
29 # Backport of https://chromium-review.googlesource.com/c/chromium/src/+/1138251/
30 SRC_URI_append_armv7a = " file://0001-skia-Build-skcms-with-mfp16-format-ieee-on-GCC-ARM-b.patch"
31 SRC_URI_append_armv7ve = " file://0001-skia-Build-skcms-with-mfp16-format-ieee-on-GCC-ARM-b.patch"
32
33 # Backport of https://chromium-review.googlesource.com/c/chromium/third_party/ffmpeg/+/1390286
34 SRC_URI_append_aarch64 = " file://0001-libavcodec-Remove-dynamic-relocs-from-h264idct_neon..patch"
35
36 # we don't include SRCPV in PV, so we have to manually include SRCREVs in do_fetch vardeps
37 do_fetch[vardeps] += "SRCREV_v8"
38 SRCREV_FORMAT = "main_v8"
39
40 S = "${WORKDIR}/git"
41
42 SRC_DIR = "${S}/src"
43 OUT_DIR = "${WORKDIR}/build"
44 BUILD_TYPE = "Release"
45
46 B = "${OUT_DIR}/${BUILD_TYPE}"
47
48 WEBRUNTIME_BUILD_TARGET = "webos:weboswebruntime"
49 BROWSER_APP_BUILD_TARGET = "chrome"
50 BROWSER_APPLICATION = "chromium68-browser"
51 BROWSER_APPLICATION_DIR = "/opt/chromium68"
52
53 TARGET = "${WEBRUNTIME_BUILD_TARGET} ${BROWSER_APP_BUILD_TARGET}"
54
55 # Skip do_install_append of webos_system_bus. It is not compatible with this component.
56 WEBOS_SYSTEM_BUS_FILES_LOCATION = "${S}/files/sysbus"
57
58 PACKAGECONFIG ?= "jumbo use-upstream-wayland"
59
60 # Options to enable debug-webcore build.
61 # Add the following line to local.conf (or local.dev.inc) to enable them:
62 #   PACKAGECONFIG_append_pn-chromium68 = " debug-webcore"
63 # Other debug options are controlled by sections later in this file
64 PACKAGECONFIG[debug-webcore] = "remove_webcore_debug_symbols=false,remove_webcore_debug_symbols=true"
65
66 # Set a default value for jumbo file merge of 8. This should be good for build
67 # servers and workstations with a big number of cores. In case build is
68 # happening in a machine with less cores but still enough RAM a good value could
69 # be 50.
70 JUMBO_FILE_MERGE_LIMIT="8"
71 PACKAGECONFIG[jumbo] = "use_jumbo_build=true jumbo_file_merge_limit=${JUMBO_FILE_MERGE_LIMIT}, use_jumbo_build=false"
72
73 PACKAGECONFIG[lttng] = "use_lttng=true,use_lttng=false,lttng-ust,lttng-tools lttng-modules babeltrace"
74
75 # Chromium can use v4l2 device for hardware accelerated video decoding on such boards as Renesas R-car M3, for example.
76 # In case of R-car m3, additional patches are required for gstreamer and v4l2apps.
77 # See https://github.com/igel-oss/meta-browser-hwdecode/tree/igalia-chromium71.
78 PACKAGECONFIG[use-linux-v4l2] = "use_v4l2_codec=true use_v4lplugin=true use_linux_v4l2_only=true"
79
80 PACKAGECONFIG[use-upstream-wayland] = " \
81         ozone_platform_wayland_external=false ozone_platform_wayland=true \
82         use_system_minigbm=true, \
83         ozone_platform_wayland_external=true ozone_platform_wayland=false \
84 "
85
86 GN_ARGS = "\
87     enable_memorymanager_webapi=false\
88     ffmpeg_branding=\"Chrome\"\
89     host_os=\"linux\"\
90     ozone_auto_platforms=false\
91     proprietary_codecs=true\
92     target_os=\"linux\"\
93     treat_warnings_as_errors=false\
94     is_agl=true\
95     use_cbe=true\
96     is_chrome_cbe=true\
97     use_cups=false\
98     use_custom_libcxx=false\
99     use_kerberos=false\
100     use_neva_media=false\
101     use_ozone=true\
102     use_xkbcommon=true\
103     use_pmlog=false\
104     use_system_debugger_abort=true\
105     use_webos_gpu_info_collector=false\
106     ${PACKAGECONFIG_CONFARGS}\
107 "
108
109 # From Chromium's BUILDCONFIG.gn:
110 # Set to enable the official build level of optimization. This has nothing
111 # to do with branding, but enables an additional level of optimization above
112 # release (!is_debug). This might be better expressed as a tri-state
113 # (debug, release, official) but for historical reasons there are two
114 # separate flags.
115 # See also: https://groups.google.com/a/chromium.org/d/msg/chromium-dev/hkcb6AOX5gE/PPT1ukWoBwAJ
116 GN_ARGS += "is_debug=false is_official_build=true"
117
118 # is_cfi default value is true for x86-64 builds with is_official_build=true.
119 # As of M63, we explicitly need to set it to false, otherwise we fail the
120 # following assertion in //build/config/sanitizers/sanitizers.gni:
121 #   assert(!is_cfi || is_clang,
122 #          "is_cfi requires setting is_clang = true in 'gn args'")
123 GN_ARGS += "is_cfi=false"
124
125 # By default, passing is_official_build=true to GN causes its symbol_level
126 # variable to be set to "2". This means the compiler will be passed "-g2" and
127 # we will end up with a very large chrome binary (around 5Gb as of M58)
128 # regardless of whether DEBUG_BUILD has been set or not. In addition, binutils,
129 # file and other utilities are unable to read a 32-bit binary this size, which
130 # causes it not to be stripped.
131 # The solution is two-fold:
132 # 1. Make sure -g is not passed on 32-bit architectures via DEBUG_FLAGS. -g is
133 #    the same as -g2. -g1 generates an 800MB binary, which is a lot more
134 #    manageable.
135 # 2. Explicitly pass symbol_level=0 to GN. This causes -g0 to be passed
136 #    instead, so that if DEBUG_BUILD is not set GN will not create a huge debug
137 #    binary anyway. Since our compiler flags are passed after GN's, -g0 does
138 #    not cause any issues if DEBUG_BUILD is set, as -g1 will be passed later.
139 DEBUG_FLAGS_remove_arm = "-g"
140 DEBUG_FLAGS_append_arm = "-g1"
141 DEBUG_FLAGS_remove_x86 = "-g"
142 DEBUG_FLAGS_append_x86 = "-g1"
143 GN_ARGS += "symbol_level=0"
144
145 # We do not want to use Chromium's own Debian-based sysroots, it is easier to
146 # just let Chromium's build system assume we are not using a sysroot at all and
147 # let Yocto handle everything.
148 GN_ARGS += "use_sysroot=false"
149
150 # Toolchains we will use for the build. We need to point to the toolchain file
151 # we've created, set the right target architecture and make sure we are not
152 # using Chromium's toolchain (bundled clang, bundled binutils etc).
153 GN_ARGS += "\
154         custom_toolchain=\"//build/toolchain/yocto:yocto_target\" \
155         gold_path=\"\" \
156         host_toolchain=\"//build/toolchain/yocto:yocto_native\" \
157         is_clang=${@is_default_cc_clang(d)} \
158         clang_base_path=\"${@clang_install_path(d)}\" \
159         clang_use_chrome_plugins=false \
160         linux_use_bundled_binutils=false \
161         target_cpu=\"${@gn_target_arch_name(d)}\" \
162         v8_snapshot_toolchain=\"//build/toolchain/yocto:yocto_target\" \
163 "
164
165 # ARM builds need special additional flags (see ${S}/build/config/arm.gni).
166 # If we do not pass |arm_arch| and friends to GN, it will deduce a value that
167 # will then conflict with TUNE_CCARGS and CC.
168 # Note that as of M61 in some corner cases parts of the build system disable
169 # the "compiler_arm_fpu" GN config, whereas -mfpu is always passed via ${CC}.
170 # We might want to rework that if there are issues in the future.
171 def get_compiler_flag(params, param_name, d):
172     """Given a sequence of compiler arguments in |params|, returns the value of
173     an option |param_name| or an empty string if the option is not present."""
174     for param in params:
175       if param.startswith(param_name):
176         return param.split('=')[1]
177     return ''
178
179 ARM_FLOAT_ABI = "${@bb.utils.contains('TUNE_FEATURES', 'callconvention-hard', 'hard', 'softfp', d)}"
180 ARM_FPU = "${@get_compiler_flag(d.getVar('TUNE_CCARGS').split(), '-mfpu', d)}"
181 ARM_TUNE = "${@get_compiler_flag(d.getVar('TUNE_CCARGS').split(), '-mcpu', d)}"
182 ARM_VERSION_aarch64 = "8"
183 ARM_VERSION_armv7a = "7"
184 ARM_VERSION_armv7ve = "7"
185 ARM_VERSION_armv6 = "6"
186
187 # GN computes and defaults to it automatically where needed
188 # forcing it from cmdline breaks build on places where it ends up
189 # overriding what GN wants
190 TUNE_CCARGS_remove = "-mthumb"
191
192 GN_ARGS_append_arm = " \
193         arm_float_abi=\"${ARM_FLOAT_ABI}\" \
194         arm_fpu=\"${ARM_FPU}\" \
195         arm_tune=\"${ARM_TUNE}\" \
196         arm_version=${ARM_VERSION} \
197 "
198 # tcmalloc's atomicops-internals-arm-v6plus.h uses the "dmb" instruction that
199 # is not available on (some?) ARMv6 models, which causes the build to fail.
200 GN_ARGS_append_armv6 += 'use_allocator="none"'
201 # The WebRTC code fails to build on ARMv6 when NEON is enabled.
202 # https://bugs.chromium.org/p/webrtc/issues/detail?id=6574
203 GN_ARGS_append_armv6 += 'arm_use_neon=false'
204
205 # Disable glibc shims on musl
206 # tcmalloc does not play well with musl as of M62 (and possibly earlier).
207 # https://github.com/gperftools/gperftools/issues/693
208 GN_ARGS_append_libc-musl = ' use_allocator_shim=false'
209
210 # V8's JIT infrastructure requires binaries such as mksnapshot and
211 # mkpeephole to be run in the host during the build. However, these
212 # binaries must have the same bit-width as the target (e.g. a x86_64
213 # host targeting ARMv6 needs to produce a 32-bit binary). Instead of
214 # depending on a third Yocto toolchain, we just build those binaries
215 # for the target and run them on the host with QEMU.
216 python do_create_v8_qemu_wrapper () {
217     """Creates a small wrapper that invokes QEMU to run some target V8 binaries
218     on the host."""
219     qemu_libdirs = [d.expand('${STAGING_DIR_HOST}${libdir}'),
220                     d.expand('${STAGING_DIR_HOST}${base_libdir}')]
221     qemu_cmd = qemu_wrapper_cmdline(d, d.getVar('STAGING_DIR_HOST', True),
222                                     qemu_libdirs)
223     wrapper_path = d.expand('${B}/v8-qemu-wrapper.sh')
224     with open(wrapper_path, 'w') as wrapper_file:
225         wrapper_file.write("""#!/bin/sh
226
227 # This file has been generated automatically.
228 # It invokes QEMU to run binaries built for the target in the host during the
229 # build process.
230
231 %s "$@"
232 """ % qemu_cmd)
233     os.chmod(wrapper_path, 0o755)
234 }
235 do_create_v8_qemu_wrapper[dirs] = "${B}"
236 addtask create_v8_qemu_wrapper after do_patch before do_configure
237
238 python do_write_toolchain_file () {
239     """Writes a BUILD.gn file for Yocto detailing its toolchains."""
240     toolchain_dir = d.expand("${S}/src/build/toolchain/yocto")
241     bb.utils.mkdirhier(toolchain_dir)
242     toolchain_file = os.path.join(toolchain_dir, "BUILD.gn")
243     write_toolchain_file(d, toolchain_file)
244 }
245 addtask write_toolchain_file after do_patch before do_configure
246
247 # More options to speed up the build
248 GN_ARGS += "\
249     enable_nacl=false\
250     disable_ftp_support=true\
251     enable_print_preview=false\
252     enable_remoting=false\
253     use_glib=true\
254     use_gnome_keyring=false\
255     use_pulseaudio=false\
256 "
257
258 # Respect ld-is-gold in DISTRO_FEATURES when enabling gold
259 # Similar patch applied in meta-browser
260 # http://patchwork.openembedded.org/patch/77755/
261 EXTRA_OEGN_GOLD = "${@bb.utils.contains('DISTRO_FEATURES', 'ld-is-gold', 'use_gold=true', 'use_gold=false', d)}"
262 GN_ARGS += "${EXTRA_OEGN_GOLD}"
263
264 # Doesn't build for armv[45]*
265 COMPATIBLE_MACHINE = "(-)"
266 COMPATIBLE_MACHINE_aarch64 = "(.*)"
267 COMPATIBLE_MACHINE_armv6 = "(.*)"
268 COMPATIBLE_MACHINE_armv7a = "(.*)"
269 COMPATIBLE_MACHINE_armv7ve = "(.*)"
270 COMPATIBLE_MACHINE_x86 = "(.*)"
271 COMPATIBLE_MACHINE_x86-64 = "(.*)"
272
273 #CHROMIUM_PLUGINS_PATH = "${libdir}"
274 CBE_DATA_PATH = "${libdir}/cbe"
275 CBE_DATA_LOCALES_PATH = "${CBE_DATA_PATH}/locales"
276
277 # The text relocations are intentional -- see comments in [GF-52468]
278 # TODO: check if we need INSANE_SKIP on ldflags
279 INSANE_SKIP_${PN} = "textrel ldflags"
280
281
282 do_compile[progress] = "outof:^\[(\d+)/(\d+)\]\s+"
283 do_compile() {
284     if [ ! -f ${OUT_DIR}/${BUILD_TYPE}/build.ninja ]; then
285          do_configure
286     fi
287
288     export PATH="${S}/depot_tools:$PATH"
289     ${S}/depot_tools/ninja -v -C ${OUT_DIR}/${BUILD_TYPE} ${TARGET}
290 }
291
292 do_configure() {
293     configure_env
294 }
295
296 configure_env() {
297     export GYP_CHROMIUM_NO_ACTION=1
298     export PATH="${S}/depot_tools:$PATH"
299
300     GN_ARGS="${GN_ARGS}"
301     echo GN_ARGS is ${GN_ARGS}
302     echo BUILD_TARGETS are ${TARGET}
303     cd ${SRC_DIR}
304     gn gen ${OUT_DIR}/${BUILD_TYPE} --args="${GN_ARGS}"
305 }
306
307 WINDOW_SIZE ?= "1920,1080"
308
309 configure_browser_settings() {
310     USER_AGENT="Mozilla/5.0 (Linux; NetCast; U) AppleWebKit/537.31 (KHTML, like Gecko) Chrome/${CHROMIUM_VERSION} Safari/537.31"
311     echo "${USER_AGENT}" > ${D_DIR}/user_agent_conf
312     #We can replace below WINDOW_SIZE values from build configuration if available
313     #echo "${WINDOW_SIZE}" > ${D_DIR}/window_size_conf
314 }
315
316 install_chromium_browser() {
317     D_DIR=${D}${BROWSER_APPLICATION_DIR}
318     install -d ${D_DIR}
319
320     # Install browser files
321      if [ -e "${SRC_DIR}/webos/install" ]; then
322          cd ${OUT_DIR}/${BUILD_TYPE}
323          xargs --arg-file=${SRC_DIR}/webos/install/default_browser/binary.list cp -R --no-dereference --preserve=mode,links -v --target-directory=${D_DIR}
324          cd ${SRC_DIR}
325          xargs --arg-file=${SRC_DIR}/webos/install/default_browser/runtime.list cp -R --no-dereference --preserve=mode,links -v --target-directory=${D_DIR}
326      fi
327
328     # AGL does not have PMLOG
329     sed -i.bak s/PmLogCtl.*// ${D_DIR}/run_webbrowser
330
331     # To execute chromium in JAILER, Security Part needs permissions change
332     # run_webbrowser: Script file for launching chromium
333     chmod -v 755 ${D_DIR}/chrome
334     chmod -v 755 ${D_DIR}/kill_webbrowser
335     chmod -v 755 ${D_DIR}/run_webbrowser
336
337     configure_browser_settings
338 }
339
340 install_webruntime() {
341     install -d ${D}${libdir}
342     install -d ${D}${includedir}/${BPN}
343     install -d ${D}${CBE_DATA_PATH}
344     install -d ${D}${CBE_DATA_LOCALES_PATH}
345
346     # Install webos webview files
347     if [ -e "${SRC_DIR}/webos/install" ]; then
348         cd ${SRC_DIR}
349         xargs --arg-file=${SRC_DIR}/webos/install/weboswebruntime/staging_inc.list cp --parents --target-directory=${D}${includedir}/${BPN}
350
351         cd ${OUT_DIR}/${BUILD_TYPE}
352
353         cp libcbe.so ${D}${libdir}/
354         if [ "${WEBOS_LTTNG_ENABLED}" = "1" ]; then
355           # use bindir if building non-cbe
356           cp libchromium_lttng_provider.so ${D}${libdir}/
357         fi
358         xargs --arg-file=${SRC_DIR}/webos/install/weboswebruntime/binary.list cp --parents --target-directory=${D}${CBE_DATA_PATH}
359         cat ${SRC_DIR}/webos/install/weboswebruntime/data_locales.list | xargs -I{} install -m 755 -p {} ${D}${CBE_DATA_LOCALES_PATH}
360     fi
361
362     # move this to separate mksnapshot-cross recipe once we figure out how to build just cross mksnapshot from chromium repository
363     install -d ${D}${bindir_cross}
364     gzip -c ${OUT_DIR}/${BUILD_TYPE}/${MKSNAPSHOT_PATH}mksnapshot > ${D}${bindir_cross}/${HOST_SYS}-mksnapshot.gz
365 }
366
367 do_install() {
368     install_webruntime
369     install_chromium_browser
370 }
371
372 WEBOS_SYSTEM_BUS_DIRS_LEGACY_BROWSER_APPLICATION = " \
373     ${webos_sysbus_prvservicesdir}/${BROWSER_APPLICATION}.service \
374     ${webos_sysbus_pubservicesdir}/${BROWSER_APPLICATION}.service \
375     ${webos_sysbus_prvrolesdir}/${BROWSER_APPLICATION}.json \
376     ${webos_sysbus_pubrolesdir}/${BROWSER_APPLICATION}.json \
377 "
378
379 SYSROOT_DIRS_append = " ${bindir_cross}"
380
381 PACKAGES_prepend = " \
382     ${PN}-cross-mksnapshot \
383     ${BROWSER_APPLICATION} \
384 "
385
386 FILES_${BROWSER_APPLICATION} += " \
387     ${BROWSER_APPLICATION_DIR} \
388     ${WEBOS_SYSTEM_BUS_DIRS_LEGACY_BROWSER_APPLICATION} \
389 "
390
391 RDEPENDS_${BROWSER_APPLICATION} += "${PN}"
392
393 VIRTUAL-RUNTIME_gpu-libs ?= ""
394 RDEPENDS_${PN} += "${VIRTUAL-RUNTIME_gpu-libs}"
395
396 # The text relocations are intentional -- see comments in [GF-52468]
397 # TODO: check if we need INSANE_SKIP on ldflags
398 INSANE_SKIP_${BROWSER_APPLICATION} += "libdir ldflags textrel"
399
400 FILES_${PN} = " \
401     ${libdir}/*.so \
402     ${CBE_DATA_PATH}/* \
403     ${libdir}/${BPN}/*.so \
404     ${WEBOS_SYSTEM_BUS_DIRS} \
405 "
406
407 FILES_${PN}-dev = " \
408     ${includedir} \
409 "
410
411 FILES_${PN}-cross-mksnapshot = "${bindir_cross}/${HOST_SYS}-mksnapshot.gz"