3 Copyright (c) 1998-2000 by Peter Vreman
5 This unit handles the writing of script files
7 This program is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 2 of the License, or
10 (at your option) any later version.
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with this program; if not, write to the Free Software
19 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
21 ****************************************************************************
35 constructor Init(const s
:string);
36 constructor InitExec(const s
:string);
38 procedure AddStart(const s
:string);
39 procedure Add(const s
:string);
40 Function Empty
:boolean;
41 procedure WriteToDisk
;virtual;
44 PAsmScript
= ^TAsmScript
;
45 TAsmScript
= Object (TScript
)
46 Constructor Init (Const ScriptName
: String);
47 Procedure AddAsmCommand (Const Command
, Options
,FileName
: String);
48 Procedure AddLinkCommand (Const Command
, Options
, FileName
: String);
49 Procedure AddDeleteCommand (Const FileName
: String);
50 Procedure WriteToDisk
;virtual;
54 TLinkRes
= Object (TScript
)
55 procedure Add(const s
:string);
56 procedure AddFileName(const s
:string);
73 {****************************************************************************
75 ****************************************************************************}
77 constructor TScript
.Init(const s
:string);
85 constructor TScript
.InitExec(const s
:string);
87 fn
:=FixFileName(s
)+source_os
.scriptext
;
93 destructor TScript
.Done
;
99 procedure TScript
.AddStart(const s
:string);
105 procedure TScript
.Add(const s
:string);
111 Function TScript
.Empty
:boolean;
117 procedure TScript
.WriteToDisk
;
123 while not data
.Empty
do
133 {****************************************************************************
135 ****************************************************************************}
137 Constructor TAsmScript
.Init (Const ScriptName
: String);
139 Inherited InitExec(ScriptName
);
143 Procedure TAsmScript
.AddAsmCommand (Const Command
, Options
,FileName
: String);
147 Add('echo Assembling '+FileName
);
148 Add (Command
+' '+Options
);
149 Add('if [ $? != 0 ]; then DoExitAsm '+FileName
+'; fi');
153 Add('SET THEFILE='+FileName
);
154 Add('echo Assembling %THEFILE%');
156 Add(command
+' '+Options
);
157 Add('if errorlevel 1 goto asmend');
162 Procedure TasmScript
.AddLinkCommand (Const Command
, Options
, FileName
: String);
166 Add('echo Linking '+FileName
);
167 Add (Command
+' '+Options
);
168 Add('if [ $? != 0 ]; then DoExitLink '+FileName
+'; fi');
172 Add('SET THEFILE='+FileName
);
173 Add('echo Linking %THEFILE%');
175 Add (Command
+' '+Options
);
176 Add('if errorlevel 1 goto linkend');
181 Procedure TAsmScript
.AddDeleteCommand (Const FileName
: String);
186 Add('Del '+FileName
);
191 Procedure TAsmScript
.WriteToDisk
;
194 AddStart('{ echo "An error occurred while linking $1"; exit 1; }');
195 AddStart('DoExitLink ()');
196 AddStart('{ echo "An error occurred while assembling $1"; exit 1; }');
197 AddStart('DoExitAsm ()');
198 AddStart('#!/bin/sh');
200 AddStart('@echo off');
203 Add('echo An error occured while assembling %THEFILE%');
206 Add('echo An error occured while linking %THEFILE%');
209 inherited WriteToDisk
;
213 {****************************************************************************
215 ****************************************************************************}
217 procedure TLinkRes
.Add(const s
:string);
223 procedure TLinkRes
.AddFileName(const s
:string);
227 if not(s
[1] in ['a'..'z','A'..'Z','/','\','.']) then
228 inherited Add('.'+DirSep
+s
)
237 Revision 1.1 2002/02/19 08:23:48 sasu
240 Revision 1.1 2000/07/13 06:29:56 michael
243 Revision 1.6 2000/02/09 13:23:04 peter
246 Revision 1.5 2000/02/07 11:52:26 michael
249 Revision 1.4 2000/01/07 01:14:39 peter
250 * updated copyright to 2000
252 Revision 1.3 1999/10/21 14:29:37 peter
253 * redesigned linker object
254 + library support for linux (only procedures can be exported)