blob: 782b0b76ed6f131d79f9101f19b11f1ef9cb1ba5 [file] [log] [blame]
Colin Crosse441b9d2015-01-26 16:30:13 -08001#!/bin/bash
2
Dan Willemsen87b17d12015-07-14 00:39:06 -07003set -e
4
5# Switch to the build directory
6cd $(dirname "${BASH_SOURCE[0]}")
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
Dan Willemsen87b17d12015-07-14 00:39:06 -070011BOOTSTRAP=".soong.bootstrap"
Colin Cross24679672015-04-10 15:45:15 -070012if [ ! -f "${BOOTSTRAP}" ]; then
Colin Crossf7531f12015-03-25 14:09:02 -070013 echo "Error: soong script must be located in a directory created by bootstrap.bash"
14 exit 1
15fi
16
Colin Cross24679672015-04-10 15:45:15 -070017source "${BOOTSTRAP}"
Colin Crossf7531f12015-03-25 14:09:02 -070018
Dan Willemsen87b17d12015-07-14 00:39:06 -070019# Now switch to the source directory so that all the relative paths from
20# $BOOTSTRAP are correct
21cd ${SRCDIR_FROM_BUILDDIR}
Colin Crosse441b9d2015-01-26 16:30:13 -080022
Colin Crosse441b9d2015-01-26 16:30:13 -080023# Let Blueprint know that the Ninja we're using performs multiple passes that
24# can regenerate the build manifest.
25export BLUEPRINT_NINJA_HAS_MULTIPASS=1
26
Colin Cross68f55102015-03-25 14:43:57 -070027# Ninja can't depend on environment variables, so do a manual comparison
28# of the relevant environment variables from the last build using the
29# soong_env tool and trigger a build manifest regeneration if necessary
Colin Cross24679672015-04-10 15:45:15 -070030ENVFILE="${BUILDDIR}/.soong.environment"
31ENVTOOL="${BUILDDIR}/.bootstrap/bin/soong_env"
32if [ -f "${ENVFILE}" ]; then
33 if [ -x "${ENVTOOL}" ]; then
34 if ! "${ENVTOOL}" "${ENVFILE}"; then
Colin Cross68f55102015-03-25 14:43:57 -070035 echo "forcing build manifest regeneration"
Colin Cross24679672015-04-10 15:45:15 -070036 rm -f "${ENVFILE}"
Colin Cross68f55102015-03-25 14:43:57 -070037 fi
38 else
39 echo "Missing soong_env tool, forcing build manifest regeneration"
Colin Cross24679672015-04-10 15:45:15 -070040 rm -f "${ENVFILE}"
Colin Cross68f55102015-03-25 14:43:57 -070041 fi
42fi
43
Dan Willemsen87b17d12015-07-14 00:39:06 -070044"prebuilts/ninja/${PREBUILTOS}/ninja" -f "${BUILDDIR}/build.ninja" "$@"