[M120 Migration][MM] Handle live stream duration and currenttime
[platform/framework/web/chromium-efl.git] / tizen_src / build / gn_chromiumefl.sh
1 #!/bin/bash
2
3 tizen_build_conf="/etc/tizen-build.conf"
4 get_profile() {
5   local profile=
6   # TV has something different.
7   if [ ! -f "$tizen_build_conf" ]; then
8     profile=desktop
9   elif [ "$(grep "TZ_BUILD_PROJECT" "$tizen_build_conf" | grep "Unified")" != "" ]; then
10     profile=unified
11   elif [ "$(grep "TZ_BUILD_RELEASE_NAME" "$tizen_build_conf" | grep "TV")" != "" ]; then
12     profile=tv
13   elif [ "$(grep "TZ_BUILD_PROJECT" "$tizen_build_conf" | grep "Wearable")" != "" ]; then
14     profile=wearable
15   elif [ "$(grep "TZ_BUILD_PROJECT" "$tizen_build_conf" | grep "DA")" != "" ]; then
16     profile=da
17   else
18     echo "There isn't proper profile."
19     return 1;
20   fi
21   echo $profile
22 }
23
24 get_tizen_version() {
25   echo $(grep "TZ_BUILD_VERSION" "$tizen_build_conf" | sed -e "s/TZ_BUILD_VERSION=//g")
26 }
27
28 source $(dirname $0)/common.sh --tizen_$(get_tizen_version)
29 trap 'error_report $0 $LINENO' ERR SIGINT SIGTERM SIGQUIT
30 host_arch=$(getHostArch)
31 system_deps=$(getSystemDeps $(get_profile))
32 export HOST_ARCH=$host_arch
33
34 supported_targets=("tizen" "desktop")
35
36 if [ -z "$GN_GENERATOR_OUTPUT" ]; then
37   if [ $BUILD_CHROME == 1 ]; then
38     GN_GENERATOR_OUTPUT="out.chrome.${host_arch}"
39   else
40     GN_GENERATOR_OUTPUT="out.${host_arch}"
41   fi
42 fi
43
44 echo ${host_arch}
45 echo $GN_GENERATOR_OUTPUT
46
47 if [ -z "$GN_GENERATOR_FLAG" ]; then
48   export GN_GENERATOR_FLAG=$GN_GENERATOR_OUTPUT
49 fi
50
51 EXTRA_GN_ARGS="$@"
52
53 # __GN_CHROMIUMEFL_TARGET is defined when we are called from build_desktop.sh.
54 # Otherwise we are called by gbs which already passes the is_tizen flag.
55 if [ "$__GN_CHROMIUMEFL_TARGET" == "desktop" ]; then
56   target=desktop
57 fi
58
59 while [[ $# > 0 ]]; do
60   case "$1" in
61     is_tizen=true)
62       buildType="gbs"
63       target="tizen"
64       ;;
65     tizen_version=*)
66       tizen_version=$(echo $1 | sed -e 's#tizen_version\=\([0-9.]*\)#\1#')
67       ;;
68     tizen_emulator_support=true)
69       tizen_emulator_support=true
70       ;;
71     tizen_product_tv=true)
72       tizen_product_tv=true
73       ;;
74     tizen_product_da=true)
75       tizen_product_da=true
76       ;;
77     use_system_icu=true)
78       system_deps=("${system_deps[@]/icu/}")
79       system_deps+=" icu"
80       ;;
81     use_system_icu=false)
82       system_deps=("${system_deps[@]/icu/}")
83       ;;
84     is_clang=true)
85       is_clang=true
86       ;;
87   esac
88   shift;
89 done
90
91 findElementInArray "$target" "${supported_targets[@]}"
92 if [[ $? == 1 ]]; then
93   echo "Unsupported target: $target"
94   exit 1
95 fi
96
97 if [ "$__GN_CHROMIUMEFL_TARGET" == "crosscompile" ]; then
98   buildType=crosscompile
99   EXTRA_GN_ARGS+=" edje_compiler=${TOPDIR}/out.${host_arch}/Dependencies/Root/bin/edje_cc"
100 fi
101
102 ORIGINAL_GN_DEFINES="$GN_DEFINES"
103 export GN_DEFINES=$(echo "$GN_DEFINES" | sed -e 's/component\s*=\s*shared_library//g')
104 if [ "$ORIGINAL_GN_DEFINES" != "$GN_DEFINES" ]; then
105     echo "WARNING: component build is not supported."
106     echo "Removing component=shared_library from GN_DEFINES."
107 fi
108
109 COMMON_GN_PARAMETERS="use_libjpeg_turbo=true
110                       rtc_enable_sctp=false
111                       use_alsa=false
112                       use_aura=true
113                       use_kerberos=false
114                       use_ozone=true
115                       toolkit_views=true
116                       use_pango=false
117                       use_cairo=false
118                       enable_plugins=true
119                       enable_extensions=true
120                       enable_print_preview=false
121                       enable_oop_printing=false
122                       use_cups=false
123                       depth=\"${TOPDIR}\"
124                       use_libpci=false
125                       enable_ppapi=false
126                      "
127
128 add_desktop_flags() {
129   local is_clang=false
130   if [ $USE_CLANG == 1 ]; then
131     is_clang=true
132   else
133      ADDITIONAL_GN_PARAMETERS+="use_system_libjpeg=true
134                                "
135   fi
136
137   local build_chrome=false
138   if [ $BUILD_CHROME == 1 ]; then
139     build_chrome=true
140   fi
141
142   ADDITIONAL_GN_PARAMETERS+="gcc_ver=\"$(getGccVersion)\"
143                              is_clang=${is_clang}
144                              is_tizen=false
145                              target_cpu=\"${host_arch}\"
146                              target_os="\"linux\""
147                              use_sysroot=false
148                              use_wayland=false
149                              use_plugin_placeholder_hole=true
150                              werror=false
151                              dcheck_always_on=false
152                              enable_nacl=false
153                              build_chrome=${build_chrome}
154                              use_gold=true
155                              use_lld=false
156                             "
157 }
158
159 add_arm_flags() {
160   ADDITIONAL_GN_PARAMETERS+="arm_use_neon=true
161                             "
162   if [ "$host_arch" == "arm64" ]; then
163     ADDITIONAL_GN_PARAMETERS+="system_libdir=\"lib64\"
164                                deps_lib_path=\"/usr/lib64\"
165                                v8_control_flow_integrity=false
166                               "
167   fi
168 }
169
170 add_emulator_flags() {
171   if [ "$host_arch" == "x64" ]; then
172     ADDITIONAL_GN_PARAMETERS+="system_libdir=\"lib64\"
173                                deps_lib_path=\"/usr/lib64\"
174                               "
175   fi
176 }
177
178 add_riscv_flags() {
179   ADDITIONAL_GN_PARAMETERS+="
180                             "
181   if [ "$host_arch" == "riscv64" ]; then
182     ADDITIONAL_GN_PARAMETERS+="system_libdir=\"lib64\"
183                                deps_lib_path=\"/usr/lib64\"
184                                v8_control_flow_integrity=false
185                                v8_enable_webassembly=true
186                               "
187   fi
188 }
189
190 add_tizen_flags() {
191   ADDITIONAL_GN_PARAMETERS+="is_tizen=true
192                              use_zygote_handle=true
193                              gcc_ver=\"$(getGccVersion)\"
194                              enable_plugins=true
195                              python_ver=\"$(getPythonVersion)\"
196                              is_official_build=true
197                              enable_nacl=false
198                              use_xkbcommon=true
199                              target_os="\"tizen\""
200                              target_sysroot=\"/\"
201                              current_cpu=\"${host_arch}\"
202                              host_cpu=\"${host_arch}\"
203                              target_cpu=\"${host_arch}\"
204                              use_real_dbus_clients=false
205                              use_nss_certs=true
206                              use_system_libwayland=true
207                              v8_use_external_startup_data=true
208                             "
209
210   # FIXME : Note that the v8_snapshot_toolchain has been set to wrong
211   # toolchain clang in x64 build even is_clang is false.
212   # This sets it to toolchain gcc forcibly as workaround.
213   # It needs to be set to the toolchain gcc under is_clang is false.
214   if [ "$host_arch" == "x64" ]; then
215     ADDITIONAL_GN_PARAMETERS+="v8_snapshot_toolchain=\"//tizen_src/build/toolchain/tizen:tizen_x64\"
216                               "
217   fi
218
219   if [ "$is_clang" == "true" ]; then
220     ADDITIONAL_GN_PARAMETERS+="host_toolchain=\"//tizen_src/build/toolchain/tizen:tizen_clang_$host_arch\"
221                                v8_snapshot_toolchain=\"//tizen_src/build/toolchain/tizen:tizen_clang_$host_arch\"
222                                use_lld=true
223                                use_thin_lto=true
224                               "
225   else
226     ADDITIONAL_GN_PARAMETERS+="host_toolchain=\"//tizen_src/build/toolchain/tizen:tizen_$host_arch\"
227                                v8_snapshot_toolchain=\"//tizen_src/build/toolchain/tizen:tizen_$host_arch\"
228                                use_system_libjpeg=true
229                               "
230   fi
231
232   if [[ "${system_deps[@]}" =~ "icu" ]]; then
233     ADDITIONAL_GN_PARAMETERS+="icu_use_data_file=false
234                                use_system_icu=true
235                               "
236                 processICU replace_icu
237   else
238     ADDITIONAL_GN_PARAMETERS+="icu_use_data_file=true
239                               "
240   fi
241
242
243   if [ "$tizen_product_tv" == "true" ]; then
244     ADDITIONAL_GN_PARAMETERS+="enable_plugins=true
245                                use_plugin_placeholder_hole=true
246                                use_atk=false
247                               "
248   fi
249   ADDITIONAL_GN_PARAMETERS+="tizen_multimedia=true
250                              proprietary_codecs=true
251                              tizen_audio_io=true
252                              tizen_web_speech_recognition=true
253                              tizen_tbm_support=false
254                              ffmpeg_branding=\"Chrome\"
255                             "
256
257   if [ "$tizen_product_tv" == "true" ]; then
258     ADDITIONAL_GN_PARAMETERS+="tizen_pepper_extensions=false
259                               "
260   fi
261
262   # Enable video hole only for standard and TV profile
263   if [ \( "$tizen_product_tv" == "true" \) -o \( "$tizen_product_da" != "true" -a "$tizen_emulator_support" != "true" \) ]; then
264     ADDITIONAL_GN_PARAMETERS+="tizen_video_hole=true
265                               "
266   else
267     ADDITIONAL_GN_PARAMETERS+="tizen_video_hole=false
268                               "
269   fi
270 }
271
272 add_wayland_flags() {
273   if [ "$use_wayland" == "true" ]; then
274     ADDITIONAL_GN_PARAMETERS+="use_wayland=true
275                                wayland_bringup=true
276                               "
277   else
278     ADDITIONAL_GN_PARAMETERS+="use_wayland=false
279                                wayland_bringup=false
280                               "
281   fi
282 }
283
284 add_gbs_flags() {
285   # To reduce binary size, O2 is only applied to major components
286   # and Os is applied to the others.
287   local lto_level="s"
288
289   if [ "$is_clang" == "true" ]; then
290    lto_level="z"
291   fi
292
293   ADDITIONAL_GN_PARAMETERS+="lto_level=\"$lto_level\"
294                             "
295
296   # TODO(youngsoo):
297   # Due to large file size issue of libchromium-ewk.so,
298   # The symbol level is set to 1 by default.
299   # Once the issue is fixed, set it to the level from platform.
300   local symbol_level=$(echo " $CFLAGS" | sed -e 's#.* -g\([0-9]\).*#\1#')
301   if [ "$host_arch" == "x86" ]; then
302     symbol_level="0"
303   elif [ "$symbol_level" != "0" ]; then
304     symbol_level="1"
305   fi
306
307   if [[ $symbol_level =~ ^[0-9]$ ]]; then
308     ADDITIONAL_GN_PARAMETERS+="symbol_level=$symbol_level
309                               "
310   else
311     ADDITIONAL_GN_PARAMETERS+="symbol_level=1
312                               "
313   fi
314   # target_arch changed to target_cpu but not changed because it seems that
315   # it is used for gbs and added target_cpu also.
316   ADDITIONAL_GN_PARAMETERS+="target_cpu=\"${host_arch}\"
317                             "
318 }
319
320 add_cross_flags() {
321   # target_arch changed to target_cpu but not changed because it seems that
322   # it is used for gbs and added target_cpu also.
323   ADDITIONAL_GN_PARAMETERS+="target_cpu=\"arm\"
324                              sysroot=\"$SYSROOTDIR\"
325                              arm_tune=\"arm7\"
326                             "
327
328   # Compiling yasm with crosscompile + icecc leads to some strange errors (one file is built for target instead of host).
329   # Yasm is an assembler used only by the build (not at runtime) and it is generally available in Linux distros so let's just
330   # use it from the system.
331   ADDITIONAL_GN_PARAMETERS+="use_system_yasm=true"
332 }
333
334 if [ "$target" == "desktop" ]; then
335   add_desktop_flags
336 else
337   add_tizen_flags
338   if [ "$host_arch" == "arm" -o "$host_arch" == "arm64" ]; then
339     add_arm_flags
340   elif [ "$host_arch" == "x86" -o "$host_arch" == "x64" ]; then
341     add_emulator_flags
342   elif [ "$host_arch" == "riscv64" -o "$host_arch" == "riscv64" ]; then
343     add_riscv_flags
344   fi
345   if [ "$buildType" == "gbs" ]; then
346     add_gbs_flags
347   elif [ "$buildType" == "crosscompile" ]; then
348     add_cross_flags
349   fi
350 fi
351
352 if [ "$system_deps" != "" ]; then
353   echo "** use system lib : replace **"
354   #replacing original files with correct ones according to $system_deps
355   $TOPDIR/build/linux/unbundle/replace_gn_files.py $system_deps
356 fi
357
358 _GN_ARGS="
359     gen
360     $GN_GENERATOR_FLAG
361     --root=${TOPDIR}
362     --dotfile=${TOPDIR}/tizen_src/.gn
363     --args=
364     $COMMON_GN_PARAMETERS
365     $ADDITIONAL_GN_PARAMETERS
366     $EXTRA_GN_ARGS
367     "
368
369 if [ "$target" == "tizen" ]; then
370   echo $BUILD_ARCH > host_arch.txt
371 fi
372
373 if [ "$BUILD_ARCH" != "x86_64" ]; then
374   echo $target > target.txt
375   echo $target > third_party/node/target.txt
376 fi
377
378 printf "GN_ARGUMENTS:\n"
379 for arg in $_GN_ARGS; do
380   printf "    * ${arg##-D}\n"
381 done
382 for arg in $system_deps; do
383   printf "    * ${arg##-D}\n"
384 done
385
386 ${TOPDIR}/tizen_src/build/gn_chromiumefl \
387     ${_GN_ARGS}
388
389 ret=$?
390
391 exit $ret