mirror of
https://github.com/golang/go
synced 2024-11-18 12:44:49 -07:00
e9ca907325
Remove all of the code generation and the concept of "APPDIR" - just generate godoc.zip and index files in the app directory. Simplify generation of the zip - use a symlink so that every file in godoc.zip is under the "goroot" directory, regardless of the environment. Previously, the prefix would be dependent on the location of the user's GOROOT. Running the setup script is now optional - it's now possible to run dev_appserver.py on a regular checkout of cmd/godoc without godoc.zip and search index files. Use environment variables to switch whether the zip file is used vs reading GOROOT from the filesystem. Change-Id: I1ce95c891717fe2da975f979778fd775b23f18c8 Reviewed-on: https://go-review.googlesource.com/46725 Reviewed-by: Andrew Bonventre <andybons@golang.org>
73 lines
1.4 KiB
Bash
Executable File
73 lines
1.4 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
|
|
# Copyright 2011 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.
|
|
|
|
# This script creates a .zip file representing the $GOROOT file system
|
|
# and computes the corresponding search index files.
|
|
#
|
|
# These are used in production (see app.prod.yaml)
|
|
|
|
set -e -u -x
|
|
|
|
ZIPFILE=godoc.zip
|
|
INDEXFILE=godoc.index
|
|
SPLITFILES=index.split.
|
|
|
|
error() {
|
|
echo "error: $1"
|
|
exit 2
|
|
}
|
|
|
|
install() {
|
|
go install
|
|
}
|
|
|
|
getArgs() {
|
|
if [ ! -v GOROOT ]; then
|
|
GOROOT="$(go env GOROOT)"
|
|
echo "GOROOT not set explicitly, using go env value instead"
|
|
fi
|
|
|
|
# safety checks
|
|
if [ ! -d "$GOROOT" ]; then
|
|
error "$GOROOT is not a directory"
|
|
fi
|
|
|
|
# reporting
|
|
echo "GOROOT = $GOROOT"
|
|
}
|
|
|
|
makeZipfile() {
|
|
echo "*** make $ZIPFILE"
|
|
rm -f $ZIPFILE goroot
|
|
ln -s "$GOROOT" goroot
|
|
zip -q -r $ZIPFILE goroot/* # glob to ignore dotfiles (like .git)
|
|
rm goroot
|
|
}
|
|
|
|
makeIndexfile() {
|
|
echo "*** make $INDEXFILE"
|
|
godoc=$(go env GOPATH)/bin/godoc
|
|
# NOTE: run godoc without GOPATH set. Otherwise third-party packages will end up in the index.
|
|
GOPATH= $godoc -write_index -goroot goroot -index_files=$INDEXFILE -zip=$ZIPFILE
|
|
}
|
|
|
|
splitIndexfile() {
|
|
echo "*** split $INDEXFILE"
|
|
rm -f $SPLITFILES*
|
|
split -b8m $INDEXFILE $SPLITFILES
|
|
}
|
|
|
|
cd $(dirname $0)
|
|
|
|
install
|
|
getArgs "$@"
|
|
makeZipfile
|
|
makeIndexfile
|
|
splitIndexfile
|
|
rm $INDEXFILE
|
|
|
|
echo "*** setup complete"
|