blob: e48f4803536e8f11d5af0e92974182c15cad37a6 [file] [log] [blame]
Colin Crosse441b9d2015-01-26 16:30:13 -08001#!/bin/bash
2
Dan Willemsen87b17d12015-07-14 00:39:06 -07003set -e
4
5ORIG_SRCDIR=$(dirname "${BASH_SOURCE[0]}")
6if [[ "$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 Cross14747412016-04-27 16:10:38 -070011 export BUILDDIR=$("${ORIG_SRCDIR}/build/soong/scripts/reverse_path.py" "$ORIG_SRCDIR")
Dan Willemsen87b17d12015-07-14 00:39:06 -070012 cd $ORIG_SRCDIR
13fi
14if [[ -z "$BUILDDIR" ]]; then
15 echo "error: Run ${BASH_SOURCE[0]} from the build output directory"
16 exit 1
17fi
18export SRCDIR="."
19export BOOTSTRAP="${SRCDIR}/bootstrap.bash"
20
Dan Willemsen98c93e92015-06-10 16:59:11 -070021export TOPNAME="Android.bp"
Colin Crosse441b9d2015-01-26 16:30:13 -080022export BOOTSTRAP_MANIFEST="${SRCDIR}/build/soong/build.ninja.in"
Dan Willemsene5e20332015-06-23 19:46:20 -070023export RUN_TESTS="-t"
Colin Crosse441b9d2015-01-26 16:30:13 -080024
25case $(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;;
35esac
36export GOROOT="${SRCDIR}/prebuilts/go/$PREBUILTOS/"
37export GOARCH="amd64"
38export GOCHAR="6"
39
Colin Crosse441b9d2015-01-26 16:30:13 -080040if [[ $# -eq 0 ]]; then
Dan Willemsen87b17d12015-07-14 00:39:06 -070041 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 Cross14747412016-04-27 16:10:38 -070048 export SRCDIR_FROM_BUILDDIR=$(build/soong/scripts/reverse_path.py "$BUILDDIR")
Dan Willemsen87b17d12015-07-14 00:39:06 -070049
50 sed -e "s|@@BuildDir@@|${BUILDDIR}|" \
51 -e "s|@@SrcDirFromBuildDir@@|${SRCDIR_FROM_BUILDDIR}|" \
Colin Crosse441b9d2015-01-26 16:30:13 -080052 -e "s|@@PrebuiltOS@@|${PREBUILTOS}|" \
Dan Willemsen87b17d12015-07-14 00:39:06 -070053 "$SRCDIR/build/soong/soong.bootstrap.in" > $BUILDDIR/.soong.bootstrap
54 ln -sf "${SRCDIR_FROM_BUILDDIR}/build/soong/soong.bash" $BUILDDIR/soong
Colin Crosse441b9d2015-01-26 16:30:13 -080055fi
56
Dan Willemsen87b17d12015-07-14 00:39:06 -070057"$SRCDIR/build/blueprint/bootstrap.bash" "$@"