Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add build option --race #7

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions runner.conf.sample
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
32 changes: 31 additions & 1 deletion runner/build.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package runner

import (
"container/list"
"io"
"io/ioutil"
"os"
Expand All @@ -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 {
Expand All @@ -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
}
1 change: 1 addition & 0 deletions runner/settings.go
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down