[Tizen][Build] Move jhbuild handling to build_desktop.sh
[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    --debug       build debug version of chromium-efl (in $GYP_GENERATOR_OUTPUT/Debug instead of default $GYP_GENERATOR_OUTPUT/Release)
24    -jN           set number of jobs, just like with make or ninja
25
26 examples:
27 $0 --skip-gyp
28 $0 --skip-gyp --ccache
29 $0 --skip-ninja
30 EOF
31   exit
32 }
33
34 SKIP_GYP=0
35 USE_CCACHE=0
36 SKIP_NINJA=0
37
38 BUILD_SUBDIRECTORY=Release
39
40 if echo "$@" | grep -cq '\(\(\-\-help\)\|\(\-h\)\)'; then
41   usage
42 fi
43
44 if echo "$@" | grep -cq '\-\-skip-gyp'; then
45   SKIP_GYP=1
46 fi
47
48 if echo "$@" | grep -cq '\-\-skip-ninja'; then
49   SKIP_NINJA=1
50 fi
51
52 if echo "$@" | grep -cq '\-\-ccache'; then
53   USE_CCACHE=1
54 fi
55
56 JHBUILD_STAMPFILE="${GYP_GENERATOR_OUTPUT}/Dependencies/jhbuild.stamp"
57
58 if echo "$@" | grep -cq '\-\-force-jhbuild'; then
59   rm -f $JHBUILD_STAMPFILE
60 fi
61
62 if echo "$@" | grep -cq '\-\-debug'; then
63   BUILD_SUBDIRECTORY=Debug
64 fi
65
66 # Will be empty string if -j not specified or ill-formatted, otherwise -j and the number argument together.
67 # \grep because folks often alias grep but we want the vanilla behavior.
68 JOBS=$(echo "$@" | \grep -Eo '\-j\s*[1-9]([0-9]*)')
69
70 set -e
71
72 JHBUILD_DEPS="${GYP_GENERATOR_OUTPUT}/Dependencies/Root"
73 if [ "${host_arch}" == "x64" ]; then
74   _LIBDIR=lib64
75 elif [ "${host_arch}" == "ia32" ]; then
76   _LIBDIR=lib
77 fi
78 export PKG_CONFIG_PATH="${JHBUILD_DEPS}/${_LIBDIR}/pkgconfig"
79
80 if [ ! -f "$JHBUILD_STAMPFILE" ]; then
81   jhbuild --no-interact -f ${SCRIPTDIR}/jhbuild/jhbuildrc
82
83   if [ "$?" == "0" ]; then
84     echo "Yay! jhbuild done!" > $JHBUILD_STAMPFILE
85   fi
86 fi
87
88 if [ "$SKIP_GYP" == "0" ]; then
89   ${TOPDIR}/build/gyp_chromiumefl.sh
90 fi
91
92 if [ "$SKIP_NINJA" == "0" ]; then
93   if [ "$USE_CCACHE" == "1" ]; then
94     echo using ccache
95     set +e
96     source $TOPDIR/build/ccache_env.sh desktop
97     set -e
98   fi
99   export LD_LIBRARY_PATH="${JHBUILD_DEPS}/${_LIBDIR}:$LD_LIBRARY_PATH"
100   export PATH="${JHBUILD_DEPS}/bin:$PATH"
101   ninja -C ${GYP_GENERATOR_OUTPUT}/${BUILD_SUBDIRECTORY} ${JOBS}
102 fi