Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 # Copyright (c) 2012 The Native Client Authors. All rights reserved. | 1 # Copyright (c) 2012 The Native Client Authors. All rights reserved. |
| 2 # Use of this source code is governed by a BSD-style license that can be | 2 # Use of this source code is governed by a BSD-style license that can be |
| 3 # found in the LICENSE file. | 3 # found in the LICENSE file. |
| 4 # | 4 # |
| 5 # Environment variable NACL_ARCH should be set to one of the following | 5 # Environment variable NACL_ARCH should be set to one of the following |
| 6 # values: i686 x86_64 pnacl arm | 6 # values: i686 x86_64 pnacl arm |
| 7 | 7 |
| 8 | 8 |
| 9 # NAMING CONVENTION | 9 # NAMING CONVENTION |
| 10 # ================= | 10 # ================= |
| (...skipping 278 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 289 if cmp ${TC_INCLUDES}${INC} ${NACLPORTS_INCLUDE}${INC} > /dev/null; then | 289 if cmp ${TC_INCLUDES}${INC} ${NACLPORTS_INCLUDE}${INC} > /dev/null; then |
| 290 continue | 290 continue |
| 291 fi | 291 fi |
| 292 fi | 292 fi |
| 293 MakeDir $(dirname ${NACLPORTS_INCLUDE}${INC}) | 293 MakeDir $(dirname ${NACLPORTS_INCLUDE}${INC}) |
| 294 LogExecute install -m 644 ${TC_INCLUDES}${INC} ${NACLPORTS_INCLUDE}${INC} | 294 LogExecute install -m 644 ${TC_INCLUDES}${INC} ${NACLPORTS_INCLUDE}${INC} |
| 295 done | 295 done |
| 296 } | 296 } |
| 297 | 297 |
| 298 | 298 |
| 299 PatchSpecFile() { | 299 PatchSpecsFile() { |
| 300 if [ "${NACL_ARCH}" = "pnacl" -o \ | 300 if [ "${NACL_ARCH}" = "pnacl" -o \ |
| 301 "${NACL_ARCH}" = "emscripten" ]; then | 301 "${NACL_ARCH}" = "emscripten" ]; then |
| 302 # The arm compiler doesn't currently need a patched specs file | 302 # The emscripten compiler doesn't currently need a patched specs file |
|
noelallen1
2014/10/07 18:25:03
NIT: A split sentence is kinda confusing. And th
Sam Clegg
2014/10/07 18:34:26
Done.
| |
| 303 # as it ships with the correct paths. As does the pnacl toolchain. | 303 # as it ships with the correct paths. As does the pnacl toolchain. |
| 304 return | 304 return |
| 305 fi | 305 fi |
| 306 | 306 |
| 307 # SPECS_FILE is where nacl-gcc 'specs' file will be installed | 307 # SPECS_FILE is where nacl-gcc 'specs' file will be installed |
| 308 local SPECS_DIR= | 308 local SPECS_DIR= |
| 309 if [ "${NACL_ARCH}" = "arm" ]; then | 309 if [ "${NACL_ARCH}" = "arm" ]; then |
| 310 SPECS_DIR=${NACL_TOOLCHAIN_ROOT}/lib/gcc/arm-nacl/4.8.2 | 310 SPECS_DIR=${NACL_TOOLCHAIN_ROOT}/lib/gcc/arm-nacl/4.8.2 |
| 311 if [ ! -d "${SPECS_DIR}" ]; then | 311 if [ ! -d "${SPECS_DIR}" ]; then |
| 312 SPECS_DIR=${NACL_TOOLCHAIN_ROOT}/lib/gcc/arm-nacl/4.8.3 | 312 SPECS_DIR=${NACL_TOOLCHAIN_ROOT}/lib/gcc/arm-nacl/4.8.3 |
| 313 fi | 313 fi |
| 314 else | 314 else |
| 315 SPECS_DIR=${NACL_TOOLCHAIN_ROOT}/lib/gcc/x86_64-nacl/4.4.3 | 315 SPECS_DIR=${NACL_TOOLCHAIN_ROOT}/lib/gcc/x86_64-nacl/4.4.3 |
| 316 fi | 316 fi |
| 317 local SPECS_FILE=${SPECS_DIR}/specs | 317 local SPECS_FILE=${SPECS_DIR}/specs |
| 318 | 318 |
| 319 # NACL_SDK_MULITARCH_USR is a version of NACL_TOOLCHAIN_ROOT that gets passed | 319 # NACL_SDK_MULITARCH_USR is a version of NACL_TOOLCHAIN_ROOT that gets passed |
| 320 # into the gcc specs file. It has a gcc spec-file conditional for | 320 # into the gcc specs file. It has a gcc spec-file conditional for |
| 321 # ${NACL_ARCH} | 321 # ${NACL_ARCH} |
| 322 local NACL_SDK_MULTIARCH_USR=${NACL_TOOLCHAIN_ROOT}/\%\(nacl_arch\)/usr | 322 local NACL_SDK_MULTIARCH_USR=${NACL_TOOLCHAIN_ROOT}/\%\(nacl_arch\)/usr |
| 323 local NACL_SDK_MULTIARCH_USR_INCLUDE=${NACL_SDK_MULTIARCH_USR}/include | 323 local NACL_SDK_MULTIARCH_USR_INCLUDE=${NACL_SDK_MULTIARCH_USR}/include |
| 324 local NACL_SDK_MULTIARCH_USR_LIB=${NACL_SDK_MULTIARCH_USR}/lib | 324 local NACL_SDK_MULTIARCH_USR_LIB=${NACL_SDK_MULTIARCH_USR}/lib |
| 325 local ERROR_MSG="Shared libraries are not supported by newlib toolchain" | 325 local ERROR_MSG="Shared libraries are not supported by newlib toolchain" |
| 326 | 326 |
| 327 # fix up spaces so gcc sees entire path | 327 # fix up spaces so gcc sees entire path |
| 328 local SED_SAFE_SPACES_USR_INCLUDE=${NACL_SDK_MULTIARCH_USR_INCLUDE/ /\ /} | 328 local SED_SAFE_SPACES_USR_INCLUDE=${NACL_SDK_MULTIARCH_USR_INCLUDE/ /\ /} |
| 329 local SED_SAFE_SPACES_USR_LIB=${NACL_SDK_MULTIARCH_USR_LIB/ /\ /} | 329 local SED_SAFE_SPACES_USR_LIB=${NACL_SDK_MULTIARCH_USR_LIB/ /\ /} |
| 330 | 330 |
| 331 if [ -f ${SPECS_FILE} ]; then | |
| 332 if grep -q "${NACL_SDK_MULTIARCH_USR_LIB}" ${SPECS_FILE}; then | |
| 333 echo "Specs file already patched" | |
| 334 return | |
| 335 fi | |
| 336 echo "Patching existing specs file" | |
| 337 cp ${SPECS_FILE} ${SPECS_FILE}.current | |
| 338 else | |
| 339 echo "Creating new specs file" | |
| 340 ${NACLCC} -dumpspecs > ${SPECS_FILE}.current | |
| 341 fi | |
| 342 | |
| 343 # add include & lib search paths to specs file | |
| 331 if [ "${NACL_ARCH}" = "arm" ]; then | 344 if [ "${NACL_ARCH}" = "arm" ]; then |
| 332 local ARCH_SUBST='/\*cpp:/ { \ | 345 local ARCH_SUBST='/\*cpp:/ { \ |
| 333 printf("*nacl_arch:\narm-nacl\n\n", $1); } \ | 346 printf("*nacl_arch:\narm-nacl\n\n", $1); } \ |
| 334 { print $0; }' | 347 { print $0; }' |
| 335 else | 348 else |
| 336 local ARCH_SUBST='/\*cpp:/ { \ | 349 local ARCH_SUBST='/\*cpp:/ { \ |
| 337 printf("*nacl_arch:\n%%{m64:x86_64-nacl; m32:i686-nacl; :x86_64-nacl}\n\ n", $1); } \ | 350 printf("*nacl_arch:\n%%{m64:x86_64-nacl; m32:i686-nacl; :x86_64-nacl}\n\ n", $1); } \ |
| 338 { print $0; }' | 351 { print $0; }' |
| 339 fi | 352 fi |
| 340 | 353 |
| 341 # have nacl-gcc dump specs file & add include & lib search paths | 354 cat ${SPECS_FILE}.current |\ |
| 342 ${NACLCC} -dumpspecs |\ | |
| 343 awk "${ARCH_SUBST}" |\ | 355 awk "${ARCH_SUBST}" |\ |
| 344 sed "/*cpp:/{ | 356 sed "/*cpp:/{ |
| 345 N | 357 N |
| 346 s|$| -isystem ${SED_SAFE_SPACES_USR_INCLUDE}| | 358 s|$| -isystem ${SED_SAFE_SPACES_USR_INCLUDE}| |
| 347 }" |\ | 359 }" |\ |
| 348 sed "/*link_libgcc:/{ | 360 sed "/*link_libgcc:/{ |
| 349 N | 361 N |
| 350 s|$| -rpath-link=${SED_SAFE_SPACES_USR_LIB} -L${SED_SAFE_SPACES_USR_LIB}| | 362 s|$| -rpath-link=${SED_SAFE_SPACES_USR_LIB} -L${SED_SAFE_SPACES_USR_LIB}| |
| 351 }" > ${SPECS_FILE} | 363 }" > ${SPECS_FILE} |
| 352 | 364 |
| 353 # For newlib toolchain, modify the specs file to give an error when attempting | 365 # For static-only toolchains (i.e. newlib), modify the specs file to give an |
| 354 # to create a shared object. | 366 # error when attempting to create a shared object. |
| 355 if [ "${NACL_LIBC}" = "newlib" ]; then | 367 if [ "${NACL_SHARED}" != "1" ]; then |
| 356 sed -i.bak "s/%{shared:-shared/%{shared:%e${ERROR_MSG}/" "${SPECS_FILE}" | 368 sed -i.bak "s/%{shared:-shared/%{shared:%e${ERROR_MSG}/" "${SPECS_FILE}" |
| 357 fi | 369 fi |
| 358 } | 370 } |
| 359 | 371 |
| 360 | 372 |
| 361 CheckSDKVersion() { | 373 CheckSDKVersion() { |
| 362 if [ -z "${MIN_SDK_VERSION:-}" ]; then | 374 if [ -z "${MIN_SDK_VERSION:-}" ]; then |
| 363 return | 375 return |
| 364 fi | 376 fi |
| 365 local GETOS=${NACL_SDK_ROOT}/tools/getos.py | 377 local GETOS=${NACL_SDK_ROOT}/tools/getos.py |
| (...skipping 1268 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1634 | 1646 |
| 1635 | 1647 |
| 1636 ###################################################################### | 1648 ###################################################################### |
| 1637 # Always run | 1649 # Always run |
| 1638 # These functions are called when this script is imported to do | 1650 # These functions are called when this script is imported to do |
| 1639 # any essential checking/setup operations. | 1651 # any essential checking/setup operations. |
| 1640 ###################################################################### | 1652 ###################################################################### |
| 1641 CheckToolchain | 1653 CheckToolchain |
| 1642 CheckPatchVersion | 1654 CheckPatchVersion |
| 1643 CheckSDKVersion | 1655 CheckSDKVersion |
| 1644 PatchSpecFile | 1656 PatchSpecsFile |
| 1645 InjectSystemHeaders | 1657 InjectSystemHeaders |
| 1646 InstallConfigSite | 1658 InstallConfigSite |
| 1647 GetRevision | 1659 GetRevision |
| OLD | NEW |