commit 057d9c3

chld  ·  2026-02-06 04:56:04 +0000 UTC
parent 0e9751d
compiles, builds, push
3 files changed,  +33, -5
+7, -5
 1@@ -3,20 +3,22 @@ package dgr
 2 import (
 3 	"fmt"
 4 	"os"
 5+	"path/filepath"
 6 )
 7 
 8-func Msg(a string) {
 9+func Msg(a string, b string) {
10 	fmt.Printf("\033[m\033[32;1m==>\033[m ")
11-	fmt.Printf("%s\n", a)
12+	fmt.Printf("%s: %s\n", a, b)
13 }
14 
15-func Info(a string) {
16+func Info(a string, b string) {
17 	fmt.Printf("\033[m\033[1m)\t\033[m")
18-	fmt.Printf("%s\n", a)
19+	fmt.Printf("%s: %s\n", a, b)
20 }
21 
22 func Die(a string, b string, exit int) {
23-	fmt.Printf("\033[m\033[31;1mERROR:\033[m ")
24+	fmt.Printf("\033[m\033[31m%s: \033[1mERROR:\033[m ",
25+		filepath.Base(os.Args[0]))
26 	fmt.Printf("%s: %s\n", a, b)
27 	os.Exit(exit)
28 }
+3, -0
 1@@ -4,6 +4,7 @@ import (
 2 	"fmt"
 3 	"git.sr.ht/~chld/dgr/cmd"
 4 	"git.sr.ht/~chld/dgr/extra"
 5+	"git.sr.ht/~chld/dgr/pkg"
 6 	"os"
 7 	"path/filepath"
 8 )
 9@@ -22,6 +23,8 @@ func main() {
10 	}
11 
12 	switch os.Args[1] {
13+	case "m":
14+		dgrb.Build(os.Args[2])
15 	case "sp":
16 		dgre.VC("DTR_DIR")
17 		fmt.Println(dgr.FindPkg(os.Args[2]))
+23, -0
 1@@ -0,0 +1,23 @@
 2+package dgrb
 3+
 4+import (
 5+	"git.sr.ht/~chld/dgr/cmd"
 6+	//"git.sr.ht/~chld/dgr/extra"
 7+	"os"
 8+	"os/exec"
 9+	"path/filepath"
10+)
11+
12+func Build(pkg string) {
13+	var makefile string = "ndmake.sh"
14+	dgr.Msg("building", pkg)
15+
16+	in, out := os.Stdin, os.Stdout
17+	cmd := exec.Command("sh", dgr.FindPkg(pkg)+string(filepath.Separator)+makefile, "make")
18+	cmd.Stdin, cmd.Stdout = in, out // asign stdin andS stout to cmd
19+	cmd.Stderr = os.Stderr          // and stderr, i guess
20+
21+	if err := cmd.Run(); err != nil {
22+		dgr.Die("build failed", pkg, 1)
23+	}
24+}