Jamie Gennis | 1bc967e | 2014-05-27 16:34:41 -0700 | [diff] [blame] | 1 | #!/bin/bash |
| 2 | |
| 3 | # SRCDIR should be set to the path of the root source directory. It can be |
| 4 | # either an absolute path or a path relative to the build directory. Whether |
| 5 | # its an absolute or relative path determines whether the build directory can be |
| 6 | # moved relative to or along with the source directory without re-running the |
| 7 | # bootstrap script. |
| 8 | SRCDIR=`dirname "${BASH_SOURCE[0]}"` |
| 9 | |
| 10 | # BOOTSTRAP should be set to the path of this script. It can be either an |
| 11 | # absolute path or one relative to the build directory (which of these is used |
| 12 | # should probably match what's used for SRCDIR). |
| 13 | BOOTSTRAP="${BASH_SOURCE[0]}" |
| 14 | |
| 15 | # These variables should be set by auto-detecting or knowing a priori the Go |
| 16 | # toolchain properties. |
| 17 | GOROOT=`go env GOROOT` |
| 18 | GOOS=`go env GOHOSTOS` |
| 19 | GOARCH=`go env GOHOSTARCH` |
| 20 | GOCHAR=`go env GOCHAR` |
| 21 | |
| 22 | case "$#" in |
| 23 | 1) IN="$1";BOOTSTRAP_MANIFEST="$1";; |
| 24 | 2) IN="$1";BOOTSTRAP_MANIFEST="$2";; |
| 25 | *) IN="${SRCDIR}/build.ninja.in";BOOTSTRAP_MANIFEST="$IN";; |
| 26 | esac |
| 27 | |
| 28 | sed -e "s|@@SrcDir@@|$SRCDIR|g" \ |
| 29 | -e "s|@@GoRoot@@|$GOROOT|g" \ |
| 30 | -e "s|@@GoOS@@|$GOOS|g" \ |
| 31 | -e "s|@@GoArch@@|$GOARCH|g" \ |
| 32 | -e "s|@@GoChar@@|$GOCHAR|g" \ |
| 33 | -e "s|@@Bootstrap@@|$BOOTSTRAP|g" \ |
| 34 | -e "s|@@BootstrapManifest@@|$BOOTSTRAP_MANIFEST|g" \ |
| 35 | $IN > build.ninja |