chromium*: remove jumbo build options
[AGL/meta-agl-demo.git] / recipes-wam / chromium / chromium.inc
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 pythonnative
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 at-spi2-atk gperf-native gconf nss nss-native nspr nspr-native bison-native qemu-native"
18
19 PROVIDES = "${BROWSER_APPLICATION}"
20
21 SRCREV_v8 = "1e3af71f1ff3735e8a5b639c48dfca63a7b8a647"
22
23 # we don't include SRCPV in PV, so we have to manually include SRCREVs in do_fetch vardeps
24 do_fetch[vardeps] += "SRCREV_v8"
25 SRCREV_FORMAT = "main_v8"
26
27 S = "${WORKDIR}/git"
28
29 SRC_DIR = "${S}/src"
30 BUILD_TYPE = "Release"
31
32 B = "${WORKDIR}/build"
33 OUT_DIR = "${B}/${BUILD_TYPE}"
34
35 WEBRUNTIME_BUILD_TARGET = "webos:weboswebruntime"
36 BROWSER_APP_BUILD_TARGET = "chrome"
37 BROWSER_APPLICATION = "chromium84-browser"
38 BROWSER_APPLICATION_DIR = "/opt/chromium84"
39
40 TARGET = "${WEBRUNTIME_BUILD_TARGET} ${BROWSER_APP_BUILD_TARGET}"
41
42 # Skip do_install:append of webos_system_bus. It is not compatible with this component.
43 WEBOS_SYSTEM_BUS_FILES_LOCATION = "${S}/files/sysbus"
44
45 PACKAGECONFIG ?= "use-upstream-wayland"
46
47 PACKAGECONFIG[lttng] = "use_lttng=true,use_lttng=false,lttng-ust,lttng-tools lttng-modules babeltrace"
48
49 # Chromium can use v4l2 device for hardware accelerated video decoding on such boards as Renesas R-car M3, for example.
50 # In case of R-car m3, additional patches are required for gstreamer and v4l2apps.
51 # See https://github.com/igel-oss/meta-browser-hwdecode/tree/igalia-chromium71.
52 PACKAGECONFIG[use-linux-v4l2] = "use_v4l2_codec=true use_v4lplugin=true use_linux_v4l2_only=true"
53
54 PACKAGECONFIG[use-upstream-wayland] = " \
55     ozone_platform_wayland_external=false ozone_platform_wayland=true, \
56     ozone_platform_wayland_external=true ozone_platform_wayland=false \
57 "
58
59 # Options to enable debug build. Add this PACKAGECONFIG to local.conf
60 # to enable debug build. By default debug is completely disabled to
61 # speed up build
62 PACKAGECONFIG[debug] = "symbol_level=2 use_debug_fission=true,symbol_level=1"
63 PACKAGECONFIG[debug-blink] = "blink_symbol_level=2 use_debug_fission=true,blink_symbol_level=1"
64
65 GN_ARGS = "\
66     enable_memorymanager_webapi=false\
67     ffmpeg_branding=\"Chrome\"\
68     host_os=\"linux\"\
69     ozone_auto_platforms=false\
70     proprietary_codecs=true\
71     target_os=\"linux\"\
72     treat_warnings_as_errors=false\
73     is_agl=true\
74     use_cbe=true\
75     is_chrome_cbe=true\
76     is_component_build=false\
77     use_cups=false\
78     use_custom_libcxx=false\
79     use_kerberos=false\
80     use_neva_media=false\
81     use_ozone=true\
82     use_xkbcommon=true\
83     use_wayland_gbm=false\
84     use_pmlog=false\
85     use_system_debugger_abort=true\
86     ${PACKAGECONFIG_CONFARGS}\
87 "
88
89 # From Chromium's BUILDCONFIG.gn:
90 # Set to enable the official build level of optimization. This has nothing
91 # to do with branding, but enables an additional level of optimization above
92 # release (!is_debug). This might be better expressed as a tri-state
93 # (debug, release, official) but for historical reasons there are two
94 # separate flags.
95 # See also: https://groups.google.com/a/chromium.org/d/msg/chromium-dev/hkcb6AOX5gE/PPT1ukWoBwAJ
96 GN_ARGS += "is_debug=false is_official_build=true"
97
98 # is_cfi default value is true for x86-64 builds with is_official_build=true.
99 # As of M63, we explicitly need to set it to false, otherwise we fail the
100 # following assertion in //build/config/sanitizers/sanitizers.gni:
101 #   assert(!is_cfi || is_clang,
102 #          "is_cfi requires setting is_clang = true in 'gn args'")
103 GN_ARGS += "is_cfi=false"
104
105 # We do not want to use Chromium's own Debian-based sysroots, it is easier to
106 # just let Chromium's build system assume we are not using a sysroot at all and
107 # let Yocto handle everything.
108 GN_ARGS += "use_sysroot=false"
109
110 # ARM builds need special additional flags (see ${S}/build/config/arm.gni).
111 # If we do not pass |arm_arch| and friends to GN, it will deduce a value that
112 # will then conflict with TUNE_CCARGS and CC.
113 # Note that as of M61 in some corner cases parts of the build system disable
114 # the "compiler_arm_fpu" GN config, whereas -mfpu is always passed via ${CC}.
115 # We might want to rework that if there are issues in the future.
116 def get_compiler_flag(params, param_name, d):
117     """Given a sequence of compiler arguments in |params|, returns the value of
118     an option |param_name| or an empty string if the option is not present."""
119     for param in params:
120       if param.startswith(param_name):
121         return param.split('=')[1]
122     return ''
123
124 ARM_FLOAT_ABI = "${@bb.utils.contains('TUNE_FEATURES', 'callconvention-hard', 'hard', 'softfp', d)}"
125 ARM_FPU = "${@get_compiler_flag(d.getVar('TUNE_CCARGS').split(), '-mfpu', d)}"
126 ARM_TUNE = "${@get_compiler_flag(d.getVar('TUNE_CCARGS').split(), '-mcpu', d)}"
127 ARM_VERSION:aarch64 = "8"
128 ARM_VERSION:armv7a = "7"
129 ARM_VERSION:armv7ve = "7"
130 ARM_VERSION:armv6 = "6"
131
132 # GN computes and defaults to it automatically where needed
133 # forcing it from cmdline breaks build on places where it ends up
134 # overriding what GN wants
135 TUNE_CCARGS:remove = "-mthumb"
136
137 GN_ARGS:append:arm = " \
138         arm_float_abi=\"${ARM_FLOAT_ABI}\" \
139         arm_fpu=\"${ARM_FPU}\" \
140         arm_tune=\"${ARM_TUNE}\" \
141         arm_version=${ARM_VERSION} \
142 "
143 # tcmalloc's atomicops-internals-arm-v6plus.h uses the "dmb" instruction that
144 # is not available on (some?) ARMv6 models, which causes the build to fail.
145 GN_ARGS:append:armv6 = ' use_allocator="none"'
146 # The WebRTC code fails to build on ARMv6 when NEON is enabled.
147 # https://bugs.chromium.org/p/webrtc/issues/detail?id=6574
148 GN_ARGS:append:armv6 = ' arm_use_neon=false'
149
150 # Disable glibc shims on musl
151 # tcmalloc does not play well with musl as of M62 (and possibly earlier).
152 # https://github.com/gperftools/gperftools/issues/693
153 GN_ARGS:append:libc-musl = ' use_allocator_shim=false'
154
155 # More options to speed up the build
156 GN_ARGS += "\
157     enable_nacl=false\
158     disable_ftp_support=true\
159     enable_print_preview=false\
160     enable_remoting=false\
161     use_glib=true\
162     use_gnome_keyring=false\
163     use_pulseaudio=false\
164 "
165
166 # Doesn't build for armv[45]*
167 COMPATIBLE_MACHINE = "(-)"
168 COMPATIBLE_MACHINE:aarch64 = "(.*)"
169 COMPATIBLE_MACHINE:armv6 = "(.*)"
170 COMPATIBLE_MACHINE:armv7a = "(.*)"
171 COMPATIBLE_MACHINE:armv7ve = "(.*)"
172 COMPATIBLE_MACHINE:x86 = "(.*)"
173 COMPATIBLE_MACHINE:x86-64 = "(.*)"
174
175 #CHROMIUM_PLUGINS_PATH = "${libdir}"
176 CBE_DATA_PATH = "${libdir}/cbe"
177 CBE_DATA_LOCALES_PATH = "${CBE_DATA_PATH}/locales"
178
179 # The text relocations are intentional -- see comments in [GF-52468]
180 # TODO: check if we need INSANE_SKIP on ldflags
181 INSANE_SKIP:${PN} = "textrel ldflags"
182
183
184 do_compile[progress] = "outof:^\[(\d+)/(\d+)\]\s+"
185 do_compile() {
186     if [ ! -f ${OUT_DIR}/build.ninja ]; then
187          do_configure
188     fi
189
190     export PATH="${S}/depot_tools:$PATH"
191     ${S}/depot_tools/ninja ${PARALLEL_MAKE} -v -C ${OUT_DIR} ${TARGET}
192 }
193
194 do_configure() {
195     configure_env
196 }
197
198 configure_env() {
199     export GYP_CHROMIUM_NO_ACTION=1
200     export PATH="${S}/depot_tools:$PATH"
201
202     GN_ARGS="${GN_ARGS}"
203     echo GN_ARGS is ${GN_ARGS}
204     echo BUILD_TARGETS are ${TARGET}
205     cd ${SRC_DIR}
206     gn gen ${OUT_DIR} --args="${GN_ARGS}"
207 }
208
209 WINDOW_SIZE ?= "1920,1080"
210
211 configure_browser_settings() {
212     USER_AGENT="Mozilla/5.0 (Linux; NetCast; U) AppleWebKit/537.31 (KHTML, like Gecko) Chrome/${CHROMIUM_VERSION} Safari/537.31"
213     echo "${USER_AGENT}" > ${D_DIR}/user_agent_conf
214     #We can replace below WINDOW_SIZE values from build configuration if available
215     #echo "${WINDOW_SIZE}" > ${D_DIR}/window_size_conf
216 }
217
218 install_chromium_browser() {
219     # Install browser files
220     ${S}/depot_tools/ninja ${PARALLEL_MAKE} -C ${OUT_DIR} webos/install/default_browser
221
222     D_DIR=${D}${BROWSER_APPLICATION_DIR}
223     L_DIR=${D}${CBE_DATA_PATH}
224     install -d ${D_DIR}
225     install -d ${L_DIR}
226
227     cp -R --no-dereference --preserve=mode,links -v ${OUT_DIR}/image/${BROWSER_APPLICATION_DIR}/* ${D_DIR}
228
229     # AGL does not have PMLOG
230     sed -i.bak s/PmLogCtl.*// ${D_DIR}/run_webbrowser
231
232     # To execute chromium in JAILER, Security Part needs permissions change
233     # run_webbrowser: Script file for launching chromium
234     chmod -v 755 ${D_DIR}/chrome
235     chmod -v 755 ${D_DIR}/kill_webbrowser
236     chmod -v 755 ${D_DIR}/run_webbrowser
237
238     configure_browser_settings
239 }
240
241 install_webruntime() {
242
243     # # Generate install webos webview files
244     # ${S}/depot_tools/ninja ${PARALLEL_MAKE} -C ${OUT_DIR} webos/install/weboswebruntime
245
246     # # Move installation files to D directory
247     # mv ${OUT_DIR}/image/* ${D}
248     # # Rename include and locale directories
249     # mv ${D}${includedir}/webruntime ${D}${includedir}/${BPN}
250     # mv ${D}${CBE_DATA_PATH}/neva_locales ${D}${CBE_DATA_LOCALES_PATH}
251
252     # # move this to separate mksnapshot-cross recipe once we figure out how to build just cross mksnapshot from chromium repository
253     # install -d ${D}${bindir_cross}
254     # gzip -c ${OUT_DIR}/${MKSNAPSHOT_PATH}mksnapshot > ${D}${bindir_cross}/${HOST_SYS}-mksnapshot.gz
255
256     install -d ${D}${libdir}
257     install -d ${D}${libdir}/swiftshader
258     install -d ${D}${includedir}/${BPN}
259     install -d ${D}${CBE_DATA_PATH}
260     install -d ${D}${CBE_DATA_LOCALES_PATH}
261
262     # Install webos webview files
263     ${S}/depot_tools/ninja ${PARALLEL_MAKE} -C ${OUT_DIR} webos/install/weboswebruntime
264
265     install -v -m 0644 ${OUT_DIR}/swiftshader/*.so ${D}${libdir}/swiftshader
266
267     cp -R --no-dereference --preserve=mode,links -v ${OUT_DIR}/image/${includedir}/${BPN}/* ${D}${includedir}/${BPN}/
268     install -v -m 0644 ${OUT_DIR}/image/${libdir}/*.so ${D}${libdir}
269
270     install -v -m 0644 ${OUT_DIR}/image/${CBE_DATA_PATH}/icudtl.dat ${D}${CBE_DATA_PATH}
271     install -v -m 0644 ${OUT_DIR}/image/${CBE_DATA_PATH}/snapshot_blob.bin ${D}${CBE_DATA_PATH}
272     # app_runtime_content.pak, webos_content.pak, extensions_shell_and_test.pak
273     install -v -m 0644 ${OUT_DIR}/image/${CBE_DATA_PATH}/*.pak ${D}${CBE_DATA_PATH}
274
275     cp -R --no-dereference --preserve=mode,links -v ${OUT_DIR}/image/${CBE_DATA_LOCALES_PATH}/*.pak ${D}${CBE_DATA_LOCALES_PATH}
276
277     chown root:root -R ${D}${libdir}
278     chown root:root -R ${D}${includedir}
279     chown root:root -R ${D}${CBE_DATA_LOCALES_PATH}
280
281     # move this to separate mksnapshot-cross recipe once we figure out how to build just cross mksnapshot from chromium repository
282     install -d ${D}${base_bindir}
283     gzip -c ${OUT_DIR}/${MKSNAPSHOT_PATH}mksnapshot > ${D}${base_bindir}/${HOST_SYS}-mksnapshot.gz
284
285 }
286
287 do_install() {
288     install_webruntime
289     install_chromium_browser
290 }
291
292 WEBOS_SYSTEM_BUS_DIRS_LEGACY_BROWSER_APPLICATION = " \
293     ${webos_sysbus_prvservicesdir}/${BROWSER_APPLICATION}.service \
294     ${webos_sysbus_pubservicesdir}/${BROWSER_APPLICATION}.service \
295     ${webos_sysbus_prvrolesdir}/${BROWSER_APPLICATION}.json \
296     ${webos_sysbus_pubrolesdir}/${BROWSER_APPLICATION}.json \
297 "
298
299 SYSROOT_DIRS:append = " ${bindir_cross}"
300
301 PACKAGES:prepend = " \
302     ${PN}-cross-mksnapshot \
303     ${BROWSER_APPLICATION} \
304 "
305
306 FILES:${BROWSER_APPLICATION} += " \
307     ${BROWSER_APPLICATION_DIR} \
308     ${WEBOS_SYSTEM_BUS_DIRS_LEGACY_BROWSER_APPLICATION} \
309 "
310
311 RDEPENDS:${BROWSER_APPLICATION} += "${PN}"
312
313 VIRTUAL-RUNTIME_gpu-libs ?= ""
314 RDEPENDS:${PN} += "${VIRTUAL-RUNTIME_gpu-libs}"
315
316 # The text relocations are intentional -- see comments in [GF-52468]
317 # TODO: check if we need INSANE_SKIP on ldflags
318 INSANE_SKIP:${BROWSER_APPLICATION} += "libdir ldflags textrel"
319
320 FILES:${PN} = " \
321     ${libdir}/*.so \
322     ${libdir}/swiftshader/*.so \
323     ${CBE_DATA_PATH}/* \
324     ${libdir}/${BPN}/*.so \
325     ${WEBOS_SYSTEM_BUS_DIRS} \
326 "
327
328 FILES:${PN}-dev = " \
329     ${includedir} \
330 "
331
332 FILES:${PN}-cross-mksnapshot = "${bindir_cross}/${HOST_SYS}-mksnapshot.gz"