chromium68, wam: bump revision
[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
16
17 DEPENDS = "virtual/gettext wayland wayland-native pixman freetype 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"
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 "
25 SRCREV_chromium68 = "259a8b56bc833956f3acd318b7f19b028277beda"
26 SRCREV_v8 = "1e3af71f1ff3735e8a5b639c48dfca63a7b8a647"
27
28 # we don't include SRCPV in PV, so we have to manually include SRCREVs in do_fetch vardeps
29 do_fetch[vardeps] += "SRCREV_v8"
30 SRCREV_FORMAT = "main_v8"
31
32 S = "${WORKDIR}/git"
33
34 SRC_DIR = "${S}/src"
35 OUT_DIR = "${WORKDIR}/build"
36 BUILD_TYPE = "Release"
37
38 WEBRUNTIME_BUILD_TARGET = "webos:weboswebruntime"
39 BROWSER_APP_BUILD_TARGET = "chrome"
40 BROWSER_APPLICATION = "chromium68-browser"
41 BROWSER_APPLICATION_DIR = "/opt/chromium68"
42
43 TARGET = "${WEBRUNTIME_BUILD_TARGET} ${BROWSER_APP_BUILD_TARGET}"
44
45 # Skip do_install_append of webos_system_bus. It is not compatible with this component.
46 WEBOS_SYSTEM_BUS_FILES_LOCATION = "${S}/files/sysbus"
47
48 PACKAGECONFIG ?= "jumbo use-upstream-wayland"
49
50 # Options to enable debug/debug-webcore build.
51 # Add the following line to local.conf (or local.dev.inc) to enable them:
52 #   PACKAGECONFIG_append_pn-chromium68 = " debug debug-webcore"
53 # By default debug is completely disabled to speed up build
54 PACKAGECONFIG[debug] = "is_debug=false is_component_build=false symbol_level=2, is_debug=false symbol_level=0"
55 PACKAGECONFIG[debug-webcore] = "remove_webcore_debug_symbols=false,remove_webcore_debug_symbols=true"
56
57 # Set a default value for jumbo file merge of 8. This should be good for build
58 # servers and workstations with a big number of cores. In case build is
59 # happening in a machine with less cores but still enough RAM a good value could
60 # be 50.
61 JUMBO_FILE_MERGE_LIMIT="8"
62 PACKAGECONFIG[jumbo] = "use_jumbo_build=true jumbo_file_merge_limit=${JUMBO_FILE_MERGE_LIMIT}, use_jumbo_build=false"
63
64 PACKAGECONFIG[lttng] = "use_lttng=true,use_lttng=false,lttng-ust,lttng-tools lttng-modules babeltrace"
65
66 # Chromium can use v4l2 device for hardware accelerated video decoding on such boards as Renesas R-car M3, for example.
67 # In case of R-car m3, additional patches are required for gstreamer and v4l2apps.
68 # See https://github.com/igel-oss/meta-browser-hwdecode/tree/igalia-chromium71.
69 PACKAGECONFIG[use-linux-v4l2] = "use_v4l2_codec=true use_v4lplugin=true use_linux_v4l2_only=true"
70
71 PACKAGECONFIG[use-upstream-wayland] = " \
72         ozone_platform_wayland_external=false ozone_platform_wayland=true \
73         use_system_minigbm=true, \
74         ozone_platform_wayland_external=true ozone_platform_wayland=false \
75 "
76
77 GN_ARGS = "\
78     cros_host_ar=\"${BUILD_AR}\"\
79     cros_host_cc=\"${BUILD_CC}\"\
80     cros_host_cxx=\"${BUILD_CXX}\"\
81     cros_host_extra_ldflags=\"${BUILD_LDFLAGS}\"\
82     cros_target_ar=\"${AR}\"\
83     cros_target_cc=\"${CC}\"\
84     cros_target_cxx=\"${CXX}\"\
85     enable_memorymanager_webapi=false\
86     ffmpeg_branding=\"Chrome\"\
87     host_os=\"linux\"\
88     is_cross_linux_build=true\
89     is_clang=false\
90     ozone_auto_platforms=false\
91     proprietary_codecs=true\
92     target_os=\"linux\"\
93     target_sysroot=\"${STAGING_DIR_HOST}\"\
94     treat_warnings_as_errors=false\
95     is_agl=true\
96     use_cbe=true\
97     is_chrome_cbe=true\
98     use_cups=false\
99     use_custom_libcxx=false\
100     use_kerberos=false\
101     use_neva_media=false\
102     use_ozone=true\
103     use_xkbcommon=true\
104     use_pmlog=false\
105     use_sysroot=false\
106     use_system_debugger_abort=true\
107     use_webos_gpu_info_collector=false\
108     ${PACKAGECONFIG_CONFARGS}\
109 "
110
111 # We need this for cross to 32 bit architectures, as we do not have a way
112 # to retrieve a host gcc for 32 bits in yocto
113 GN_ARGS_TOOLCHAIN = "\
114     is_host_clang=true\
115     host_toolchain=\"//build/toolchain/yocto:clang_yocto_native\" \
116     fatal_linker_warnings=false\
117     use_custom_libcxx_for_host=true\
118 "
119
120 # But for x86-64 previous setting fails in torque, so this makes build use
121 # gcc on host, and use host toolchain for v8 snapshot and torque
122 GN_ARGS_TOOLCHAIN_x86-64 = "\
123     is_host_clang=false\
124     use_custom_libcxx_for_host=false\
125     v8_snapshot_toolchain=\"//build/toolchain/cros:host\" \
126     cros_v8_snapshot_is_clang=false\
127     cros_v8_snapshot_ar=\"${BUILD_AR}\"\
128     cros_v8_snapshot_cc=\"${BUILD_CC}\"\
129     cros_v8_snapshot_cxx=\"${BUILD_CXX}\"\
130     cros_v8_snapshot_extra_ldflags=\"${BUILD_LDFLAGS}\"\
131 "
132
133 GN_ARGS += "${GN_ARGS_TOOLCHAIN}"
134
135 python do_write_toolchain_file () {
136     """Writes a BUILD.gn file for Yocto detailing its toolchains."""
137     toolchain_dir = d.expand("${S}/src/build/toolchain/yocto")
138     bb.utils.mkdirhier(toolchain_dir)
139     toolchain_file = os.path.join(toolchain_dir, "BUILD.gn")
140     write_toolchain_file(d, toolchain_file)
141 }
142 addtask write_toolchain_file after do_patch before do_configure
143 # end TODO: drop this after we migrate to ubuntu 16.04 or above
144
145 # More options to speed up the build
146 GN_ARGS += "\
147     enable_nacl=false\
148     disable_ftp_support=true\
149     enable_print_preview=false\
150     enable_remoting=false\
151     use_glib=true\
152     use_gnome_keyring=false\
153     use_pulseaudio=false\
154 "
155
156 # Following options help build with icecc
157 GN_ARGS += "\
158     linux_use_bundled_binutils=false\
159     use_debug_fission=false\
160 "
161
162 # Respect ld-is-gold in DISTRO_FEATURES when enabling gold
163 # Similar patch applied in meta-browser
164 # http://patchwork.openembedded.org/patch/77755/
165 EXTRA_OEGN_GOLD = "${@bb.utils.contains('DISTRO_FEATURES', 'ld-is-gold', 'use_gold=true', 'use_gold=false', d)}"
166 GN_ARGS += "${EXTRA_OEGN_GOLD}"
167
168 GN_ARGS_append_arm = " target_cpu=\"arm\""
169 GN_ARGS_append_qemux86 = " target_cpu=\"x86\""
170 GN_ARGS_append_aarch64 = " target_cpu=\"arm64\""
171
172 # ARM builds need special additional flags (see ${S}/build/config/arm.gni).
173 ARM_FLOAT_ABI = "${@bb.utils.contains('TUNE_FEATURES', 'callconvention-hard', 'hard', 'softfp', d)}"
174 GN_ARGS_append_armv6 = " arm_arch=\"armv6\" arm_version=6 arm_float_abi=\"${ARM_FLOAT_ABI}\""
175 GN_ARGS_append_armv7a = " arm_arch=\"armv7-a\" arm_version=7 arm_float_abi=\"${ARM_FLOAT_ABI}\""
176 GN_ARGS_append_armv7ve = " arm_arch=\"armv7ve\" arm_version=7 arm_float_abi=\"${ARM_FLOAT_ABI}\""
177 # tcmalloc's atomicops-internals-arm-v6plus.h uses the "dmb" instruction that
178 # is not available on (some?) ARMv6 models, which causes the build to fail.
179 GN_ARGS_append_armv6 += 'use_allocator="none"'
180 # The WebRTC code fails to build on ARMv6 when NEON is enabled.
181 # https://bugs.chromium.org/p/webrtc/issues/detail?id=6574
182 GN_ARGS_append_armv6 += 'arm_use_neon=false'
183
184 # Doesn't build for armv[45]*
185 COMPATIBLE_MACHINE = "(-)"
186 COMPATIBLE_MACHINE_aarch64 = "(.*)"
187 COMPATIBLE_MACHINE_armv6 = "(.*)"
188 COMPATIBLE_MACHINE_armv7a = "(.*)"
189 COMPATIBLE_MACHINE_armv7ve = "(.*)"
190 COMPATIBLE_MACHINE_x86 = "(.*)"
191 COMPATIBLE_MACHINE_x86-64 = "(.*)"
192
193 #CHROMIUM_PLUGINS_PATH = "${libdir}"
194 CBE_DATA_PATH = "${libdir}/cbe"
195 CBE_DATA_LOCALES_PATH = "${CBE_DATA_PATH}/locales"
196
197 # The text relocations are intentional -- see comments in [GF-52468]
198 # TODO: check if we need INSANE_SKIP on ldflags
199 INSANE_SKIP_${PN} = "textrel ldflags"
200
201
202 do_compile[progress] = "outof:^\[(\d+)/(\d+)\]\s+"
203 do_compile() {
204     if [ ! -f ${OUT_DIR}/${BUILD_TYPE}/build.ninja ]; then
205          do_configure
206     fi
207
208     export PATH="${S}/depot_tools:$PATH"
209     ${S}/depot_tools/ninja -C ${OUT_DIR}/${BUILD_TYPE} ${TARGET}
210 }
211
212 do_configure() {
213     configure_env
214 }
215
216 configure_env() {
217     export GYP_CHROMIUM_NO_ACTION=1
218     export PATH="${S}/depot_tools:$PATH"
219
220     GN_ARGS="${GN_ARGS}"
221     echo GN_ARGS is ${GN_ARGS}
222     echo BUILD_TARGETS are ${TARGET}
223     cd ${SRC_DIR}
224     gn gen ${OUT_DIR}/${BUILD_TYPE} --args="${GN_ARGS}"
225 }
226
227 WINDOW_SIZE ?= "1920,1080"
228
229 configure_browser_settings() {
230     USER_AGENT="Mozilla/5.0 (Linux; NetCast; U) AppleWebKit/537.31 (KHTML, like Gecko) Chrome/${CHROMIUM_VERSION} Safari/537.31"
231     echo "${USER_AGENT}" > ${D_DIR}/user_agent_conf
232     #We can replace below WINDOW_SIZE values from build configuration if available
233     #echo "${WINDOW_SIZE}" > ${D_DIR}/window_size_conf
234 }
235
236 install_chromium_browser() {
237     D_DIR=${D}${BROWSER_APPLICATION_DIR}
238     install -d ${D_DIR}
239
240     # Install browser files
241      if [ -e "${SRC_DIR}/webos/install" ]; then
242          cd ${OUT_DIR}/${BUILD_TYPE}
243          xargs --arg-file=${SRC_DIR}/webos/install/default_browser/binary.list cp -R --no-dereference --preserve=mode,links -v --target-directory=${D_DIR}
244          cd ${SRC_DIR}
245          xargs --arg-file=${SRC_DIR}/webos/install/default_browser/runtime.list cp -R --no-dereference --preserve=mode,links -v --target-directory=${D_DIR}
246      fi
247
248     # AGL does not have PMLOG
249     sed -i.bak s/PmLogCtl.*// ${D_DIR}/run_webbrowser
250
251     # To execute chromium in JAILER, Security Part needs permissions change
252     # run_webbrowser: Script file for launching chromium
253     chmod -v 755 ${D_DIR}/chrome
254     chmod -v 755 ${D_DIR}/kill_webbrowser
255     chmod -v 755 ${D_DIR}/run_webbrowser
256
257     configure_browser_settings
258 }
259
260 MKSNAPSHOT_PATH = ""
261 MKSNAPSHOT_PATH_arm = "clang_x86_v8_arm/"
262 MKSNAPSHOT_PATH_aarch64 = "clang_x64_v8_arm64/"
263
264 install_webruntime() {
265     install -d ${D}${libdir}
266     install -d ${D}${includedir}/${BPN}
267     install -d ${D}${CBE_DATA_PATH}
268     install -d ${D}${CBE_DATA_LOCALES_PATH}
269
270     # Install webos webview files
271     if [ -e "${SRC_DIR}/webos/install" ]; then
272         cd ${SRC_DIR}
273         xargs --arg-file=${SRC_DIR}/webos/install/weboswebruntime/staging_inc.list cp --parents --target-directory=${D}${includedir}/${BPN}
274
275         cd ${OUT_DIR}/${BUILD_TYPE}
276
277         cp libcbe.so ${D}${libdir}/
278         if [ "${WEBOS_LTTNG_ENABLED}" = "1" ]; then
279           # use bindir if building non-cbe
280           cp libchromium_lttng_provider.so ${D}${libdir}/
281         fi
282         xargs --arg-file=${SRC_DIR}/webos/install/weboswebruntime/binary.list cp --parents --target-directory=${D}${CBE_DATA_PATH}
283         cat ${SRC_DIR}/webos/install/weboswebruntime/data_locales.list | xargs -I{} install -m 755 -p {} ${D}${CBE_DATA_LOCALES_PATH}
284     fi
285
286     # move this to separate mksnapshot-cross recipe once we figure out how to build just cross mksnapshot from chromium repository
287     install -d ${D}${bindir_cross}
288     gzip -c ${OUT_DIR}/${BUILD_TYPE}/${MKSNAPSHOT_PATH}mksnapshot > ${D}${bindir_cross}/${HOST_SYS}-mksnapshot.gz
289 }
290
291 do_install() {
292     install_webruntime
293     install_chromium_browser
294 }
295
296 WEBOS_SYSTEM_BUS_DIRS_LEGACY_BROWSER_APPLICATION = " \
297     ${webos_sysbus_prvservicesdir}/${BROWSER_APPLICATION}.service \
298     ${webos_sysbus_pubservicesdir}/${BROWSER_APPLICATION}.service \
299     ${webos_sysbus_prvrolesdir}/${BROWSER_APPLICATION}.json \
300     ${webos_sysbus_pubrolesdir}/${BROWSER_APPLICATION}.json \
301 "
302
303 SYSROOT_DIRS_append = " ${bindir_cross}"
304
305 PACKAGES_prepend = " \
306     ${PN}-cross-mksnapshot \
307     ${BROWSER_APPLICATION} \
308 "
309
310 FILES_${BROWSER_APPLICATION} += " \
311     ${BROWSER_APPLICATION_DIR} \
312     ${WEBOS_SYSTEM_BUS_DIRS_LEGACY_BROWSER_APPLICATION} \
313 "
314
315 RDEPENDS_${BROWSER_APPLICATION} += "${PN}"
316
317 VIRTUAL-RUNTIME_gpu-libs ?= ""
318 RDEPENDS_${PN} += "${VIRTUAL-RUNTIME_gpu-libs}"
319
320 # The text relocations are intentional -- see comments in [GF-52468]
321 # TODO: check if we need INSANE_SKIP on ldflags
322 INSANE_SKIP_${BROWSER_APPLICATION} += "libdir ldflags textrel"
323
324 FILES_${PN} = " \
325     ${libdir}/*.so \
326     ${CBE_DATA_PATH}/* \
327     ${libdir}/${BPN}/*.so \
328     ${WEBOS_SYSTEM_BUS_DIRS} \
329 "
330
331 FILES_${PN}-dev = " \
332     ${includedir} \
333 "
334
335 FILES_${PN}-cross-mksnapshot = "${bindir_cross}/${HOST_SYS}-mksnapshot.gz"