Skip to content

Commit 1aa748c

Browse files
committed
Makefile: create basic 'build' and 'clean' targets
Popular convention in Go projects (including the 'project-layout' repository [1]) seems to be using Makefiles for automating build/release tasks. In anticipation of adding complex packaging scripts in future patches, create an initial Makefile with 'build' and 'clean' targets. Note that the 'build' target utilizes the 'GOOS' and 'GOARCH' of the environment to allow generating executables for any supported Go platform, defaulting to the current platform the build is running on. This behavior will be critical in later patches, when we want to create MacOS ARM64 packages on MacOS Intel build machines. [1] https://github.com/golang-standards/project-layout/blob/master/Makefile Signed-off-by: Victoria Dye <[email protected]>
1 parent e232439 commit 1aa748c

File tree

2 files changed

+23
-0
lines changed

2 files changed

+23
-0
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
/git-bundle-server
22
/git-bundle-web-server
3+
/bin/

Makefile

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
# Default target
2+
build:
3+
4+
# Helpful paths
5+
BINDIR := $(CURDIR)/bin
6+
7+
# Platform information
8+
GOOS := $(shell go env GOOS)
9+
GOARCH := $(shell go env GOARCH)
10+
11+
# Build targets
12+
.PHONY: build
13+
build:
14+
$(RM) -r $(BINDIR)
15+
@mkdir -p $(BINDIR)
16+
GOOS="$(GOOS)" GOARCH="$(GOARCH)" go build -o $(BINDIR) ./...
17+
18+
# Cleanup targets
19+
.PHONY: clean
20+
clean:
21+
go clean ./...
22+
$(RM) -r $(BINDIR)

0 commit comments

Comments
 (0)