From ad33296d987d4ba4ac2bbfbf91fa973732671266 Mon Sep 17 00:00:00 2001 From: Kevin Davis Date: Wed, 24 Jun 2020 14:21:01 -0400 Subject: [PATCH] Use OS specific build directories (#600) * feat: use os specific build directories * fix typo --- Makefile | 25 ++++++++++++++++++------- docker-compose.yml | 8 ++++---- networks/local/kavanode/wrapper.sh | 3 ++- 3 files changed, 24 insertions(+), 12 deletions(-) diff --git a/Makefile b/Makefile index 22c42400..9e0b0249 100644 --- a/Makefile +++ b/Makefile @@ -3,7 +3,18 @@ VERSION := $(shell echo $(shell git describe --tags) | sed 's/^v//') COMMIT := $(shell git log -1 --format='%H') LEDGER_ENABLED ?= true - +ifeq ($(DETECTED_OS),) + ifeq ($(OS),Windows_NT) + DETECTED_OS := windows + else + UNAME_S = $(shell uname -s) + ifeq ($(UNAME_S),Darwin) + DETECTED_OS := mac + else + DETECTED_OS := linux + endif + endif +endif export GO111MODULE = on # process build tags @@ -64,16 +75,16 @@ BUILD_FLAGS := -tags "$(build_tags)" -ldflags '$(ldflags)' all: install build: go.sum -ifeq ($(OS),Windows_NT) - go build -mod=readonly $(BUILD_FLAGS) -o build/kvd.exe ./cmd/kvd - go build -mod=readonly $(BUILD_FLAGS) -o build/kvcli.exe ./cmd/kvcli +ifeq ($(OS), Windows_NT) + go build -mod=readonly $(BUILD_FLAGS) -o build/$(DETECTED_OS)/kvd.exe ./cmd/kvd + go build -mod=readonly $(BUILD_FLAGS) -o build/$(DETECTED_OS)/kvcli.exe ./cmd/kvcli else - go build -mod=readonly $(BUILD_FLAGS) -o build/kvd ./cmd/kvd - go build -mod=readonly $(BUILD_FLAGS) -o build/kvcli ./cmd/kvcli + go build -mod=readonly $(BUILD_FLAGS) -o build/$(DETECTED_OS)/kvd ./cmd/kvd + go build -mod=readonly $(BUILD_FLAGS) -o build/$(DETECTED_OS)/kvcli ./cmd/kvcli endif build-linux: go.sum - LEDGER_ENABLED=false GOOS=linux GOARCH=amd64 $(MAKE) build + LEDGER_ENABLED=false GOOS=linux GOARCH=amd64 DETECTED_OS=linux $(MAKE) build install: go.sum go install -mod=readonly $(BUILD_FLAGS) ./cmd/kvd diff --git a/docker-compose.yml b/docker-compose.yml index 62ebd1ec..86ec47d6 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -10,7 +10,7 @@ services: - ID=0 - LOG=${LOG:-kvd.log} volumes: - - ./build:/kvd:Z + - ./build/linux:/kvd:Z networks: localnet: ipv4_address: 192.168.10.2 @@ -24,7 +24,7 @@ services: - ID=1 - LOG=${LOG:-kvd.log} volumes: - - ./build:/kvd:Z + - ./build/linux:/kvd:Z networks: localnet: ipv4_address: 192.168.10.3 @@ -38,7 +38,7 @@ services: ports: - "26661-26662:26656-26657" volumes: - - ./build:/kvd:Z + - ./build/linux:/kvd:Z networks: localnet: ipv4_address: 192.168.10.4 @@ -52,7 +52,7 @@ services: ports: - "26663-26664:26656-26657" volumes: - - ./build:/kvd:Z + - ./build/linux:/kvd:Z networks: localnet: ipv4_address: 192.168.10.5 diff --git a/networks/local/kavanode/wrapper.sh b/networks/local/kavanode/wrapper.sh index 2ebd9c26..328380ff 100755 --- a/networks/local/kavanode/wrapper.sh +++ b/networks/local/kavanode/wrapper.sh @@ -1,6 +1,7 @@ #!/usr/bin/env sh -BINARY=/kvd/${BINARY:-kvd} +BINARY=/kvd/linux/${BINARY:-kvd} +echo "binary: ${BINARY}" ID=${ID:-0} LOG=${LOG:-kvd.log}