diff --git a/htrace-htraced/BUILDING.txt b/htrace-htraced/BUILDING.txt index abc0113..76098b3 100644 --- a/htrace-htraced/BUILDING.txt +++ b/htrace-htraced/BUILDING.txt @@ -13,7 +13,7 @@ The htrace go code consists of 4 main parts: This is the equivalent of the Java HTrace client library, but written in Go. You can build all these parts simply by running "gobuild.sh". -The binaries will be created in bin/. +The binaries will be created in the target dir. Dependencies ============ diff --git a/htrace-htraced/src/go/gobuild.sh b/htrace-htraced/src/go/gobuild.sh index 81c9f7d..75b1a8e 100755 --- a/htrace-htraced/src/go/gobuild.sh +++ b/htrace-htraced/src/go/gobuild.sh @@ -22,9 +22,9 @@ # # Builds the HTrace server code. # -# ./build.sh Builds the code. -# ./build.sh test Builds and runs all unit tests. -# ./build.sh bench Builds and runs all benchmarks +# ./gobuild.sh Builds the code. +# ./gobuild.sh test Builds and runs all unit tests. +# ./gobuild.sh bench Builds and runs all benchmarks # die() { @@ -39,13 +39,13 @@ if [ $# -gt 0 ]; then fi RELEASE_VERSION=${RELEASE_VERSION:-unknown} -# Set up directories. The build/ directory is where build dependencies and -# build binaries should go. +# Set up directories. SCRIPT_DIR="$(cd "$( dirname $0 )" && pwd)" -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}" +# Dir to build and create the binaries in +export BUILD_DIR="${SCRIPT_DIR}/../../target" +mkdir -p "${BUILD_DIR}" || die "failed to mkdir -p ${BUILD_DIR}" +cd "${BUILD_DIR}" || die "failed to cd to ${SCRIPT_DIR}" +export GOPATH="${BUILD_DIR}" # Use the unsafe package when possible to get greater speed. For example, # go-codec can bypass the overhead of converting between []byte and string in @@ -84,14 +84,16 @@ fi case $ACTION in clean) - rm -rf -- "${GOBIN}" ${SCRIPT_DIR}/pkg + rm -rf -- "${BUILD_DIR}" ;; install) # Ensure that we have the godep program. - PATH="${PATH}:${GOBIN}" + PATH="${PATH}:${BUILD_DIR}" which godep &> /dev/null if [ $? -ne 0 ]; then echo "Installing godep..." + # Need Godeps over in $BUILD_DIR + cp -r "${SCRIPT_DIR}/Godeps" "${BUILD_DIR}" &> /dev/null go get github.com/tools/godep || die "failed to get godep" fi @@ -105,6 +107,10 @@ install) # Inject the release and git version into the htraced ldflags. FLAGS="-X main.RELEASE_VERSION ${RELEASE_VERSION} -X main.GIT_VERSION ${GIT_VERSION}" + # Copy src to the build dir for building. go install will not let me + # have src in location and output to another (and it leaves pkg droppings + # behind where ever the src it uses building resides) + rsync -a --delete "${SCRIPT_DIR}/src" "${BUILD_DIR}/src" go install ${TAGS} -ldflags "${FLAGS}" -v org/apache/htrace/... "$@" ;; bench)