@@ -7,9 +7,12 @@ GO := $(CURDIR)/script/go
77GOFMT := $(CURDIR ) /script/gofmt
88
99GOFLAGS := \
10- --tags "static" \
1110 -ldflags "-X main.BuildVersion=$(shell git rev-parse HEAD) -X main.BuildDescribe=$(shell git describe --tags --always --dirty) "
1211
12+ ifdef USE_ISATTY
13+ GOFLAGS := $(GOFLAGS ) --tags isatty
14+ endif
15+
1316GO_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}}' ./...)
1417
1518.PHONY : all
@@ -20,6 +23,38 @@ bin/git-sizer:
2023 mkdir -p bin
2124 $(GO ) build $(GOFLAGS ) -o $@ $(PACKAGE )
2225
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+
2358.PHONY : test
2459test : bin/git-sizer gotest
2560
0 commit comments