Repository: incubator-htrace Updated Branches: refs/heads/3.1 ea949c39e -> 40cb0fdea
HTRACE-67 The go build should put downloaded files into a separate directory (Colin Patrick McCabe) Project: http://git-wip-us.apache.org/repos/asf/incubator-htrace/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-htrace/commit/40cb0fde Tree: http://git-wip-us.apache.org/repos/asf/incubator-htrace/tree/40cb0fde Diff: http://git-wip-us.apache.org/repos/asf/incubator-htrace/diff/40cb0fde Branch: refs/heads/3.1 Commit: 40cb0fdea8e6b014c46f233640bad18fd8809e25 Parents: ea949c3 Author: stack <[email protected]> Authored: Sun Jan 11 23:25:25 2015 -0800 Committer: stack <[email protected]> Committed: Sun Jan 11 23:29:17 2015 -0800 ---------------------------------------------------------------------- .gitignore | 8 ++- htrace-core/pom.xml | 5 -- htrace-core/src/go/generate_version.sh | 66 -------------------- htrace-core/src/go/gobuild.sh | 51 ++++++++++----- .../src/go/src/org/apache/htrace/htrace/cmd.go | 5 +- .../go/src/org/apache/htrace/htraced/htraced.go | 3 + .../go/src/org/apache/htrace/htraced/rest.go | 4 +- 7 files changed, 49 insertions(+), 93 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-htrace/blob/40cb0fde/.gitignore ---------------------------------------------------------------------- diff --git a/.gitignore b/.gitignore index c4229d9..db19503 100644 --- a/.gitignore +++ b/.gitignore @@ -9,11 +9,15 @@ *~ *.swp dependency-reduced-pom.xml -htrace-core/src/go/bin -htrace-core/src/go/pkg htrace-core/src/go/src/org/apache/htrace/resource +<<<<<<< HEAD htrace-core/src/go/src/github.com/ htrace-core/src/go/src/gopkg.in/ htrace-core/src/go/src/org/apache/htrace/common/version.go htrace-core/src/go/src/code.google.com/ htrace-core/src/go/src/golang.org/ +======= +!htrace-core/src/go/src/org/apache/htrace/resource/catalog.go +htrace-core/src/go/build +htrace-core/src/go/pkg +>>>>>>> 10f2c6a... HTRACE-67 The go build should put downloaded files into a separate directory (Colin Patrick McCabe) http://git-wip-us.apache.org/repos/asf/incubator-htrace/blob/40cb0fde/htrace-core/pom.xml ---------------------------------------------------------------------- diff --git a/htrace-core/pom.xml b/htrace-core/pom.xml index bb9a30f..2133cb0 100644 --- a/htrace-core/pom.xml +++ b/htrace-core/pom.xml @@ -114,11 +114,6 @@ language governing permissions and limitations under the License. --> <arg value="-c"/> <arg value="./gobuild.sh clean"/> </exec> - <exec executable="git" failonerror="true" dir="${basedir}/src/go"> - <arg value="clean"/> - <arg value="-ffqdx"/> - <arg value="."/> - </exec> </tasks> </configuration> </execution> http://git-wip-us.apache.org/repos/asf/incubator-htrace/blob/40cb0fde/htrace-core/src/go/generate_version.sh ---------------------------------------------------------------------- diff --git a/htrace-core/src/go/generate_version.sh b/htrace-core/src/go/generate_version.sh deleted file mode 100755 index cece713..0000000 --- a/htrace-core/src/go/generate_version.sh +++ /dev/null @@ -1,66 +0,0 @@ -#!/usr/bin/env bash - -# -# Licensed to the Apache Software Foundation (ASF) under one -# or more contributor license agreements. See the NOTICE file -# distributed with this work for additional information -# regarding copyright ownership. The ASF licenses this file -# to you under the Apache License, Version 2.0 (the -# "License"); you may not use this file except in compliance -# with the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. -# - -# -# Generates the version.go file. -# -# ./generate_version.sh [release-version] Generates the version.go file -# - -die() { - echo $@ - exit 1 -} - -[ $# -lt 1 ] && die "You must specify the release version." -RELEASE_VERSION=$1 - -SCRIPT_DIR="$(cd "$( dirname $0 )" && pwd)" -cd "${SCRIPT_DIR}" -GIT_VERSION=$(git rev-parse HEAD) -[ $? -eq 0 ] || die "Failed to run 'git rev-parse HEAD'" -cat <<EOF > "./src/org/apache/htrace/common/version.go" -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -// THIS IS GENERATED CODE. DO NOT EDIT. - -package common - -const RELEASE_VERSION = "$RELEASE_VERSION" -const GIT_VERSION = "$GIT_VERSION" -EOF http://git-wip-us.apache.org/repos/asf/incubator-htrace/blob/40cb0fde/htrace-core/src/go/gobuild.sh ---------------------------------------------------------------------- diff --git a/htrace-core/src/go/gobuild.sh b/htrace-core/src/go/gobuild.sh index 3e3c0e7..7c0e52f 100755 --- a/htrace-core/src/go/gobuild.sh +++ b/htrace-core/src/go/gobuild.sh @@ -32,25 +32,20 @@ die() { exit 1 } -ACTION=build +ACTION=install if [ $# -gt 0 ]; then - if [ "x${1}" == "xbench" ]; then - # run benchmarks - ACTION="test" - set -- "$@" -test.bench=. - else - # run specified action - ACTION="${1}" - fi + ACTION="${1}" shift fi RELEASE_VERSION=${RELEASE_VERSION:-unknown} +# Set up directories. The build/ directory is where build dependencies and +# build binaries should go. SCRIPT_DIR="$(cd "$( dirname $0 )" && pwd)" -cd $SCRIPT_DIR || die "failed to cd to $SCRIPT_DIR" -export GOPATH="$GOPATH:${SCRIPT_DIR}" -export GOBIN="${SCRIPT_DIR}/bin" -mkdir -p ${GOBIN} || die "failed to create ${GOBIN}" +export GOBIN="${SCRIPT_DIR}/build" +mkdir -p "${GOBIN}" || die "failed to mkdir -p ${GOBIN}" +cd "${GOBIN}" || die "failed to cd to ${SCRIPT_DIR}" +export GOPATH="${GOBIN}:${SCRIPT_DIR}" # Check for go which go &> /dev/null @@ -82,18 +77,40 @@ if [ -n "${ldconfig}" ]; then fi fi -if [ "$ACTION" == "build" ]; then +case $ACTION in +clean) + rm -rf -- "${GOBIN}" pkg + find "${SCRIPT_DIR}/src/org/apache/htrace/resource" ! -name 'catalog.go' \ + -type f -exec rm -f {} + + ;; +install) + # Ensure that we have the godep program. PATH="${PATH}:${GOBIN}" which godep &> /dev/null if [ $? -ne 0 ]; then echo "Installing godep..." go get github.com/tools/godep || die "failed to get godep" fi + + # Download dependencies into the build directory. echo "godep restore..." godep restore || die "failed to set up dependencies" go run "$SCRIPT_DIR/src/org/apache/htrace/bundler/bundler.go" \ --src="$SCRIPT_DIR/../web/" --dst="$SCRIPT_DIR/src/org/apache/htrace/resource/" \ || die "bundler failed" - ${SCRIPT_DIR}/generate_version.sh "${RELEASE_VERSION}" -fi -go "${ACTION}" -v org/apache/htrace/... "$@" + + # Discover the git version + GIT_VERSION=$(git rev-parse HEAD) + [ $? -eq 0 ] || GIT_VERSION="unknown" + + # Inject the release and git version into the htraced ldflags. + FLAGS="-X main.RELEASE_VERSION ${RELEASE_VERSION} -X main.GIT_VERSION ${GIT_VERSION}" + go install -ldflags "${FLAGS}" -v org/apache/htrace/... "$@" + ;; +bench) + go test -v org/apache/htrace/... -test.bench=. "$@" + ;; +*) + go ${ACTION} -v org/apache/htrace/... "$@" + ;; +esac http://git-wip-us.apache.org/repos/asf/incubator-htrace/blob/40cb0fde/htrace-core/src/go/src/org/apache/htrace/htrace/cmd.go ---------------------------------------------------------------------- diff --git a/htrace-core/src/go/src/org/apache/htrace/htrace/cmd.go b/htrace-core/src/go/src/org/apache/htrace/htrace/cmd.go index 2d75253..b366ef1 100644 --- a/htrace-core/src/go/src/org/apache/htrace/htrace/cmd.go +++ b/htrace-core/src/go/src/org/apache/htrace/htrace/cmd.go @@ -31,6 +31,9 @@ import ( "os" ) +var RELEASE_VERSION string +var GIT_VERSION string + func main() { // Load htraced configuration cnf := conf.LoadApplicationConfig() @@ -66,7 +69,7 @@ func main() { // Print the version of the htrace binary. func printVersion() int { - fmt.Printf("Running htrace command version %s.\n", common.RELEASE_VERSION) + fmt.Printf("Running htrace command version %s.\n", RELEASE_VERSION) return 0 } http://git-wip-us.apache.org/repos/asf/incubator-htrace/blob/40cb0fde/htrace-core/src/go/src/org/apache/htrace/htraced/htraced.go ---------------------------------------------------------------------- diff --git a/htrace-core/src/go/src/org/apache/htrace/htraced/htraced.go b/htrace-core/src/go/src/org/apache/htrace/htraced/htraced.go index d6cfe2a..403b1f9 100644 --- a/htrace-core/src/go/src/org/apache/htrace/htraced/htraced.go +++ b/htrace-core/src/go/src/org/apache/htrace/htraced/htraced.go @@ -24,6 +24,9 @@ import ( "org/apache/htrace/conf" ) +var RELEASE_VERSION string +var GIT_VERSION string + func main() { cnf := conf.LoadApplicationConfig() store, err := CreateDataStore(cnf, nil) http://git-wip-us.apache.org/repos/asf/incubator-htrace/blob/40cb0fde/htrace-core/src/go/src/org/apache/htrace/htraced/rest.go ---------------------------------------------------------------------- diff --git a/htrace-core/src/go/src/org/apache/htrace/htraced/rest.go b/htrace-core/src/go/src/org/apache/htrace/htraced/rest.go index 74018c0..7eb8870 100644 --- a/htrace-core/src/go/src/org/apache/htrace/htraced/rest.go +++ b/htrace-core/src/go/src/org/apache/htrace/htraced/rest.go @@ -34,8 +34,8 @@ type serverInfoHandler struct { } func (handler *serverInfoHandler) ServeHTTP(w http.ResponseWriter, req *http.Request) { - version := common.ServerInfo{ReleaseVersion: common.RELEASE_VERSION, - GitVersion: common.GIT_VERSION} + version := common.ServerInfo{ReleaseVersion: RELEASE_VERSION, + GitVersion: GIT_VERSION} buf, err := json.Marshal(&version) if err != nil { log.Printf("error marshalling ServerInfo: %s\n", err.Error())
