64ff98f5edc2182fcd57e94e340bdc82a6b0af04
[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 EXTRA_GYP_ARGS="$@"
14
15 # __GYP_CHROMIUMEFL_TARGET is defined when we are called from build_desktop.sh.
16 # Otherwise we are called by gbs whch already passes the correct building_for_* flag.
17 if [ "$__GYP_CHROMIUMEFL_TARGET" == "desktop" ]; then
18   target=desktop
19 fi
20
21 while [[ $# > 0 ]]; do
22   case "$1" in
23     -Dbuilding_for_tizen_*=1)
24       buildType="gbs"
25       target=$(echo $1 | sed -e 's#-Dbuilding_for_tizen_\([a-z]*\)\=1#\1#')
26       ;;
27     -Dchromium_efl_tizen_version=*)
28       tizen_version=$(echo $1 | sed -e 's#-Dchromium_efl_tizen_version\=\([0-9.]*\)#\1#')
29       ;;
30   esac
31   shift;
32 done
33
34 findElementInArray "$target" "${supported_targets[@]}"
35 if [[ $? == 1 ]]; then
36   echo "Unsupported target: $target"
37   exit 1
38 fi
39
40 if [ "$__GYP_CHROMIUMEFL_TARGET" == "crosscompile" ]; then
41   buildType=crosscompile
42   EXTRA_GYP_ARGS+=" -Dedje_compiler=${TOPDIR}/out.${host_arch}/Dependencies/Root/bin/edje_cc"
43   if [ "$target" == "mobile" ]; then
44     EXTRA_GYP_ARGS+=" -Dcustom_libc_dir=/opt/usr/eglibc-2.18/lib"
45   fi
46 fi
47
48 ORIGINAL_GYP_DEFINES="$GYP_DEFINES"
49 export GYP_DEFINES=$(echo "$GYP_DEFINES" | sed -e 's/component\s*=\s*shared_library//g')
50 if [ "$ORIGINAL_GYP_DEFINES" != "$GYP_DEFINES" ]; then
51     echo "WARNING: component build is not supported."
52     echo "Removing component=shared_library from GYP_DEFINES."
53 fi
54
55 COMMON_GYP_PARAMETERS="
56                       -Duse_libjpeg_turbo=1
57                       -Dproprietary_codecs=1
58                       -Duse_aura=0
59                       -Duse_efl=1
60                       -Duse_gnome_keyring=0
61                       -Duse_openssl=1
62                       -Duse_openssl_certs=1
63                       -Dtizen_multimedia_support=1
64                       -Denable_plugins=1
65                       -Denable_extensions=1
66                       -Duse_cups=0
67                       -Duse_allocator=none
68                       -Ddisable_fatal_linker_warnings=
69                       "
70
71 add_desktop_flags() {
72   ADDITIONAL_GYP_PARAMETERS+="-Dbuilding_for_tizen=0
73                               -Dbuilding_for_tizen_mobile=0
74                               -Dbuilding_for_tizen_tv=0
75                               -Dclang=${USE_CLANG}
76                               -Dtizen_multimedia_use_capi_for_me=0
77                               -Dwerror=
78                              "
79 }
80
81 add_arm_flags() {
82   ADDITIONAL_GYP_PARAMETERS+="-Darmv7=1
83                               -Darm_thumb=1
84                               -Darm_neon=1
85                              "
86 }
87
88 add_tizen_flags() {
89   ADDITIONAL_GYP_PARAMETERS+="-Dbuilding_for_tizen=1
90                               -Dtizen=1
91                               -Dwerror=
92                               -Dpython_ver=$(getPythonVersion)
93                               -Denable_basic_printing=1
94                               -Denable_print_preview=1
95                               -Duse_kerberos=0
96                               -Duse_gconf=0
97                               -Duse_alsa=0
98                               -Dclang=0
99                               -Dlinux_use_bundled_gold=0
100                               -Dlinux_use_gold_flags=0
101                               -Dlinux_use_bundled_binutils=0
102                               -Ddisable_nacl=1
103                               -Dprebuilt_ld_gold_dir=${TOPDIR}/tizen_src/build/prebuild
104                              "
105   if [ "$target" == "mobile" ]; then
106     ADDITIONAL_GYP_PARAMETERS+="-Dtizen_multimedia_use_capi_for_me=0
107                                "
108   elif [ "$target" == "tv" ] && [ "$tizen_version" != "3.0" ]; then
109     ADDITIONAL_GYP_PARAMETERS+="-Dtizen_multimedia_use_capi_for_me=1
110                                "
111   else
112     ADDITIONAL_GYP_PARAMETERS+="-Dtizen_multimedia_use_capi_for_me=0
113                                "
114   fi
115 }
116
117 add_gbs_flags() {
118   ADDITIONAL_GYP_PARAMETERS+="-Dtarget_arch=$host_arch
119                               -Dhost_arch=$host_arch
120                               -Dsysroot=
121                               --no-parallel
122                              "
123   # TODO(b.kelemen): ideally crosscompile should also support system libs.
124   # Unfortunately the gbs root doesn't contain everything chromium needs.
125   SYSTEM_DEPS="-Duse_system_expat=1
126                -Duse_system_flac=1
127                -Duse_system_icu=1
128                -Duse_system_libjpeg=0
129                -Duse_system_libpng=1
130                -Duse_system_libusb=1
131                -Duse_system_libxml=1
132                -Duse_system_libxslt=1
133                -Duse_system_minizip=1
134                -Duse_system_speex=1
135                -Duse_system_zlib=1
136               "
137   if [ "$target" == "mobile" ]; then
138     SYSTEM_DEPS+="-Duse_system_bzip2=1
139                   -Duse_system_libexif=1
140                   -Duse_system_nspr=1
141                  "
142   fi
143 }
144
145 add_cross_flags() {
146   ADDITIONAL_GYP_PARAMETERS+="-Dtarget_arch=arm
147                               -Dhost_arch=$host_arch
148                               -Dsysroot=$SYSROOTDIR
149                               -Darm_tune=arm7
150                               -Dhost_clang=0
151                              "
152
153   # Compiling yasm with crosscompile + icecc leads to some strange errors (one file is built for target instead of host).
154   # Yasm is an assembler used only by the build (not at runtime) and it is generally available in Linux distros so let's just
155   # use it from the system.
156   ADDITIONAL_GYP_PARAMETERS+="-Duse_system_yasm=1"
157 }
158
159 if [ "$target" == "desktop" ]; then
160   add_desktop_flags
161 else
162   add_tizen_flags
163   if [ "$target" == "mobile" -o "$target" == "tv" ]; then
164     if [ "$target_arch" == "arm" ]; then
165       add_arm_flags
166     fi
167     if [ "$buildType" == "gbs" ]; then
168       add_gbs_flags
169     elif [ "$buildType" == "crosscompile" ]; then
170       add_cross_flags
171     fi
172   fi
173   if [ "$SYSTEM_DEPS" != "" ]; then
174     #replacing original files with correct ones according to $SYSTEM_DEPS
175     $TOPDIR/build/linux/unbundle/replace_gyp_files.py $SYSTEM_DEPS
176   fi
177 fi
178
179 _GYP_ARGS="
180     $COMMON_GYP_PARAMETERS
181     $SYSTEM_DEPS
182     $ADDITIONAL_GYP_PARAMETERS
183     $EXTRA_GYP_ARGS
184     "
185 printf "GYP_ARGUMENTS:\n"
186 for arg in $_GYP_ARGS; do
187   printf "    * ${arg##-D}\n"
188 done
189
190 ${TOPDIR}/tizen_src/build/gyp_chromiumefl \
191     ${_GYP_ARGS} \
192     ${TOPDIR}/tizen_src/ewk/chromium-ewk.gyp \
193     ${TOPDIR}/xwalk/xwalk.gyp
194
195 ret=$?
196
197 if [ "$SYSTEM_DEPS" != "" ]; then
198   # Restore gyp files to their original states not to mess up the tree permanently.
199   $TOPDIR/build/linux/unbundle/replace_gyp_files.py --undo $SYSTEM_DEPS
200 fi
201
202 exit $ret