Skip to content

Commit

Permalink
goppy build support build plugin
Browse files Browse the repository at this point in the history
  • Loading branch information
markus621 committed Oct 22, 2024
1 parent 81ab12f commit f8e22eb
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions internal/commands/build.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,9 @@ func CmdBuild() console.CommandGetter {
setter.Setup("build", "Building app")
setter.Flag(func(flagsSetter console.FlagsSetter) {
flagsSetter.StringVar("arch", "amd64,arm64", "")
flagsSetter.StringVar("mode", "app", "")
})
setter.ExecFunc(func(_ []string, arch string) {
setter.ExecFunc(func(_ []string, arch, mode string) {
console.Infof("--- BUILD ---")

pack := make([]string, 0, 10)
Expand Down Expand Up @@ -53,7 +54,15 @@ func CmdBuild() console.CommandGetter {
console.Fatalf("possible only arch: amd64, arm64")
}

chunk = append(chunk, `go build -ldflags='-s -w' -a -o `+buildDir+"/"+appName+"_"+arch+" "+main)
switch mode {
case "app":
chunk = append(chunk, `go build -ldflags='-s -w' -a -o `+buildDir+"/"+appName+"_"+arch+" "+main)
case "plugin":
chunk = append(chunk, `go build -buildmode=plugin -ldflags='-s -w' -a -o `+buildDir+"/"+appName+"_"+arch+".so "+main)
default:
console.Fatalf("possible only mode: app, plugin")
}

pack = append(pack, strings.Join(chunk, " "))
}
}
Expand Down

0 comments on commit f8e22eb

Please sign in to comment.