summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: bd73987)
raw | patch | inline | side by side (parent: bd73987)
author | DeaDDooMER <deaddoomer@deadsoftware.ru> | |
Tue, 4 Aug 2020 15:57:57 +0000 (18:57 +0300) | ||
committer | DeaDDooMER <deaddoomer@deadsoftware.ru> | |
Tue, 4 Aug 2020 15:57:57 +0000 (18:57 +0300) |
src/generic/Dsw/Mod/MakeMain.cp | patch | blob | history |
index acf9619195372ae79e6b78374795cf60e75dcd5e..b88795d846777093012fcf5ba61934780c18ff28 100644 (file)
debugJobs = FALSE;
TYPE
+ Name = ARRAY 256 OF CHAR;
+
String = POINTER TO ARRAY OF CHAR;
Selector = POINTER TO RECORD
Module = POINTER TO RECORD
name: DevCPT.Name;
+ library: DevCPT.Name;
odc: Files.Name;
depth: INTEGER; (* 0: leaf, MAX: root *)
dir: DevCPM.Directory;
worker: DswProcs.Process;
END;
+ Library = POINTER TO RECORD
+ name: Name;
+ library: Name;
+ next: Library;
+ END;
+
VAR (* options *)
auto, trap, clean, symonly, nocode1, nocode2: BOOLEAN;
exe, target, base: String;
modList, lnkList, cmpList: ARRAY maxImps OF Module;
def: Selector; (* with head, global list of selectors *)
dirList: DevCPM.Directory;
+ libList: Library;
PROCEDURE Error (IN str, p0, p1: ARRAY OF CHAR; i2: INTEGER);
VAR p2: ARRAY 32 OF CHAR;
END
END AddModule;
+ PROCEDURE AddLibrary (IN key, val: ARRAY OF CHAR);
+ VAR x: Library;
+ BEGIN
+ x := libList;
+ WHILE (x # NIL) & (x.name$ # key$) DO x := x.next END;
+ IF x # NIL THEN x.library := val$
+ ELSE NEW(x); x.name := key$; x.library := val$; x.next := libList; libList := x
+ END
+ END AddLibrary;
+
+ PROCEDURE AddLib (IN s: ARRAY OF CHAR);
+ VAR key, val: Name; i, j: INTEGER;
+ BEGIN
+ i := 0; j := 0;
+ WHILE (s[i] # 0X) & (s[i] # "=") DO
+ key[j] := s[i];
+ INC(j);
+ INC(i)
+ END;
+ key[j] := 0X;
+ j := 0;
+ IF s[i] = "=" THEN
+ INC(i);
+ WHILE s[i] # 0X DO
+ val[j] := s[i];
+ INC(j);
+ INC(i)
+ END
+ END;
+ val[j] := 0X;
+ IF key # "" THEN AddLibrary(key, val)
+ ELSE Error("empty library key", "", "", 0)
+ END
+ END AddLib;
+
+ PROCEDURE FindLib (IN key: ARRAY OF CHAR): Library;
+ VAR x: Library;
+ BEGIN
+ x := libList;
+ WHILE (x # NIL) & (x.name$ # key$) DO x := x.next END;
+ RETURN x
+ END FindLib;
+
PROCEDURE StrToInt (IN s: ARRAY OF CHAR; def: INTEGER): INTEGER;
VAR x, res: INTEGER;
BEGIN
Log.String(" -c Remove all generated files"); Log.Ln;
Log.String(" -s Generate symbol files only"); Log.Ln;
Log.String(" -d selector Add selector"); Log.Ln;
+ Log.String(" -r lib[=s] Replace library name on link stage"); Log.Ln;
Log.String(" -t target Specify target rules"); Log.Ln;
Log.String(" -o file Generate object file"); Log.Ln;
Log.String(" -j num Specifies the number of jobs to run simultaneously"); Log.Ln;
exe := NIL; auto := FALSE; jobs := 1; def.next := NIL; mno := 0; rno := 0;
target := NewStr("default"); base := NewStr("cprules");
LOOP
- CASE DswOpts.GetOpt("acbxd:sgGo:t:j:f:") OF
+ CASE DswOpts.GetOpt("acbxd:sgGo:t:j:f:r:h") OF
| "a": auto := TRUE
| "b": nocode1 := TRUE
| "x": nocode2 := TRUE
| "s": symonly := TRUE
| "f": base := DswOpts.str
| "d": Define(DswOpts.str, TRUE)
+ | "r": AddLib(DswOpts.str)
| "h": Help
| "j": jobs := MIN(MAX(StrToInt(DswOpts.str, 1), 1), maxJobs)
| "o": exe := DswOpts.str
IF sym = eql THEN DevCPS.Get(sym)
ELSE INCL(DevCPM.options, DevCPM.noCode)
END;
- IF sym = string THEN INCL(m.flags, library); DevCPS.Get(sym)
+ IF sym = string THEN INCL(m.flags, library); m.library := DevCPS.str$; DevCPS.Get(sym)
ELSE err(string)
END;
CheckSym(rbrak)
RETURN ready
END Ready;
+ PROCEDURE PrepareCompilerDeps (m: Module; p: DswProcs.Process; root, libsOnly: BOOLEAN);
+ VAR i: INTEGER; s: ARRAY 3 OF CHAR; lib: Library;
+ BEGIN
+ IF ~(trace IN m.flags) THEN
+ INCL(m.flags, trace);
+ FOR i := 0 TO m.mno - 1 DO
+ PrepareCompilerDeps(m.imp[i], p, FALSE, libsOnly)
+ END;
+ IF ~libsOnly OR (library IN m.flags) THEN
+ IF library IN m.flags THEN s := "-l" ELSE s := "-m" END;
+ IF root THEN s[1] := CAP(s[1]) END;
+ IF library IN m.flags THEN
+ lib := FindLib(m.library$);
+ IF lib # NIL THEN
+ IF lib.library$ # "" THEN
+ p.PutParam(s);
+ p.PutParam(lib.library$)
+ END
+ ELSE
+ p.PutParam(s);
+ p.PutParam(m.library$)
+ END
+ ELSE
+ p.PutParam(s);
+ p.PutParam(m.name$)
+ END
+ END;
+ EXCL(m.flags, trace)
+ END
+ END PrepareCompilerDeps;
+
PROCEDURE PrepareCompiler (m: Module): DswProcs.Process;
- VAR p: DswProcs.Process; s: Selector;
+ VAR p: DswProcs.Process; s: Selector; i: INTEGER;
BEGIN
ASSERT(m # NIL, 20);
ASSERT(m.odc # "", 21);
p.PutParam(s.name$);
s := s.next
END;
+ FOR i := 0 TO m.mno - 1 DO
+ PrepareCompilerDeps(m.imp[i], p, TRUE, FALSE);
+ END;
RETURN p
END PrepareCompiler;
p.PutParam(lnkList[i].name$)
END
END;
+ FOR i := 0 TO mno - 1 DO
+ IF library IN lnkList[i].flags THEN
+ PrepareCompilerDeps(lnkList[i], p, FALSE, TRUE)
+ END
+ END;
p.Execute(ok);
IF ok THEN
p.Wait;