diff options
author | Determinant <[email protected]> | 2019-12-06 09:45:54 -0500 |
---|---|---|
committer | Determinant <[email protected]> | 2019-12-06 09:45:54 -0500 |
commit | b6d1796be78b1156d835f8a81efbf8cc24750520 (patch) | |
tree | 273144a7b7a181a39651d1953a895c58c446cd84 /scripts | |
parent | ec20efb7676c597c26edc63ae0ac47d3ec8b478c (diff) |
improve build scripts
Diffstat (limited to 'scripts')
-rw-r--r-- | scripts/Makefile | 26 | ||||
-rwxr-xr-x | scripts/build.sh | 23 | ||||
-rwxr-xr-x | scripts/clean.sh | 6 | ||||
-rw-r--r-- | scripts/env.sh | 14 |
4 files changed, 69 insertions, 0 deletions
diff --git a/scripts/Makefile b/scripts/Makefile new file mode 100644 index 0000000..6cabb03 --- /dev/null +++ b/scripts/Makefile @@ -0,0 +1,26 @@ +# NOTE: do NOT use the Makefile directly, please run `./build.sh` instead + +.PHONY: all clean + +all: build/test_msgnet build/test_p2p_stress build/test_msgnet_tls build/bench_network + +build/libsalticidae.a: build + rm -f $@ + ln -sv "${GOPATH}/src/github.com/Determinant/salticidae-go/salticidae/libsalticidae.a" $@ + +build: + mkdir -p build + +build/test_msgnet: build/libsalticidae.a test_msgnet/main.go + go build -o $@ github.com/Determinant/salticidae-go/test_msgnet +build/test_msgnet_tls: build/libsalticidae.a test_msgnet_tls/main.go + go build -o $@ github.com/Determinant/salticidae-go/test_msgnet_tls +build/test_p2p_stress: build/libsalticidae.a test_p2p_stress/main.go + go build -o $@ github.com/Determinant/salticidae-go/test_p2p_stress +build/bench_network: build/libsalticidae.a bench_network/main.go + go build -o $@ github.com/Determinant/salticidae-go/bench_network + +clean: + rm -rf build/ + cd salticidae/; make clean + rm salticidae/CMakeCache.txt diff --git a/scripts/build.sh b/scripts/build.sh new file mode 100755 index 0000000..1cf1488 --- /dev/null +++ b/scripts/build.sh @@ -0,0 +1,23 @@ +#!/bin/bash -e + +prefix="$(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" + cd "$SALTICIDAE_PATH" + cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX="$SALTICIDAE_PATH/build" . + make -j4 + make install + cd - +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/clean.sh b/scripts/clean.sh new file mode 100755 index 0000000..450b874 --- /dev/null +++ b/scripts/clean.sh @@ -0,0 +1,6 @@ +#!/bin/bash +SRC_DIR="$(dirname "${BASH_SOURCE[0]}")" + +source "$SRC_DIR/env.sh" +cd "$SALTICIDAE_PATH" +make clean diff --git a/scripts/env.sh b/scripts/env.sh new file mode 100644 index 0000000..318c483 --- /dev/null +++ b/scripts/env.sh @@ -0,0 +1,14 @@ +export GOPATH="$(go env GOPATH)" +export SALTICIDAE_ORG="Determinant" + +if [[ "$OSTYPE" == "linux-gnu" ]]; then + export SALTICIDAE_PATH="$GOPATH/src/github.com/$SALTICIDAE_ORG/salticidae-go/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 + export CGO_CFLAGS="-I/usr/local/opt/openssl/include" + export CGO_LDFLAGS="-L/usr/local/opt/openssl/lib/ -lsalticidae -luv -lssl -lcrypto" +else + echo "Your system is not supported yet." + exit 1 +fi |