Files
avo/build/global.go

43 lines
625 B
Go
Raw Normal View History

2018-11-30 20:43:31 -08:00
package build
2018-11-30 20:58:51 -08:00
import (
"flag"
"io"
"log"
"os"
2018-11-30 21:37:17 -08:00
"github.com/mmcloughlin/avo"
2018-11-30 20:58:51 -08:00
)
2018-11-30 20:43:31 -08:00
// ctx provides a global build context.
var ctx = NewContext()
func TEXT(name, signature string) {
ctx.Function(name)
ctx.SignatureExpr(signature)
}
2018-11-30 21:37:17 -08:00
func LABEL(name string) { ctx.Label(avo.Label(name)) }
2018-11-30 20:58:51 -08:00
var (
output = flag.String("output", "", "output filename (default stdout)")
)
func EOF() {
if !flag.Parsed() {
flag.Parse()
}
var w io.Writer = os.Stdout
if *output != "" {
if f, err := os.Create(*output); err != nil {
log.Fatal(err)
} else {
defer f.Close()
w = f
}
}
2018-11-30 21:37:17 -08:00
os.Exit(ctx.Main(w, os.Stderr))
2018-11-30 20:58:51 -08:00
}