90660cac88b1d83e7a3643767db511eafc2ff9a5
[platform/framework/web/chromium-efl.git] / tizen_src / build / gyp_chromiumefl.sh
1 #!/bin/bash
2
3 source $(dirname $0)/common.sh
4 trap 'error_report $0 $LINENO' ERR SIGINT SIGTERM SIGQUIT
5 host_arch=$(getHostArch)
6
7 supported_targets=("mobile" "tv" "desktop")
8
9 if [ -z "$GYP_GENERATOR_OUTPUT" ]; then
10   GYP_GENERATOR_OUTPUT=${TOPDIR}/"out.${host_arch}"
11 fi
12
13 if [ -z "$GYP_GENERATOR_FLAGS" ]; then
14   export GYP_GENERATOR_FLAGS="output_dir=${GYP_GENERATOR_OUTPUT}"
15 fi
16
17 EXTRA_GYP_ARGS="$@"
18
19 # __GYP_CHROMIUMEFL_TARGET is defined when we are called from build_desktop.sh.
20 # Otherwise we are called by gbs whch already passes the correct building_for_* flag.
21 if [ "$__GYP_CHROMIUMEFL_TARGET" == "desktop" ]; then
22   target=desktop
23 fi
24
25 while [[ $# > 0 ]]; do
26   case "$1" in
27     -Dbuilding_for_tizen_*=1)
28       buildType="gbs"
29       target=$(echo $1 | sed -e 's#-Dbuilding_for_tizen_\([a-z]*\)\=1#\1#')
30       ;;
31     -Dchromium_efl_tizen_version=*)
32       tizen_version=$(echo $1 | sed -e 's#-Dchromium_efl_tizen_version\=\([0-9.]*\)#\1#')
33       ;;
34     -Dtizen_emulator_support=1)
35       tizen_emulator_support=1
36       ;;
37     -Duse_wayland=1)
38       use_wayland=1
39       ;;
40     --xwalk)
41       building_xwalk=1
42       ;;
43     -Dbuilding_crosswalk_bin=*)
44       building_xwalk_for_development=1
45       ;;
46   esac
47   shift;
48 done
49
50 findElementInArray "$target" "${supported_targets[@]}"
51 if [[ $? == 1 ]]; then
52   echo "Unsupported target: $target"
53   exit 1
54 fi
55
56 if [ "$__GYP_CHROMIUMEFL_TARGET" == "crosscompile" ]; then
57   buildType=crosscompile
58   EXTRA_GYP_ARGS+=" -Dedje_compiler=${TOPDIR}/out.${host_arch}/Dependencies/Root/bin/edje_cc"
59 fi
60
61 ORIGINAL_GYP_DEFINES="$GYP_DEFINES"
62 export GYP_DEFINES=$(echo "$GYP_DEFINES" | sed -e 's/component\s*=\s*shared_library//g')
63 if [ "$ORIGINAL_GYP_DEFINES" != "$GYP_DEFINES" ]; then
64     echo "WARNING: component build is not supported."
65     echo "Removing component=shared_library from GYP_DEFINES."
66 fi
67
68 COMMON_GYP_PARAMETERS="
69                       -Duse_libjpeg_turbo=1
70                       -Dproprietary_codecs=1
71                       -Duse_alsa=0
72                       -Duse_aura=0
73                       -Duse_efl=1
74                       -Duse_gconf=0
75                       -Duse_kerberos=0
76                       -Duse_ozone=1
77                       -Dozone_auto_platforms=0
78                       -Dozone_platform_wayland=0
79                       -Duse_gnome_keyring=0
80                       -Duse_pango=0
81                       -Duse_cairo=0
82                       -Denable_plugins=1
83                       -Denable_extensions=1
84                       -Duse_cups=0
85                       -Duse_allocator=none
86                       -Duse_libpci=0
87                       -Ddisable_fatal_linker_warnings=
88                       --depth=${TOPDIR}
89                       "
90
91 if [ "$building_xwalk" == "1" ] && [ "$building_xwalk_for_development" != "1" ]; then
92   COMMON_GYP_PARAMETERS+="
93                          -Dxwalk_link_against_chromium_ewk=1
94                          "
95 fi
96
97 add_desktop_flags() {
98   ADDITIONAL_GYP_PARAMETERS+="-Dbuilding_for_tizen=0
99                               -Dbuilding_for_tizen_mobile=0
100                               -Dbuilding_for_tizen_tv=0
101                               -Dclang=${USE_CLANG}
102                               -Dwerror=
103                               -Duse_sysroot=0
104                               -Duse_wayland=0
105                              "
106 }
107
108 add_arm_flags() {
109   ADDITIONAL_GYP_PARAMETERS+="-Darmv7=1
110                               -Darm_thumb=1
111                               -Darm_neon=1
112                              "
113 }
114
115 add_tizen_flags() {
116   ADDITIONAL_GYP_PARAMETERS+="-Dbuilding_for_tizen=1
117                               -Dtizen=1
118                               -Dpython_ver=$(getPythonVersion)
119                               -Denable_basic_printing=1
120                               -Denable_print_preview=1
121                               -Dclang=0
122                               -Dlinux_use_bundled_gold=0
123                               -Dlinux_use_bundled_binutils=0
124                               -Ddisable_nacl=1
125                               -Dtizen_multimedia_eme_support=0
126                              "
127
128   # TODO(youngsoo): Once binutils-gold issue on tizen v3.0 ARM 64bit is fixed,
129   #                 make the latest tizen version unconditional.
130   if [ "$tizen_version" == "3.0" ] && [ "$host_arch" == "arm" ]; then
131     # [M48_2564] Temporary disabling the flag for switching to new chromium
132     #            FIXME: http://web.sec.samsung.net/bugzilla/show_bug.cgi?id=15383
133     ADDITIONAL_GYP_PARAMETERS+="-Dlinux_use_gold_flags=0
134                                 -Dprebuilt_ld_gold_dir=${TOPDIR}/tizen_src/build/prebuild
135                                "
136   elif [ "$tizen_version" == "2.4" -a "$target" == "tv" ]; then
137     ADDITIONAL_GYP_PARAMETERS+="-Dlinux_use_gold_flags=0
138                                 -Dprebuilt_ld_gold_dir=${TOPDIR}/tizen_src/build/prebuild/tizen_v2.4_tv
139                                "
140   else
141     ADDITIONAL_GYP_PARAMETERS+="-Dlinux_use_gold_flags=0
142                                 -Dprebuilt_ld_gold_dir=${TOPDIR}/tizen_src/build/prebuild
143                                "
144   fi
145
146   if [ "$tizen_version" == "3.0" ]; then
147     # [M49_2623] Temporary disabling the flag.
148     #            FIXME: http://165.213.149.170/jira/browse/TWF-610
149     ADDITIONAL_GYP_PARAMETERS+="-Dtizen_multimedia_support=0
150                                 -Dtizen_tbm_support=0
151                                "
152   else
153     ADDITIONAL_GYP_PARAMETERS+="-Dtizen_multimedia_support=0
154                                 -Dwerror=
155                                "
156   fi
157
158   add_wayland_flags
159 }
160
161 add_wayland_flags() {
162   if [ "$use_wayland" == "1" ]; then
163     ADDITIONAL_GYP_PARAMETERS+="-Duse_wayland=1
164                                 -Dwayland_bringup=1
165                                "
166   else
167     ADDITIONAL_GYP_PARAMETERS+="-Duse_wayland=0
168                                 -Dwayland_bringup=0
169                                "
170   fi
171 }
172
173 add_gbs_flags() {
174   ADDITIONAL_GYP_PARAMETERS+="-Dtarget_arch=$host_arch
175                               -Dhost_arch=$host_arch
176                               -Dsysroot=
177                               --no-parallel
178                              "
179   # TODO(b.kelemen): ideally crosscompile should also support system libs.
180   # Unfortunately the gbs root doesn't contain everything chromium needs.
181   SYSTEM_DEPS="-Duse_system_expat=1
182                -Duse_system_libjpeg=0
183                -Duse_system_libpng=1
184                -Duse_system_libusb=1
185                -Duse_system_libxml=1
186                -Duse_system_libxslt=1
187                -Duse_system_re2=1
188                -Duse_system_zlib=1
189               "
190
191   # [M50_2661] Temporary using the icu of internal chformium instead of system.
192   #            The icu of system doesn't support utrie2.h
193   #            FIXME: http://suprem.sec.samsung.net/jira/browse/TWF-967
194   SYSTEM_DEPS+="-Duse_system_icu=0
195                "
196
197   if [ "$target" == "mobile" ]; then
198     SYSTEM_DEPS+="-Duse_system_bzip2=1
199                   -Duse_system_libexif=1
200                   -Duse_system_nspr=1
201                  "
202   fi
203 }
204
205 add_cross_flags() {
206   ADDITIONAL_GYP_PARAMETERS+="-Dtarget_arch=arm
207                               -Dhost_arch=$host_arch
208                               -Dsysroot=$SYSROOTDIR
209                               -Darm_tune=arm7
210                               -Dhost_clang=0
211                              "
212
213   # Compiling yasm with crosscompile + icecc leads to some strange errors (one file is built for target instead of host).
214   # Yasm is an assembler used only by the build (not at runtime) and it is generally available in Linux distros so let's just
215   # use it from the system.
216   ADDITIONAL_GYP_PARAMETERS+="-Duse_system_yasm=1"
217 }
218
219 if [ "$target" == "desktop" ]; then
220   add_desktop_flags
221 else
222   add_tizen_flags
223   if [ "$target" == "mobile" -o "$target" == "tv" ]; then
224     if [ "$target_arch" == "arm" ]; then
225       add_arm_flags
226     fi
227     if [ "$buildType" == "gbs" ]; then
228       add_gbs_flags
229     elif [ "$buildType" == "crosscompile" ]; then
230       add_cross_flags
231     fi
232   fi
233   if [ "$SYSTEM_DEPS" != "" ]; then
234     #replacing original files with correct ones according to $SYSTEM_DEPS
235     $TOPDIR/build/linux/unbundle/replace_gyp_files.py $SYSTEM_DEPS
236   fi
237 fi
238
239 _GYP_ARGS="
240     $COMMON_GYP_PARAMETERS
241     $SYSTEM_DEPS
242     $ADDITIONAL_GYP_PARAMETERS
243     $EXTRA_GYP_ARGS
244     "
245 printf "GYP_ARGUMENTS:\n"
246 for arg in $_GYP_ARGS; do
247   printf "    * ${arg##-D}\n"
248 done
249
250 ${TOPDIR}/tizen_src/build/gyp_chromiumefl \
251     ${_GYP_ARGS} \
252     ${TOPDIR}/tizen_src/ewk/chromium-ewk.gyp
253
254 ret=$?
255
256 if [ "$SYSTEM_DEPS" != "" ]; then
257   # Restore gyp files to their original states not to mess up the tree permanently.
258   $TOPDIR/build/linux/unbundle/replace_gyp_files.py --undo $SYSTEM_DEPS
259 fi
260
261 exit $ret