diff options
author | Determinant <[email protected]> | 2019-12-06 10:12:06 -0500 |
---|---|---|
committer | Determinant <[email protected]> | 2019-12-06 10:12:06 -0500 |
commit | 5266d3a41ceb38108cedeed646902f3252cb4f53 (patch) | |
tree | a45273a29aea118d0b63e374a2b3229444e97cda | |
parent | b6d1796be78b1156d835f8a81efbf8cc24750520 (diff) |
add setup.sh
-rw-r--r-- | Makefile | 8 | ||||
-rwxr-xr-x | scripts/build.sh | 9 | ||||
-rw-r--r-- | scripts/env.sh | 3 | ||||
-rwxr-xr-x | setup.sh | 9 |
4 files changed, 21 insertions, 8 deletions
@@ -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" |