diff --git a/runner.conf.sample b/runner.conf.sample index 5ac3c05..2ccbf85 100644 --- a/runner.conf.sample +++ b/runner.conf.sample @@ -5,6 +5,7 @@ build_log: runner-build-errors.log valid_ext: .go, .tpl, .tmpl, .html build_delay: 600 colors: 1 +race: 0 log_color_main: cyan log_color_build: yellow log_color_runner: green diff --git a/runner/build.go b/runner/build.go index 7f0242f..275eb26 100644 --- a/runner/build.go +++ b/runner/build.go @@ -1,6 +1,7 @@ package runner import ( + "container/list" "io" "io/ioutil" "os" @@ -10,7 +11,8 @@ import ( func build() (string, bool) { buildLog("Building...") - cmd := exec.Command("go", "build", "-o", buildPath(), root()) + args := getBuildArgs() + cmd := exec.Command("go", args...) stderr, err := cmd.StderrPipe() if err != nil { @@ -37,3 +39,31 @@ func build() (string, bool) { return "", true } + +func getListOfArgs() (l *list.List) { + l = list.New() + build := l.PushBack("build") + l.PushBack("-o") + l.PushBack(buildPath()) + l.PushBack(root()) + + if settings["race"] == "1" { + buildLog("Building with --race") + l.InsertAfter("--race", build) + } + + return +} + +func getBuildArgs() (args []string) { + list_args := getListOfArgs() + + args = make([]string, list_args.Len()) + var x int = 0 + for e := list_args.Front(); e != nil; e = e.Next() { + args[x] = e.Value.(string) + x++ + } + + return +} diff --git a/runner/settings.go b/runner/settings.go index 61e2412..c3f3eff 100644 --- a/runner/settings.go +++ b/runner/settings.go @@ -24,6 +24,7 @@ var settings = map[string]string{ "valid_ext": ".go, .tpl, .tmpl, .html", "build_delay": "600", "colors": "1", + "race": "0", "log_color_main": "cyan", "log_color_build": "yellow", "log_color_runner": "green",