Home | History | Annotate | Download | only in
      1 #!/bin/bash
      2 
      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   export BUILDDIR=$("${ORIG_SRCDIR}/build/soong/scripts/reverse_path.py" "$ORIG_SRCDIR")
     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 
     21 export TOPNAME="Android.bp"
     22 export BOOTSTRAP_MANIFEST="${SRCDIR}/build/soong/build.ninja.in"
     23 export RUN_TESTS="-t"
     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 
     40 if [[ $# -eq 0 ]]; then
     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 
     48     export SRCDIR_FROM_BUILDDIR=$(build/soong/scripts/reverse_path.py "$BUILDDIR")
     49 
     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 
     57 "$SRCDIR/build/blueprint/bootstrap.bash" "$@"
     58