1#!/bin/bash
2# Copyright (c) 2012 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
8set -o xtrace
9
10SCRIPT_DIR="$(cd $(dirname $0) && pwd)"
11cd ${SCRIPT_DIR}
12
13OUT_DIR=out
14NACLPORTS_URL=http://naclports.googlecode.com/svn/trunk/src
15NACLPORTS_REV=1290
16NACLPORTS_DIR=${OUT_DIR}/naclports
17
18if [ -z "${NACL_SDK_ROOT:-}" ]; then
19  echo "-------------------------------------------------------------------"
20  echo "NACL_SDK_ROOT is unset."
21  echo "This environment variable needs to be pointed at some version of"
22  echo "the Native Client SDK (the directory containing toolchain/)."
23  echo "NOTE: set this to an absolute path."
24  echo "-------------------------------------------------------------------"
25  exit -1
26fi
27
28Banner() {
29  echo "######################################################################"
30  echo $*
31  echo "######################################################################"
32}
33
34# echo a command to stdout and then execute it.
35LogExecute() {
36  echo $*
37  $*
38}
39
40Clone() {
41  local url=$1
42  local dir=$2
43  local sha=$3
44  if [ ! -d $dir ]; then
45    LogExecute git clone $url $dir
46  else
47    pushd $dir
48    LogExecute git fetch origin
49    popd
50  fi
51
52  pushd $dir
53  LogExecute git checkout $sha
54  popd
55}
56
57Banner Cloning naclports
58if [ ! -d ${NACLPORTS_DIR} ]; then
59  mkdir -p ${NACLPORTS_DIR}
60  pushd ${NACLPORTS_DIR}
61  gclient config --name=src ${NACLPORTS_URL}
62  popd
63fi
64
65pushd ${NACLPORTS_DIR}
66gclient sync -r ${NACLPORTS_REV}
67popd
68
69
70Banner Building lua
71pushd ${NACLPORTS_DIR}/src
72# Do a 'clean' first, since previous lua build from the naclports bundle
73# building might be installed in the toolchain, and that one is built
74# without readline support.
75make TOOLCHAIN=pnacl clean
76make TOOLCHAIN=pnacl lua-ppapi
77popd
78
79Banner Done!
80