build-cctools.sh 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. #!/bin/bash
  2. set -x -e -v
  3. # This script is for building cctools (Apple's binutils) for Linux using
  4. # crosstool-ng (https://github.com/diorcety/crosstool-ng).
  5. WORKSPACE=$HOME/workspace
  6. UPLOAD_DIR=$WORKSPACE/artifacts
  7. # Repository info
  8. : CROSSTOOL_NG_REPOSITORY ${CROSSTOOL_NG_REPOSITORY:=https://github.com/diorcety/crosstool-ng}
  9. : CROSSTOOL_NG_REV ${CROSSTOOL_NG_REV:=master}
  10. # hacky
  11. ln -s `which gcc` ~/bin/x86_64-linux-gnu-gcc
  12. export PATH=$PATH:~/bin
  13. # Set some crosstools-ng directories
  14. CT_TOP_DIR=$WORKSPACE/crosstool-ng-build
  15. CT_PREFIX_DIR=$WORKSPACE/cctools
  16. CT_SRC_DIR=$CT_TOP_DIR/src
  17. CT_TARBALLS_DIR=$CT_TOP_DIR
  18. CT_WORK_DIR=$CT_SRC_DIR
  19. CT_LIB_DIR=$WORKSPACE/crosstool-ng
  20. CT_BUILD_DIR=$CT_TOP_DIR/build
  21. CT_LLVM_DIR=$WORKSPACE/clang
  22. CT_BUILDTOOLS_PREFIX_DIR=$CT_PREFIX_DIR
  23. # Create our directories
  24. rm -rf $CT_TOP_DIR
  25. mkdir $CT_TOP_DIR
  26. rm -rf $CT_PREFIX_DIR
  27. mkdir $CT_PREFIX_DIR
  28. mkdir -p $CT_SRC_DIR
  29. # Clone the crosstool-ng repo
  30. tc-vcs checkout $CT_LIB_DIR $CROSSTOOL_NG_REPOSITORY $CROSSTOOL_NG_REPOSITORY $CROSSTOOL_NG_REV
  31. # Fetch clang from tooltool
  32. cd $WORKSPACE
  33. wget -O tooltool.py https://raw.githubusercontent.com/mozilla/build-tooltool/master/tooltool.py
  34. chmod +x tooltool.py
  35. : TOOLTOOL_CACHE ${TOOLTOOL_CACHE:=/home/worker/tooltool-cache}
  36. export TOOLTOOL_CACHE
  37. wget ${GECKO_HEAD_REPOSITORY}/raw-file/${GECKO_HEAD_REV}/browser/config/tooltool-manifests/linux64/clang.manifest
  38. python tooltool.py -v --manifest=clang.manifest fetch
  39. # Copy clang into the crosstools-ng srcdir
  40. cp -Rp $CT_LLVM_DIR $CT_SRC_DIR
  41. # Configure crosstools-ng
  42. sed=sed
  43. CT_CONNECT_TIMEOUT=5
  44. CT_BINUTILS_VERSION=809
  45. CT_PATCH_ORDER=bundled
  46. CT_BUILD=x86_64-linux-gnu
  47. CT_HOST=x86_64-linux-gnu
  48. CT_TARGET=x86_64-apple-darwin10
  49. CT_LLVM_FULLNAME=clang
  50. cd $CT_TOP_DIR
  51. # gets a bit too verbose here
  52. set +x
  53. . $CT_LIB_DIR/scripts/functions
  54. . $CT_LIB_DIR/scripts/build/binutils/cctools.sh
  55. # Build cctools
  56. do_binutils_get
  57. do_binutils_extract
  58. do_binutils_for_host
  59. set -x
  60. strip $CT_PREFIX_DIR/bin/*
  61. # Put a tarball in the artifacts dir
  62. mkdir -p $UPLOAD_DIR
  63. tar czf $UPLOAD_DIR/cctools.tar.gz -C $WORKSPACE `basename $CT_PREFIX_DIR`