-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathxlib80_v10.lpr
168 lines (145 loc) · 3.68 KB
/
xlib80_v10.lpr
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
program xlib80_v10;
{$mode objfpc}{$H+}
uses
{$IFDEF UNIX}
cthreads,
{$ENDIF}
Classes, SysUtils, CustApp,
{ you can add units after this }
lacogen_types, umessages, typinfo,
uasmglobals, uxlibcommandline, uenvironment, uxlib80, uobject;
type
{ TXLIB80 }
TXLIB80 = class(TCustomApplication)
protected
procedure DoRun; override;
procedure ProcessAdd;
procedure ProcessList;
procedure ProcessRemove;
procedure ShowHelp;
procedure ShowTitle;
public
constructor Create(TheOwner: TComponent); override;
destructor Destroy; override;
procedure Initialisation;
end;
var
Application: TXLIB80;
{$R *.res}
{ TXLIB80 }
constructor TXLIB80.Create(TheOwner: TComponent);
begin
inherited Create(TheOwner);
StopOnException:=True;
end;
destructor TXLIB80.Destroy;
begin
inherited Destroy;
end;
procedure TXLIB80.DoRun;
begin
try
Initialisation;
EnvObject := TEnvironment.Create;
CmdObject := TLibCommandLine.Create;
try
ShowTitle;
if ParamCount > 0 then
begin
// : : :
// Lib80.dostuff
CmdObject.ProcessCommandLine;
case CmdObject.CommandType of
lctAdd: ProcessAdd;
lctList: ProcessList;
lctRemove: ProcessRemove;
otherwise
raise Exception.Create('No command flag specified (-a -l -r)');
end;
end;
finally
FreeAndNil(CmdObject);
FreeAndNil(EnvObject);
end;
except
On E:Exception do
try
WriteLn('EXCEPTION: ' + E.Message);
except
end;
end;
{ add your program here }
// stop program loop
Terminate;
end;
procedure TXLIB80.Initialisation;
begin
// Initialisation stuff here
end;
procedure TXLIB80.ShowHelp;
begin
WriteLn('Usage can be add, list or remove:');
WriteLn;
WriteLn('xlib80 -a libraryname[' + FILETYPE_LIBRARY + '] filename[' + FILETYPE_OBJECT + ']');
WriteLn('xlib80 -l libraryname[' + FILETYPE_LIBRARY + '] modulename');
WriteLn('xlib80 -r libraryname[' + FILETYPE_LIBRARY + '] modulename');
WriteLn;
WriteLn('Filenames can be discrete or wildcards, e.g. ..\source\*.obj80');
WriteLn('Module names can include ? or * for wildcards, e.g. MOD?FLOAT*');
WriteLn('Multiple file or module names can be specified');
WriteLn('Adding a module that already exists will overwrite');
WriteLn;
end;
procedure TXLIB80.ProcessAdd;
var i: integer;
lib: TLib80;
begin
CmdObject.TidyLibraryName(False);
CmdObject.TidyTargetFilenames;
lib := TLib80.Create(CmdObject.LibName);
WriteLn('Adding to library ' + CmdObject.LibName);
try
if CmdObject.Targets.Count = 0 then
WriteLn('No targets to add to library')
else
begin
for i := 0 to CmdObject.Targets.Count-1 do
begin
WriteLn('Adding ' + CmdObject.Targets[i]);
lib.AddFile(CmdObject.Targets[i]);
end;
lib.Save;
end;
finally
FreeAndNil(lib);
end;
end;
procedure TXLIB80.ProcessList;
begin
CmdObject.TidyLibraryName(True);
end;
procedure TXLIB80.ProcessRemove;
begin
CmdObject.TidyLibraryName(True);
end;
procedure TXLIB80.ShowTitle;
begin
WriteLn;
WriteLn('XLIB80 Cross Librarian for x80 processors V' + EnvObject.Version);
WriteLn('Copyright (C)2020-' + COPYRIGHT_YEAR + ' Duncan Munro');
WriteLn;
if ParamCount = 0 then
begin
WriteLn('This program comes with ABSOLUTELY NO WARRANTY');
WriteLn('This is free software, and you are welcome to redistribute it');
WriteLn('under certain conditions');
WriteLn;
ShowHelp;
end;
end;
begin
Application:=TXLIB80.Create(nil);
Application.Title:='XLIB80';
Application.Run;
Application.Free;
end.