mirror of
https://github.com/golang/go
synced 2024-11-19 07:04:43 -07:00
build: add bootstrap.bash for bootstrapping new systems
Change-Id: Ic74830608fe077b4e97e8ce8009017c1e273c672 Reviewed-on: https://go-review.googlesource.com/6408 Reviewed-by: Rob Pike <r@golang.org>
This commit is contained in:
parent
86a7c85f83
commit
deff22dd88
71
src/bootstrap.bash
Executable file
71
src/bootstrap.bash
Executable file
@ -0,0 +1,71 @@
|
||||
#!/bin/bash
|
||||
# Copyright 2015 The Go Authors. All rights reserved.
|
||||
# Use of this source code is governed by a BSD-style
|
||||
# license that can be found in the LICENSE file.
|
||||
|
||||
# When run as (for example)
|
||||
#
|
||||
# GOOS=linux GOARCH=ppc64 bootstrap.bash
|
||||
#
|
||||
# this script cross-compiles a toolchain for that GOOS/GOARCH
|
||||
# combination, leaving the resulting tree in ../../go-${GOOS}-${GOARCH}-bootstrap.
|
||||
# That tree can be copied to a machine of the given target type
|
||||
# and used as $GOROOT_BOOTSTRAP to bootstrap a local build.
|
||||
#
|
||||
# Only changes that have been committed to Git (at least locally,
|
||||
# not necessary reviewed and submitted to master) are included in the tree.
|
||||
|
||||
set -e
|
||||
|
||||
if [ "$GOOS" = "" -o "$GOARCH" = "" ]; then
|
||||
echo "usage: GOOS=os GOARCH=arch ./bootstrap.bash" >&2
|
||||
exit 2
|
||||
fi
|
||||
|
||||
targ="../../go-${GOOS}-${GOARCH}-bootstrap"
|
||||
if [ -e $targ ]; then
|
||||
echo "$targ already exists; remove before continuing"
|
||||
exit 2
|
||||
fi
|
||||
|
||||
unset GOROOT
|
||||
src=$(cd .. && pwd)
|
||||
echo "#### Copying to $targ"
|
||||
cp -R "$src" "$targ"
|
||||
cd "$targ"
|
||||
echo
|
||||
echo "#### Cleaning $targ"
|
||||
rm .gitignore
|
||||
git clean -f -d
|
||||
echo
|
||||
echo "#### Building $targ"
|
||||
echo
|
||||
cd src
|
||||
./make.bash --no-banner
|
||||
gohostos="$(../bin/go env GOHOSTOS)"
|
||||
gohostarch="$(../bin/go env GOHOSTARCH)"
|
||||
goos="$(../bin/go env GOOS)"
|
||||
goarch="$(../bin/go env GOARCH)"
|
||||
|
||||
# NOTE: Cannot invoke go command after this point.
|
||||
# We're about to delete all but the cross-compiled binaries.
|
||||
cd ..
|
||||
if [ "$goos" = "$gohostos" -a "$goarch" = "$gohostarch" ]; then
|
||||
# cross-compile for local system. nothing to copy.
|
||||
# useful if you've bootstrapped yourself but want to
|
||||
# prepare a clean toolchain for others.
|
||||
true
|
||||
else
|
||||
mv bin/*_*/* bin
|
||||
rmdir bin/*_*
|
||||
rm -rf "pkg/${gohostos}_${gohostarch}" "pkg/tool/${gohostos}_${gohostarch}"
|
||||
fi
|
||||
rm -rf pkg/bootstrap pkg/obj .git
|
||||
|
||||
echo ----
|
||||
echo Bootstrap toolchain for "$GOOS/$GOARCH" installed in "$(pwd)".
|
||||
echo Building tbz.
|
||||
cd ..
|
||||
tar cf - "go-${GOOS}-${GOARCH}-bootstrap" | bzip2 -9 >"go-${GOOS}-${GOARCH}-bootstrap.tbz"
|
||||
ls -l "$(pwd)/go-${GOOS}-${GOARCH}-bootstrap.tbz"
|
||||
exit 0
|
Loading…
Reference in New Issue
Block a user