Use OS specific build directories (#600)

* feat: use os specific build directories

* fix typo
This commit is contained in:
Kevin Davis 2020-06-24 14:21:01 -04:00 committed by GitHub
parent b539820c88
commit ad33296d98
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 24 additions and 12 deletions

View File

@ -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

View File

@ -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

View File

@ -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}