-
Notifications
You must be signed in to change notification settings - Fork 1
/
Bakefile
103 lines (86 loc) · 2.02 KB
/
Bakefile
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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
func get_prefix {
shell go list ./internal/version
return context.shell.stdout
}
func get_commit {
shell git rev-parse --short HEAD 2>/dev/null
return context.shell.stdout
}
func get_go_version {
shell go version
return context.shell.stdout
}
export func get_compile_time {
shell LC_ALL=en_US date
return context.shell.stdout
}
let prefix = get_prefix()
let version = "v0.1.0"
let commit = get_commit()
let go_version = get_go_version()
let compile_time = get_compile_time()
let build_variables = "-X \"$(prefix).Version=$(version)\" -X \"$(prefix).Commit=$(commit)\" -X \"$(prefix).GoVersion=$(go_version)\" -X \"$(prefix).CompileTime=$(compile_time)\""
let build_flags = "-ldflags '$(build_variables)'"
// Build for the native platform
export alias build: ["build/bake", "build/bagels"]
"build/bake" {
shell {
go generate ./...
go build $(build_flags) -o $(context.output) cmd/bake/*.go
}
}
"build/bagels" {
shell {
go generate ./...
go build $(build_flags) -o $(context.output) cmd/bagels/*.go
}
}
// Format Go code
export func format {
shell gofmt -l -s -w .
}
// Lint Go code
export func lint {
shell golint .
}
// Vet Go code
export func vet {
shell go vet ./...
}
// Test Go code
export func test {
shell go test -v ./...
}
export func install_tools {
shell cat tools.go | grep _ | awk -F'"' '{print $$2}' | xargs -tI % go install %
}
// Copy the nanorc file to the build output
export alias nano : ["tools/nano/bake.nanorc"]
"tools/nano/bake.nanorc" {
shell {
mkdir -p build
cp tools/nano/bake.nanorc build
}
}
// Build the vscode tool
export func vscode {
shell {
bake run --in tools/vscode package
mkdir -p build
cp tools/vscode/bake-lsp*.vsix build
}
}
// Build the PrismJS grammar
export func prism {
shell {
bake run --in tools/prism build
mkdir -p build
cp tools/prism/build/* build/
}
}
// Build tools
export alias tools: [vscode, nano, prism]
// Clean all dynamically created files
export func clean {
shell rm -rf ./build &> /dev/null || true
}