rsc.io/go@v0.0.0-20150416155037-e040fd465409/src/go/types.bash (about) 1 #!/bin/bash 2 3 # Copyright 2015 The Go Authors. All rights reserved. 4 # Use of this source code is governed by a BSD-style 5 # license that can be found in the LICENSE file. 6 7 # Run this script to update the packages ./exact and ./types 8 # in the $GOROOT/src/go directory. They are vendored from the 9 # original sources in x/tools. Imports are renamed as needed. 10 # 11 # Delete this script once go/exact and go/types don't exist anymore in x/tools. 12 13 set -e 14 15 ### Safety first. 16 if [ ! -d "$GOPATH" ]; then 17 echo 2>&1 '$GOPATH must be set.' 18 exit 1 19 fi 20 if [ ! -d "$GOROOT" ]; then 21 echo 2>&1 '$GOROOT must be set.' 22 exit 1 23 fi 24 25 GODIR=$GOROOT/src/go 26 27 function vendor() ( 28 SRCDIR=$GOPATH/src/golang.org/x/tools/$1 29 DSTDIR=$GODIR/$2 30 31 echo 2>&1 "vendoring $SRCDIR => $DSTDIR" 32 33 # create directory 34 rm -rf $DSTDIR 35 mkdir -p $DSTDIR 36 cd $DSTDIR 37 38 # copy go sources and update import paths 39 for f in $SRCDIR/*.go; do 40 # copy $f and update imports 41 sed -e 's|"golang.org/x/tools/go/exact"|"go/exact"|' \ 42 -e 's|"golang.org/x/tools/go/types"|"go/types"|' \ 43 -e 's|"golang.org/x/tools/go/gcimporter"|"go/internal/gcimporter"|' \ 44 $f | gofmt > tmp.go 45 mv -f tmp.go `basename $f` 46 done 47 48 # copy testdata, if any 49 if [ -e $SRCDIR/testdata ]; then 50 cp -R $SRCDIR/testdata/ $DSTDIR/testdata/ 51 fi 52 ) 53 54 function install() ( 55 PKG=$GODIR/$1 56 57 echo 2>&1 "installing $PKG" 58 cd $PKG 59 go install 60 ) 61 62 function test() ( 63 PKG=$GODIR/$1 64 65 echo 2>&1 "testing $PKG" 66 cd $PKG 67 if ! go test; then 68 echo 2>&1 "TESTING $PKG FAILED" 69 exit 1 70 fi 71 ) 72 73 ### go/exact 74 vendor go/exact exact 75 test exact 76 install exact 77 78 ### go/types 79 vendor go/types types 80 # cannot test w/o gcimporter 81 install types 82 83 ### go/gcimporter 84 vendor go/gcimporter internal/gcimporter 85 test internal/gcimporter 86 install internal/gcimporter 87 88 ### test go/types (requires gcimporter) 89 test types 90 91 # All done. 92 echo 2>&1 "DONE" 93 exit 0