blob: fab15de5f4afdbfe45f95a9df63d269ddf9de6f1 [file] [log] [blame]
Colin Crosse441b9d2015-01-26 16:30:13 -08001#!/bin/bash
2
3# Determine the build directory location based on the location of this script.
4BPBUILD="${BASH_SOURCE[0]}"
5BUILDDIR=`dirname "${BASH_SOURCE[0]}"`
Colin Crossf7531f12015-03-25 14:09:02 -07006BOOTSTRAP=${BUILDDIR}/.soong.bootstrap
Colin Crosse441b9d2015-01-26 16:30:13 -08007
Colin Crossf7531f12015-03-25 14:09:02 -07008# The source directory path and operating system will get written to
9# .soong.bootstrap by the bootstrap script.
10
11if [ ! -f ${BUILDDIR}/${BOOTSTRAP} ]; then
12 echo "Error: soong script must be located in a directory created by bootstrap.bash"
13 exit 1
14fi
15
16source ${BUILDDIR}/.soong.bootstrap
17
Colin Crosse441b9d2015-01-26 16:30:13 -080018if [[ ${SRCDIR_IN:0:1} == '/' ]]; then
19 # SRCDIR_IN is an absolute path
20 SRCDIR=${SRCDIR_IN}
21else
22 # SRCDIR_IN is a relative path
23 SRCDIR=${BUILDDIR}/${SRCDIR_IN}
24fi
25
Colin Crosse441b9d2015-01-26 16:30:13 -080026# Let Blueprint know that the Ninja we're using performs multiple passes that
27# can regenerate the build manifest.
28export BLUEPRINT_NINJA_HAS_MULTIPASS=1
29
Colin Cross68f55102015-03-25 14:43:57 -070030# 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
33ENVFILE=${BUILDDIR}/.soong.environment
34ENVTOOL=${BUILDDIR}/.bootstrap/bin/soong_env
35if [ -f ${ENVFILE} ]; then
36 if [ -x ${ENVTOOL} ]; then
37 if ! ${ENVTOOL} ${ENVFILE}; then
38 echo "forcing build manifest regeneration"
39 rm -f ${ENVFILE}
40 fi
41 else
42 echo "Missing soong_env tool, forcing build manifest regeneration"
43 rm -f ${ENVFILE}
44 fi
45fi
46
Colin Crosse441b9d2015-01-26 16:30:13 -080047${SRCDIR}/prebuilts/ninja/${PREBUILTOS}/ninja -C ${BUILDDIR} "$@"