From 443883f95bea9388ecee15b193db87f44edb63d6 Mon Sep 17 00:00:00 2001 From: DeaDDooMER Date: Sat, 15 Feb 2020 14:49:25 +0300 Subject: [PATCH] cpmake: rewrite module depth detection --- src/generic/Dsw/Mod/MakeMain.cp | 48 ++++++++++++++++----------------- 1 file changed, 24 insertions(+), 24 deletions(-) diff --git a/src/generic/Dsw/Mod/MakeMain.cp b/src/generic/Dsw/Mod/MakeMain.cp index 98d76c5..c45005e 100644 --- a/src/generic/Dsw/Mod/MakeMain.cp +++ b/src/generic/Dsw/Mod/MakeMain.cp @@ -27,6 +27,7 @@ MODULE DswMakeMain; imported = 0; trace = 1; hasObj = 2; hasSym = 3; hasErrors = 4; library = 5; debugImport = FALSE; + debugOrder = FALSE; debugJobs = FALSE; TYPE @@ -42,7 +43,8 @@ MODULE DswMakeMain; name: DevCPT.Name; path: Files.Name; selectors: Selector; (* with head, list of selectors for this module *) - mno, depth: INTEGER; + depth: INTEGER; (* 0: leaf, MAX: root *) + mno: INTEGER; imp: ARRAY maxImps OF Module; flags: SET; worker: DswProcs.Process; @@ -57,6 +59,8 @@ MODULE DswMakeMain; jobs: INTEGER; exe: String; + (* --------- options --------- *) + PROCEDURE IdentLen (IN s: ARRAY OF CHAR): INTEGER; VAR i: INTEGER; BEGIN @@ -146,7 +150,6 @@ MODULE DswMakeMain; END StrToInt; PROCEDURE ParseArgs; - VAR res: INTEGER; BEGIN jobs := 1; LOOP @@ -164,6 +167,8 @@ MODULE DswMakeMain; END END ParseArgs; + (* --------- loader --------- *) + PROCEDURE Import (m: Module; IN name: DevCPT.Name); VAR i, j: INTEGER; imp: Module; BEGIN @@ -322,16 +327,14 @@ MODULE DswMakeMain; END END GetSource; - PROCEDURE Trace (m, parent: Module; depth: INTEGER; VAR lno: INTEGER); + PROCEDURE Trace (m, parent: Module; VAR lno: INTEGER); VAR i: INTEGER; BEGIN - m.depth := MAX(m.depth, depth); IF ~(trace IN m.flags) THEN INCL(m.flags, trace); - IF m.mno > 0 THEN - FOR i := 0 TO m.mno - 1 DO - Trace(m.imp[i], m, depth + 1, lno) - END + FOR i := 0 TO m.mno - 1 DO + Trace(m.imp[i], m, lno); + m.depth := MAX(m.depth, m.imp[i].depth + 1) END; IF ~(imported IN m.flags) THEN INCL(m.flags, imported); @@ -353,7 +356,7 @@ MODULE DswMakeMain; WHILE i < mno DO m := cmpList[i]; j := i - 1; - WHILE (j >= 0) & (cmpList[j].depth < m.depth) DO + WHILE (j >= 0) & (cmpList[j].depth > m.depth) DO cmpList[j + 1] := cmpList[j]; DEC(j) END; @@ -362,7 +365,7 @@ MODULE DswMakeMain; END END Sort; - PROCEDURE MakeTree; + PROCEDURE CheckDeps; VAR i, j, num: INTEGER; m: Module; s: String; ok: BOOLEAN; BEGIN i := 0; rno := mno; @@ -379,11 +382,17 @@ MODULE DswMakeMain; END; num := 0; FOR i := 0 TO rno - 1 DO - Trace(modList[i], modList[i], 0, num); + Trace(modList[i], modList[i], num) END; ASSERT((err # 0) OR (num = mno), 100); Sort; - END MakeTree; + IF debugOrder THEN + Log.String("Parallel depth:"); Log.Ln; + FOR i := 0 TO mno - 1 DO + Log.String(" " + cmpList[i].name); Log.Int(cmpList[i].depth); Log.Ln; + END + END + END CheckDeps; PROCEDURE IsCompiled (m: Module): BOOLEAN; CONST target = {hasSym, hasObj}; @@ -517,19 +526,13 @@ MODULE DswMakeMain; END END Link; - PROCEDURE WriteSelector (s: Selector); - BEGIN - Log.String(s.name$); - IF s.value THEN Log.Char("+") ELSE Log.Char("-") END - END WriteSelector; - PROCEDURE Main; VAR m: Module; s: Selector; p: DswProcs.Process; ok: BOOLEAN; i, res: INTEGER; BEGIN IF Kernel.trapCount # 0 THEN Kernel.Quit(1) END; ParseArgs; IF err = 0 THEN - MakeTree; + CheckDeps; IF err = 0 THEN Compile; IF err = 0 THEN @@ -537,11 +540,8 @@ MODULE DswMakeMain; END END END; - IF err = 0 THEN - Log.String("no errors"); Log.Ln; - Kernel.Quit(0) - ELSE - Kernel.Quit(1) + IF err = 0 THEN Kernel.Quit(0) + ELSE Kernel.Quit(1) END; END Main; -- 2.29.2