[mcs] Add compilergenerated attribute for private event backing fields to match newer csc
[mono-project.git] / nacl / common.sh
blob65e7dc7a4ad8862dd2ea74e86bff43aa49dcbfe1
1 # Copyright (c) 2011 The Native Client Authors. All rights reserved.
2 # Use of this source code is governed by a BSD-style license that be
3 # found in the LICENSE file.
6 set -o nounset
7 set -o errexit
9 # scripts that source this file must be run from within packages tree
10 readonly SAVE_PWD=$(pwd)
12 # Pick platform directory for compiler.
13 readonly OS_NAME=$(uname -s)
14 if [ $OS_NAME = "Darwin" ]; then
15 readonly OS_SUBDIR="mac"
16 readonly OS_SUBDIR_SHORT="mac"
17 elif [ $OS_NAME = "Linux" ]; then
18 readonly OS_SUBDIR="linux"
19 readonly OS_SUBDIR_SHORT="linux"
20 else
21 readonly OS_SUBDIR="windows"
22 readonly OS_SUBDIR_SHORT="win"
25 readonly MACHINE=$(uname -m)
26 if [ $MACHINE = "x86_64" ]; then
27 readonly TARGET_BITSIZE=${TARGET_BITSIZE:-"64"}
28 readonly HOST_BITSIZE=${HOST_BITSIZE:-"64"}
29 else
30 # uname -m reports i686 on Linux and i386 on Mac
31 readonly TARGET_BITSIZE=${TARGET_BITSIZE:-"32"}
32 readonly HOST_BITSIZE=${HOST_BITSIZE:-"32"}
35 if [ $TARGET_BITSIZE == "64" ]; then
36 readonly TARGET_BIT_PREFIX="64"
37 readonly CROSS_ID=x86_64
38 else
39 readonly TARGET_BIT_PREFIX=""
40 readonly CROSS_ID=i686
42 # we might want to override the detected host platform (e.g. on OSX 10.6)
43 if [ $HOST_BITSIZE == "64" ]; then
44 readonly HOST_BIT_PREFIX="64"
45 else
46 readonly HOST_BIT_PREFIX=""
49 export NACL_CROSS_PREFIX=${CROSS_ID}-nacl
50 export NACL_CROSS_PREFIX_DASH=${NACL_CROSS_PREFIX}-
52 readonly NACL_NEWLIB=${NACL_NEWLIB:-"0"}
54 if [ $NACL_NEWLIB = "1" ]; then
55 readonly NACL_SDK_BASE=${NACL_SDK_ROOT}/toolchain/${OS_SUBDIR_SHORT}_x86_newlib
56 else
57 case "${NACL_SDK_ROOT}" in
58 *pepper_15* | *pepper_16* | *pepper_17*)
59 readonly NACL_SDK_BASE=${NACL_SDK_ROOT}/toolchain/${OS_SUBDIR_SHORT}_x86
62 readonly NACL_SDK_BASE=${NACL_SDK_ROOT}/toolchain/${OS_SUBDIR_SHORT}_x86_glibc
64 esac
67 readonly NACL_BIN_PATH=${NACL_SDK_BASE}/bin
68 export NACLCC=${NACL_BIN_PATH}/${NACL_CROSS_PREFIX_DASH}gcc
69 export NACLCXX=${NACL_BIN_PATH}/${NACL_CROSS_PREFIX_DASH}g++
70 export NACLAR=${NACL_BIN_PATH}/${NACL_CROSS_PREFIX_DASH}ar
71 export NACLRANLIB=${NACL_BIN_PATH}/${NACL_CROSS_PREFIX_DASH}ranlib
72 export NACLLD=${NACL_BIN_PATH}/${NACL_CROSS_PREFIX_DASH}ld
73 export NACLAS=${NACL_BIN_PATH}/${NACL_CROSS_PREFIX_DASH}as
75 # NACL_SDK_GCC_SPECS_PATH is where nacl-gcc 'specs' file will be installed
76 readonly NACL_SDK_GCC_SPECS_PATH=${NACL_SDK_BASE}/lib/gcc/x86_64-nacl/4.4.3
78 # NACL_SDK_USR is where the headers, libraries, etc. will be installed
79 readonly NACL_SDK_USR=${NACL_SDK_BASE}/${NACL_CROSS_PREFIX}/usr
80 readonly NACL_SDK_USR_INCLUDE=${NACL_SDK_USR}/include
81 readonly NACL_SDK_USR_LIB=${NACL_SDK_USR}/lib
84 ######################################################################
85 # Helper functions
86 ######################################################################
88 Banner() {
89 echo "######################################################################"
90 echo $*
91 echo "######################################################################"
95 VerifyPath() {
96 # make sure path isn't all slashes (possibly from an unset variable)
97 local PATH=$1
98 local TRIM=${PATH##/}
99 if [ ${#TRIM} -ne 0 ]; then
100 return 0
101 else
102 return 1
107 ChangeDir() {
108 local NAME=$1
109 if VerifyPath ${NAME}; then
110 cd ${NAME}
111 else
112 echo "ChangeDir called with bad path."
113 exit -1
118 Remove() {
119 local NAME=$1
120 if VerifyPath ${NAME}; then
121 rm -rf ${NAME}
122 else
123 echo "Remove called with bad path."
124 exit -1
129 MakeDir() {
130 local NAME=$1
131 if VerifyPath ${NAME}; then
132 mkdir -p ${NAME}
133 else
134 echo "MakeDir called with bad path."
135 exit -1
140 PatchSpecFile() {
141 # fix up spaces so gcc sees entire path
142 local SED_SAFE_SPACES_USR_INCLUDE=${NACL_SDK_USR_INCLUDE/ /\ /}
143 local SED_SAFE_SPACES_USR_LIB=${NACL_SDK_USR_LIB/ /\ /}
144 # have nacl-gcc dump specs file & add include & lib search paths
145 ${NACL_SDK_BASE}/bin/x86_64-nacl-gcc -dumpspecs |\
146 sed "/*cpp:/{
148 s|$| -I${SED_SAFE_SPACES_USR_INCLUDE}|
149 }" |\
150 sed "/*link_libgcc:/{
152 s|$| -L${SED_SAFE_SPACES_USR_LIB}|
153 }" >${NACL_SDK_GCC_SPECS_PATH}/specs
157 DefaultConfigureStep() {
158 Banner "Configuring ${PACKAGE_NAME}"
159 # export the nacl tools
160 export CC=${NACLCC}
161 export CXX=${NACLCXX}
162 export AR=${NACLAR}
163 export RANLIB=${NACLRANLIB}
164 export PKG_CONFIG_PATH=${NACL_SDK_USR_LIB}/pkgconfig
165 export PKG_CONFIG_LIBDIR=${NACL_SDK_USR_LIB}
166 export PATH=${NACL_BIN_PATH}:${PATH};
167 ChangeDir ${NACL_PACKAGES_REPOSITORY}/${PACKAGE_NAME}
168 Remove ${PACKAGE_NAME}-build
169 MakeDir ${PACKAGE_NAME}-build
170 cd ${PACKAGE_NAME}-build
171 ../configure \
172 --host=nacl \
173 --disable-shared \
174 --prefix=${NACL_SDK_USR} \
175 --exec-prefix=${NACL_SDK_USR} \
176 --libdir=${NACL_SDK_USR_LIB} \
177 --oldincludedir=${NACL_SDK_USR_INCLUDE} \
178 --with-http=off \
179 --with-html=off \
180 --with-ftp=off \
181 --with-x=no
185 DefaultBuildStep() {
186 # assumes pwd has makefile
187 make clean
188 if [ $TARGET_BITSIZE == "64" ]; then
189 make -j8
190 else
191 make
196 DefaultInstallStep() {
197 # assumes pwd has makefile
198 make install
202 DefaultCleanUpStep() {
203 PatchSpecFile
204 ChangeDir ${SAVE_PWD}
208 DefaultPackageInstall() {
209 DefaultPreInstallStep
210 DefaultDownloadStep
211 DefaultExtractStep
212 DefaultPatchStep
213 DefaultConfigureStep
214 DefaultBuildStep
215 DefaultInstallStep
216 DefaultCleanUpStep