summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 3694658)
raw | patch | inline | side by side (parent: 3694658)
author | DeaDDooMER <deaddoomer@deadsoftware.ru> | |
Mon, 24 Feb 2020 17:02:10 +0000 (20:02 +0300) | ||
committer | DeaDDooMER <deaddoomer@deadsoftware.ru> | |
Mon, 24 Feb 2020 17:02:10 +0000 (20:02 +0300) |
src/generic/Dsw/Mod/MakeMain.cp | patch | blob | history |
index 989b8bcb2ce6727184062b5f0eb9489993a5acbf..04388d2a574ddde1ce50e7968e6b0b5c32867c0c 100644 (file)
jobs: INTEGER;
exe: String;
+ PROCEDURE Error (e: INTEGER; IN p0, p1: ARRAY OF CHAR; i2: INTEGER);
+ VAR msg, p2: ARRAY 128 OF CHAR;
+ BEGIN
+ 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 *)
+ | 5: msg := "unterminated string"
+ | 6: msg := "unknown processor ^0"
+ | 7: msg := "unknown os ^0"
+ | 8: msg := "unknown compiler ^0"
+ | 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"
+ | 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"
+ | 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"
+ 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)
+ END Error;
+
(* --------- options --------- *)
PROCEDURE IdentLen (IN s: ARRAY OF CHAR): INTEGER;
i := IdentLen(n);
IF i # 0 THEN
IF ~((n[i] = 0X) OR (((n[i] = "+") OR (n[i] = "-")) & (n[i + 1] = 0X))) THEN
- Log.String("option -D expect + or - after identifier"); Log.Ln; INC(err)
+ Error(0, "", "", 0)
END;
v := n[i] # "-"; n[i] := 0X; s := def;
WHILE (s.next # NIL) & (s.next.name$ # n$) DO s := s.next END;
END;
s.next.value := v
ELSE
- Log.String("option -D expect identifier"); Log.Ln; INC(err)
+ Error(1, "", "", 0)
END
END Define;
WHILE (s.next # NIL) & (s.next.name$ # n$) DO s := s.next END;
IF s.next # NIL THEN s.next := s.next.next END
ELSE
- Log.String("option -U expect identifier"); Log.Ln; INC(err)
+ Error(2, "", "", 0)
END
END Undefine;
INC(mno)
END
ELSE
- Log.String("module name must be identifier"); Log.Ln; INC(err)
+ Error(3, "", "", 0)
END
END AddModule;
BEGIN
Strings.StringToInt(s, x, res);
IF res # 0 THEN
- Log.String("expected integer"); Log.Ln; INC(err);
+ Error(4, s, "", 0);
x := def
END;
RETURN x
AddChar(ch); ch := s[i]; INC(i)
END;
IF ch # 0X THEN ch := s[i]; INC(i)
- ELSE Log.String("unterminated string"); Log.Ln; INC(err)
+ ELSE Error(5, "", "", 0)
END
| " ":
REPEAT ch := s[i]; INC(i) UNTIL ch # " ";
IF s$ = "none" THEN processor := anymach
ELSIF s$ = "486" THEN processor := mach386
ELSIF s$ = "68k" THEN processor := mach68k
- ELSE Log.String("unknwon processor "); Log.String(s); Log.Ln; INC(err)
+ ELSE Error(6, s, "", 0)
END
| "s":
s := DswOpts.str;
ELSIF s$ = "win32" THEN os := win32
ELSIF s$ = "cygwin" THEN os := cygwin
ELSIF s$ = "darwin" THEN os := darwin
- ELSE Log.String("unknwon os "); Log.String(s); Log.Ln; INC(err)
+ 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 Log.String("unknwon compiler "); Log.String(s); Log.Ln; INC(err)
+ ELSE Error(8, s, "", 0)
END
| "i":
s := DswOpts.str;
Strings.ToLower(s, s);
IF s$ = "dev2" THEN linker := dev2
- ELSE Log.String("unknwon linker "); Log.String(s); Log.Ln; INC(err)
+ ELSE Error(9, s, "", 0)
END
- | ":": Log.String("missing argument for option -T"); Log.String(DswOpts.str); Log.Ln; INC(err)
- | "?": Log.String("unknown option -T"); Log.String(DswOpts.str); Log.Ln; INC(err)
- | 0X: Log.String("unknown option -T"); Log.Ln; INC(err)
+ | ":": Error(10, "-T" + DswOpts.str, "", 0)
+ | "?": Error(11, "-T" + DswOpts.str, "", 0)
+ | 0X: Error(11, "-T", "", 0)
END
END ParseTargetOpts;
CASE DswOpts.GetOpt("g:i:") OF
| "g": cpcArgs := ToStringList(DswOpts.str);
| "i": cplArgs := ToStringList(DswOpts.str);
- | ":": Log.String("missing argument for option -C"); Log.String(DswOpts.str); Log.Ln; INC(err)
- | "?": Log.String("unknown option -C"); Log.String(DswOpts.str); Log.Ln; INC(err)
- | 0X: Log.String("unknown option -C"); Log.Ln; INC(err)
+ | ":": Error(10, "-C" + DswOpts.str, "", 0)
+ | "?": Error(11, "-C" + DswOpts.str, "", 0)
+ | 0X: Error(11, "-C", "", 0)
END
END ParseCommandOpts;
CASE DswOpts.GetOpt("g:i:") OF
| "g": cpcExe := DswOpts.str;
| "i": cplExe := DswOpts.str;
- | ":": Log.String("missing argument for option -X"); Log.String(DswOpts.str); Log.Ln; INC(err)
- | "?": Log.String("unknown option -X"); Log.String(DswOpts.str); Log.Ln; INC(err)
- | 0X: Log.String("unknown option -X"); Log.Ln; INC(err)
+ | ":": Error(10, "-X" + DswOpts.str, "", 0)
+ | "?": Error(11, "-X" + DswOpts.str, "", 0)
+ | 0X: Error(11, "-X", "", 0)
END
END ParseExternalOpts;
| "T": ParseTargetOpts
| "C": ParseCommandOpts
| "X": ParseExternalOpts
- | ":": Log.String("missing argument for option -"); Log.String(DswOpts.str); Log.Ln; INC(err)
- | "?": Log.String("unknown option -"); Log.String(DswOpts.str); Log.Ln; INC(err)
+ | ":": Error(10, "-" + DswOpts.str, "", 0)
+ | "?": Error(11, "-" + DswOpts.str, "", 0)
| "$": AddModule(DswOpts.str, def)
| 0X: EXIT
END
PROCEDURE CheckParams;
BEGIN
IF compiler = anycp THEN
- Log.String("compiler not selected"); Log.Ln; INC(err)
+ Error(12, "", "", 0)
ELSIF compiler = cpnative THEN
IF processor = anymach THEN
- Log.String("processor not selected"); Log.Ln; INC(err)
+ Error(13, "", "", 0)
ELSIF processor # mach386 THEN
- Log.String("processor not supported by native compiler"); Log.Ln; INC(err)
+ Error(14, "", "", 0)
END
END;
IF (compiler = cpfront) & (linker # anyint) THEN
- Log.String("internal linker not required for cpfront"); Log.Ln; INC(err)
+ Error(15, "", "", 0)
END;
IF (compiler = cpfront) & (exe # NIL) THEN
- Log.String("cpfront can't out executable file"); Log.Ln; INC(err)
+ Error(16, "", "", 0)
END;
IF (exe # NIL) & (compiler = cpnative) & (linker = anyint) THEN
- Log.String("linker not selected"); Log.Ln; INC(err)
+ Error(17, "", "", 0)
END;
IF (linker = dev2) & (os = anyos) THEN
- Log.String("os not selected"); Log.Ln; INC(err)
+ Error(18, "", "", 0)
END;
IF (exe # NIL) & (exe^ = "") THEN
- Log.String("output file name can't be empty"); Log.Ln; INC(err)
+ Error(19, "", "", 0)
END;
IF cpcExe = NIL THEN
IF compiler = cpnative THEN cpcExe := NewStr("cpc486")
END;
EXCL(m.flags, trace)
ELSE
- Log.String("recursive import of " + m.name + " in " + parent.name); Log.Ln; INC(err)
+ Error(20, m.name$, parent.name$, 0)
END
END Trace;
CheckModule(m, s, ok);
IF ~ok THEN INC(err) END
ELSE
- Log.String("unable to open module " + m.name); Log.Ln; INC(err)
+ Error(21, m.name$, "", 0)
END;
INC(i)
END;
Log.String("Link "); Log.String(exe); Log.Ln;
res := p.Result();
IF res # 0 THEN
- Log.String("linker terminated with error"); Log.Int(res); Log.Ln;
- INC(err)
+ Error(22, "", "", res)
END
ELSE
- Log.String("unable to execute linker"); Log.Int(i); Log.Ln;
- INC(err)
+ Error(23, "", "", 0)
END
END LinkDev2;
END
END
END
- END
- ELSE INC(err)
+ END
+ ELSE Error(24, "", "", 0)
END;
IF err = 0 THEN Kernel.Quit(0)
ELSE Kernel.Quit(1)