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 13SMOOTHLIFE_URL=https://github.com/binji/smoothnacl 14SMOOTHLIFE_DIR=${OUT_DIR}/smoothlife 15SMOOTHLIFE_SHA=e81cf2b00290add556dcdc8aa84506ca007bc853 16 17if [ -z "${NACL_SDK_ROOT:-}" ]; then 18 echo "-------------------------------------------------------------------" 19 echo "NACL_SDK_ROOT is unset." 20 echo "This environment variable needs to be pointed at some version of" 21 echo "the Native Client SDK (the directory containing toolchain/)." 22 echo "NOTE: set this to an absolute path." 23 echo "-------------------------------------------------------------------" 24 exit -1 25fi 26 27Banner() { 28 echo "######################################################################" 29 echo $* 30 echo "######################################################################" 31} 32 33# echo a command to stdout and then execute it. 34LogExecute() { 35 echo $* 36 $* 37} 38 39Clone() { 40 local url=$1 41 local dir=$2 42 local sha=$3 43 if [ ! -d $dir ]; then 44 LogExecute git clone $url $dir 45 else 46 pushd $dir 47 LogExecute git fetch origin 48 popd 49 fi 50 51 pushd $dir 52 LogExecute git checkout $sha 53 popd 54} 55 56readonly OS_NAME=$(uname -s) 57if [ $OS_NAME = "Darwin" ]; then 58 OS_JOBS=4 59elif [ $OS_NAME = "Linux" ]; then 60 OS_JOBS=`nproc` 61else 62 OS_JOBS=1 63fi 64 65Banner Cloning smoothlife 66Clone ${SMOOTHLIFE_URL} ${SMOOTHLIFE_DIR} ${SMOOTHLIFE_SHA} 67 68pushd ${SMOOTHLIFE_DIR} 69 70Banner Updating submodules 71LogExecute git submodule update --init 72 73Banner Building FFTW 74LogExecute make ports TOOLCHAIN=pnacl CONFIG=Release 75 76Banner Building smoothlife 77LogExecute make TOOLCHAIN=pnacl CONFIG=Release -j${OS_JOBS} 78 79popd 80 81LogExecute cp ${SMOOTHLIFE_DIR}/pnacl/Release/smoothnacl.{pexe,nmf} ${OUT_DIR} 82 83Banner Done! 84