build 2.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. #!/bin/bash
  2. [% c('var/setarch') %]
  3. [% c("var/set_default_env") -%]
  4. distdir=/var/tmp/dist/[% project %]
  5. mkdir -p /var/tmp/dist
  6. tar -C /var/tmp/dist -xf [% c('input_files_by_name/cmake') %]
  7. export PATH="/var/tmp/dist/cmake/bin:$PATH"
  8. tar -C /var/tmp/dist -xf [% c('input_files_by_name/prev_rust') %]
  9. cd /var/tmp/dist/rust-[% c('var/prev_version') %]-[% c('arch') %]-unknown-linux-gnu
  10. ./install.sh --prefix=$distdir-rust-old
  11. export PATH="$distdir-rust-old/bin:$PATH"
  12. [% IF ! c("var/windows") %]
  13. [% pc(c('var/compiler'), 'var/setup', { compiler_tarfile => c('input_files_by_name/' _ c('var/compiler')) }) %]
  14. [% END -%]
  15. [% IF c("var/osx") %]
  16. # We need to clear `CC` and `LDFLAGS` as they are used for the host platform
  17. # (i.e. Linux).
  18. unset CC
  19. unset LDFLAGS
  20. # Target 10.6 as our toolchain does. Without this explicit declaration Bad
  21. # Things will happen, as a lot of dependent code then assumes that the
  22. # official macOS target, x86_64-apple-darwin, essentially means 10.4.
  23. export MACOSX_DEPLOYMENT_TARGET=10.6
  24. # The Rust target for macOS is x86_64-apple-darwin, yet our toolchain is built
  25. # for x86_64-apple-darwin10. We can't mix those targets as clang gets confused
  26. # that way. Changing the Rust target to x86_64-apple-darwin10 would require a
  27. # fair amount of patching, thus we create symlinks to prvoide Rust with the
  28. # necessary tools while using our toolchain underneath, targeting 10.6.
  29. cd $cctoolsdir
  30. for f in `ls x86_64-apple-darwin10-*`; do
  31. ln -s $f ${f//x86_64-apple-darwin10/x86_64-apple-darwin}
  32. done
  33. cd ..
  34. ln -s x86_64-apple-darwin10 x86_64-apple-darwin
  35. mkdir -p $distdir/helper
  36. # We need to adapt our CFLAGS and make sure our flags are passed down to all
  37. # dependencies. Using `CFLAGS_x86_apple-darwin` did not do the trick, so resort
  38. # to a wrapper script.
  39. cat > $distdir/helper/x86_64-apple-darwin-clang << 'EOF'
  40. #!/bin/sh
  41. BASEDIR=/var/tmp/dist/macosx-toolchain
  42. $BASEDIR/cctools/bin/x86_64-apple-darwin-clang -target x86_64-apple-darwin -mlinker-version=136 -B $BASEDIR/cctools/bin -isysroot $BASEDIR/SDK/ -Wl,-syslibroot,$BASEDIR/SDK/ -Wl,-dead_strip -Wl,-pie "$@"
  43. EOF
  44. chmod +x $distdir/helper/x86_64-apple-darwin-clang
  45. export PATH=$distdir/helper:$PATH
  46. [% END %]
  47. cd $rootdir
  48. mkdir /var/tmp/build
  49. tar -C /var/tmp/build -xf [% c('input_files_by_name/rust') %]
  50. cd /var/tmp/build/rustc-[% c('version') %]-src
  51. [% IF c("var/linux") %]
  52. # binaryen hardcodes /usr/bin/cc and /usr/bin/c++ as the C and C++ compiler.
  53. # But that is too old on Debian Wheezy which is why we need to patch it, so
  54. # we can use our own GCC instead.
  55. patch -p1 < $rootdir/binaryen.patch
  56. [% END %]
  57. mkdir build
  58. cd build
  59. ../configure --prefix=$distdir [% c("var/configure_opt") %]
  60. make -j[% c("buildconf/num_procs") %]
  61. make install
  62. cd /var/tmp/dist
  63. [% c('tar', {
  64. tar_src => [ project ],
  65. tar_args => '-czf ' _ dest_dir _ '/' _ c('filename'),
  66. }) %]