2015-01-27 01:30:13 +01:00
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
# Determine the build directory location based on the location of this script.
|
|
|
|
BPBUILD="${BASH_SOURCE[0]}"
|
|
|
|
BUILDDIR=`dirname "${BASH_SOURCE[0]}"`
|
2015-04-11 00:45:15 +02:00
|
|
|
BOOTSTRAP="${BUILDDIR}/.soong.bootstrap"
|
2015-03-25 22:09:02 +01:00
|
|
|
|
|
|
|
# The source directory path and operating system will get written to
|
|
|
|
# .soong.bootstrap by the bootstrap script.
|
|
|
|
|
2015-04-11 00:45:15 +02:00
|
|
|
if [ ! -f "${BOOTSTRAP}" ]; then
|
2015-03-25 22:09:02 +01:00
|
|
|
echo "Error: soong script must be located in a directory created by bootstrap.bash"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2015-04-11 00:45:15 +02:00
|
|
|
source "${BOOTSTRAP}"
|
2015-01-27 01:30:13 +01:00
|
|
|
|
|
|
|
if [[ ${SRCDIR_IN:0:1} == '/' ]]; then
|
|
|
|
# SRCDIR_IN is an absolute path
|
2015-04-11 00:45:15 +02:00
|
|
|
SRCDIR="${SRCDIR_IN}"
|
2015-01-27 01:30:13 +01:00
|
|
|
else
|
|
|
|
# SRCDIR_IN is a relative path
|
2015-04-11 00:45:15 +02:00
|
|
|
SRCDIR="${BUILDDIR}/${SRCDIR_IN}"
|
2015-01-27 01:30:13 +01:00
|
|
|
fi
|
|
|
|
|
|
|
|
# Let Blueprint know that the Ninja we're using performs multiple passes that
|
|
|
|
# can regenerate the build manifest.
|
|
|
|
export BLUEPRINT_NINJA_HAS_MULTIPASS=1
|
|
|
|
|
2015-03-25 22:43:57 +01:00
|
|
|
# Ninja can't depend on environment variables, so do a manual comparison
|
|
|
|
# of the relevant environment variables from the last build using the
|
|
|
|
# soong_env tool and trigger a build manifest regeneration if necessary
|
2015-04-11 00:45:15 +02:00
|
|
|
ENVFILE="${BUILDDIR}/.soong.environment"
|
|
|
|
ENVTOOL="${BUILDDIR}/.bootstrap/bin/soong_env"
|
|
|
|
if [ -f "${ENVFILE}" ]; then
|
|
|
|
if [ -x "${ENVTOOL}" ]; then
|
|
|
|
if ! "${ENVTOOL}" "${ENVFILE}"; then
|
2015-03-25 22:43:57 +01:00
|
|
|
echo "forcing build manifest regeneration"
|
2015-04-11 00:45:15 +02:00
|
|
|
rm -f "${ENVFILE}"
|
2015-03-25 22:43:57 +01:00
|
|
|
fi
|
|
|
|
else
|
|
|
|
echo "Missing soong_env tool, forcing build manifest regeneration"
|
2015-04-11 00:45:15 +02:00
|
|
|
rm -f "${ENVFILE}"
|
2015-03-25 22:43:57 +01:00
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
2015-04-11 00:45:15 +02:00
|
|
|
"${SRCDIR}/prebuilts/ninja/${PREBUILTOS}/ninja" -C "${BUILDDIR}" "$@"
|