From: DeaDDooMER Date: Mon, 24 Feb 2020 22:27:48 +0000 (+0300) Subject: cpmake: allow custom search pathes X-Git-Url: http://deadsoftware.ru/gitweb?a=commitdiff_plain;h=ae26c0758042976e510279675ec821147fe0fde5;p=cpc.git cpmake: allow custom search pathes --- diff --git a/src/generic/Dsw/Mod/MakeMain.cp b/src/generic/Dsw/Mod/MakeMain.cp index bd06566..9cb6a98 100644 --- a/src/generic/Dsw/Mod/MakeMain.cp +++ b/src/generic/Dsw/Mod/MakeMain.cp @@ -5,6 +5,9 @@ MODULE DswMakeMain; CONST version = "0.3.0"; + modDir = "Mod"; + sysDir = "System"; + maxImps = 127; maxJobs = maxImps; @@ -60,6 +63,7 @@ MODULE DswMakeMain; 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; @@ -74,6 +78,7 @@ MODULE DswMakeMain; processor, compiler, os, linker: INTEGER; cpcExe, cplExe: String; cpcArgs, cplArgs: StringList; + dirList: DevCPM.Directory; auto: BOOLEAN; jobs: INTEGER; exe: String; @@ -177,7 +182,7 @@ MODULE DswMakeMain; 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); @@ -189,6 +194,7 @@ MODULE DswMakeMain; Strings.StringToUtf8(n, m.name, res); ASSERT(res = 0); m.selectors := CopySelectorList(selectors); + m.dir := dir; modList[i] := m; INC(mno) END @@ -291,7 +297,6 @@ MODULE DswMakeMain; 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; @@ -389,12 +394,23 @@ MODULE DswMakeMain; 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) @@ -406,9 +422,10 @@ MODULE DswMakeMain; | "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; @@ -568,8 +585,8 @@ MODULE DswMakeMain; VAR s: Selector; BEGIN DevCPM.Init(source); + DevCPM.symList := m.dir; (* - DevCPM.symList := m.insym; DevCPM.codePath := m.outcode; DevCPM.symPath := m.outsym; *) @@ -594,31 +611,27 @@ MODULE DswMakeMain; 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); @@ -630,6 +643,23 @@ MODULE DswMakeMain; 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); @@ -681,14 +711,14 @@ MODULE DswMakeMain; 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) @@ -754,6 +784,15 @@ MODULE DswMakeMain; 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 @@ -763,6 +802,7 @@ MODULE DswMakeMain; w := DswProcs.dir.New(); w.Program(cpcExe); w.PutParam("-legacy"); + PutPath(w, "-legacysymdir", m.dir); PutParams(w, cpcArgs); CASE compiler OF | cpfront: @@ -912,6 +952,7 @@ MODULE DswMakeMain; 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