Make it possible to compile chromium-efl on desktop using clang
[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 if [ -z "$GYP_GENERATOR_OUTPUT" ]; then
8   GYP_GENERATOR_OUTPUT=${TOPDIR}/"out.${host_arch}"
9 fi
10
11 EXTRA_GYP_ARGS="$@"
12
13 # __GYP_CHROMIUMEFL_TARGET is defined when we are called from build_desktop.sh.
14 # Otherwise we are called by gbs whch already passes the correct building_for_* flag.
15 if [ "$__GYP_CHROMIUMEFL_TARGET" == "desktop" ]; then
16   target=desktop
17 elif echo "$@" | grep -cq '\-\Dbuilding_for_tizen_mobile=1'; then
18   target=mobile
19   buildType=gbs
20 elif echo "$@" | grep -cq '\-\Dbuilding_for_tizen_tv=1'; then
21   target=tv
22   buildType=gbs
23 fi
24
25 if [ "$__GYP_CHROMIUMEFL_TARGET" == "crosscompile" ]; then
26   buildType=crosscompile
27   EXTRA_GYP_ARGS+=" -Dedje_compiler=${TOPDIR}/out.${host_arch}/Dependencies/Root/bin/edje_cc"
28   if [ "$target" == "mobile" ]; then
29     EXTRA_GYP_ARGS+=" -Dcustom_libc_dir=/opt/usr/eglibc-2.18/lib"
30   fi
31 fi
32
33 ORIGINAL_GYP_DEFINES="$GYP_DEFINES"
34 export GYP_DEFINES=$(echo "$GYP_DEFINES" | sed -e 's/component\s*=\s*shared_library//g')
35 if [ "$ORIGINAL_GYP_DEFINES" != "$GYP_DEFINES" ]; then
36     echo "WARNING: component build is not supported."
37     echo "Removing component=shared_library from GYP_DEFINES."
38 fi
39
40 COMMON_GYP_PARAMETERS="
41                       -Duse_libjpeg_turbo=1
42                       -Dproprietary_codecs=1
43                       -Dtizen_multimedia_support=1
44                       -Duse_aura=0
45                       -Duse_efl=1
46                       -Duse_gnome_keyring=0
47                       -Dtoolkit_uses_gtk=0
48                       "
49 if [[ $BUILD_CONTENT_SHELL == 1 ]]; then
50   COMMON_GYP_PARAMETERS+="-Dchromium_efl_library_type=static_library"
51 fi
52
53 add_desktop_flags() {
54   ADDITIONAL_GYP_PARAMETERS+="-Dbuilding_for_tizen=0
55                               -Dclang=${USE_CLANG}
56                               -Dmake_clang_dir=${CLANG_DIR}
57                              "
58 }
59
60 add_arm_flags() {
61   ADDITIONAL_GYP_PARAMETERS+="-Darmv7=1
62                               -Darm_thumb=1
63                               -Darm_neon=1
64                              "
65 }
66
67 add_tizen_flags() {
68   ADDITIONAL_GYP_PARAMETERS+="-Dbuilding_for_tizen=1
69                               -Dwerror=
70                               -Dpython_ver=$(getPythonVersion)
71                               -Denable_basic_printing=1
72                               -Denable_print_preview=1
73                               -Duse_kerberos=0
74                               -Duse_gconf=0
75                               -Duse_alsa=0
76                               -Dclang=0
77                               -Dlinux_use_bundled_gold=0
78                               -Dlinux_use_bundled_binutils=0
79                               -Dprebuilt_ld_gold_dir=${TOPDIR}/build/prebuild
80                              "
81 }
82
83 add_gbs_flags() {
84   ADDITIONAL_GYP_PARAMETERS+="-Dtarget_arch=$host_arch
85                               -Dhost_arch=$host_arch
86                               -Dsysroot=
87                               --no-parallel
88                              "
89   # TODO(b.kelemen): ideally crosscompile should also support system libs.
90   # Unfortunately the gbs root doesn't contain everything chromium needs.
91   SYSTEM_DEPS="-Duse_system_expat=1
92                -Duse_system_flac=1
93                -Duse_system_icu=1
94                -Duse_system_libjpeg=0
95                -Duse_system_libpng=1
96                -Duse_system_libusb=1
97                -Duse_system_libxml=1
98                -Duse_system_libxslt=1
99                -Duse_system_minizip=1
100                -Duse_system_speex=1
101                -Duse_system_zlib=1
102               "
103   if [ "$target" == "mobile" ]; then
104     SYSTEM_DEPS+="-Duse_system_bzip2=1
105                   -Duse_system_libexif=1
106                   -Duse_system_nspr=1
107                   -Duse_system_vpx=1"
108   fi
109 }
110
111 add_cross_flags() {
112   ADDITIONAL_GYP_PARAMETERS+="-Dtarget_arch=arm
113                               -Dhost_arch=$host_arch
114                               -Dsysroot=$SYSROOTDIR
115                               -Darm_tune=arm7
116                               -Dhost_clang=0
117                              "
118
119   # Compiling yasm with crosscompile + icecc leads to some strange errors (one file is built for target instead of host).
120   # Yasm is an assembler used only by the build (not at runtime) and it is generally available in Linux distros so let's just
121   # use it from the system.
122   ADDITIONAL_GYP_PARAMETERS+="-Duse_system_yasm=1"
123 }
124
125 if [ "$target" == "desktop" ]; then
126   add_desktop_flags
127 else
128   add_tizen_flags
129   if [ "$target" == "mobile" -o "$target" == "tv" ]; then
130     if [ "$target_arch" == "arm" ]; then
131       add_arm_flags
132     fi
133     if [ "$buildType" == "gbs" ]; then
134       add_gbs_flags
135     elif [ "$buildType" == "crosscompile" ]; then
136       add_cross_flags
137     fi
138   fi
139   if [ "$SYSTEM_DEPS" != "" ]; then
140     #replacing original files with correct ones according to $SYSTEM_DEPS
141     $TOPDIR/src/build/linux/unbundle/replace_gyp_files.py $SYSTEM_DEPS
142   fi
143 fi
144
145 set -x
146 ${TOPDIR}/build/gyp_chromiumefl \
147                                  $COMMON_GYP_PARAMETERS \
148                                  $SYSTEM_DEPS \
149                                  $ADDITIONAL_GYP_PARAMETERS \
150                                  $EXTRA_GYP_ARGS \
151                                  ${TOPDIR}/ewk/chromium-ewk.gyp
152
153 ret=$?
154
155 if [ "$SYSTEM_DEPS" != "" ]; then
156   # Restore gyp files to their original states not to mess up the tree permanently.
157   $TOPDIR/src/build/linux/unbundle/replace_gyp_files.py --undo $SYSTEM_DEPS
158 fi
159
160 exit $ret