summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: fe8a1b7)
raw | patch | inline | side by side (parent: fe8a1b7)
author | DeaDDooMER <deaddoomer@deadsoftware.ru> | |
Mon, 24 Feb 2020 22:27:48 +0000 (01:27 +0300) | ||
committer | DeaDDooMER <deaddoomer@deadsoftware.ru> | |
Mon, 24 Feb 2020 22:27:48 +0000 (01:27 +0300) |
src/generic/Dsw/Mod/MakeMain.cp | patch | blob | history |
index bd06566f501cd9a00c76bd1fa0af2f0704680a2a..9cb6a98e7ed5de28fee74f202633123605f25b76 100644 (file)
CONST
version = "0.3.0";
+ modDir = "Mod";
+ sysDir = "System";
+
maxImps = 127;
maxJobs = maxImps;
path: Files.Name;
selectors: Selector; (* with head, list of selectors for this module *)
depth: INTEGER; (* 0: leaf, MAX: root *)
+ dir: DevCPM.Directory;
mno: INTEGER;
imp: ARRAY maxImps OF Module;
flags: SET;
processor, compiler, os, linker: INTEGER;
cpcExe, cplExe: String;
cpcArgs, cplArgs: StringList;
+ dirList: DevCPM.Directory;
auto: BOOLEAN;
jobs: INTEGER;
exe: String;
RETURN t
END CopySelectorList;
- PROCEDURE AddModule (IN n: ARRAY OF CHAR; selectors: Selector);
+ PROCEDURE AddModule (IN n: ARRAY OF CHAR; selectors: Selector; dir: DevCPM.Directory);
VAR i, res: INTEGER; m: Module;
BEGIN
i := IdentLen(n);
Strings.StringToUtf8(n, m.name, res);
ASSERT(res = 0);
m.selectors := CopySelectorList(selectors);
+ m.dir := dir;
modList[i] := m;
INC(mno)
END
Log.String(" dev2 Dev2 based ELF/PE linker"); Log.Ln;
(*
Log.String(" -Fp path Add path with project"); Log.Ln;
- Log.String(" -Fx path Add postfix for project directories"); Log.Ln;
*)
Log.String(" -Xp path Use executable file for Component Pascal compiler"); Log.Ln;
Log.String(" -Xi path Use executable file for internal linker (native only)"); Log.Ln;
END
END ParseInfoOpts;
+ PROCEDURE ParseFileOpts;
+ VAR d: DevCPM.Directory;
+ BEGIN
+ CASE DswOpts.GetOpt("p:") OF
+ | "p": NEW(d); d.path := DswOpts.str$; d.legacy := TRUE; d.next := dirList; dirList := d
+ | ":": Error(10, "-F" + DswOpts.str, "", 0)
+ | "?": Error(11, "-F" + DswOpts.str, "", 0)
+ | 0X: Error(11, "-F", "", 0)
+ END
+ END ParseFileOpts;
+
PROCEDURE ParseArgs;
BEGIN
exe := NIL; auto := FALSE; jobs := 1; def.next := NIL; mno := 0; rno := 0;
processor := anymach; os := anyos; compiler := anycp;
LOOP
- CASE DswOpts.GetOpt("ao:j:D:U:TCXIhV") OF
+ CASE DswOpts.GetOpt("ao:j:D:U:TCXIFhV") OF
| "a": auto := TRUE
| "o": exe := DswOpts.str
| "j": jobs := MIN(MAX(StrToInt(DswOpts.str, 1), 1), maxJobs)
| "C": ParseCommandOpts
| "X": ParseExternalOpts
| "I": ParseInfoOpts
+ | "F": ParseFileOpts
| ":": Error(10, "-" + DswOpts.str, "", 0)
| "?": Error(11, "-" + DswOpts.str, "", 0)
- | "$": AddModule(DswOpts.str, def)
+ | "$": AddModule(DswOpts.str, def, dirList)
| 0X: EXIT
END
END;
VAR s: Selector;
BEGIN
DevCPM.Init(source);
+ DevCPM.symList := m.dir;
(*
- DevCPM.symList := m.insym;
DevCPM.codePath := m.outcode;
DevCPM.symPath := m.outsym;
*)
Kernel.FastCollect
END CheckModule;
- PROCEDURE GetSource (IN modName: ARRAY OF CHAR; OUT path: Files.Name; OUT s: String);
- CONST modDir = "Mod"; sysDir = "System";
- VAR dir, name: Files.Name; loc: Files.Locator;
- text: DswDocuments.Model; r: DswDocuments.Reader; i, res: INTEGER;
-
- PROCEDURE MakePath (dir, name: Files.Name; type: Files.Type; OUT path: Files.Name);
- BEGIN
- ASSERT(name # "", 21);
- IF dir = "" THEN path := modDir + "/" + name
- ELSE path := dir + "/" + modDir + "/" + name
- END;
- Kernel.MakeFileName(path, type)
- END MakePath;
+ PROCEDURE MakePath (IN dir, name: Files.Name; IN type: Files.Type; OUT path: Files.Name);
+ BEGIN
+ ASSERT(name # "", 21);
+ IF dir = "" THEN path := modDir + "/" + name
+ ELSE path := dir + "/" + modDir + "/" + name
+ END;
+ Kernel.MakeFileName(path, type)
+ END MakePath;
+ PROCEDURE Open (loc: Files.Locator; IN sub, name: Files.Name; OUT path: Files.Name; OUT text: DswDocuments.Model);
+ VAR res: INTEGER;
BEGIN
- s := NIL; path := "";
- Kernel.SplitName(modName, dir, name);
- loc := Files.dir.This(dir).This(modDir);
- (* --> Kernel.MakeFileName(name, Kernel.docType); <-- *)
- MakePath(dir, name, "cp", path);
+ ASSERT(loc # NIL, 20);
+ ASSERT(name # "", 21);
+ (* !!! use Kernel.MakeFileName instead ".ext" concat !!! *)
+ MakePath(sub, name, "cp", path);
DswDocuments.Open(loc, name + ".cp", text, res);
IF text = NIL THEN
- MakePath(dir, name, "odc", path);
+ MakePath(sub, name, "odc", path);
DswDocuments.Open(loc, name + ".odc", text, res);
- IF (text = NIL) & (dir = "") THEN
+ IF (text = NIL) & (sub = "") THEN
MakePath(sysDir, name, "cp", path);
loc := Files.dir.This(sysDir).This(modDir);
DswDocuments.Open(loc, name + ".cp", text, res);
END
END
END
+ END
+ END Open;
+
+ PROCEDURE GetSource (IN modName: ARRAY OF CHAR; list: DevCPM.Directory; OUT path: Files.Name; OUT s: String);
+ VAR
+ sub, name: Files.Name; loc: Files.Locator; base: DevCPM.Directory;
+ text: DswDocuments.Model; r: DswDocuments.Reader; i, res: INTEGER;
+ BEGIN
+ s := NIL; path := ""; base := list;
+ Kernel.SplitName(modName, sub, name);
+ loc := Files.dir.This(sub).This(modDir);
+ Open(loc, sub, name, path, text);
+ WHILE (text = NIL) & (base # NIL) DO
+ ASSERT(base.legacy, 100);
+ loc := Files.dir.This(base.path).This(sub).This(modDir);
+ Open(loc, sub, name, path, text);
+ base := base.next
END;
IF text # NIL THEN
NEW(s, text.Length() + 1);
END Sort;
PROCEDURE CheckDeps;
- VAR i, j, num: INTEGER; m: Module; s: String; ok: BOOLEAN;
+ VAR i, j, num: INTEGER; m: Module; src: String; ok: BOOLEAN;
BEGIN
i := 0; rno := mno;
WHILE (err = 0) & (i < mno) DO
m := modList[i];
- GetSource(m.name$, m.path, s);
- IF s # NIL THEN
- CheckModule(m, s, ok);
+ GetSource(m.name$, m.dir, m.path, src);
+ IF src # NIL THEN
+ CheckModule(m, src, ok);
IF ~ok THEN INC(err) END
ELSE
Error(21, m.name$, "", 0)
IF debugArgs THEN Log.Ln END
END PutParams;
+ PROCEDURE PutPathList (w: DswProcs.Process; IN par: ARRAY OF CHAR; base: DevCPM.Directory);
+ BEGIN
+ IF base # NIL THEN
+ PutPath(w, base.next); (* in revese order *)
+ w.PutParam(par);
+ w.PutParam(base.path);
+ END
+ END PutPathList;
+
PROCEDURE ExecuteCompiler (m: Module): DswProcs.Process;
VAR w: DswProcs.Process; ok: BOOLEAN;
BEGIN
w := DswProcs.dir.New();
w.Program(cpcExe);
w.PutParam("-legacy");
+ PutPath(w, "-legacysymdir", m.dir);
PutParams(w, cpcArgs);
CASE compiler OF
| cpfront:
ASSERT(compiler = cpnative, 22);
p := DswProcs.dir.New();
p.Program(cplExe);
+ PutPath(w, "-legacycodedir", dirList);
IF os # anyos THEN
p.PutParam("-os");
CASE os OF