Skip to content

Commit

Permalink
Use OS specific build directories (#600)
Browse files Browse the repository at this point in the history
* feat: use os specific build directories

* fix typo
  • Loading branch information
karzak authored Jun 24, 2020
1 parent b539820 commit ad33296
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 12 deletions.
25 changes: 18 additions & 7 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
8 changes: 4 additions & 4 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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
Expand Down
3 changes: 2 additions & 1 deletion networks/local/kavanode/wrapper.sh
Original file line number Diff line number Diff line change
@@ -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}

Expand Down

0 comments on commit ad33296

Please sign in to comment.