forked from rosa/hakurei
cmd/dist: build hsu separately
This program must be built with cgo disabled, and was missed when migrating build script. Signed-off-by: Ophestra <cat@gensokyo.uk>
This commit is contained in:
Vendored
+24
-9
@@ -35,8 +35,11 @@ func getenv(key, fallback string) string {
|
||||
|
||||
// mustRun runs a command with the current process's environment and panics
|
||||
// on error or non-zero exit code.
|
||||
func mustRun(ctx context.Context, name string, arg ...string) {
|
||||
func mustRun(ctx context.Context, env []string, name string, arg ...string) {
|
||||
cmd := exec.CommandContext(ctx, name, arg...)
|
||||
if env != nil {
|
||||
cmd.Env = append(cmd.Environ(), env...)
|
||||
}
|
||||
cmd.Stdin, cmd.Stdout, cmd.Stderr = os.Stdin, os.Stdout, os.Stderr
|
||||
if err := cmd.Run(); err != nil {
|
||||
panic(err)
|
||||
@@ -49,6 +52,7 @@ var comp []byte
|
||||
func main() {
|
||||
log.SetFlags(0)
|
||||
log.SetPrefix("")
|
||||
log.SetOutput(os.Stdout)
|
||||
|
||||
verbose := os.Getenv("VERBOSE") != ""
|
||||
runTests := os.Getenv("HAKUREI_DIST_MAKE") == ""
|
||||
@@ -91,26 +95,37 @@ func main() {
|
||||
verboseFlag = "-buildvcs=false"
|
||||
}
|
||||
|
||||
log.Printf("Building hakurei for %s/%s.", runtime.GOOS, runtime.GOARCH)
|
||||
mustRun(ctx, "go", "generate", "./...")
|
||||
log.Printf("Building hakurei %s for %s/%s.", version, runtime.GOOS, runtime.GOARCH)
|
||||
mustRun(ctx, nil, "go", "generate", "./...")
|
||||
mustRun(
|
||||
ctx, "go", "build",
|
||||
ctx, nil, "go", "build",
|
||||
"-trimpath",
|
||||
verboseFlag, "-o", s,
|
||||
"-ldflags=-s -w "+
|
||||
"-buildid= -linkmode external -extldflags=-static "+
|
||||
"-X hakurei.app/internal/info.buildVersion="+version+" "+
|
||||
"-X hakurei.app/internal/info.hakureiPath="+prefix+"/bin/hakurei "+
|
||||
"-X hakurei.app/internal/info.hsuPath="+prefix+"/bin/hsu "+
|
||||
"-X main.hakureiPath="+prefix+"/bin/hakurei",
|
||||
"./...",
|
||||
"-X hakurei.app/internal/info.hsuPath="+prefix+"/bin/hsu",
|
||||
"./cmd/hakurei",
|
||||
"./cmd/sharefs",
|
||||
)
|
||||
log.Println()
|
||||
|
||||
log.Printf("Building cmd/hsu for %s/%s.", runtime.GOOS, runtime.GOARCH)
|
||||
mustRun(
|
||||
ctx, []string{"CGO_ENABLED=0"}, "go", "build",
|
||||
"-trimpath",
|
||||
verboseFlag, "-o", s,
|
||||
"-ldflags=-s -w "+
|
||||
"-buildid= "+
|
||||
"-X main.hakureiPath="+prefix+"/bin/hakurei",
|
||||
"./cmd/hsu",
|
||||
)
|
||||
|
||||
log.Println()
|
||||
if runTests {
|
||||
log.Println("##### Testing Hakurei.")
|
||||
mustRun(
|
||||
ctx, "go", "test",
|
||||
ctx, nil, "go", "test",
|
||||
"-ldflags=-buildid= -linkmode external -extldflags=-static",
|
||||
"./...",
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user