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.Bool("c", "clean", false, "clean build files first")
|
||||||
f.BoolL("no-strip", false, "don't strip the final binary")
|
f.BoolL("no-strip", false, "don't strip the final binary")
|
||||||
f.BoolL("debug", false, "build a debug binary (disables strip)")
|
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("s", "source-dir", "./", "source directorty")
|
||||||
f.String("b", "build-dir", "./build", "build directorty")
|
f.String("b", "build-dir", "./build", "build directorty")
|
||||||
f.String("d", "dest-dir", "./", "destination 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("clean"),
|
||||||
c.Flags.Bool("no-strip"),
|
c.Flags.Bool("no-strip"),
|
||||||
c.Flags.Bool("debug"),
|
c.Flags.Bool("debug"),
|
||||||
|
c.Flags.Bool("race"),
|
||||||
c.Flags.String("tags"),
|
c.Flags.String("tags"),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
@ -91,6 +93,7 @@ func runBuildDocker(c *grumble.Context) error {
|
|||||||
c.Flags.Bool("clean"),
|
c.Flags.Bool("clean"),
|
||||||
c.Flags.Bool("no-strip"),
|
c.Flags.Bool("no-strip"),
|
||||||
c.Flags.Bool("debug"),
|
c.Flags.Bool("debug"),
|
||||||
|
c.Flags.Bool("race"),
|
||||||
c.Flags.Bool("custom"),
|
c.Flags.Bool("custom"),
|
||||||
c.Flags.String("tags"),
|
c.Flags.String("tags"),
|
||||||
)
|
)
|
||||||
|
|||||||
@ -40,7 +40,7 @@ const (
|
|||||||
PostHookName = "GML_BUILD_POST_HOOKS"
|
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.
|
// Force no strip if this is a debug build.
|
||||||
if debugBuild {
|
if debugBuild {
|
||||||
noStrip = true
|
noStrip = true
|
||||||
@ -81,7 +81,7 @@ func Build(sourceDir, buildDir, destDir string, clean, noStrip, debugBuild bool,
|
|||||||
|
|
||||||
// Run go build.
|
// Run go build.
|
||||||
utils.PrintColorln("> building Go source")
|
utils.PrintColorln("> building Go source")
|
||||||
err = buildGo(ctx, tags, clean, noStrip)
|
err = buildGo(ctx, tags, clean, noStrip, race)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@ -104,7 +104,7 @@ func buildCLib(ctx *Context) (err error) {
|
|||||||
return utils.RunCommand(ctx.Env(), ctx.BuildDir, "make")
|
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.
|
// Delete the output binary to force relinking.
|
||||||
// This is faster than building with the -a option.
|
// This is faster than building with the -a option.
|
||||||
e, err := utils.Exists(ctx.OutputFile)
|
e, err := utils.Exists(ctx.OutputFile)
|
||||||
@ -132,6 +132,9 @@ func buildGo(ctx *Context, tags string, clean, noStrip bool) (err error) {
|
|||||||
if ctx.DebugBuild {
|
if ctx.DebugBuild {
|
||||||
ldflags = append(ldflags, "-compressdwarf=false")
|
ldflags = append(ldflags, "-compressdwarf=false")
|
||||||
}
|
}
|
||||||
|
if race {
|
||||||
|
args = append(args, "-race")
|
||||||
|
}
|
||||||
if utils.Verbose {
|
if utils.Verbose {
|
||||||
args = append(args, "-v")
|
args = append(args, "-v")
|
||||||
}
|
}
|
||||||
|
|||||||
@ -61,7 +61,7 @@ func Containers() []string {
|
|||||||
func Build(
|
func Build(
|
||||||
container string,
|
container string,
|
||||||
sourceDir, buildDir, destDir string,
|
sourceDir, buildDir, destDir string,
|
||||||
clean, noStrip, debugBuild, customContainer bool,
|
clean, noStrip, debugBuild, race, customContainer bool,
|
||||||
tags string,
|
tags string,
|
||||||
) (err error) {
|
) (err error) {
|
||||||
if !customContainer {
|
if !customContainer {
|
||||||
@ -135,6 +135,9 @@ func Build(
|
|||||||
if debugBuild {
|
if debugBuild {
|
||||||
args = append(args, "--debug")
|
args = append(args, "--debug")
|
||||||
}
|
}
|
||||||
|
if race {
|
||||||
|
args = append(args, "--race")
|
||||||
|
}
|
||||||
|
|
||||||
// Add the tags if defined.
|
// Add the tags if defined.
|
||||||
tags = strings.TrimSpace(tags)
|
tags = strings.TrimSpace(tags)
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user