commit be35a6f
chld
·
2026-02-07 06:03:25 +0000 UTC
parent c19a03c
dependency building
2 files changed,
+49,
-1
M
main.go
M
main.go
+48,
-0
1@@ -76,6 +76,11 @@ func main() {
2 f := strings.Fields(string(file))
3 var a int
4 for a < len(f) {
5+ /*
6+ . = build time dep
7+ / = link time dep
8+ > = runtime dep
9+ */
10 if strings.Contains(f[a], ".") {
11 fmt.Printf("\t\033[1m%s \033[m[%s]\n", strings.ReplaceAll(f[a], ".", ""), "build time")
12 } else if strings.Contains(f[a], "/") {
13@@ -113,12 +118,55 @@ func main() {
14 dgrb.Build(pkgs[i], "clean")
15 }
16 case "m":
17+ /*
18+ dep model:
19+
20+ . first
21+ / second
22+ > last
23+
24+ we will reorder the array to get this
25+ */
26 if len(pkgs) < 1 {
27 help()
28 os.Exit(1)
29 }
30+
31 dgre.VC("DTR_DIR")
32 for i := range len(pkgs) {
33+ x, b := dgr.FindPkg(pkgs[i])
34+ if !b {
35+ dgr.Warn("could not find package", pkgs[i])
36+ continue
37+ }
38+ dgr.Msg("dependencies of package \033[m\033[33m", pkgs[i], "\033[m:")
39+ file, _ := os.ReadFile(filepath.Join(x, "deps"))
40+ f := strings.Fields(string(file))
41+ var nf []string // new variable called nf for reordering
42+ var bt []string // store .
43+ var lt []string // store /
44+ var rt []string // store >
45+
46+ var a int
47+ for a < len(f) {
48+ if strings.Contains(f[a], ".") {
49+ bt = append(bt, f[a])
50+ } else if strings.Contains(f[a], "/") {
51+ lt = append(lt, f[a])
52+ } else if strings.Contains(f[a], ">") {
53+ rt = append(rt, f[a])
54+ }
55+ a++
56+ continue
57+ }
58+ nf = append(nf, bt...)
59+ nf = append(nf, lt...)
60+ nf = append(nf, rt...)
61+ // now build dependencies
62+ for n := range len(nf) {
63+ dgrb.Build(nf[n], "make")
64+ }
65+
66 dgrb.Build(pkgs[i], "make")
67 }
68 case "mi":
+1,
-1
1@@ -8,7 +8,7 @@ import (
2
3 func Build(pkg string, do string) {
4 var makefile string = "ndmake.sh"
5- dgr.Msg(do+"ing", pkg)
6+ dgr.Msg("running ", do, " for ", pkg)
7
8 pk, b := dgr.FindPkg(pkg)
9 if !b {