aboutsummaryrefslogtreecommitdiffhomepage
path: root/cmd/dist/main.go
diff options
context:
space:
mode:
authorOphestra <cat@gensokyo.uk>2026-10-01 22:24:09 +0900
committerOphestra <cat@gensokyo.uk>2026-10-01 22:24:09 +0900
commit4b19686109b0962ea68dfe58feafffe3bac9c202 (patch)
tree706d986f74c012eb414f03c268bec057b3c5ba86 /cmd/dist/main.go
parent8fea10f7d05648900ce1d9abb899402298382e7d (diff)
cmd/dist: optionally build with race instrument
This is mostly useful for the integration test suites. Signed-off-by: Ophestra <cat@gensokyo.uk>
Diffstat (limited to 'cmd/dist/main.go')
-rw-r--r--cmd/dist/main.go14
1 files changed, 12 insertions, 2 deletions
diff --git a/cmd/dist/main.go b/cmd/dist/main.go
index 8e1c57c1..1034f282 100644
--- a/cmd/dist/main.go
+++ b/cmd/dist/main.go
@@ -56,6 +56,7 @@ func main() {
verbose := os.Getenv("VERBOSE") != ""
runTests := os.Getenv("HAKUREI_DIST_MAKE") == ""
+ race := os.Getenv("HAKUREI_RACE") != ""
version = getenv("HAKUREI_VERSION", strings.TrimSpace(version))
prefix := getenv("PREFIX", "/usr/local")
destdir := getenv("DESTDIR", "dist")
@@ -64,6 +65,10 @@ func main() {
log.Println()
}
+ if race {
+ version += "-race"
+ }
+
if err := os.MkdirAll(destdir, 0755); err != nil {
log.Fatal(err)
}
@@ -95,12 +100,17 @@ func main() {
verboseFlag = "-buildvcs=false"
}
+ raceFlag := "-race"
+ if !race {
+ raceFlag = "-buildvcs=false"
+ }
+
log.Printf("Building hakurei %s for %s/%s.", version, runtime.GOOS, runtime.GOARCH)
mustRun(ctx, nil, "go", "generate", "./...")
mustRun(
ctx, nil, "go", "build",
"-trimpath",
- verboseFlag, "-o", s,
+ verboseFlag, raceFlag, "-o", s,
"-ldflags=-s -w "+
"-buildid= -linkmode external -extldflags=-static "+
"-X hakurei.app/internal/info.buildVersion="+version+" "+
@@ -125,7 +135,7 @@ func main() {
if runTests {
log.Println("##### Testing Hakurei.")
mustRun(
- ctx, nil, "go", "test",
+ ctx, nil, "go", "test", raceFlag,
"-ldflags=-buildid= -linkmode external -extldflags=-static",
"./...",
)