-
Notifications
You must be signed in to change notification settings - Fork 0
/
magefile.go
43 lines (32 loc) · 977 Bytes
/
magefile.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
// https://github.com/codemicro/chip8
// Copyright (c) 2021, codemicro and contributors
// SPDX-License-Identifier: MIT
// Filename: magefile.go
//+build mage
package main
import (
"fmt"
"github.com/magefile/mage/mg"
"os"
"path/filepath"
"github.com/codemicro/alib-go/mage/exmg"
"github.com/magefile/mage/sh"
)
func Build() error {
const buildPackage = "github.com/codemicro/chip8/cmd/c8run"
outputDir := filepath.Join("bin", fmt.Sprintf("%s-%s", exmg.GetTargetOS(), exmg.GetTargetArch()))
basePackageName := filepath.Base(buildPackage)
_ = os.MkdirAll(outputDir, os.ModeDir)
return sh.Run("go", "build", "-o", filepath.Join(outputDir, basePackageName), buildPackage)
}
func Test() error {
const testPackage = "github.com/codemicro/chip8/..."
var command = []string{"test", "-v"}
var runFunc = sh.Run
if mg.Verbose() {
command = append(command, "-v")
runFunc = sh.RunV
}
command = append(command, testPackage)
return runFunc("go", command...)
}