]> Cypherpunks repositories - gostls13.git/commitdiff
build script tweaks
authorRuss Cox <rsc@golang.org>
Thu, 1 Apr 2010 02:48:33 +0000 (19:48 -0700)
committerRuss Cox <rsc@golang.org>
Thu, 1 Apr 2010 02:48:33 +0000 (19:48 -0700)
factor out environment variable checks.
infer $GOROOT etc during build if not set.
it's still necessary to set them for yourself
to use the standard Makefiles.

when running all.bash, don't recompile all the
go packages in run.bash, since make.bash already did.

R=r
CC=golang-dev
https://golang.org/cl/609042

src/all.bash
src/env.bash [new file with mode: 0644]
src/make.bash
src/run.bash

index 67c19cd43fd3fd9b8460cb27a96ccb4088b1ff13..00c1ca74dd978b409674d80c685ec7a967535699 100755 (executable)
@@ -5,4 +5,4 @@
 
 set -e
 bash make.bash
-bash run.bash
+bash run.bash --no-rebuild
diff --git a/src/env.bash b/src/env.bash
new file mode 100644 (file)
index 0000000..6ab491a
--- /dev/null
@@ -0,0 +1,55 @@
+#!/usr/bin/env bash
+# Copyright 2009 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.
+
+if test -z "$GOBIN"; then
+       if ! test -d "$HOME"/bin; then
+               echo '$GOBIN is not set and $HOME/bin is not a directory or does not exist.' 1>&2
+               echo 'mkdir $HOME/bin or set $GOBIN to a directory where binaries should' 1>&2
+               echo 'be installed.' 1>&2
+               exit 1
+       fi
+       GOBIN="$HOME/bin"
+elif ! test -d "$GOBIN"; then
+       echo '$GOBIN is not a directory or does not exist' 1>&2
+       echo 'create it or set $GOBIN differently' 1>&2
+       exit 1
+fi
+
+GOROOT=${GOROOT:-$(cd ..; pwd)}
+if ! test -f "$GOROOT"/include/u.h
+then
+       echo '$GOROOT is not set correctly or not exported' 1>&2
+       exit 1
+fi
+
+# Double-check that we're in $GOROOT, for people with multiple Go trees.
+# Various aspects of the build cd into $GOROOT-rooted paths,
+# making it easy to jump to a different tree and get confused.
+DIR1=$(cd ..; pwd)
+DIR2=$(cd $GOROOT; pwd)
+if [ "$DIR1" != "$DIR2" ]; then
+       echo 'Suspicious $GOROOT: does not match current directory.' 1>&2
+       exit 1
+fi
+
+GOARCH=${GOARCH:-$(uname -m | sed 's/^..86$/386/; s/^.86$/386/; s/x86_64/amd64/')}
+case "$GOARCH" in
+amd64 | 386 | arm)
+       ;;
+*)
+       echo '$GOARCH is set to <'$GOARCH'>, must be amd64, 386, or arm' 1>&2
+       exit 1
+esac
+
+GOOS=${GOOS:-$(uname | tr A-Z a-z)}
+case "$GOOS" in
+darwin | freebsd | linux | mingw | nacl)
+       ;;
+*)
+       echo '$GOOS is set to <'$GOOS'>, must be darwin, freebsd, linux, mingw, or nacl' 1>&2
+       exit 1
+esac
+
+export GOBIN GOROOT GOARCH GOOS
index c2a350af7f1a0bf9ac9be6f7a9ec3248d723e39f..d8638145eab10c78b3576d216c57f234a6806e5e 100755 (executable)
@@ -4,48 +4,11 @@
 # license that can be found in the LICENSE file.
 
 set -e
+. ./env.bash
 
-if test -z "$GOBIN"; then
-       if ! test -d "$HOME"/bin; then
-               echo '$GOBIN is not set and $HOME/bin is not a directory or does not exist.' 1>&2
-               echo 'mkdir $HOME/bin or set $GOBIN to a directory where binaries should' 1>&2
-               echo 'be installed.' 1>&2
-               exit 1
-       fi
-       GOBIN="$HOME/bin"
-elif ! test -d "$GOBIN"; then
-       echo '$GOBIN is not a directory or does not exist' 1>&2
-       echo 'create it or set $GOBIN differently' 1>&2
-       exit 1
-fi
-
-GOBIN="${GOBIN:-$HOME/bin}"
 export MAKEFLAGS=-j4
-
 unset CDPATH   # in case user has it set
 
-if ! test -f "$GOROOT"/include/u.h
-then
-       echo '$GOROOT is not set correctly or not exported' 1>&2
-       exit 1
-fi
-
-case "$GOARCH" in
-amd64 | 386 | arm)
-       ;;
-*)
-       echo '$GOARCH is set to <'$GOARCH'>, must be amd64, 386, or arm' 1>&2
-       exit 1
-esac
-
-case "$GOOS" in
-darwin | freebsd | linux | mingw | nacl)
-       ;;
-*)
-       echo '$GOOS is set to <'$GOOS'>, must be darwin, freebsd, linux, mingw, or nacl' 1>&2
-       exit 1
-esac
-
 rm -f "$GOBIN"/quietgcc
 CC=${CC:-gcc}
 sed -e "s|@CC@|$CC|" < "$GOROOT"/src/quietgcc.bash > "$GOBIN"/quietgcc
index 35d499f95695135af575f8e6e77bf9fc2d5be898..85dd59a55e7180f5d7e76ee8e55154ae10d42c0e 100755 (executable)
@@ -4,12 +4,21 @@
 # license that can be found in the LICENSE file.
 
 set -e
+. ./env.bash
 
-GOBIN="${GOBIN:-$HOME/bin}"
+export MAKEFLAGS=-j4
+unset CDPATH   # in case user has it set
 
 # no core files, please
 ulimit -c 0
 
+# allow make.bash to avoid double-build of everything
+rebuild=true
+if [ "$1" = "--no-rebuild" ]; then
+       rebuild=false
+       shift
+fi
+               
 xcd() {
        echo
        echo --- cd $1
@@ -21,9 +30,11 @@ maketest() {
        do
                (
                        xcd $i
-                       "$GOBIN"/gomake clean
-                       time "$GOBIN"/gomake
-                       "$GOBIN"/gomake install
+                       if $rebuild; then
+                               "$GOBIN"/gomake clean
+                               time "$GOBIN"/gomake
+                               "$GOBIN"/gomake install
+                       fi
                        "$GOBIN"/gomake test
                ) || exit $?
        done
@@ -36,20 +47,26 @@ maketest \
 # from what maketest does.
 
 (xcd pkg/sync;
-"$GOBIN"/gomake clean;
-time "$GOBIN"/gomake
+if $rebuild; then
+       "$GOBIN"/gomake clean;
+       time "$GOBIN"/gomake
+fi
 GOMAXPROCS=10 "$GOBIN"/gomake test
 ) || exit $?
 
 (xcd cmd/gofmt
-"$GOBIN"/gomake clean
-time "$GOBIN"/gomake
+if $rebuild; then
+       "$GOBIN"/gomake clean;
+       time "$GOBIN"/gomake
+fi
 time "$GOBIN"/gomake smoketest
 ) || exit $?
 
 (xcd cmd/ebnflint
-"$GOBIN"/gomake clean
-time "$GOBIN"/gomake
+if $rebuild; then
+       "$GOBIN"/gomake clean;
+       time "$GOBIN"/gomake
+fi
 time "$GOBIN"/gomake test
 ) || exit $?