@@ -7,9 +7,12 @@ GO := $(CURDIR)/script/go
7
7
GOFMT := $(CURDIR ) /script/gofmt
8
8
9
9
GOFLAGS := \
10
- --tags "static" \
11
10
-ldflags "-X main.BuildVersion=$(shell git rev-parse HEAD) -X main.BuildDescribe=$(shell git describe --tags --always --dirty) "
12
11
12
+ ifdef USE_ISATTY
13
+ GOFLAGS := $(GOFLAGS ) --tags isatty
14
+ endif
15
+
13
16
GO_SRCS := $(shell cd $(GOPATH ) /src/$(PACKAGE ) && $(GO ) list -f '{{$$ip := .ImportPath}}{{range .GoFiles}}{{printf ".gopath/src/% s/% s\n" $$ip .}}{{end}}{{range .CgoFiles}}{{printf ".gopath/src/% s/% s\n" $$ip .}}{{end}}{{range .TestGoFiles}}{{printf ".gopath/src/% s/% s\n" $$ip .}}{{end}}{{range .XTestGoFiles}}{{printf ".gopath/src/% s/% s\n" $$ip .}}{{end}}' ./...)
14
17
15
18
.PHONY : all
@@ -20,6 +23,38 @@ bin/git-sizer:
20
23
mkdir -p bin
21
24
$(GO ) build $(GOFLAGS ) -o $@ $(PACKAGE )
22
25
26
+ # Cross-compile for a bunch of common platforms. Note that this
27
+ # doesn't work with USE_ISATTY:
28
+ .PHONY : common-platforms
29
+ common-platforms : \
30
+ bin/git-sizer-linux-amd64 \
31
+ bin/git-sizer-linux-386 \
32
+ bin/git-sizer-darwin-amd64 \
33
+ bin/git-sizer-darwin-386 \
34
+ bin/git-sizer-windows-amd64.exe \
35
+ bin/git-sizer-windows-386.exe
36
+
37
+ # Define rules for a bunch of common platforms that are supported by go; see
38
+ # https://golang.org/doc/install/source#environment
39
+ # You can compile for any other platform in that list by running
40
+ # make GOOS=foo GOARCH=bar
41
+
42
+ define PLATFORM_template =
43
+ .PHONY: bin/git-sizer-$(1 ) -$(2 )$(3 )
44
+ bin/git-sizer-$(1 ) -$(2 )$(3 ) :
45
+ mkdir -p bin
46
+ GOOS=$(1 ) GOARCH=$(2 ) $$(GO ) build $$(GOFLAGS ) -o $$@ $$(PACKAGE )
47
+ endef
48
+
49
+ $(eval $(call PLATFORM_template,linux,amd64))
50
+ $(eval $(call PLATFORM_template,linux,386))
51
+
52
+ $(eval $(call PLATFORM_template,darwin,386))
53
+ $(eval $(call PLATFORM_template,darwin,amd64))
54
+
55
+ $(eval $(call PLATFORM_template,windows,amd64,.exe))
56
+ $(eval $(call PLATFORM_template,windows,386,.exe))
57
+
23
58
.PHONY : test
24
59
test : bin/git-sizer gotest
25
60
0 commit comments