/
builder.go
44 lines (38 loc) · 948 Bytes
/
builder.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
// Copyright Jay Conrod. All rights reserved.
// This file is part of rules_go_simple. Use of this source code is governed by
// the 3-clause BSD license that can be found in the LICENSE.txt file.
// builder is a tool used to perform various tasks related to building Go code,
// such as compiling packages, linking executables, and generating
// test sources.
package main
import (
"log"
"os"
)
func main() {
log.SetFlags(0)
log.SetPrefix("builder: ")
if len(os.Args) <= 2 {
log.Fatalf("usage: %s stdimportcfg|compile|link|test options...", os.Args[0])
}
verb := os.Args[1]
args := os.Args[2:]
var action func(args []string) error
switch verb {
case "stdimportcfg":
action = stdImportcfg
case "compile":
action = compile
case "link":
action = link
case "test":
action = test
default:
log.Fatalf("unknown action: %s", verb)
}
log.SetPrefix(verb + ": ")
err := action(args)
if err != nil {
log.Fatal(err)
}
}