Implement content_shell app on top of chromium-efl library.
[platform/framework/web/chromium-efl.git] / tizen_src / build / build_desktop.sh
1 #!/bin/bash
2
3 SCRIPTDIR=$( cd $(dirname $0) ; pwd -P )
4 TOPDIR=$( cd ${SCRIPTDIR}/.. ; pwd -P )
5
6 source ${SCRIPTDIR}/common.sh
7
8 host_arch=$(getHostArch)
9
10 export GYP_GENERATOR_OUTPUT=${TOPDIR}/"out.${host_arch}"
11
12 usage() {
13 cat << EOF
14 usage: $0 [OPTIONS]
15
16 Build desktop version of chromium-efl
17
18 OPTIONS:
19    -h, --help    Show this message
20    --skip-gyp    Skip restore_gyp, jhbuild and gyp_chromium steps
21    --ccache      configure ccache installed in your system
22    --skip-ninja  Skip ninja step
23    --build-ewk-unittests  build ewk unittests
24    --debug       build debug version of chromium-efl (in $GYP_GENERATOR_OUTPUT/Debug instead of default $GYP_GENERATOR_OUTPUT/Release)
25    -jN           set number of jobs, just like with make or ninja
26
27 examples:
28 $0 --skip-gyp
29 $0 --skip-gyp --ccache
30 $0 --skip-ninja
31 EOF
32   exit
33 }
34
35 SKIP_GYP=0
36 USE_CCACHE=0
37 SKIP_NINJA=0
38
39 BUILD_SUBDIRECTORY=Release
40
41 if echo "$@" | grep -cq '\(\(\-\-help\)\|\(\-h\)\)'; then
42   usage
43 fi
44
45 if echo "$@" | grep -cq '\-\-skip-gyp'; then
46   SKIP_GYP=1
47 fi
48
49 if echo "$@" | grep -cq '\-\-skip-ninja'; then
50   SKIP_NINJA=1
51 fi
52
53 if echo "$@" | grep -cq '\-\-ccache'; then
54   USE_CCACHE=1
55 fi
56
57 if echo "$@" | grep -cq '\-\-build-ewk-unittests'; then
58   BUILD_EWK_UNITTESTS=1
59 fi
60
61 if echo "$@" | grep -cq '\-\-content_shell'; then
62   BUILD_CONTENT_SHELL=1
63 fi
64
65 JHBUILD_STAMPFILE="${GYP_GENERATOR_OUTPUT}/Dependencies/Root/jhbuild.stamp"
66
67 shouldForceJHBuild() {
68   if echo "$@" | grep -cq '\-\-force-jhbuild'; then
69     return 1
70   fi
71
72   # Check if anything in jhbuild is more recent than stamp file.
73   for i in $(find "$SCRIPTDIR/jhbuild"); do
74     if [ -f "$i" -a "$JHBUILD_STAMPFILE" -ot "$i" ]; then
75       return 1
76     fi
77   done
78
79   return 0
80 }
81
82 if [ "$(shouldForceJHBuild $@)" == "1" ]; then
83   rm -f $JHBUILD_STAMPFILE
84 fi
85
86 if echo "$@" | grep -cq '\-\-debug'; then
87   BUILD_SUBDIRECTORY=Debug
88 fi
89
90 # Will be empty string if -j not specified or ill-formatted, otherwise -j and the number argument together.
91 # \grep because folks often alias grep but we want the vanilla behavior.
92 JOBS=$(echo "$@" | \grep -Eo '\-j\s*[1-9]([0-9]*)')
93
94 set -e
95
96 JHBUILD_DEPS="${GYP_GENERATOR_OUTPUT}/Dependencies/Root"
97 if [ "${host_arch}" == "x64" ]; then
98   _LIBDIR=lib64
99 elif [ "${host_arch}" == "ia32" ]; then
100   _LIBDIR=lib
101 fi
102 export PKG_CONFIG_PATH="${JHBUILD_DEPS}/${_LIBDIR}/pkgconfig"
103
104 if [ ! -f "$JHBUILD_STAMPFILE" ]; then
105   jhbuild --no-interact -f ${SCRIPTDIR}/jhbuild/jhbuildrc
106
107   if [ "$?" == "0" ]; then
108     echo "Yay! jhbuild done!" > $JHBUILD_STAMPFILE
109   fi
110 fi
111
112 if [ "$SKIP_GYP" == "0" ]; then
113   ${TOPDIR}/build/gyp_chromiumefl.sh
114 fi
115
116 if [ "$SKIP_NINJA" == "0" ]; then
117   if [ "$USE_CCACHE" == "1" ]; then
118     echo using ccache
119     set +e
120     source $TOPDIR/build/ccache_env.sh desktop
121     set -e
122   fi
123   export LD_LIBRARY_PATH="${JHBUILD_DEPS}/${_LIBDIR}:$LD_LIBRARY_PATH"
124   export PATH="${JHBUILD_DEPS}/bin:$PATH"
125
126   TARGETS="chromium-efl efl_webprocess chromium-ewk efl_webview_app"
127   if [ "$BUILD_EWK_UNITTESTS" == "1" ]; then
128     TARGETS="$TARGETS ewk_unittests"
129   fi
130
131   if [ "$BUILD_CONTENT_SHELL" == "1" ]; then
132     TARGETS="$TARGETS content_shell_efl"
133   fi
134
135   ninja -C ${GYP_GENERATOR_OUTPUT}/${BUILD_SUBDIRECTORY} ${JOBS} ${TARGETS}
136 fi