From b35fa3c3fee588fdea3139f49be3b6d1f9c52a89 Mon Sep 17 00:00:00 2001 From: DeaDDooMER Date: Tue, 25 Feb 2020 22:14:59 +0300 Subject: [PATCH] cpmake: make commonly used options shorter with help update --- src/generic/Dsw/Mod/MakeMain.cp | 203 ++++++++++++++++---------------- 1 file changed, 101 insertions(+), 102 deletions(-) diff --git a/src/generic/Dsw/Mod/MakeMain.cp b/src/generic/Dsw/Mod/MakeMain.cp index e024a3c..f416a34 100644 --- a/src/generic/Dsw/Mod/MakeMain.cp +++ b/src/generic/Dsw/Mod/MakeMain.cp @@ -3,7 +3,7 @@ MODULE DswMakeMain; IMPORT Kernel, Files, Log, Strings, DswOpts, DswProcs, DswDocuments, DevCPM, DevCPT, DevCPR, DevCPS; CONST - version = "0.3.0"; + version = "0.3"; modDir = "Mod"; sysDir = "System"; @@ -79,6 +79,7 @@ MODULE DswMakeMain; cpcArgs, cplArgs: StringList; dirList: DevCPM.Directory; auto: BOOLEAN; + trap: BOOLEAN; jobs: INTEGER; exe: String; printCompileModList: BOOLEAN; @@ -91,9 +92,9 @@ MODULE DswMakeMain; CASE e OF | 0: msg := "option -D expect + or - after identifier" | 1: msg := "option -D expect identifier" - | 2: msg := "option -U expect identifier" - | 3: msg := "module name must be identifier" - | 4: msg := "expected integer" (* p0 = in str *) + | 2: msg := "option -U expect identifier" (* rm *) + | 3: msg := "invalid module name" + | 4: msg := "invalid integer value" | 5: msg := "unterminated string" | 6: msg := "unknown processor ^0" | 7: msg := "unknown os ^0" @@ -101,28 +102,31 @@ MODULE DswMakeMain; | 9: msg := "unknown linker ^0" | 10: msg := "missing argument for option ^0" | 11: msg := "unknown option ^0" - | 12: msg := "compiler not selected" - | 13: msg := "processor not selected" - | 14: msg := "processor not supported by native compiler" + | 12: msg := "compiler not selected (use option -g)" + | 13: msg := "processor not selected (use option -m)" + | 14: msg := "selected processor not supported by native compiler" | 15: msg := "internal linker not required for cpfront" - | 16: msg := "cpfront can't out executable file" - | 17: msg := "linker not selected" - | 18: msg := "os not selected" - | 19: msg := "output file name can't be empty" + | 16: msg := "cpfront can't produce executable file" + | 17: msg := "linker not selected (use option -i)" + | 18: msg := "os not selected (use option -s)" + | 19: msg := "specified empty file name" | 20: msg := "recursive import of ^0 in ^1" | 21: msg := "unable to open module ^1" | 22: msg := "linker terminated with code ^2" | 23: msg := "unable to execute linker" | 24: msg := "trap occured" - | 25: msg := "compiler not installed" - | 26: msg := "linker not installed" + | 25: msg := "compiler not installed (use option -Xg to select executable)" + | 26: msg := "linker not installed (use option -Xi to select executable)" ELSE Strings.IntToString(err, msg) END; Strings.IntToString(i2, p2); Log.String(Kernel.argv[0]$); Log.String(": "); Log.ParamMsg(msg, p0, p1, p2); Log.Ln; - INC(err) + INC(err); + IF trap THEN + HALT(100) + END END Error; (* --------- options --------- *) @@ -261,37 +265,35 @@ MODULE DswMakeMain; BEGIN Log.String("Usage: cpmake [options] module..."); Log.Ln; Log.String("Options:"); Log.Ln; - Log.String(" -Tm cpu Generate code for specified processor"); Log.Ln; - Log.String(" none Unknown processor (cpfront only)"); Log.Ln; - Log.String(" 486 Intel 486"); Log.Ln; - Log.String(" -Ts os Generate code for specified operation system"); Log.Ln; - Log.String(" none Unknown operation system"); Log.Ln; - Log.String(" linux Linux"); Log.Ln; - Log.String(" -Tg compiler Specify Component Pascal compiler"); Log.Ln; - Log.String(" native BlackBox based native code compiler"); Log.Ln; - Log.String(" cpfront BlackBox based C code translator"); Log.Ln; - Log.String(" -Ti linker Specify internal linker (native only)"); Log.Ln; - Log.String(" dev2 Dev2 based ELF/PE linker"); Log.Ln; -(* - Log.String(" -Fp path Add path with project"); 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; - Log.String(" -Cg params Pass parameters to Component Pasacal compiler directly"); Log.Ln; - Log.String(" -Ci params Pass parameters to internal linker directly"); Log.Ln; - Log.String(" -II Trap on user interrupt"); Log.Ln; - Log.String(" -IC Print module list for compilation and quit"); Log.Ln; - Log.String(" -IL Print module list for linking and quit"); Log.Ln; - Log.String(" -Ic Print file list for compilation and quit"); Log.Ln; -(* - Log.String(" -Il Print file list for linking and quit"); Log.Ln; -*) - Log.String(" -a Enable automatic dependency resolution"); Log.Ln; - Log.String(" -o name Generate executable file"); Log.Ln; - Log.String(" -j num Specifies the number of jobs to run simultaneously"); Log.Ln; + Log.String(" -a Enable automatic dependency resolution"); Log.Ln; + Log.String(" -Cg params Pass parameters to Component Pasacal compiler directly"); Log.Ln; + Log.String(" -Ci params Pass parameters to internal linker directly"); Log.Ln; Log.String(' -D ident["+"|"-"] Add preprocessor selector'); Log.Ln; - Log.String(" -h Print help and quit"); Log.Ln; - Log.String(" -V Print version and quit"); Log.Ln; + Log.String(" -g compiler Specify Component Pascal compiler"); Log.Ln; + Log.String(" cpfront BlackBox based C code translator"); Log.Ln; + Log.String(" native BlackBox based native code compiler"); Log.Ln; + Log.String(" -h Print help and quit"); Log.Ln; + Log.String(" -i linker Specify internal linker (native only)"); Log.Ln; + Log.String(" dev2 Dev2 based ELF/PE linker"); Log.Ln; + Log.String(" -II Trap on user interrupt (debug)"); Log.Ln; + Log.String(" -IT Trap on first error (debug)"); Log.Ln; + Log.String(" -IC Print module list for compilation and quit"); Log.Ln; + Log.String(" -IL Print module list for linking and quit"); Log.Ln; + Log.String(" -Ic Print file list for compilation and quit"); Log.Ln; + Log.String(" -j num Specifies the number of jobs to run simultaneously"); Log.Ln; + Log.String(" -m cpu Generate code for specified processor"); Log.Ln; + Log.String(" none Unknown processor (cpfront only)"); Log.Ln; + Log.String(" 486 Intel 486+"); Log.Ln; + Log.String(" -o name Generate executable file (native only)"); Log.Ln; + Log.String(" -s os Generate code for specified operation system"); Log.Ln; + Log.String(" none Unknown operation system"); Log.Ln; + Log.String(" freebsd FreeBSD"); Log.Ln; + Log.String(" linux Linux"); Log.Ln; + Log.String(" openbsd OpenBSD"); Log.Ln; + Log.String(" win32 Windows"); Log.Ln; + Log.String(" -V Print version and quit"); 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; Kernel.Quit(1) END Help; @@ -301,49 +303,6 @@ MODULE DswMakeMain; Kernel.Quit(0) END Version; - PROCEDURE ParseTargetOpts; - VAR s: DswOpts.String; - BEGIN - CASE DswOpts.GetOpt("m:s:g:i:") OF - | "m": - s := DswOpts.str; - Strings.ToLower(s, s); - IF s$ = "none" THEN processor := anymach - ELSIF s$ = "486" THEN processor := mach386 - ELSIF s$ = "68k" THEN processor := mach68k - ELSE Error(6, s, "", 0) - END - | "s": - s := DswOpts.str; - Strings.ToLower(s, s); - IF s$ = "none" THEN os := anyos - ELSIF s$ = "linux" THEN os := linux - ELSIF s$ = "freebsd" THEN os := freebsd - ELSIF s$ = "openbsd" THEN os := openbsd - ELSIF s$ = "win32" THEN os := win32 - ELSIF s$ = "cygwin" THEN os := cygwin - ELSIF s$ = "darwin" THEN os := darwin - ELSE Error(7, s, "", 0) - END - | "g": - s := DswOpts.str; - Strings.ToLower(s, s); - IF s$ = "native" THEN compiler := cpnative - ELSIF s$ = "cpfront" THEN compiler := cpfront - ELSE Error(8, s, "", 0) - END - | "i": - s := DswOpts.str; - Strings.ToLower(s, s); - IF s$ = "dev2" THEN linker := dev2 - ELSE Error(9, s, "", 0) - END - | ":": Error(10, "-T" + DswOpts.str, "", 0) - | "?": Error(11, "-T" + DswOpts.str, "", 0) - | 0X: Error(11, "-T", "", 0) - END - END ParseTargetOpts; - PROCEDURE ParseCommandOpts; BEGIN CASE DswOpts.GetOpt("g:i:") OF @@ -368,7 +327,8 @@ MODULE DswMakeMain; PROCEDURE ParseInfoOpts; BEGIN - CASE DswOpts.GetOpt("CLcI") OF + CASE DswOpts.GetOpt("CLcIT") OF + | "T": trap := TRUE | "I": Kernel.intTrap := TRUE | "C": printCompileModList := TRUE | "L": printLinkModList := TRUE @@ -391,18 +351,51 @@ MODULE DswMakeMain; END ParseFileOpts; PROCEDURE ParseArgs; + VAR s: String; 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:TCXIFhV") OF + CASE DswOpts.GetOpt("ao:j:D:m:s:g:i:TCXIFhV") OF | "a": auto := TRUE | "o": exe := DswOpts.str | "j": jobs := MIN(MAX(StrToInt(DswOpts.str, 1), 1), maxJobs) + | "m": + s := DswOpts.str; + Strings.ToLower(s, s); + IF s$ = "none" THEN processor := anymach + ELSIF s$ = "486" THEN processor := mach386 + ELSIF s$ = "68k" THEN processor := mach68k + ELSE Error(6, s, "", 0) + END + | "s": + s := DswOpts.str; + Strings.ToLower(s, s); + IF s$ = "none" THEN os := anyos + ELSIF s$ = "linux" THEN os := linux + ELSIF s$ = "freebsd" THEN os := freebsd + ELSIF s$ = "openbsd" THEN os := openbsd + ELSIF s$ = "win32" THEN os := win32 + ELSIF s$ = "cygwin" THEN os := cygwin + ELSIF s$ = "darwin" THEN os := darwin + ELSE Error(7, s, "", 0) + END + | "g": + s := DswOpts.str; + Strings.ToLower(s, s); + IF s$ = "native" THEN compiler := cpnative + ELSIF s$ = "cpfront" THEN compiler := cpfront + ELSE Error(8, s, "", 0) + END + | "i": + s := DswOpts.str; + Strings.ToLower(s, s); + IF s$ = "dev2" THEN linker := dev2 + ELSE Error(9, s, "", 0) + END | "h": Help | "V": Version | "D": Define(DswOpts.str, TRUE) - | "T": ParseTargetOpts | "C": ParseCommandOpts | "X": ParseExternalOpts | "I": ParseInfoOpts @@ -597,16 +590,14 @@ MODULE DswMakeMain; BEGIN DevCPM.Init(source); DevCPM.symList := m.dir; -(* - DevCPM.codePath := m.outcode; - DevCPM.symPath := m.outsym; -*) + (*DevCPM.codePath := m.outcode;*) + (*DevCPM.symPath := m.outsym;*) DevCPM.name := m.name$; -(* - IF m.found THEN INCL(DevCPM.options, DevCPM.comAware) END; - IF errorTrap IN m.opts THEN INCL(DevCPM.options, DevCPM.trap) END; - IF oberon IN m.opts THEN INCL(DevCPM.options, DevCPM.oberon) END; -*) + INCL(DevCPM.options, DevCPM.comAware); + IF trap THEN + INCL(DevCPM.options, DevCPM.trap) + END; + (*IF oberon IN m.opts THEN INCL(DevCPM.options, DevCPM.oberon) END;*) DevCPR.Init; s := def.next; WHILE s # NIL DO @@ -812,6 +803,9 @@ MODULE DswMakeMain; ASSERT(m.worker = NIL, 22); w := DswProcs.dir.New(); w.Program(cpcExe); + IF trap THEN + w.PutParam("-trap") + END; w.PutParam("-legacy"); PutPathList(w, "-legacysymdir", m.dir); s := def.next; @@ -890,6 +884,9 @@ MODULE DswMakeMain; ASSERT(compiler = cpnative, 22); p := DswProcs.dir.New(); p.Program(cplExe); + IF trap THEN + p.PutParam("-trap") + END; PutPathList(p, "-legacycodedir", dirList); IF os # anyos THEN p.PutParam("-os"); @@ -959,13 +956,15 @@ MODULE DswMakeMain; Log.String(cmpList[i].odc); Log.Char(" ") END; Log.Ln -(* ELSIF printLinkFileList THEN + (* + ELSIF printLinkFileList THEN FOR i := 0 TO mno - 1 DO IF ~(library IN lnkList[i].flags) THEN Log.String(lnkList[i].ocf); Log.Char(" ") END END; - Log.Ln*) + Log.Ln + *) END END PrintInfo; @@ -996,7 +995,7 @@ MODULE DswMakeMain; END; IF err = 0 THEN Kernel.Quit(0) ELSE Kernel.Quit(1) - END; + END END Main; BEGIN -- 2.29.2