skia2/platform_tools/nacl/nacl_make
borenet@google.com da5e6e9098 Use exportVar function in nacl_make
Dumps out the variables as they are defined for debugging
(SkipBuildbotRuns)

R=djsollen@google.com

Review URL: https://codereview.chromium.org/14655006

git-svn-id: http://skia.googlecode.com/svn/trunk@9010 2bbb7eff-a529-9590-31e7-b0007b416f81
2013-05-06 13:49:41 +00:00

111 lines
2.6 KiB
Bash
Executable File

#!/bin/bash
function exportVar {
NAME=$1
VALUE=$2
echo export $NAME=\"$VALUE\"
export $NAME="$VALUE"
}
function setenv {
if [ -z "$1" ]; then
echo "ERROR: setenv() requires one argument."
exit 1
fi
if [ -z "${NACL_SDK_ROOT}" ]; then
echo "ERROR: This script requires NACL_SDK_ROOT to be set."
exit 1
fi
ARCH_WIDTH=$1
if [ ${ARCH_WIDTH} = "32" ]; then
CROSS_ID=i686
elif [ ${ARCH_WIDTH} = "64" ]; then
CROSS_ID=x86_64
else
echo "ERROR: Unknown arch width: ${ARCH_WIDTH}"
exit 1
fi
OS_NAME=$(uname -s)
if [ $OS_NAME = "Darwin" ]; then
OS_SUBDIR="mac"
OS_SUBDIR_SHORT="mac"
OS_JOBS=4
elif [ $OS_NAME = "Linux" ]; then
OS_SUBDIR="linux"
OS_SUBDIR_SHORT="linux"
OS_JOBS=4
else
OS_SUBDIR="windows"
OS_SUBDIR_SHORT="win"
OS_JOBS=1
fi
NACL_TOOLCHAIN_ROOT=${NACL_SDK_ROOT}/toolchain/${OS_SUBDIR_SHORT}_x86_newlib
NACL_BIN_PATH=${NACL_TOOLCHAIN_ROOT}/bin
export NACL_CROSS_PREFIX=${CROSS_ID}-nacl
if [[ -z "$NACL_MAKE_CCACHE" ]]; then
exportVar NACLCC ${NACL_BIN_PATH}/${NACL_CROSS_PREFIX}-gcc
exportVar NACLCXX ${NACL_BIN_PATH}/${NACL_CROSS_PREFIX}-g++
else
exportVar NACLCC "${NACL_MAKE_CCACHE} ${NACL_BIN_PATH}/${NACL_CROSS_PREFIX}-gcc"
exportVar NACLCXX "${NACL_MAKE_CCACHE} ${NACL_BIN_PATH}/${NACL_CROSS_PREFIX}-g++"
fi
exportVar NACLAR ${NACL_BIN_PATH}/${NACL_CROSS_PREFIX}-ar
exportVar NACLRANLIB ${NACL_BIN_PATH}/${NACL_CROSS_PREFIX}-ranlib
exportVar NACLLD ${NACL_BIN_PATH}/${NACL_CROSS_PREFIX}-ld
exportVar NACLSTRINGS ${NACL_BIN_PATH}/${NACL_CROSS_PREFIX}-strings
exportVar NACLSTRIP ${NACL_BIN_PATH}/${NACL_CROSS_PREFIX}-strip
exportVar CC "${NACLCC}"
exportVar CXX "${NACLCXX}"
exportVar AR "${NACLAR}"
exportVar RANLIB "${NACLRANLIB}"
exportVar PATH ${NACL_BIN_PATH}:${PATH};
exportVar GYP_DEFINES "skia_os=nacl skia_arch_width=${ARCH_WIDTH}"
}
function build {
if [ -z "$1" ]; then
echo "ERROR: build() requires one argument."
exit 1
fi
setenv $1
export SKIA_OUT=out/nacl$1
make ${MAKE_ARGS}
}
MAKE_ARGS=""
while (( "$#" )); do
if [[ "$1" == "--use-ccache" ]];
then
if [[ -z "$NACL_MAKE_CCACHE" ]];
then
NACL_MAKE_CCACHE=$(which ccache)
fi
elif [ -z "${MAKE_ARGS}" ]; then
MAKE_ARGS="$1"
else
MAKE_ARGS="${MAKE_ARGS} $1"
fi
shift
done
if [[ -n "$NACL_MAKE_CCACHE" ]]; then
$NACL_MAKE_CCACHE --version &> /dev/null
if [[ "$?" != "0" ]]; then
echo "Unable to find ccache!"
exit 1
fi
fi
build 32 && \
build 64 && \
if ! [ -L platform_tools/nacl/out ]; then
ln -s ../../out platform_tools/nacl
fi