blob: 778f5e0a3ee07ec2d53ff142eceab467b64038df [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 Cross24679672015-04-10 15:45:15 -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
Colin Cross24679672015-04-10 15:45:15 -070011if [ ! -f "${BOOTSTRAP}" ]; then
Colin Crossf7531f12015-03-25 14:09:02 -070012 echo "Error: soong script must be located in a directory created by bootstrap.bash"
13 exit 1
14fi
15
Colin Cross24679672015-04-10 15:45:15 -070016source "${BOOTSTRAP}"
Colin Crossf7531f12015-03-25 14:09:02 -070017
Colin Crosse441b9d2015-01-26 16:30:13 -080018if [[ ${SRCDIR_IN:0:1} == '/' ]]; then
19 # SRCDIR_IN is an absolute path
Colin Cross24679672015-04-10 15:45:15 -070020 SRCDIR="${SRCDIR_IN}"
Colin Crosse441b9d2015-01-26 16:30:13 -080021else
22 # SRCDIR_IN is a relative path
Colin Cross24679672015-04-10 15:45:15 -070023 SRCDIR="${BUILDDIR}/${SRCDIR_IN}"
Colin Crosse441b9d2015-01-26 16:30:13 -080024fi
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
Colin Cross24679672015-04-10 15:45:15 -070033ENVFILE="${BUILDDIR}/.soong.environment"
34ENVTOOL="${BUILDDIR}/.bootstrap/bin/soong_env"
35if [ -f "${ENVFILE}" ]; then
36 if [ -x "${ENVTOOL}" ]; then
37 if ! "${ENVTOOL}" "${ENVFILE}"; then
Colin Cross68f55102015-03-25 14:43:57 -070038 echo "forcing build manifest regeneration"
Colin Cross24679672015-04-10 15:45:15 -070039 rm -f "${ENVFILE}"
Colin Cross68f55102015-03-25 14:43:57 -070040 fi
41 else
42 echo "Missing soong_env tool, forcing build manifest regeneration"
Colin Cross24679672015-04-10 15:45:15 -070043 rm -f "${ENVFILE}"
Colin Cross68f55102015-03-25 14:43:57 -070044 fi
45fi
46
Colin Cross24679672015-04-10 15:45:15 -070047"${SRCDIR}/prebuilts/ninja/${PREBUILTOS}/ninja" -C "${BUILDDIR}" "$@"