OLD | NEW |
| (Empty) |
1 #!/bin/bash | |
2 | |
3 function exportVar { | |
4 NAME=$1 | |
5 VALUE=$2 | |
6 echo export $NAME=\"$VALUE\" | |
7 export $NAME="$VALUE" | |
8 } | |
9 | |
10 function setenv { | |
11 if [ -z "$1" ]; then | |
12 echo "ERROR: setenv() requires one argument." | |
13 exit 1 | |
14 fi | |
15 if [ -z "${NACL_SDK_ROOT}" ]; then | |
16 echo "ERROR: This script requires NACL_SDK_ROOT to be set." | |
17 exit 1 | |
18 fi | |
19 | |
20 ARCH_WIDTH=$1 | |
21 if [ ${ARCH_WIDTH} = "32" ]; then | |
22 ARCH_TYPE=x86 | |
23 CROSS_ID=i686 | |
24 elif [ ${ARCH_WIDTH} = "64" ]; then | |
25 ARCH_TYPE=x86_64 | |
26 CROSS_ID=x86_64 | |
27 else | |
28 echo "ERROR: Unknown arch width: ${ARCH_WIDTH}" | |
29 exit 1 | |
30 fi | |
31 | |
32 OS_NAME=$(uname -s) | |
33 if [ $OS_NAME = "Darwin" ]; then | |
34 OS_SUBDIR="mac" | |
35 OS_SUBDIR_SHORT="mac" | |
36 OS_JOBS=4 | |
37 elif [ $OS_NAME = "Linux" ]; then | |
38 OS_SUBDIR="linux" | |
39 OS_SUBDIR_SHORT="linux" | |
40 OS_JOBS=4 | |
41 else | |
42 OS_SUBDIR="windows" | |
43 OS_SUBDIR_SHORT="win" | |
44 OS_JOBS=1 | |
45 fi | |
46 | |
47 NACL_TOOLCHAIN_ROOT=${NACL_SDK_ROOT}/toolchain/${OS_SUBDIR_SHORT}_x86_newlib | |
48 NACL_BIN_PATH=${NACL_TOOLCHAIN_ROOT}/bin | |
49 export NACL_CROSS_PREFIX=${CROSS_ID}-nacl | |
50 | |
51 if [[ -z "$NACL_MAKE_CCACHE" ]]; then | |
52 exportVar NACLCC ${NACL_BIN_PATH}/${NACL_CROSS_PREFIX}-gcc | |
53 exportVar NACLCXX ${NACL_BIN_PATH}/${NACL_CROSS_PREFIX}-g++ | |
54 else | |
55 exportVar NACLCC "${NACL_MAKE_CCACHE} ${NACL_BIN_PATH}/${NACL_CROSS_PREFIX}-
gcc" | |
56 exportVar NACLCXX "${NACL_MAKE_CCACHE} ${NACL_BIN_PATH}/${NACL_CROSS_PREFIX}
-g++" | |
57 fi | |
58 exportVar NACLAR ${NACL_BIN_PATH}/${NACL_CROSS_PREFIX}-ar | |
59 exportVar NACLRANLIB ${NACL_BIN_PATH}/${NACL_CROSS_PREFIX}-ranlib | |
60 exportVar NACLLD ${NACL_BIN_PATH}/${NACL_CROSS_PREFIX}-ld | |
61 exportVar NACLSTRINGS ${NACL_BIN_PATH}/${NACL_CROSS_PREFIX}-strings | |
62 exportVar NACLSTRIP ${NACL_BIN_PATH}/${NACL_CROSS_PREFIX}-strip | |
63 | |
64 exportVar CC "${NACLCC}" | |
65 exportVar CXX "${NACLCXX}" | |
66 exportVar AR "${NACLAR}" | |
67 exportVar RANLIB "${NACLRANLIB}" | |
68 exportVar PATH ${NACL_BIN_PATH}:${PATH}; | |
69 exportVar C_INCLUDE_PATH "${NACL_SDK_ROOT}/include:${NACL_SDK_ROOT}/ports/incl
ude:${C_INCLUDE_PATH}" | |
70 exportVar CPLUS_INCLUDE_PATH "${NACL_SDK_ROOT}/include:${NACL_SDK_ROOT}/ports/
include:${CPLUS_INCLUDE_PATH}" | |
71 exportVar GYP_DEFINES \ | |
72 "skia_os=nacl skia_gpu=0 skia_arch_width=${ARCH_WIDTH} skia_arch_type=${AR
CH_TYPE}" | |
73 } | |
74 | |
75 function build { | |
76 if [ -z "$1" ]; then | |
77 echo "ERROR: build() requires one argument." | |
78 exit 1 | |
79 fi | |
80 setenv $1 | |
81 | |
82 export SKIA_OUT=out/nacl$1 | |
83 make ${MAKE_ARGS} | |
84 } | |
85 | |
86 MAKE_ARGS="" | |
87 | |
88 while (( "$#" )); do | |
89 if [[ "$1" == "--use-ccache" ]]; | |
90 then | |
91 if [[ -z "$NACL_MAKE_CCACHE" ]]; | |
92 then | |
93 NACL_MAKE_CCACHE=$(which ccache) | |
94 fi | |
95 elif [ -z "${MAKE_ARGS}" ]; then | |
96 MAKE_ARGS="$1" | |
97 else | |
98 MAKE_ARGS="${MAKE_ARGS} $1" | |
99 fi | |
100 shift | |
101 done | |
102 | |
103 if [[ -n "$NACL_MAKE_CCACHE" ]]; then | |
104 $NACL_MAKE_CCACHE --version &> /dev/null | |
105 if [[ "$?" != "0" ]]; then | |
106 echo "Unable to find ccache!" | |
107 exit 1 | |
108 fi | |
109 fi | |
110 | |
111 build 32 && \ | |
112 build 64 && \ | |
113 if ! [ -L platform_tools/nacl/out ]; then | |
114 ln -s ../../out platform_tools/nacl | |
115 fi | |
OLD | NEW |