From 5266d3a41ceb38108cedeed646902f3252cb4f53 Mon Sep 17 00:00:00 2001 From: Determinant Date: Fri, 6 Dec 2019 10:12:06 -0500 Subject: add setup.sh --- Makefile | 8 ++++++-- scripts/build.sh | 9 ++++----- scripts/env.sh | 3 ++- setup.sh | 9 +++++++++ 4 files changed, 21 insertions(+), 8 deletions(-) create mode 100755 setup.sh diff --git a/Makefile b/Makefile index 5cb488f..243ed40 100644 --- a/Makefile +++ b/Makefile @@ -1,6 +1,10 @@ -.PHONY: all clean +.PHONY: all clean cdep examples -all: build/test_msgnet build/test_p2p_stress build/test_msgnet_tls build/bench_network +all: cdep examples + +examples: build/test_msgnet build/test_p2p_stress build/test_msgnet_tls build/bench_network + +cdep: build/libsalticidae.a build/libsalticidae.a: build scripts/build.sh diff --git a/scripts/build.sh b/scripts/build.sh index 1cf1488..2443a76 100755 --- a/scripts/build.sh +++ b/scripts/build.sh @@ -1,23 +1,22 @@ #!/bin/bash -e -prefix="$(pwd)/build" +prefix="${1:-$(pwd)}/build" SRC_DIR="$(dirname "${BASH_SOURCE[0]}")" source "${SRC_DIR}/env.sh" if [[ "$OSTYPE" == "linux-gnu" ]]; then - go get -d "github.com/$SALTICIDAE_ORG/salticidae-go" + go get -u -d "github.com/$SALTICIDAE_ORG/salticidae-go" cd "$SALTICIDAE_PATH" cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX="$SALTICIDAE_PATH/build" . make -j4 make install cd - + rm -f "$prefix/libsalticidae.a" + ln -sv "$GOPATH/src/github.com/$SALTICIDAE_ORG/salticidae-go/salticidae/libsalticidae.a" "$prefix/libsalticidae.a" elif [[ "$OSTYPE" == "darwin"* ]]; then brew install Determinant/salticidae/salticidae else echo "Your system is not supported yet." exit 1 fi - -rm -f "$prefix/libsalticidae.a" -ln -sv "$GOPATH/src/github.com/$SALTICIDAE_ORG/salticidae-go/salticidae/libsalticidae.a" "$prefix/libsalticidae.a" diff --git a/scripts/env.sh b/scripts/env.sh index 318c483..2e32fd5 100644 --- a/scripts/env.sh +++ b/scripts/env.sh @@ -1,8 +1,9 @@ export GOPATH="$(go env GOPATH)" export SALTICIDAE_ORG="Determinant" +export SALTICIDAE_GO_PATH="$GOPATH/src/github.com/$SALTICIDAE_ORG/salticidae-go" if [[ "$OSTYPE" == "linux-gnu" ]]; then - export SALTICIDAE_PATH="$GOPATH/src/github.com/$SALTICIDAE_ORG/salticidae-go/salticidae" + export SALTICIDAE_PATH="$SALTICIDAE_GO_PATH/salticidae" export CGO_CFLAGS="-I$SALTICIDAE_PATH/build/include/" export CGO_LDFLAGS="-L$SALTICIDAE_PATH/build/lib/ -lsalticidae -luv -lssl -lcrypto -lstdc++" elif [[ "$OSTYPE" == "darwin"* ]]; then diff --git a/setup.sh b/setup.sh new file mode 100755 index 0000000..5d633c5 --- /dev/null +++ b/setup.sh @@ -0,0 +1,9 @@ +#!/bin/bash -xe +tmpdir=$(mktemp -d -t salticidae-go-XXXXXXXX) +cd "$tmpdir" +curl -s https://raw.githubusercontent.com/Determinant/salticidae-go/master/scripts/build.sh -o ./build.sh +curl -s https://raw.githubusercontent.com/Determinant/salticidae-go/master/scripts/env.sh -o ./env.sh +chmod +x ./build.sh +source ./env.sh +./build.sh "$SALTICIDAE_GO_PATH" +rm -rf "$tmpdir" -- cgit v1.2.3-70-g09d2