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 6set -o nounset 7set -o errexit 8 9SCRIPT_DIR="$(cd $(dirname $0) && pwd)" 10cd ${SCRIPT_DIR} 11 12OUT_DIR=out 13NACLPORTS_URL=https://chromium.googlesource.com/external/naclports 14NACLPORTS_SHA=04ba2e1abe8557ef888b653b7a0da974e4734641 15NACLPORTS_DIR=${OUT_DIR}/naclports 16NACLAM_URL=https://github.com/johnmccutchan/NaClAMBase 17NACLAM_DIR=${OUT_DIR}/NaClAMBase 18NACLAM_SHA=0eb4647a3f99c6e66156959edc6c55d4a913468a 19 20if [ -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 28fi 29 30Banner() { 31 echo "######################################################################" 32 echo $* 33 echo "######################################################################" 34} 35 36# echo a command to stdout and then execute it. 37LogExecute() { 38 echo $* 39 $* 40} 41 42Clone() { 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 59readonly OS_NAME=$(uname -s) 60if [ $OS_NAME = "Darwin" ]; then 61 OS_JOBS=4 62elif [ $OS_NAME = "Linux" ]; then 63 OS_JOBS=`nproc` 64else 65 OS_JOBS=1 66fi 67 68Banner Cloning naclports 69Clone ${NACLPORTS_URL} ${NACLPORTS_DIR} ${NACLPORTS_SHA} 70 71Banner Building bullet 72pushd ${NACLPORTS_DIR} 73make NACL_ARCH=pnacl bullet 74popd 75 76Banner Cloning NaClAMBase 77Clone ${NACLAM_URL} ${NACLAM_DIR} ${NACLAM_SHA} 78 79Banner Building NaClAM 80LogExecute cp Makefile ${NACLAM_DIR} 81pushd ${NACLAM_DIR} 82LogExecute make -j${OS_JOBS} 83popd 84 85LogExecute cp ${NACLAM_DIR}/pnacl/Release/NaClAMBullet.{pexe,nmf} ${OUT_DIR} 86 87Banner Done! 88