2026-09-17 20:33:18 +02:00
|
|
|
# gasm-devkit.
|
|
|
|
|
#
|
|
|
|
|
# Replace gasm-devkit here and the values in the variable block. Everything below the block
|
|
|
|
|
# is the standard set and is identical in every repository; see the `justfile` skill.
|
2026-09-16 22:53:01 +02:00
|
|
|
binary := "gasm"
|
|
|
|
|
package := "./cmd/gasm"
|
2026-07-06 09:49:50 +02:00
|
|
|
|
2026-09-17 20:33:18 +02:00
|
|
|
# What the test and bench recipes sweep. Scope this to the logic packages when a thin
|
|
|
|
|
# cmd/ drags the coverage floor down, for example "./internal/... ./pkg/...". Never name
|
|
|
|
|
# a directory the project does not have: a pattern that matches nothing is a setup
|
|
|
|
|
# failure, not an empty run.
|
|
|
|
|
packages := "./arch/... ./asm/... ./ast/... ./disasm/... ./format/... ./lexer/... ./lint/... ./lsp/... ./parser/... ./token/... ./verify/..."
|
2026-09-16 22:53:01 +02:00
|
|
|
|
|
|
|
|
bindir := env_var_or_default("BINDIR", env_var("HOME") / ".local" / "bin")
|
2026-07-06 09:49:50 +02:00
|
|
|
|
|
|
|
|
default:
|
|
|
|
|
@just --list
|
|
|
|
|
|
2026-09-16 22:53:01 +02:00
|
|
|
# Compile. Zero errors, zero warnings.
|
2026-07-06 09:49:50 +02:00
|
|
|
build:
|
2026-09-16 22:53:01 +02:00
|
|
|
CGO_ENABLED=0 go build -ldflags "-s -w" -o bin/{{binary}} {{package}}
|
2026-07-06 09:49:50 +02:00
|
|
|
|
2026-09-16 22:53:01 +02:00
|
|
|
# The test gate: the suite, no cache, the coverage floor.
|
2026-07-06 09:49:50 +02:00
|
|
|
test:
|
2026-09-16 22:53:01 +02:00
|
|
|
#!/usr/bin/env perl
|
2026-09-17 20:33:18 +02:00
|
|
|
system(q{go}, q{test}, q{-count=1}, q{-timeout}, q{10m},
|
|
|
|
|
q{-coverprofile}, q{coverage.out}, qw({{packages}})) == 0
|
2026-09-16 22:53:01 +02:00
|
|
|
or die qq{the test suite failed\n};
|
|
|
|
|
open(my $c, q{-|}, q{go}, q{tool}, q{cover}, q{-func=coverage.out}) or die qq{cover: $!};
|
|
|
|
|
my $total;
|
|
|
|
|
while (my $l = <$c>) { $total = $1 if $l =~ m{^total:\s+\S+\s+([0-9.]+)%} }
|
|
|
|
|
close($c);
|
|
|
|
|
die qq{no total line in coverage.out\n} unless defined $total;
|
|
|
|
|
printf qq{Total coverage: %s%%\n}, $total;
|
|
|
|
|
exit($total < 80 ? 1 : 0);
|
2026-07-06 09:49:50 +02:00
|
|
|
|
2026-09-16 22:53:01 +02:00
|
|
|
# The same suite under the race detector. The expensive one.
|
|
|
|
|
race:
|
2026-09-17 20:33:18 +02:00
|
|
|
go test -race -count=1 -timeout 10m {{packages}}
|
2026-09-16 22:53:01 +02:00
|
|
|
|
|
|
|
|
# Fast scoped run for iterating. This is the one that runs after every edit.
|
|
|
|
|
unit pkgs=packages run=".*":
|
|
|
|
|
go test {{pkgs}} -run '{{run}}'
|
|
|
|
|
|
|
|
|
|
# Time-boxed fuzz of one target in one package. The package is required; never a gate.
|
|
|
|
|
fuzz target pkg fuzztime="60s":
|
|
|
|
|
go test -run '^$' -fuzz '{{target}}' -fuzztime={{fuzztime}} {{pkg}}
|
|
|
|
|
|
|
|
|
|
# Benchmarks. On an idle machine only.
|
|
|
|
|
bench pkgs=packages:
|
|
|
|
|
go test -run '^$' -bench=. -benchmem -count=5 {{pkgs}}
|
|
|
|
|
|
|
|
|
|
# Format in place.
|
2026-07-06 09:49:50 +02:00
|
|
|
fmt:
|
|
|
|
|
gofmt -w .
|
|
|
|
|
|
2026-09-16 22:53:01 +02:00
|
|
|
# Zero diff. Prints nothing when everything is formatted.
|
|
|
|
|
fmt-check:
|
|
|
|
|
#!/usr/bin/env perl
|
|
|
|
|
open(my $g, q{-|}, q{gofmt}, q{-l}, q{.}) or die qq{gofmt: $!};
|
|
|
|
|
my @bad = <$g>;
|
|
|
|
|
close($g);
|
|
|
|
|
print @bad;
|
|
|
|
|
exit(@bad ? 1 : 0);
|
|
|
|
|
|
|
|
|
|
# Both static gates: go vet and go fix -diff.
|
|
|
|
|
vet:
|
|
|
|
|
go vet ./...
|
|
|
|
|
go fix -diff ./...
|
|
|
|
|
|
|
|
|
|
# The definition of done, in one command. Once per task, never per edit.
|
|
|
|
|
gates: build fmt-check vet test race
|
|
|
|
|
|
|
|
|
|
# Build artefacts only, not the installed binary.
|
|
|
|
|
clean:
|
|
|
|
|
rm -rf bin/ coverage.out
|
|
|
|
|
|
|
|
|
|
# Build, then copy the binary into bindir.
|
|
|
|
|
install: build
|
|
|
|
|
install -d "{{bindir}}"
|
|
|
|
|
install -m 755 bin/{{binary}} "{{bindir}}/{{binary}}"
|
|
|
|
|
|
|
|
|
|
# Remove the installed binary.
|
|
|
|
|
uninstall:
|
|
|
|
|
rm -f "{{bindir}}/{{binary}}"
|
|
|
|
|
|
|
|
|
|
# Run the program. The flag is there because `go run` does not stamp the build otherwise.
|
2026-09-17 20:33:18 +02:00
|
|
|
run:
|
|
|
|
|
go run -buildvcs=true {{package}}
|
2026-07-06 09:49:50 +02:00
|
|
|
|
2026-09-16 22:53:01 +02:00
|
|
|
# Run with watch or hot reload, where the project has one.
|
|
|
|
|
dev:
|
|
|
|
|
go run -buildvcs=true {{package}}
|
2026-07-06 09:49:50 +02:00
|
|
|
|
2026-09-16 22:53:01 +02:00
|
|
|
# Regenerate the architecture instruction tables from the Go toolchain source. Not a gate.
|
2026-07-06 09:49:50 +02:00
|
|
|
gen:
|
|
|
|
|
go run _gen/gen.go
|
|
|
|
|
gofmt -w arch/
|