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 |
Colin Cross | 1474741 | 2016-04-27 16:10:38 -0700 | [diff] [blame] | 11 | export BUILDDIR=$("${ORIG_SRCDIR}/build/soong/scripts/reverse_path.py" "$ORIG_SRCDIR") |
Dan Willemsen | 87b17d1 | 2015-07-14 00:39:06 -0700 | [diff] [blame] | 12 | cd $ORIG_SRCDIR |
| 13 | fi |
| 14 | if [[ -z "$BUILDDIR" ]]; then |
| 15 | echo "error: Run ${BASH_SOURCE[0]} from the build output directory" |
| 16 | exit 1 |
| 17 | fi |
| 18 | export SRCDIR="." |
| 19 | export BOOTSTRAP="${SRCDIR}/bootstrap.bash" |
| 20 | |
Dan Willemsen | 98c93e9 | 2015-06-10 16:59:11 -0700 | [diff] [blame] | 21 | export TOPNAME="Android.bp" |
Colin Cross | e441b9d | 2015-01-26 16:30:13 -0800 | [diff] [blame] | 22 | export BOOTSTRAP_MANIFEST="${SRCDIR}/build/soong/build.ninja.in" |
Dan Willemsen | e5e2033 | 2015-06-23 19:46:20 -0700 | [diff] [blame] | 23 | export RUN_TESTS="-t" |
Colin Cross | e441b9d | 2015-01-26 16:30:13 -0800 | [diff] [blame] | 24 | |
| 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 | |
Colin Cross | e441b9d | 2015-01-26 16:30:13 -0800 | [diff] [blame] | 40 | if [[ $# -eq 0 ]]; then |
Dan Willemsen | 87b17d1 | 2015-07-14 00:39:06 -0700 | [diff] [blame] | 41 | mkdir -p $BUILDDIR |
| 42 | |
| 43 | if [[ $(find $BUILDDIR -maxdepth 1 -name Android.bp) ]]; then |
| 44 | echo "FAILED: The build directory must not be a source directory" |
| 45 | exit 1 |
| 46 | fi |
| 47 | |
Colin Cross | 1474741 | 2016-04-27 16:10:38 -0700 | [diff] [blame] | 48 | export SRCDIR_FROM_BUILDDIR=$(build/soong/scripts/reverse_path.py "$BUILDDIR") |
Dan Willemsen | 87b17d1 | 2015-07-14 00:39:06 -0700 | [diff] [blame] | 49 | |
| 50 | sed -e "s|@@BuildDir@@|${BUILDDIR}|" \ |
| 51 | -e "s|@@SrcDirFromBuildDir@@|${SRCDIR_FROM_BUILDDIR}|" \ |
Colin Cross | e441b9d | 2015-01-26 16:30:13 -0800 | [diff] [blame] | 52 | -e "s|@@PrebuiltOS@@|${PREBUILTOS}|" \ |
Dan Willemsen | 87b17d1 | 2015-07-14 00:39:06 -0700 | [diff] [blame] | 53 | "$SRCDIR/build/soong/soong.bootstrap.in" > $BUILDDIR/.soong.bootstrap |
| 54 | ln -sf "${SRCDIR_FROM_BUILDDIR}/build/soong/soong.bash" $BUILDDIR/soong |
Colin Cross | e441b9d | 2015-01-26 16:30:13 -0800 | [diff] [blame] | 55 | fi |
| 56 | |
Dan Willemsen | 87b17d1 | 2015-07-14 00:39:06 -0700 | [diff] [blame] | 57 | "$SRCDIR/build/blueprint/bootstrap.bash" "$@" |