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