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