Dan Willemsen | d79f1af | 2015-12-09 18:03:13 -0800 | [diff] [blame] | 1 | #!/bin/bash |
| 2 | |
| 3 | # This script is intented to wrap the execution of ninja so that we |
| 4 | # can do some checks before each ninja run. |
| 5 | # |
| 6 | # It can either be run with a standalone Blueprint checkout to generate |
| 7 | # the minibp binary, or can be used by another script as part of a custom |
| 8 | # Blueprint-based build system. When used by another script, the following |
| 9 | # environment variables can be set to configure this script, which are |
| 10 | # documented below: |
| 11 | # |
| 12 | # BUILDDIR |
Dan Willemsen | 1e72321 | 2017-07-18 19:37:37 -0700 | [diff] [blame] | 13 | # NINJA |
Dan Willemsen | d79f1af | 2015-12-09 18:03:13 -0800 | [diff] [blame] | 14 | # SKIP_NINJA |
| 15 | # |
| 16 | # When run in a standalone Blueprint checkout, bootstrap.bash will install |
| 17 | # this script into the $BUILDDIR, where it may be executed. |
| 18 | # |
| 19 | # For embedding into a custom build system, the current directory when this |
| 20 | # script executes should be the same directory that $BOOTSTRAP should be |
| 21 | # called from. |
| 22 | |
| 23 | set -e |
| 24 | |
| 25 | # BUILDDIR should be set to the path to store build results. By default, |
| 26 | # this is the directory containing this script, but can be set explicitly |
| 27 | # if the custom build system only wants to install their own wrapper. |
| 28 | [ -z "$BUILDDIR" ] && BUILDDIR=`dirname "${BASH_SOURCE[0]}"` |
| 29 | |
Dan Willemsen | 7d0dddd | 2016-08-13 12:42:11 -0700 | [diff] [blame] | 30 | # NINJA should be set to the path of the ninja executable. By default, this |
| 31 | # is just "ninja", and will be looked up in $PATH. |
| 32 | [ -z "$NINJA" ] && NINJA=ninja |
| 33 | |
| 34 | |
| 35 | if [ ! -f "${BUILDDIR}/.blueprint.bootstrap" ]; then |
| 36 | echo "Please run bootstrap.bash (.blueprint.bootstrap missing)" >&2 |
| 37 | exit 1 |
| 38 | fi |
| 39 | |
Dan Willemsen | d79f1af | 2015-12-09 18:03:13 -0800 | [diff] [blame] | 40 | # .blueprint.bootstrap provides saved values from the bootstrap.bash script: |
| 41 | # |
Dan Willemsen | 1e72321 | 2017-07-18 19:37:37 -0700 | [diff] [blame] | 42 | # BLUEPRINT_BOOTSTRAP_VERSION |
| 43 | # BLUEPRINTDIR |
| 44 | # SRCDIR |
| 45 | # GOROOT |
Dan Willemsen | d79f1af | 2015-12-09 18:03:13 -0800 | [diff] [blame] | 46 | # |
Dan Willemsen | 7d0dddd | 2016-08-13 12:42:11 -0700 | [diff] [blame] | 47 | source "${BUILDDIR}/.blueprint.bootstrap" |
Dan Willemsen | d79f1af | 2015-12-09 18:03:13 -0800 | [diff] [blame] | 48 | |
Dan Willemsen | 1e72321 | 2017-07-18 19:37:37 -0700 | [diff] [blame] | 49 | if [ -z "$BLUEPRINTDIR" ]; then |
| 50 | echo "Please run bootstrap.bash (.blueprint.bootstrap outdated)" >&2 |
| 51 | exit 1 |
Dan Willemsen | d79f1af | 2015-12-09 18:03:13 -0800 | [diff] [blame] | 52 | fi |
| 53 | |
Dan Willemsen | 1e72321 | 2017-07-18 19:37:37 -0700 | [diff] [blame] | 54 | source "${BLUEPRINTDIR}/blueprint_impl.bash" |