-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
95 lines (80 loc) · 3.3 KB
/
Copy pathMakefile
File metadata and controls
95 lines (80 loc) · 3.3 KB
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
93
94
95
GO ?= go
APP ?= gost
CMD ?= ./cmd/gost
BIN_DIR ?= bin
BIN ?= $(BIN_DIR)/$(APP)
WASM_DIR ?= wasm
WASM_BIN ?= $(WASM_DIR)/gost.wasm
WASM_EXEC ?= $(WASM_DIR)/wasm_exec.js
GO_WASM_EXEC ?= $(shell $(GO) env GOROOT)/lib/wasm/wasm_exec.js
FRAMES ?= 1000
ARGS ?=
ROM ?=
RUN_CONFIG ?= configs/atari-1040ste-mono.json
RUN_FLOPPY_ARGS :=
.PHONY: help ci build test test-race vet fmt fmt-check run run-rom headless headless-rom wasm clean
help:
@printf "Available targets:\n"
@printf " make ci Run format/vet checks, race tests, and build native + wasm artifacts\n"
@printf " make build Build the emulator binary\n"
@printf " make test Run the Go test suite\n"
@printf " make test-race Run the Go test suite with the race detector\n"
@printf " make vet Run go vet over all packages\n"
@printf " make fmt Format all Go sources with gofmt\n"
@printf " make fmt-check Fail if any Go source needs gofmt\n"
@printf " make run Run the desktop emulator with %s\n" "$(RUN_CONFIG)"
@printf " make run-rom Run with a local ROM via ROM=/path/to/tos.rom\n"
@printf " make headless Run headless for FRAMES=%s\n" "$(FRAMES)"
@printf " make headless-rom Run headless with a local ROM via ROM=/path/to/tos.rom\n"
@printf " make wasm Build wasm/gost.wasm for the browser demo\n"
@printf " make clean Remove built artifacts\n"
@printf "\n"
@printf "Examples:\n"
@printf " make ci\n"
@printf " make build\n"
@printf " make run ARGS='--fullscreen'\n"
@printf " make run RUN_CONFIG=configs/atari-1040stf-color.json\n"
@printf " make run-rom ROM=TOS/TOS104GE.IMG ARGS='--preset mega-st'\n"
@printf " make headless FRAMES=1000 ARGS='--trace cpu'\n"
@printf " make headless-rom ROM=TOS/TOS102GE.IMG FRAMES=1000 ARGS='--preset mega-st --trace boot'\n"
@printf " make run ARGS='--floppy-a /path/to/disk.msa'\n"
@printf " make wasm\n"
ci: fmt-check vet test-race build wasm
build:
@mkdir -p $(BIN_DIR)
$(GO) build -o $(BIN) $(CMD)
test:
$(GO) test ./...
test-race:
$(GO) test -race ./...
vet:
$(GO) vet ./...
fmt:
gofmt -w $(shell $(GO) list -f '{{.Dir}}' ./...)
fmt-check:
@unformatted=$$(gofmt -l $(shell $(GO) list -f '{{.Dir}}' ./...)); \
if [ -n "$$unformatted" ]; then \
printf 'gofmt needs to be run on:\n%s\n' "$$unformatted"; \
exit 1; \
fi
run:
$(GO) run $(CMD) --config $(RUN_CONFIG) $(RUN_FLOPPY_ARGS) $(ARGS)
run-rom:
@test -n "$(ROM)" || (printf "set ROM=/path/to/tos.rom\n" && exit 1)
@test -f "$(ROM)" || (printf "missing local ROM at %s\n" "$(ROM)" && exit 1)
$(GO) run $(CMD) --rom "$(ROM)" $(RUN_FLOPPY_ARGS) $(ARGS)
headless:
$(GO) run $(CMD) --headless --frames $(FRAMES) $(RUN_FLOPPY_ARGS) $(ARGS)
headless-rom:
@test -n "$(ROM)" || (printf "set ROM=/path/to/tos.rom\n" && exit 1)
@test -f "$(ROM)" || (printf "missing local ROM at %s\n" "$(ROM)" && exit 1)
$(GO) run $(CMD) --headless --frames $(FRAMES) --rom "$(ROM)" $(RUN_FLOPPY_ARGS) $(ARGS)
wasm:
@test -f "$(GO_WASM_EXEC)" || (printf "missing wasm_exec.js at %s\n" "$(GO_WASM_EXEC)" && exit 1)
@mkdir -p $(WASM_DIR)
cp "$(GO_WASM_EXEC)" "$(WASM_EXEC)"
GOOS=js GOARCH=wasm $(GO) build -o $(WASM_BIN) $(CMD)
@touch $(WASM_DIR)/.nojekyll
clean:
rm -rf $(BIN_DIR)
rm -f $(WASM_BIN) $(WASM_EXEC) $(WASM_DIR)/.nojekyll