forked from manusa/helm-java
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
92 lines (81 loc) · 2.62 KB
/
Makefile
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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
CGO_ENABLED=1
LD_FLAGS=-s -w
COMMON_BUILD_ARGS=-ldflags "$(LD_FLAGS)" -buildmode=c-shared
MAVEN_OPTIONS=
LICENSE_FILE=license-header.txt
# Detect OS to be able to run build-native target and provide a name
OS_NAME=linux
ARCH=amd64
EXTENSION=so
ifeq ($(OS), Windows_NT)
OS_NAME := windows-4.0
EXTENSION := dll
else
UNAME_MACHINE := $(shell uname -m)
ifneq ($(UNAME_MACHINE), x86_64)
ARCH := arm64
endif
UNAME_KERNEL := $(shell uname -s)
ifeq ($(UNAME_KERNEL), Darwin)
OS_NAME := darwin-10.12
EXTENSION := dylib
endif
endif
NATIVE_NAME := $(OS_NAME)-$(ARCH).$(EXTENSION)
.PHONY: clean
clean:
cd native && go clean ./...
mvn clean
rm -f native/out/*.h native/out/*.so native/out/*.dylib native/out/*.dll
.PHONY: test-go
test-go:
cd native && go clean -testcache && go test ./...
.PHONY: build-native
build-native:
cd native && go build $(COMMON_BUILD_ARGS) -o ./out/helm-$(NATIVE_NAME)
.PHONY: build-native-cross-platform
build-native-cross-platform:
go install src.techknowlogick.com/xgo@latest
xgo $(COMMON_BUILD_ARGS) -out native/out/helm --targets */arm64,*/amd64 ./native
.PHONY: build-java
build-java:
mvn $(MAVEN_OPTIONS) clean verify
.PHONY: build-current-platform
build-current-platform: MAVEN_OPTIONS=-Denforcer.skipRules=requireFilesExist
build-current-platform: build-native build-java
.PHONY: build-all
build-all: build-native-cross-platform build-java
.PHONY: test
test: test-go
.PHONY: release
release:
@if [ -z "$(V)" ]; then echo "V is not set"; exit 1; fi
@if [ -z "$(VS)" ]; then echo "VS is not set"; exit 1; fi
@mvn versions:set -DnewVersion=$(V) -DgenerateBackupPoms=false
@git add .
@git commit -m "[RELEASE] Updated project version to v$(V)"
@git tag v$(V)
@git push origin v$(V)
@mvn versions:set -DnewVersion=$(VS)-SNAPSHOT -DgenerateBackupPoms=false
@git add .
@git commit -m "[RELEASE] v$(V) released, prepare for next development iteration"
@git push origin main
.PHONY: license
license:
@license_len=$$(wc -l $(LICENSE_FILE) | cut -f1 -d ' ') && \
files=$$(git ls-files | grep -E "\.go|\.java") && \
for file in $$files; do \
echo "Applying license to $$file"; \
head -n $$license_len $$file | diff -q $(LICENSE_FILE) - > /dev/null || \
( ( cat $(LICENSE_FILE); echo; cat $$file ) > $$file.temp; mv $$file.temp $$file ) \
done
.PHONY: update-go-deps
update-go-deps:
@echo ">> updating Go dependencies"
@cd native && for m in $$(go list -mod=readonly -m -f '{{ if and (not .Indirect) (not .Main)}}{{.Path}}{{end}}' all); do \
go get $$m; \
done
cd native && go mod tidy
ifneq (,$(wildcard native/vendor))
cd native && go mod vendor
endif