blob: c4c7e35c1cbb8c0881c545e1735514897342ba3b [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
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
17fi
18if [[ -z "$BUILDDIR" ]]; then
19 echo "error: Run ${BASH_SOURCE[0]} from the build output directory"
20 exit 1
21fi
22export SRCDIR="."
23export BOOTSTRAP="${SRCDIR}/bootstrap.bash"
24
Dan Willemsen98c93e92015-06-10 16:59:11 -070025export TOPNAME="Android.bp"
Colin Crosse441b9d2015-01-26 16:30:13 -080026export BOOTSTRAP_MANIFEST="${SRCDIR}/build/soong/build.ninja.in"
Dan Willemsene5e20332015-06-23 19:46:20 -070027export RUN_TESTS="-t"
Colin Crosse441b9d2015-01-26 16:30:13 -080028
29case $(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;;
39esac
40export GOROOT="${SRCDIR}/prebuilts/go/$PREBUILTOS/"
41export GOARCH="amd64"
42export GOCHAR="6"
43
Colin Crosse441b9d2015-01-26 16:30:13 -080044if [[ $# -eq 0 ]]; then
Dan Willemsen87b17d12015-07-14 00:39:06 -070045 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 Crosse441b9d2015-01-26 16:30:13 -080060 -e "s|@@PrebuiltOS@@|${PREBUILTOS}|" \
Dan Willemsen87b17d12015-07-14 00:39:06 -070061 "$SRCDIR/build/soong/soong.bootstrap.in" > $BUILDDIR/.soong.bootstrap
62 ln -sf "${SRCDIR_FROM_BUILDDIR}/build/soong/soong.bash" $BUILDDIR/soong
Colin Crosse441b9d2015-01-26 16:30:13 -080063fi
64
Dan Willemsen87b17d12015-07-14 00:39:06 -070065"$SRCDIR/build/blueprint/bootstrap.bash" "$@"