Colin Cross | e441b9d | 2015-01-26 16:30:13 -0800 | [diff] [blame] | 1 | #!/bin/bash |
| 2 | |
| 3 | # Determine the build directory location based on the location of this script. |
| 4 | BPBUILD="${BASH_SOURCE[0]}" |
| 5 | BUILDDIR=`dirname "${BASH_SOURCE[0]}"` |
Colin Cross | 2467967 | 2015-04-10 15:45:15 -0700 | [diff] [blame] | 6 | BOOTSTRAP="${BUILDDIR}/.soong.bootstrap" |
Colin Cross | e441b9d | 2015-01-26 16:30:13 -0800 | [diff] [blame] | 7 | |
Colin Cross | f7531f1 | 2015-03-25 14:09:02 -0700 | [diff] [blame] | 8 | # The source directory path and operating system will get written to |
| 9 | # .soong.bootstrap by the bootstrap script. |
| 10 | |
Colin Cross | 2467967 | 2015-04-10 15:45:15 -0700 | [diff] [blame] | 11 | if [ ! -f "${BOOTSTRAP}" ]; then |
Colin Cross | f7531f1 | 2015-03-25 14:09:02 -0700 | [diff] [blame] | 12 | echo "Error: soong script must be located in a directory created by bootstrap.bash" |
| 13 | exit 1 |
| 14 | fi |
| 15 | |
Colin Cross | 2467967 | 2015-04-10 15:45:15 -0700 | [diff] [blame] | 16 | source "${BOOTSTRAP}" |
Colin Cross | f7531f1 | 2015-03-25 14:09:02 -0700 | [diff] [blame] | 17 | |
Colin Cross | e441b9d | 2015-01-26 16:30:13 -0800 | [diff] [blame] | 18 | if [[ ${SRCDIR_IN:0:1} == '/' ]]; then |
| 19 | # SRCDIR_IN is an absolute path |
Colin Cross | 2467967 | 2015-04-10 15:45:15 -0700 | [diff] [blame] | 20 | SRCDIR="${SRCDIR_IN}" |
Colin Cross | e441b9d | 2015-01-26 16:30:13 -0800 | [diff] [blame] | 21 | else |
| 22 | # SRCDIR_IN is a relative path |
Colin Cross | 2467967 | 2015-04-10 15:45:15 -0700 | [diff] [blame] | 23 | SRCDIR="${BUILDDIR}/${SRCDIR_IN}" |
Colin Cross | e441b9d | 2015-01-26 16:30:13 -0800 | [diff] [blame] | 24 | fi |
| 25 | |
Colin Cross | e441b9d | 2015-01-26 16:30:13 -0800 | [diff] [blame] | 26 | # Let Blueprint know that the Ninja we're using performs multiple passes that |
| 27 | # can regenerate the build manifest. |
| 28 | export BLUEPRINT_NINJA_HAS_MULTIPASS=1 |
| 29 | |
Colin Cross | 68f5510 | 2015-03-25 14:43:57 -0700 | [diff] [blame] | 30 | # Ninja can't depend on environment variables, so do a manual comparison |
| 31 | # of the relevant environment variables from the last build using the |
| 32 | # soong_env tool and trigger a build manifest regeneration if necessary |
Colin Cross | 2467967 | 2015-04-10 15:45:15 -0700 | [diff] [blame] | 33 | ENVFILE="${BUILDDIR}/.soong.environment" |
| 34 | ENVTOOL="${BUILDDIR}/.bootstrap/bin/soong_env" |
| 35 | if [ -f "${ENVFILE}" ]; then |
| 36 | if [ -x "${ENVTOOL}" ]; then |
| 37 | if ! "${ENVTOOL}" "${ENVFILE}"; then |
Colin Cross | 68f5510 | 2015-03-25 14:43:57 -0700 | [diff] [blame] | 38 | echo "forcing build manifest regeneration" |
Colin Cross | 2467967 | 2015-04-10 15:45:15 -0700 | [diff] [blame] | 39 | rm -f "${ENVFILE}" |
Colin Cross | 68f5510 | 2015-03-25 14:43:57 -0700 | [diff] [blame] | 40 | fi |
| 41 | else |
| 42 | echo "Missing soong_env tool, forcing build manifest regeneration" |
Colin Cross | 2467967 | 2015-04-10 15:45:15 -0700 | [diff] [blame] | 43 | rm -f "${ENVFILE}" |
Colin Cross | 68f5510 | 2015-03-25 14:43:57 -0700 | [diff] [blame] | 44 | fi |
| 45 | fi |
| 46 | |
Colin Cross | 2467967 | 2015-04-10 15:45:15 -0700 | [diff] [blame] | 47 | "${SRCDIR}/prebuilts/ninja/${PREBUILTOS}/ninja" -C "${BUILDDIR}" "$@" |