-
Notifications
You must be signed in to change notification settings - Fork 1
/
mage.go
56 lines (43 loc) · 841 Bytes
/
mage.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
45
46
47
48
49
50
51
52
53
54
55
56
// +build mage
package main
import (
"fmt"
"github.com/magefile/mage/mg"
"github.com/magefile/mage/sh"
)
var (
// Packages is the list of packages.
Packages = []string{
"tuntap",
"fscp",
}
// Default is the default target.
Default = All
)
// All the targets are run.
func All() {
mg.Deps(Build)
}
// Build the code.
func Build() error {
for _, pkg := range Packages {
if err := sh.Run("go", "build", "./"+pkg); err != nil {
return fmt.Errorf("building package `%s`: %v", pkg, err)
}
}
mg.Deps(Test)
return nil
}
// Test the code.
func Test() error {
for _, pkg := range Packages {
args := []string{"test", "./" + pkg}
if mg.Verbose() {
args = append(args, "-v")
}
if err := sh.RunV("go", args...); err != nil {
return fmt.Errorf("building package `%s`: %v", pkg, err)
}
}
return nil
}