-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
51 lines (38 loc) · 1.32 KB
/
Makefile
File metadata and controls
51 lines (38 loc) · 1.32 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
# Strip debug info
GO_FLAGS += -ldflags="-w -s"
# Avoid embedding the build path in the executable for more reproducible builds
GO_FLAGS += -trimpath
PROJECT_FILES = cmd/$(APP_NAME)/*.go pkg/*/*.go internal/*/*.go go.mod go.sum
GENERATED_FILES = debug.log
OS = darwin linux win32
ARCH = arm64 x64
PLATFORMS = $(foreach os, $(OS), $(foreach arch, $(ARCH), $(os)-$(arch)))
PLATFORM_DIRS = $(foreach platform, $(PLATFORMS), npm/platforms/$(platform))
PLATFORM_FILES = $(foreach platform, $(PLATFORMS), npm/platforms/$(platform)/bin/$(call binaryname,$(platform)))
APP_NAME = updep
binaryname = $(if $(findstring win32, $(1)),$(APP_NAME).exe,$(APP_NAME))
os = $(subst win32,windows,$(firstword $(subst -, ,$(1))))
arch = $(subst x64,amd64,$(lastword $(subst -, ,$(1))))
.PHONY: all
all: $(PLATFORM_FILES)
.PHONY: format
format:
@go fmt ./...
npm/platforms/%/bin/$(APP_NAME) npm/platforms/%/bin/$(APP_NAME).exe: $(PROJECT_FILES)
$(info Building $*)
@GOOS=$(call os,$*) GOARCH=$(call arch,$*) go build $(GO_FLAGS) -o $@ ./cmd/$(APP_NAME)
.PHONY: run
run:
@DEBUG=1 go run ./cmd/$(APP_NAME)
.PHONY: dev-install
dev-install:
@go install ./cmd/$(APP_NAME)
.PHONY: install
install: $(PROJECT_FILES)
@go install $(GO_FLAGS) ./cmd/$(APP_NAME)
.PHONY: check
check:
echo todo
.PHONY: clean
clean:
@rm -rf $(PLATFORM_FILES) $(GENERATED_FILES)