bootstrap.bash 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. #!/bin/bash
  2. set -e
  3. ORIG_SRCDIR=$(dirname "${BASH_SOURCE[0]}")
  4. if [[ "$ORIG_SRCDIR" != "." ]]; then
  5. if [[ ! -z "$BUILDDIR" ]]; then
  6. echo "error: To use BUILDDIR, run from the source directory"
  7. exit 1
  8. fi
  9. if [[ ${ORIG_SRCDIR:0:1} == '/' ]]; then
  10. export BUILDDIR=$PWD
  11. else
  12. export BUILDDIR=$(python -c "import os; print os.path.relpath('.', '$ORIG_SRCDIR')")
  13. fi
  14. cd $ORIG_SRCDIR
  15. fi
  16. if [[ -z "$BUILDDIR" ]]; then
  17. echo "error: Run ${BASH_SOURCE[0]} from the build output directory"
  18. exit 1
  19. fi
  20. export SRCDIR="."
  21. export BOOTSTRAP="${SRCDIR}/bootstrap.bash"
  22. export TOPNAME="Android.bp"
  23. export BOOTSTRAP_MANIFEST="${SRCDIR}/build/soong/build.ninja.in"
  24. export RUN_TESTS="-t"
  25. case $(uname) in
  26. Linux)
  27. export GOOS="linux"
  28. export PREBUILTOS="linux-x86"
  29. ;;
  30. Darwin)
  31. export GOOS="darwin"
  32. export PREBUILTOS="darwin-x86"
  33. ;;
  34. *) echo "unknown OS:" $(uname) && exit 1;;
  35. esac
  36. export GOROOT="${SRCDIR}/prebuilts/go/$PREBUILTOS/"
  37. export GOARCH="amd64"
  38. export GOCHAR="6"
  39. if [[ $# -eq 0 ]]; then
  40. mkdir -p $BUILDDIR
  41. if [[ $(find $BUILDDIR -maxdepth 1 -name Android.bp) ]]; then
  42. echo "FAILED: The build directory must not be a source directory"
  43. exit 1
  44. fi
  45. if [[ ${BUILDDIR:0:1} == '/' ]]; then
  46. export SRCDIR_FROM_BUILDDIR=$PWD
  47. else
  48. export SRCDIR_FROM_BUILDDIR=$(python -c "import os; print os.path.relpath('.', '$BUILDDIR')")
  49. fi
  50. sed -e "s|@@BuildDir@@|${BUILDDIR}|" \
  51. -e "s|@@SrcDirFromBuildDir@@|${SRCDIR_FROM_BUILDDIR}|" \
  52. -e "s|@@PrebuiltOS@@|${PREBUILTOS}|" \
  53. "$SRCDIR/build/soong/soong.bootstrap.in" > $BUILDDIR/.soong.bootstrap
  54. ln -sf "${SRCDIR_FROM_BUILDDIR}/build/soong/soong.bash" $BUILDDIR/soong
  55. fi
  56. "$SRCDIR/build/blueprint/bootstrap.bash" "$@"