From 12f2ca92627be403055c428e9b5e940ab35dd9ff Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Torkel=20=C3=96degaard?= Date: Wed, 28 Jan 2015 13:10:09 +0100 Subject: [PATCH] updated build file --- build.go | 42 ++++++++++++++++++++++++++++++------------ 1 file changed, 30 insertions(+), 12 deletions(-) diff --git a/build.go b/build.go index 66163514c57..fc46a9fd4d5 100644 --- a/build.go +++ b/build.go @@ -11,6 +11,7 @@ import ( "log" "os" "os/exec" + "path" "path/filepath" "regexp" "runtime" @@ -20,12 +21,12 @@ import ( ) var ( - versionRe = regexp.MustCompile(`-[0-9]{1,3}-g[0-9a-f]{5,10}`) - goarch string - goos string - noupgrade bool - version string = "2.0.0-alpha" - race bool + versionRe = regexp.MustCompile(`-[0-9]{1,3}-g[0-9a-f]{5,10}`) + goarch string + goos string + version string = "2.0.0-alpha" + race bool + workingDir string ) const minGoVersion = 1.3 @@ -56,6 +57,8 @@ func main() { return } + workingDir, _ = os.Getwd() + for _, cmd := range flag.Args() { switch cmd { case "setup": @@ -64,17 +67,19 @@ func main() { case "build": pkg := "." var tags []string - if noupgrade { - tags = []string{"noupgrade"} - } build(pkg, tags) case "test": - pkg := "./..." - test(pkg) + test("./pkg/...") + + case "package": + test("./pkg/...") + build(".", []string{}) + + case "build-ui": + buildFrontend() case "clean": - clean() default: log.Fatalf("Unknown command %q", cmd) @@ -82,6 +87,19 @@ func main() { } } +func ChangeWorkingDir(dir string) { + os.Chdir(dir) +} + +func buildFrontend() { + ChangeWorkingDir(path.Join(workingDir, "grafana")) + defer func() { + ChangeWorkingDir(path.Join(workingDir, "../")) + }() + + runPrint("grunt") +} + func setup() { runPrint("go", "get", "-v", "github.com/tools/godep") runPrint("go", "get", "-v", "github.com/mattn/go-sqlite3")