Skip to content

Commit 74f4c96

Browse files
authored
Merge pull request #73 from github/darwin-arm64-build
Add support for building on and for Darwin:arm64
2 parents 951a51b + 449077f commit 74f4c96

File tree

7 files changed

+27
-44
lines changed

7 files changed

+27
-44
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
/bin
22
/releases
3+
/vendor

CONTRIBUTING.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ Please note that this project is released with a [Contributor Code of Conduct][c
2020

2121
Here are a few things you can do that will increase the likelihood of your pull request being accepted:
2222

23-
- Make sure that your code is formatted correctly: `make gofmt`.
23+
- Make sure that your code is formatted correctly according to `go fmt`: `go fmt .`.
2424
- Write tests.
2525
- Keep your change as focused as possible. If there are multiple changes you would like to make that are not dependent upon each other, consider submitting them as separate pull requests.
2626
- Write a [good commit message](http://tbaggery.com/2008/04/19/a-note-about-git-commit-messages.html).

Makefile

Lines changed: 4 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -3,30 +3,21 @@ GO111MODULES := 1
33
export GO111MODULES
44

55
GO := $(CURDIR)/script/go
6-
GOFMT := $(CURDIR)/script/gofmt
76

87
GO_LDFLAGS := -X main.BuildVersion=$(shell git describe --tags --always --dirty || echo unknown)
9-
GOFLAGS := -ldflags "$(GO_LDFLAGS)"
8+
GOFLAGS := -mod=readonly -ldflags "$(GO_LDFLAGS)"
109

1110
ifdef USE_ISATTY
1211
GOFLAGS := $(GOFLAGS) --tags isatty
1312
endif
1413

15-
GO_SRCS := $(sort $(shell $(GO) list -f ' \
16-
{{$$ip := .Dir}} \
17-
{{range .GoFiles }}{{printf "%s/%s\n" $$ip .}}{{end}} \
18-
{{range .CgoFiles }}{{printf "%s/%s\n" $$ip .}}{{end}} \
19-
{{range .TestGoFiles }}{{printf "%s/%s\n" $$ip .}}{{end}} \
20-
{{range .XTestGoFiles}}{{printf "%s/%s\n" $$ip .}}{{end}} \
21-
' ./...))
22-
2314
.PHONY: all
2415
all: bin/git-sizer
2516

2617
.PHONY: bin/git-sizer
2718
bin/git-sizer:
2819
mkdir -p bin
29-
$(GO) build $(GOFLAGS) -o $@ $(PACKAGE)
20+
$(GO) build $(GOFLAGS) -o $@ .
3021

3122
# Cross-compile for a bunch of common platforms. Note that this
3223
# doesn't work with USE_ISATTY:
@@ -50,7 +41,7 @@ define PLATFORM_template =
5041
.PHONY: bin/git-sizer-$(1)-$(2)$(3)
5142
bin/git-sizer-$(1)-$(2)$(3):
5243
mkdir -p bin
53-
GOOS=$(1) GOARCH=$(2) $$(GO) build $$(GOFLAGS) -ldflags "-X main.ReleaseVersion=$$(VERSION)" -o $$@ $$(PACKAGE)
44+
GOOS=$(1) GOARCH=$(2) $$(GO) build $$(GOFLAGS) -ldflags "-X main.ReleaseVersion=$$(VERSION)" -o $$@ .
5445
common-platforms: bin/git-sizer-$(1)-$(2)$(3)
5546

5647
# Note that releases don't include code from vendor (they're only used
@@ -72,8 +63,8 @@ endef
7263
$(eval $(call PLATFORM_template,linux,amd64))
7364
$(eval $(call PLATFORM_template,linux,386))
7465

75-
$(eval $(call PLATFORM_template,darwin,386))
7666
$(eval $(call PLATFORM_template,darwin,amd64))
67+
$(eval $(call PLATFORM_template,darwin,arm64))
7768

7869
$(eval $(call PLATFORM_template,windows,amd64,.exe))
7970
$(eval $(call PLATFORM_template,windows,386,.exe))
@@ -85,23 +76,6 @@ test: bin/git-sizer gotest
8576
gotest:
8677
$(GO) test -timeout 60s $(GOFLAGS) ./...
8778

88-
.PHONY: gofmt
89-
gofmt:
90-
$(GOFMT) -l -w $(GO_SRCS) | sed -e 's/^/Fixing /'
91-
92-
.PHONY: goimports
93-
goimports:
94-
goimports -l -w -e $(GO_SRCS)
95-
96-
.PHONY: govet
97-
govet:
98-
$(GO) vet ./...
99-
10079
.PHONY: clean
10180
clean:
10281
rm -rf bin
103-
104-
# List all of this project's Go sources:
105-
.PHONY: srcs
106-
srcs:
107-
@printf "%s\n" $(GO_SRCS)

docs/BUILDING.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ This procedure is intended for experts and people who want to help develop `git-
2525
git clone https://github.com/github/git-sizer.git
2626
cd git-sizer
2727

28-
2. Install Go if necessary and create and prepare a project-local `GOPATH`:
28+
2. Install Go if necessary:
2929

3030
script/bootstrap
3131

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
module github.com/github/git-sizer
22

3-
go 1.13
3+
go 1.16
44

55
require (
66
github.com/davecgh/go-spew v1.1.1 // indirect

script/ensure-go-installed.sh

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,17 @@ if [ -z "$ROOTDIR" ]; then
44
echo 1>&2 'ensure-go-installed.sh invoked without ROOTDIR set!'
55
fi
66

7-
# Is go installed, and at least 1.13?
7+
# Is go installed, and at least 1.16?
88
go_ok() {
99
set -- $(go version 2>/dev/null |
1010
sed -n 's/.*go\([0-9][0-9]*\)\.\([0-9][0-9]*\).*/\1 \2/p' |
1111
head -n 1)
12-
[ $# -eq 2 ] && [ "$1" -eq 1 ] && [ "$2" -ge 13 ]
12+
[ $# -eq 2 ] && [ "$1" -eq 1 ] && [ "$2" -ge 16 ]
1313
}
1414

1515
# If a local go is installed, use it.
1616
set_up_vendored_go() {
17-
GO_VERSION=go1.13.4
17+
GO_VERSION=go1.16.3
1818
VENDORED_GOROOT="$ROOTDIR/vendor/$GO_VERSION/go"
1919
if [ -x "$VENDORED_GOROOT/bin/go" ]; then
2020
export GOROOT="$VENDORED_GOROOT"

script/install-vendored-go

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,27 @@
11
#!/bin/sh
22

33
# The checksums below must correspond to the downloads for this version.
4-
GO_VERSION=go1.13.4
4+
GO_VERSION=go1.16.3
55

6-
if [ $(uname -s) = "Darwin" ]; then
7-
GO_PKG=${GO_VERSION}.darwin-amd64.tar.gz
8-
GO_PKG_SHA=9f0721551a24a1eb43d2005cd58bd7b17574e50384b8da8896b0754259790752
9-
elif [ $(uname -s) = "Linux" ]; then
6+
case "$(uname -s):$(uname -m)" in
7+
Linux:x86_64)
108
GO_PKG=${GO_VERSION}.linux-amd64.tar.gz
11-
GO_PKG_SHA=692d17071736f74be04a72a06dab9cac1cd759377bd85316e52b2227604c004c
12-
else
9+
GO_PKG_SHA=951a3c7c6ce4e56ad883f97d9db74d3d6d80d5fec77455c6ada6c1f7ac4776d2
10+
;;
11+
Darwin:x86_64)
12+
GO_PKG=${GO_VERSION}.darwin-amd64.tar.gz
13+
GO_PKG_SHA=6bb1cf421f8abc2a9a4e39140b7397cdae6aca3e8d36dcff39a1a77f4f1170ac
14+
;;
15+
Darwin:arm64)
16+
GO_PKG=${GO_VERSION}.darwin-arm64.tar.gz
17+
GO_PKG_SHA=f4e96bbcd5d2d1942f5b55d9e4ab19564da4fad192012f6d7b0b9b055ba4208f
18+
;;
19+
*)
1320
echo 1>&2 "I don't know how to install Go on your platform."
1421
echo 1>&2 "Please install $GO_VERSION or later and add it to your PATH."
1522
exit 1
16-
fi
23+
;;
24+
esac
1725

1826
archivesum() {
1927
shasum -a256 "$ARCHIVE"

0 commit comments

Comments
 (0)