|
@@ -24,14 +24,16 @@ unit script;
|
|
|
{$i fpcdefs.inc}
|
|
|
|
|
|
interface
|
|
|
-
|
|
|
+{$H+}
|
|
|
uses
|
|
|
+ sysutils,
|
|
|
+ globtype,
|
|
|
cclasses;
|
|
|
|
|
|
type
|
|
|
TScript=class
|
|
|
fn : string[100];
|
|
|
- data : TStringList;
|
|
|
+ data : TCmdStrList;
|
|
|
executable : boolean;
|
|
|
constructor Create(const s:string);
|
|
|
constructor CreateExec(const s:string);
|
|
@@ -44,61 +46,61 @@ type
|
|
|
|
|
|
TAsmScript = class (TScript)
|
|
|
Constructor Create(Const ScriptName : String); virtual;
|
|
|
- Procedure AddAsmCommand (Const Command, Options,FileName : String);virtual;abstract;
|
|
|
- Procedure AddLinkCommand (Const Command, Options, FileName : String);virtual;abstract;
|
|
|
- Procedure AddDeleteCommand (Const FileName : String);virtual;abstract;
|
|
|
- Procedure AddDeleteDirCommand (Const FileName : String);virtual;abstract;
|
|
|
+ Procedure AddAsmCommand (Const Command, Options,FileName : TCmdStr);virtual;abstract;
|
|
|
+ Procedure AddLinkCommand (Const Command, Options, FileName : TCmdStr);virtual;abstract;
|
|
|
+ Procedure AddDeleteCommand (Const FileName : TCmdStr);virtual;abstract;
|
|
|
+ Procedure AddDeleteDirCommand (Const FileName : TCmdStr);virtual;abstract;
|
|
|
end;
|
|
|
|
|
|
TAsmScriptDos = class (TAsmScript)
|
|
|
- Constructor Create (Const ScriptName : String); override;
|
|
|
- Procedure AddAsmCommand (Const Command, Options,FileName : String);override;
|
|
|
- Procedure AddLinkCommand (Const Command, Options, FileName : String);override;
|
|
|
- Procedure AddDeleteCommand (Const FileName : String);override;
|
|
|
- Procedure AddDeleteDirCommand (Const FileName : String);override;
|
|
|
+ Constructor Create (Const ScriptName : TCmdStr); override;
|
|
|
+ Procedure AddAsmCommand (Const Command, Options,FileName : TCmdStr);override;
|
|
|
+ Procedure AddLinkCommand (Const Command, Options, FileName : TCmdStr);override;
|
|
|
+ Procedure AddDeleteCommand (Const FileName : TCmdStr);override;
|
|
|
+ Procedure AddDeleteDirCommand (Const FileName : TCmdStr);override;
|
|
|
Procedure WriteToDisk;override;
|
|
|
end;
|
|
|
|
|
|
TAsmScriptAmiga = class (TAsmScript)
|
|
|
Constructor Create (Const ScriptName : String); override;
|
|
|
- Procedure AddAsmCommand (Const Command, Options,FileName : String);override;
|
|
|
- Procedure AddLinkCommand (Const Command, Options, FileName : String);override;
|
|
|
- Procedure AddDeleteCommand (Const FileName : String);override;
|
|
|
- Procedure AddDeleteDirCommand (Const FileName : String);override;
|
|
|
+ Procedure AddAsmCommand (Const Command, Options,FileName : TCmdStr);override;
|
|
|
+ Procedure AddLinkCommand (Const Command, Options, FileName : TCmdStr);override;
|
|
|
+ Procedure AddDeleteCommand (Const FileName : TCmdStr);override;
|
|
|
+ Procedure AddDeleteDirCommand (Const FileName : TCmdStr);override;
|
|
|
Procedure WriteToDisk;override;
|
|
|
end;
|
|
|
|
|
|
TAsmScriptUnix = class (TAsmScript)
|
|
|
Constructor Create (Const ScriptName : String);override;
|
|
|
- Procedure AddAsmCommand (Const Command, Options,FileName : String);override;
|
|
|
- Procedure AddLinkCommand (Const Command, Options, FileName : String);override;
|
|
|
- Procedure AddDeleteCommand (Const FileName : String);override;
|
|
|
- Procedure AddDeleteDirCommand (Const FileName : String);override;
|
|
|
+ Procedure AddAsmCommand (Const Command, Options,FileName : TCmdStr);override;
|
|
|
+ Procedure AddLinkCommand (Const Command, Options, FileName : TCmdStr);override;
|
|
|
+ Procedure AddDeleteCommand (Const FileName : TCmdStr);override;
|
|
|
+ Procedure AddDeleteDirCommand (Const FileName : TCmdStr);override;
|
|
|
Procedure WriteToDisk;override;
|
|
|
end;
|
|
|
|
|
|
TAsmScriptMPW = class (TAsmScript)
|
|
|
- Constructor Create (Const ScriptName : String); override;
|
|
|
- Procedure AddAsmCommand (Const Command, Options,FileName : String);override;
|
|
|
- Procedure AddLinkCommand (Const Command, Options, FileName : String);override;
|
|
|
- Procedure AddDeleteCommand (Const FileName : String);override;
|
|
|
- Procedure AddDeleteDirCommand (Const FileName : String);override;
|
|
|
+ Constructor Create (Const ScriptName : TCmdStr); override;
|
|
|
+ Procedure AddAsmCommand (Const Command, Options,FileName : TCmdStr);override;
|
|
|
+ Procedure AddLinkCommand (Const Command, Options, FileName : TCmdStr);override;
|
|
|
+ Procedure AddDeleteCommand (Const FileName : TCmdStr);override;
|
|
|
+ Procedure AddDeleteDirCommand (Const FileName : TCmdStr);override;
|
|
|
Procedure WriteToDisk;override;
|
|
|
end;
|
|
|
|
|
|
TLinkRes = Class (TScript)
|
|
|
section: string[30];
|
|
|
- procedure Add(const s:string);
|
|
|
- procedure AddFileName(const s:string);
|
|
|
- procedure EndSection(const s:string);
|
|
|
- procedure StartSection(const s:string);
|
|
|
+ procedure Add(const s:ansistring);
|
|
|
+ procedure AddFileName(const s:ansistring);
|
|
|
+ procedure EndSection(const s:ansistring);
|
|
|
+ procedure StartSection(const s:ansistring);
|
|
|
end;
|
|
|
|
|
|
var
|
|
|
AsmRes : TAsmScript;
|
|
|
|
|
|
-Function ScriptFixFileName(const s:string):string;
|
|
|
-Procedure GenerateAsmRes(const st : string);
|
|
|
+Function ScriptFixFileName(const s:TCmdStr):TCmdStr;
|
|
|
+Procedure GenerateAsmRes(const st : TCmdStr);
|
|
|
|
|
|
|
|
|
implementation
|
|
@@ -107,16 +109,15 @@ uses
|
|
|
{$ifdef hasUnix}
|
|
|
BaseUnix,
|
|
|
{$endif}
|
|
|
- SysUtils,
|
|
|
cutils,cfileutils,
|
|
|
- globtype,globals,systems,verbose;
|
|
|
+ globals,systems,verbose;
|
|
|
|
|
|
|
|
|
{****************************************************************************
|
|
|
Helpers
|
|
|
****************************************************************************}
|
|
|
|
|
|
- Function ScriptFixFileName(const s:string):string;
|
|
|
+ Function ScriptFixFileName(const s:TCmdStr):TCmdStr;
|
|
|
begin
|
|
|
if cs_link_on_target in current_settings.globalswitches then
|
|
|
ScriptFixFileName:=TargetFixFileName(s)
|
|
@@ -128,15 +129,15 @@ uses
|
|
|
TScript
|
|
|
****************************************************************************}
|
|
|
|
|
|
-constructor TScript.Create(const s:string);
|
|
|
+constructor TScript.Create(const s: TCmdStr);
|
|
|
begin
|
|
|
fn:=FixFileName(s);
|
|
|
executable:=false;
|
|
|
- data:=TStringList.Create;
|
|
|
+ data:=TCmdStrList.Create;
|
|
|
end;
|
|
|
|
|
|
|
|
|
-constructor TScript.CreateExec(const s:string);
|
|
|
+constructor TScript.CreateExec(const s:TCmdStr);
|
|
|
begin
|
|
|
fn:=FixFileName(s);
|
|
|
if cs_link_on_target in current_settings.globalswitches then
|
|
@@ -144,7 +145,7 @@ begin
|
|
|
else
|
|
|
fn:=ChangeFileExt(fn,source_info.scriptext);
|
|
|
executable:=true;
|
|
|
- data:=TStringList.Create;
|
|
|
+ data:=TCmdStrList.Create;
|
|
|
end;
|
|
|
|
|
|
|
|
@@ -154,13 +155,13 @@ begin
|
|
|
end;
|
|
|
|
|
|
|
|
|
-procedure TScript.AddStart(const s:string);
|
|
|
+procedure TScript.AddStart(const s:TCmdStr);
|
|
|
begin
|
|
|
data.Insert(s);
|
|
|
end;
|
|
|
|
|
|
|
|
|
-procedure TScript.Add(const s:string);
|
|
|
+procedure TScript.Add(const s:TCmdStr);
|
|
|
begin
|
|
|
data.Concat(s);
|
|
|
end;
|
|
@@ -175,7 +176,7 @@ procedure TScript.WriteToDisk;
|
|
|
var
|
|
|
t : file;
|
|
|
i : longint;
|
|
|
- s : string;
|
|
|
+ s : ansistring;
|
|
|
le: string[2];
|
|
|
|
|
|
begin
|
|
@@ -208,7 +209,7 @@ end;
|
|
|
Asm Response
|
|
|
****************************************************************************}
|
|
|
|
|
|
-Constructor TAsmScript.Create (Const ScriptName : String);
|
|
|
+Constructor TAsmScript.Create (Const ScriptName : TCmdStr);
|
|
|
begin
|
|
|
Inherited CreateExec(ScriptName);
|
|
|
end;
|
|
@@ -218,13 +219,13 @@ end;
|
|
|
DOS Asm Response
|
|
|
****************************************************************************}
|
|
|
|
|
|
-Constructor TAsmScriptDos.Create (Const ScriptName : String);
|
|
|
+Constructor TAsmScriptDos.Create (Const ScriptName : TCmdStr);
|
|
|
begin
|
|
|
Inherited Create(ScriptName);
|
|
|
end;
|
|
|
|
|
|
|
|
|
-Procedure TAsmScriptDos.AddAsmCommand (Const Command, Options,FileName : String);
|
|
|
+Procedure TAsmScriptDos.AddAsmCommand (Const Command, Options,FileName : TCmdStr);
|
|
|
begin
|
|
|
if FileName<>'' then
|
|
|
begin
|
|
@@ -236,7 +237,7 @@ begin
|
|
|
end;
|
|
|
|
|
|
|
|
|
-Procedure TAsmScriptDos.AddLinkCommand (Const Command, Options, FileName : String);
|
|
|
+Procedure TAsmScriptDos.AddLinkCommand (Const Command, Options, FileName : TCmdStr);
|
|
|
begin
|
|
|
if FileName<>'' then
|
|
|
begin
|
|
@@ -248,13 +249,13 @@ begin
|
|
|
end;
|
|
|
|
|
|
|
|
|
-Procedure TAsmScriptDos.AddDeleteCommand (Const FileName : String);
|
|
|
+Procedure TAsmScriptDos.AddDeleteCommand (Const FileName : TCmdStr);
|
|
|
begin
|
|
|
Add('Del ' + MaybeQuoted (ScriptFixFileName (FileName)));
|
|
|
end;
|
|
|
|
|
|
|
|
|
-Procedure TAsmScriptDos.AddDeleteDirCommand (Const FileName : String);
|
|
|
+Procedure TAsmScriptDos.AddDeleteDirCommand (Const FileName : TCmdStr);
|
|
|
begin
|
|
|
Add('Rmdir ' + MaybeQuoted (ScriptFixFileName (FileName)));
|
|
|
end;
|
|
@@ -282,21 +283,21 @@ end;
|
|
|
|
|
|
{$IF DEFINED(MORPHOS) OR DEFINED(AMIGA)}
|
|
|
{ * PathConv is implemented in the system unit! * }
|
|
|
-function PathConv(path: string): string; external name 'PATHCONV';
|
|
|
+function PathConv(path: TCmdStr): TCmdStr; external name 'PATHCONV';
|
|
|
{$ELSE}
|
|
|
-function PathConv(path: string): string;
|
|
|
+function PathConv(path: TCmdStr): TCmdStr;
|
|
|
begin
|
|
|
PathConv:=path;
|
|
|
end;
|
|
|
{$ENDIF}
|
|
|
|
|
|
-Constructor TAsmScriptAmiga.Create (Const ScriptName : String);
|
|
|
+Constructor TAsmScriptAmiga.Create (Const ScriptName : TCmdStr);
|
|
|
begin
|
|
|
Inherited Create(ScriptName);
|
|
|
end;
|
|
|
|
|
|
|
|
|
-Procedure TAsmScriptAmiga.AddAsmCommand (Const Command, Options,FileName : String);
|
|
|
+Procedure TAsmScriptAmiga.AddAsmCommand (Const Command, Options,FileName : TCmdStr);
|
|
|
begin
|
|
|
if FileName<>'' then
|
|
|
begin
|
|
@@ -313,7 +314,7 @@ begin
|
|
|
end;
|
|
|
|
|
|
|
|
|
-Procedure TAsmScriptAmiga.AddLinkCommand (Const Command, Options, FileName : String);
|
|
|
+Procedure TAsmScriptAmiga.AddLinkCommand (Const Command, Options, FileName : TCmdStr);
|
|
|
begin
|
|
|
if FileName<>'' then
|
|
|
begin
|
|
@@ -327,13 +328,13 @@ begin
|
|
|
end;
|
|
|
|
|
|
|
|
|
-Procedure TAsmScriptAmiga.AddDeleteCommand (Const FileName : String);
|
|
|
+Procedure TAsmScriptAmiga.AddDeleteCommand (Const FileName : TCmdStr);
|
|
|
begin
|
|
|
Add('Delete ' + PathConv(MaybeQuoted(ScriptFixFileName(FileName))) + ' Quiet');
|
|
|
end;
|
|
|
|
|
|
|
|
|
-Procedure TAsmScriptAmiga.AddDeleteDirCommand (Const FileName : String);
|
|
|
+Procedure TAsmScriptAmiga.AddDeleteDirCommand (Const FileName : TCmdStr);
|
|
|
begin
|
|
|
Add('Delete ' + PathConv(MaybeQuoted(ScriptFixFileName(FileName))) + ' All Quiet');
|
|
|
end;
|
|
@@ -358,13 +359,13 @@ end;
|
|
|
Unix Asm Response
|
|
|
****************************************************************************}
|
|
|
|
|
|
-Constructor TAsmScriptUnix.Create (Const ScriptName : String);
|
|
|
+Constructor TAsmScriptUnix.Create (Const ScriptName : TCmdStr);
|
|
|
begin
|
|
|
Inherited Create(ScriptName);
|
|
|
end;
|
|
|
|
|
|
|
|
|
-Procedure TAsmScriptUnix.AddAsmCommand (Const Command, Options,FileName : String);
|
|
|
+Procedure TAsmScriptUnix.AddAsmCommand (Const Command, Options,FileName : TCmdStr);
|
|
|
begin
|
|
|
if FileName<>'' then
|
|
|
Add('echo Assembling '+ScriptFixFileName(FileName));
|
|
@@ -373,7 +374,7 @@ begin
|
|
|
end;
|
|
|
|
|
|
|
|
|
-Procedure TAsmScriptUnix.AddLinkCommand (Const Command, Options, FileName : String);
|
|
|
+Procedure TAsmScriptUnix.AddLinkCommand (Const Command, Options, FileName : TCmdStr);
|
|
|
begin
|
|
|
if FileName<>'' then
|
|
|
Add('echo Linking '+ScriptFixFileName(FileName));
|
|
@@ -382,13 +383,13 @@ begin
|
|
|
end;
|
|
|
|
|
|
|
|
|
-Procedure TAsmScriptUnix.AddDeleteCommand (Const FileName : String);
|
|
|
+Procedure TAsmScriptUnix.AddDeleteCommand (Const FileName : TCmdStr);
|
|
|
begin
|
|
|
Add('rm ' + MaybeQuoted (ScriptFixFileName(FileName)));
|
|
|
end;
|
|
|
|
|
|
|
|
|
-Procedure TAsmScriptUnix.AddDeleteDirCommand (Const FileName : String);
|
|
|
+Procedure TAsmScriptUnix.AddDeleteDirCommand (Const FileName : TCmdStr);
|
|
|
begin
|
|
|
Add('rmdir ' + MaybeQuoted (ScriptFixFileName(FileName)));
|
|
|
end;
|
|
@@ -413,13 +414,13 @@ end;
|
|
|
MPW (MacOS) Asm Response
|
|
|
****************************************************************************}
|
|
|
|
|
|
-Constructor TAsmScriptMPW.Create (Const ScriptName : String);
|
|
|
+Constructor TAsmScriptMPW.Create (Const ScriptName : TCmdStr);
|
|
|
begin
|
|
|
Inherited Create(ScriptName);
|
|
|
end;
|
|
|
|
|
|
|
|
|
-Procedure TAsmScriptMPW.AddAsmCommand (Const Command, Options,FileName : String);
|
|
|
+Procedure TAsmScriptMPW.AddAsmCommand (Const Command, Options,FileName : TCmdStr);
|
|
|
begin
|
|
|
if FileName<>'' then
|
|
|
Add('Echo Assembling '+ScriptFixFileName(FileName));
|
|
@@ -428,7 +429,7 @@ begin
|
|
|
end;
|
|
|
|
|
|
|
|
|
-Procedure TAsmScriptMPW.AddLinkCommand (Const Command, Options, FileName : String);
|
|
|
+Procedure TAsmScriptMPW.AddLinkCommand (Const Command, Options, FileName : TCmdStr);
|
|
|
begin
|
|
|
if FileName<>'' then
|
|
|
Add('Echo Linking '+ScriptFixFileName(FileName));
|
|
@@ -444,13 +445,13 @@ begin
|
|
|
end;
|
|
|
|
|
|
|
|
|
-Procedure TAsmScriptMPW.AddDeleteCommand (Const FileName : String);
|
|
|
+Procedure TAsmScriptMPW.AddDeleteCommand (Const FileName : TCmdStr);
|
|
|
begin
|
|
|
Add('Delete ' + MaybeQuoted (ScriptFixFileName(FileName)));
|
|
|
end;
|
|
|
|
|
|
|
|
|
-Procedure TAsmScriptMPW.AddDeleteDirCommand (Const FileName : String);
|
|
|
+Procedure TAsmScriptMPW.AddDeleteDirCommand (Const FileName : TCmdStr);
|
|
|
begin
|
|
|
Add('Delete ' + MaybeQuoted (ScriptFixFileName (FileName)));
|
|
|
end;
|
|
@@ -465,7 +466,7 @@ end;
|
|
|
|
|
|
|
|
|
|
|
|
-Procedure GenerateAsmRes(const st : string);
|
|
|
+Procedure GenerateAsmRes(const st : TCmdStr);
|
|
|
var
|
|
|
scripttyp : tscripttype;
|
|
|
begin
|
|
@@ -490,13 +491,13 @@ end;
|
|
|
Link Response
|
|
|
****************************************************************************}
|
|
|
|
|
|
-procedure TLinkRes.Add(const s:string);
|
|
|
+procedure TLinkRes.Add(const s:TCmdStr);
|
|
|
begin
|
|
|
if s<>'' then
|
|
|
inherited Add(s);
|
|
|
end;
|
|
|
|
|
|
-procedure TLinkRes.AddFileName(const s:string);
|
|
|
+procedure TLinkRes.AddFileName(const s:TCmdStr);
|
|
|
begin
|
|
|
if section<>'' then
|
|
|
begin
|
|
@@ -517,7 +518,7 @@ begin
|
|
|
end;
|
|
|
end;
|
|
|
|
|
|
-procedure TLinkRes.EndSection(const s:string);
|
|
|
+procedure TLinkRes.EndSection(const s:TCmdStr);
|
|
|
begin
|
|
|
{ only terminate if we started the section }
|
|
|
if section='' then
|
|
@@ -525,7 +526,7 @@ begin
|
|
|
section:='';
|
|
|
end;
|
|
|
|
|
|
-procedure TLinkRes.StartSection(const s:string);
|
|
|
+procedure TLinkRes.StartSection(const s:TCmdStr);
|
|
|
begin
|
|
|
section:=s;
|
|
|
end;
|