mirror of
https://github.com/gosticks/gml.git
synced 2025-10-16 12:05:33 +00:00
added race build mode
This commit is contained in:
parent
ad5e50cb42
commit
1bfa5ea88e
@ -44,6 +44,7 @@ func init() {
|
||||
f.Bool("c", "clean", false, "clean build files first")
|
||||
f.BoolL("no-strip", false, "don't strip the final binary")
|
||||
f.BoolL("debug", false, "build a debug binary (disables strip)")
|
||||
f.BoolL("race", false, "enable data race detection")
|
||||
f.String("s", "source-dir", "./", "source directorty")
|
||||
f.String("b", "build-dir", "./build", "build directorty")
|
||||
f.String("d", "dest-dir", "./", "destination directorty")
|
||||
@ -72,6 +73,7 @@ func runBuild(c *grumble.Context) error {
|
||||
c.Flags.Bool("clean"),
|
||||
c.Flags.Bool("no-strip"),
|
||||
c.Flags.Bool("debug"),
|
||||
c.Flags.Bool("race"),
|
||||
c.Flags.String("tags"),
|
||||
)
|
||||
}
|
||||
@ -91,6 +93,7 @@ func runBuildDocker(c *grumble.Context) error {
|
||||
c.Flags.Bool("clean"),
|
||||
c.Flags.Bool("no-strip"),
|
||||
c.Flags.Bool("debug"),
|
||||
c.Flags.Bool("race"),
|
||||
c.Flags.Bool("custom"),
|
||||
c.Flags.String("tags"),
|
||||
)
|
||||
|
||||
@ -40,7 +40,7 @@ const (
|
||||
PostHookName = "GML_BUILD_POST_HOOKS"
|
||||
)
|
||||
|
||||
func Build(sourceDir, buildDir, destDir string, clean, noStrip, debugBuild bool, tags string) (err error) {
|
||||
func Build(sourceDir, buildDir, destDir string, clean, noStrip, debugBuild, race bool, tags string) (err error) {
|
||||
// Force no strip if this is a debug build.
|
||||
if debugBuild {
|
||||
noStrip = true
|
||||
@ -81,7 +81,7 @@ func Build(sourceDir, buildDir, destDir string, clean, noStrip, debugBuild bool,
|
||||
|
||||
// Run go build.
|
||||
utils.PrintColorln("> building Go source")
|
||||
err = buildGo(ctx, tags, clean, noStrip)
|
||||
err = buildGo(ctx, tags, clean, noStrip, race)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
@ -104,7 +104,7 @@ func buildCLib(ctx *Context) (err error) {
|
||||
return utils.RunCommand(ctx.Env(), ctx.BuildDir, "make")
|
||||
}
|
||||
|
||||
func buildGo(ctx *Context, tags string, clean, noStrip bool) (err error) {
|
||||
func buildGo(ctx *Context, tags string, clean, noStrip, race bool) (err error) {
|
||||
// Delete the output binary to force relinking.
|
||||
// This is faster than building with the -a option.
|
||||
e, err := utils.Exists(ctx.OutputFile)
|
||||
@ -132,6 +132,9 @@ func buildGo(ctx *Context, tags string, clean, noStrip bool) (err error) {
|
||||
if ctx.DebugBuild {
|
||||
ldflags = append(ldflags, "-compressdwarf=false")
|
||||
}
|
||||
if race {
|
||||
args = append(args, "-race")
|
||||
}
|
||||
if utils.Verbose {
|
||||
args = append(args, "-v")
|
||||
}
|
||||
|
||||
@ -61,7 +61,7 @@ func Containers() []string {
|
||||
func Build(
|
||||
container string,
|
||||
sourceDir, buildDir, destDir string,
|
||||
clean, noStrip, debugBuild, customContainer bool,
|
||||
clean, noStrip, debugBuild, race, customContainer bool,
|
||||
tags string,
|
||||
) (err error) {
|
||||
if !customContainer {
|
||||
@ -135,6 +135,9 @@ func Build(
|
||||
if debugBuild {
|
||||
args = append(args, "--debug")
|
||||
}
|
||||
if race {
|
||||
args = append(args, "--race")
|
||||
}
|
||||
|
||||
// Add the tags if defined.
|
||||
tags = strings.TrimSpace(tags)
|
||||
|
||||
Loading…
Reference in New Issue
Block a user