1 # Copyright (c) 2018 LG Electronics, Inc.
3 SUMMARY = "Chromium webruntime for webOS"
4 AUTHOR = "Lokesh Kumar Goel <lokeshkumar.goel@lge.com>"
6 LICENSE = "Apache-2.0 & BSD-3-Clause & LGPL-2.0 & LGPL-2.1"
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 \
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"
19 PROVIDES = "${BROWSER_APPLICATION}"
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 \
26 SRCREV_chromium68 = "259a8b56bc833956f3acd318b7f19b028277beda"
27 SRCREV_v8 = "1e3af71f1ff3735e8a5b639c48dfca63a7b8a647"
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"
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"
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"
43 OUT_DIR = "${WORKDIR}/build"
44 BUILD_TYPE = "Release"
46 B = "${OUT_DIR}/${BUILD_TYPE}"
48 WEBRUNTIME_BUILD_TARGET = "webos:weboswebruntime"
49 BROWSER_APP_BUILD_TARGET = "chrome"
50 BROWSER_APPLICATION = "chromium68-browser"
51 BROWSER_APPLICATION_DIR = "/opt/chromium68"
53 TARGET = "${WEBRUNTIME_BUILD_TARGET} ${BROWSER_APP_BUILD_TARGET}"
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"
58 PACKAGECONFIG ?= "jumbo use-upstream-wayland"
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"
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
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"
73 PACKAGECONFIG[lttng] = "use_lttng=true,use_lttng=false,lttng-ust,lttng-tools lttng-modules babeltrace"
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"
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 \
87 enable_memorymanager_webapi=false\
88 ffmpeg_branding=\"Chrome\"\
90 ozone_auto_platforms=false\
91 proprietary_codecs=true\
93 treat_warnings_as_errors=false\
98 use_custom_libcxx=false\
100 use_neva_media=false\
104 use_system_debugger_abort=true\
105 use_webos_gpu_info_collector=false\
106 ${PACKAGECONFIG_CONFARGS}\
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
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"
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"
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
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"
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"
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).
154 custom_toolchain=\"//build/toolchain/yocto:yocto_target\" \
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\" \
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."""
175 if param.startswith(param_name):
176 return param.split('=')[1]
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"
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"
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} \
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'
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'
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
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),
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
227 # This file has been generated automatically.
228 # It invokes QEMU to run binaries built for the target in the host during the
233 os.chmod(wrapper_path, 0o755)
235 do_create_v8_qemu_wrapper[dirs] = "${B}"
236 addtask create_v8_qemu_wrapper after do_patch before do_configure
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)
245 addtask write_toolchain_file after do_patch before do_configure
247 # More options to speed up the build
250 disable_ftp_support=true\
251 enable_print_preview=false\
252 enable_remoting=false\
254 use_gnome_keyring=false\
255 use_pulseaudio=false\
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}"
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 = "(.*)"
273 #CHROMIUM_PLUGINS_PATH = "${libdir}"
274 CBE_DATA_PATH = "${libdir}/cbe"
275 CBE_DATA_LOCALES_PATH = "${CBE_DATA_PATH}/locales"
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"
282 do_compile[progress] = "outof:^\[(\d+)/(\d+)\]\s+"
284 if [ ! -f ${OUT_DIR}/${BUILD_TYPE}/build.ninja ]; then
288 export PATH="${S}/depot_tools:$PATH"
289 ${S}/depot_tools/ninja -v -C ${OUT_DIR}/${BUILD_TYPE} ${TARGET}
297 export GYP_CHROMIUM_NO_ACTION=1
298 export PATH="${S}/depot_tools:$PATH"
301 echo GN_ARGS is ${GN_ARGS}
302 echo BUILD_TARGETS are ${TARGET}
304 gn gen ${OUT_DIR}/${BUILD_TYPE} --args="${GN_ARGS}"
307 WINDOW_SIZE ?= "1920,1080"
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
316 install_chromium_browser() {
317 D_DIR=${D}${BROWSER_APPLICATION_DIR}
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}
325 xargs --arg-file=${SRC_DIR}/webos/install/default_browser/runtime.list cp -R --no-dereference --preserve=mode,links -v --target-directory=${D_DIR}
328 # AGL does not have PMLOG
329 sed -i.bak s/PmLogCtl.*// ${D_DIR}/run_webbrowser
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
337 configure_browser_settings
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}
346 # Install webos webview files
347 if [ -e "${SRC_DIR}/webos/install" ]; then
349 xargs --arg-file=${SRC_DIR}/webos/install/weboswebruntime/staging_inc.list cp --parents --target-directory=${D}${includedir}/${BPN}
351 cd ${OUT_DIR}/${BUILD_TYPE}
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}/
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}
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
369 install_chromium_browser
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 \
379 SYSROOT_DIRS_append = " ${bindir_cross}"
381 PACKAGES_prepend = " \
382 ${PN}-cross-mksnapshot \
383 ${BROWSER_APPLICATION} \
386 FILES_${BROWSER_APPLICATION} += " \
387 ${BROWSER_APPLICATION_DIR} \
388 ${WEBOS_SYSTEM_BUS_DIRS_LEGACY_BROWSER_APPLICATION} \
391 RDEPENDS_${BROWSER_APPLICATION} += "${PN}"
393 VIRTUAL-RUNTIME_gpu-libs ?= ""
394 RDEPENDS_${PN} += "${VIRTUAL-RUNTIME_gpu-libs}"
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"
403 ${libdir}/${BPN}/*.so \
404 ${WEBOS_SYSTEM_BUS_DIRS} \
407 FILES_${PN}-dev = " \
411 FILES_${PN}-cross-mksnapshot = "${bindir_cross}/${HOST_SYS}-mksnapshot.gz"