Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Merged by Bors] - Fix building project when go-svm is imported #3052

Closed
wants to merge 9 commits into from
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ cmd/tmp
*/**/.DS_Store
/build
libgpu-setup-*
libsvm-*

.project
.settings
Expand Down
7 changes: 6 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
FROM ubuntu:18.04 AS linux
# libsvm.a is linked with fcntl64, which was added to glibc since 2.28.
# The earliest Ubuntu release that has glibc >=2.28 by default is 18.10, so the LTS one is 20.04.
# If any issues occur on 20.04, it may be downgraded back to 18.04 with manual glibc upgrade.
FROM ubuntu:20.04 AS linux
ENV DEBIAN_FRONTEND noninteractive
ENV SHELL /bin/bash
ARG TZ=US/Eastern
Expand Down Expand Up @@ -93,6 +96,8 @@ COPY --from=server_builder /go/src/github.com/spacemeshos/go-spacemesh/build/go-
COPY --from=server_builder /go/src/github.com/spacemeshos/go-spacemesh/build/go-p2p /bin/
COPY --from=server_builder /go/src/github.com/spacemeshos/go-spacemesh/build/go-harness /bin/
COPY --from=server_builder /go/src/github.com/spacemeshos/go-spacemesh/build/libgpu-setup.so /bin/
# TODO(nkryuchkov): uncomment when go-svm is imported
#COPY --from=server_builder /go/src/github.com/spacemeshos/go-spacemesh/build/libsvm.so /bin/

ENTRYPOINT ["/bin/go-harness"]
EXPOSE 7513
Expand Down
4 changes: 3 additions & 1 deletion DockerfilePrebuiltBinary
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM ubuntu:18.04 AS linux
FROM ubuntu:20.04 AS linux
ENV DEBIAN_FRONTEND noninteractive
ENV SHELL /bin/bash
ARG TZ=US/Eastern
Expand Down Expand Up @@ -30,6 +30,8 @@ COPY go-hare /bin/go-hare
COPY go-p2p /bin/go-p2p
COPY go-harness /bin/go-harness
COPY libgpu-setup.so /bin/
# TODO(nkryuchkov): uncomment when go-svm is imported
#COPY libsvm.so /bin/

ENTRYPOINT ["/bin/go-harness"]
EXPOSE 7513
Expand Down
20 changes: 13 additions & 7 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@ all: install build
.PHONY: all

LDFLAGS = -ldflags "-X main.version=${VERSION} -X main.commit=${COMMIT} -X main.branch=${BRANCH}"
include Makefile.Inc
include Makefile-gpu.Inc
# TODO(nkryuchkov): uncomment when go-svm is imported
#include Makefile-svm.Inc

DOCKER_HUB ?= spacemeshos
TEST_LOG_LEVEL ?=
Expand Down Expand Up @@ -95,11 +97,15 @@ install:
build: go-spacemesh
.PHONY: build

hare p2p: get-gpu-setup
# TODO(nkryuchkov): uncomment when go-svm is imported
get-libs: get-gpu-setup #get-svm
.PHONY: get-libs

hare p2p: get-libs
cd cmd/$@ ; go build -o $(BIN_DIR)go-$@$(EXE) $(GOTAGS) .
go-spacemesh: get-gpu-setup
go-spacemesh: get-libs
go build -o $(BIN_DIR)$@$(EXE) $(LDFLAGS) $(GOTAGS) .
harness: get-gpu-setup
harness: get-libs
cd cmd/integration ; go build -o $(BIN_DIR)go-$@$(EXE) $(GOTAGS) .
.PHONY: hare p2p harness go-spacemesh

Expand Down Expand Up @@ -135,15 +141,15 @@ docker-local-build: go-spacemesh hare p2p harness
.PHONY: docker-local-build
endif

test test-all: get-gpu-setup
test test-all: get-libs
$(ULIMIT) CGO_LDFLAGS="$(CGO_TEST_LDFLAGS)" TEST_LOG_LEVEL=$(TEST_LOG_LEVEL) go test -timeout 0 -p 1 ./...
.PHONY: test

test-no-app-test: get-gpu-setup
test-no-app-test: get-libs
$(ULIMIT) CGO_LDFLAGS="$(CGO_TEST_LDFLAGS)" TEST_LOG_LEVEL=$(TEST_LOG_LEVEL) go test -timeout 0 -p 1 -tags exclude_app_test ./...
.PHONY: test-no-app-test

test-only-app-test: get-gpu-setup
test-only-app-test: get-libs
$(ULIMIT) CGO_LDFLAGS="$(CGO_TEST_LDFLAGS)" TEST_LOG_LEVEL=$(TEST_LOG_LEVEL) go test -timeout 0 -p 1 -tags !exclude_app_test ./cmd/node
.PHONY: test-only-app-test

Expand Down
File renamed without changes.
51 changes: 51 additions & 0 deletions Makefile-svm.Inc
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
PROJ_DIR := $(dir $(realpath $(firstword $(MAKEFILE_LIST))))
BIN_DIR ?= $(PROJ_DIR)build/
export GOOS
export GOARCH
export GOARM
export BIN_DIR

SVM_VERSION := 0.0.31

export CGO_CFLAGS := $(CGO_CFLAGS) -I${BIN_DIR}

ifeq ($(OS),Windows_NT)
HOST_OS := windows
else
HOST_OS := $(shell uname | tr [A-Z] [a-z])
endif

ifeq ($(GOOS),)
GOOS := $(HOST_OS)
endif

ifeq ($(GOOS),windows)
PLATFORM := windows
SVM_CLI := svm-cli.exe
export CGO_LDFLAGS := $(CGO_LDFLAGS) -L$(BIN_DIR) -lsvm
export PATH := $(PATH):$(BIN_DIR)
else
SVM_CLI := svm-cli
ifeq ($(GOOS),darwin)
PLATFORM := macos
export CGO_LDFLAGS := $(CGO_LDFLAGS) $(BIN_DIR)/libsvm.a -lm -ldl -framework Security -framework Foundation
else
PLATFORM := linux
export CGO_LDFLAGS := $(CGO_LDFLAGS) $(BIN_DIR)/libsvm.a -lm -ldl -Wl,-rpath,$(BIN_DIR)
endif
endif

CGO_TEST_LDFLAGS := $(CGO_LDFLAGS) -Wl,-rpath,$(BIN_DIR)

SVM_ZIP = libsvm-$(PLATFORM)-$(SVM_VERSION).zip

$(PROJ_DIR)$(SVM_ZIP):
echo "Building svm-$(PLATFORM)..."
mkdir -p $(BIN_DIR)/
curl -L https://github.com/spacemeshos/svm/releases/download/v$(SVM_VERSION)/svm-$(PLATFORM)-v$(SVM_VERSION).zip -o $(PROJ_DIR)$(SVM_ZIP)
unzip $(PROJ_DIR)$(SVM_ZIP) -d $(BIN_DIR)/
chmod +x $(BIN_DIR)/$(SVM_CLI)
ls $(BIN_DIR)

get-svm: $(PROJ_DIR)$(SVM_ZIP)
.PHONY: get-svm