- add sources.
[platform/framework/web/crosswalk.git] / src / native_client_sdk / src / gonacl_appengine / src / bullet / build.sh
1 #!/bin/bash
2 # Copyright (c) 2013 The Chromium Authors. All rights reserved.
3 # Use of this source code is governed by a BSD-style license that can be
4 # found in the LICENSE file.
5
6 set -o nounset
7 set -o errexit
8
9 SCRIPT_DIR="$(cd $(dirname $0) && pwd)"
10 cd ${SCRIPT_DIR}
11
12 OUT_DIR=out
13 NACLPORTS_URL=https://chromium.googlesource.com/external/naclports
14 NACLPORTS_SHA=0096083c0fa71c014f6218bb14d7e1742d9a6b0c
15 NACLPORTS_DIR=${OUT_DIR}/naclports
16 NACLAM_URL=https://github.com/johnmccutchan/NaClAMBase
17 NACLAM_DIR=${OUT_DIR}/NaClAMBase
18 NACLAM_SHA=0eb4647a3f99c6e66156959edc6c55d4a913468a
19
20 if [ -z "${NACL_SDK_ROOT:-}" ]; then
21   echo "-------------------------------------------------------------------"
22   echo "NACL_SDK_ROOT is unset."
23   echo "This environment variable needs to be pointed at some version of"
24   echo "the Native Client SDK (the directory containing toolchain/)."
25   echo "NOTE: set this to an absolute path."
26   echo "-------------------------------------------------------------------"
27   exit -1
28 fi
29
30 Banner() {
31   echo "######################################################################"
32   echo $*
33   echo "######################################################################"
34 }
35
36 # echo a command to stdout and then execute it.
37 LogExecute() {
38   echo $*
39   $*
40 }
41
42 Clone() {
43   local url=$1
44   local dir=$2
45   local sha=$3
46   if [ ! -d $dir ]; then
47     LogExecute git clone $url $dir
48   else
49     pushd $dir
50     LogExecute git fetch origin
51     popd
52   fi
53
54   pushd $dir
55   LogExecute git checkout $sha
56   popd
57 }
58
59 readonly OS_NAME=$(uname -s)
60 if [ $OS_NAME = "Darwin" ]; then
61   OS_JOBS=4
62 elif [ $OS_NAME = "Linux" ]; then
63   OS_JOBS=`nproc`
64 else
65   OS_JOBS=1
66 fi
67
68 Banner Cloning naclports
69 Clone ${NACLPORTS_URL} ${NACLPORTS_DIR} ${NACLPORTS_SHA}
70
71 Banner Building bullet
72 pushd ${NACLPORTS_DIR}
73 make NACL_ARCH=pnacl bullet
74 popd
75
76 Banner Cloning NaClAMBase
77 Clone ${NACLAM_URL} ${NACLAM_DIR} ${NACLAM_SHA}
78
79 Banner Building NaClAM
80 LogExecute cp Makefile ${NACLAM_DIR}
81 pushd ${NACLAM_DIR}
82 LogExecute make -j${OS_JOBS}
83 popd
84
85 LogExecute cp ${NACLAM_DIR}/pnacl/Release/NaClAMBullet.{pexe,nmf} ${OUT_DIR}
86
87 Banner Done!