-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathmagefile.go
More file actions
52 lines (45 loc) · 1.31 KB
/
magefile.go
File metadata and controls
52 lines (45 loc) · 1.31 KB
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
//go:build mage
// +build mage
package main
import (
"fmt"
"os"
"os/exec"
"github.com/magefile/mage/mg"
)
// Default target to run when none is specified
// If not set, running mage will list available targets
var Default = Build
// A build step that requires additional params, or platform specific steps for example
func Build() error {
mg.Deps(BuildDecoder)
mg.Deps(BuildMeasureAlgos)
fmt.Println("Compilation finished")
return nil
}
func BuildDecoder() error {
fmt.Println("Building decoder executable...")
ldflags := os.Getenv("CGO_LDFLAGS")
cflags := os.Getenv("CGO_CFLAGS")
cmd := exec.Command("go", "build", "-o", "./bin/decoder", "./decoder")
cmd.Env = append(os.Environ(),
fmt.Sprintf("CGO_ENABLED=1"),
fmt.Sprintf("CGO_LDFLAGS=%s", ldflags),
fmt.Sprintf("CGO_CFLAGS=%s", cflags))
cmd.Stdout = os.Stdout
cmd.Stderr = os.Stderr
return cmd.Run()
}
func BuildMeasureAlgos() error {
fmt.Println("Building measureAlgos executable...")
ldflags := os.Getenv("CGO_LDFLAGS")
cflags := os.Getenv("CGO_CFLAGS")
cmd := exec.Command("go", "build", "-o", "./bin/measureAlgos", "./measureAlgos")
cmd.Env = append(os.Environ(),
fmt.Sprintf("CGO_ENABLED=1"),
fmt.Sprintf("CGO_LDFLAGS=%s", ldflags),
fmt.Sprintf("CGO_CFLAGS=%s", cflags))
cmd.Stdout = os.Stdout
cmd.Stderr = os.Stderr
return cmd.Run()
}