blob: ff1ac8a62d9c9366aba0b56653fbee6959466397 [file] [log] [blame]
Colin Crosse441b9d2015-01-26 16:30:13 -08001#!/bin/bash
2
Dan Willemsen87b17d12015-07-14 00:39:06 -07003set -e
4
Dan Willemsene0879fc2017-08-04 15:06:27 -07005if [ -z "$NO_DEPRECATION_WARNING" ]; then
6 echo '== WARNING: bootstrap.bash & ./soong are deprecated ==' >&2
7 echo 'Use `m --skip-make` with a standalone OUT_DIR instead.' >&2
8 echo 'Without envsetup.sh, use:' >&2
9 echo ' build/soong/soong_ui.bash --make-mode --skip-make' >&2
10 echo '======================================================' >&2
11fi
12
Dan Willemsen87b17d12015-07-14 00:39:06 -070013ORIG_SRCDIR=$(dirname "${BASH_SOURCE[0]}")
14if [[ "$ORIG_SRCDIR" != "." ]]; then
15 if [[ ! -z "$BUILDDIR" ]]; then
16 echo "error: To use BUILDDIR, run from the source directory"
17 exit 1
18 fi
Colin Cross14747412016-04-27 16:10:38 -070019 export BUILDDIR=$("${ORIG_SRCDIR}/build/soong/scripts/reverse_path.py" "$ORIG_SRCDIR")
Dan Willemsen87b17d12015-07-14 00:39:06 -070020 cd $ORIG_SRCDIR
21fi
22if [[ -z "$BUILDDIR" ]]; then
23 echo "error: Run ${BASH_SOURCE[0]} from the build output directory"
24 exit 1
25fi
26export SRCDIR="."
27export BOOTSTRAP="${SRCDIR}/bootstrap.bash"
Dan Willemsen91f9b542017-07-18 19:39:34 -070028export BLUEPRINTDIR="${SRCDIR}/build/blueprint"
Dan Willemsen87b17d12015-07-14 00:39:06 -070029
Dan Willemsen98c93e92015-06-10 16:59:11 -070030export TOPNAME="Android.bp"
Dan Willemsene5e20332015-06-23 19:46:20 -070031export RUN_TESTS="-t"
Colin Crosse441b9d2015-01-26 16:30:13 -080032
33case $(uname) in
34 Linux)
Colin Crosse441b9d2015-01-26 16:30:13 -080035 export PREBUILTOS="linux-x86"
36 ;;
37 Darwin)
Colin Crosse441b9d2015-01-26 16:30:13 -080038 export PREBUILTOS="darwin-x86"
39 ;;
40 *) echo "unknown OS:" $(uname) && exit 1;;
41esac
Dan Willemsen91f9b542017-07-18 19:39:34 -070042export GOROOT="${SRCDIR}/prebuilts/go/$PREBUILTOS"
Colin Crosse441b9d2015-01-26 16:30:13 -080043
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
Colin Cross14747412016-04-27 16:10:38 -070052 export SRCDIR_FROM_BUILDDIR=$(build/soong/scripts/reverse_path.py "$BUILDDIR")
Dan Willemsen87b17d12015-07-14 00:39:06 -070053
54 sed -e "s|@@BuildDir@@|${BUILDDIR}|" \
55 -e "s|@@SrcDirFromBuildDir@@|${SRCDIR_FROM_BUILDDIR}|" \
Colin Crosse441b9d2015-01-26 16:30:13 -080056 -e "s|@@PrebuiltOS@@|${PREBUILTOS}|" \
Dan Willemsen87b17d12015-07-14 00:39:06 -070057 "$SRCDIR/build/soong/soong.bootstrap.in" > $BUILDDIR/.soong.bootstrap
58 ln -sf "${SRCDIR_FROM_BUILDDIR}/build/soong/soong.bash" $BUILDDIR/soong
Colin Crosse441b9d2015-01-26 16:30:13 -080059fi
60
Dan Willemsen87b17d12015-07-14 00:39:06 -070061"$SRCDIR/build/blueprint/bootstrap.bash" "$@"