mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-04-08 11:48:04 +02:00
+ added support for macos
This commit is contained in:
parent
d7dbd71881
commit
fc8305426b
165
tests/MPWMake
Normal file
165
tests/MPWMake
Normal file
@ -0,0 +1,165 @@
|
||||
# Make file for MPW make.
|
||||
# To run it, use:
|
||||
# Make <target> -f MPWMake > Makeout ; Makeout
|
||||
# where <target> should be replaced with actual make target.
|
||||
|
||||
#Possible options:
|
||||
|
||||
DOTEST = :utils:DoTest
|
||||
|
||||
FPC = ppcppc
|
||||
#OPT
|
||||
|
||||
TEST_FPC = ::compiler:ppcppc
|
||||
TEST_OS_TARGET = macos
|
||||
TEST_CPU_TARGET = powerpc
|
||||
TEST_FULL_TARGET = {TEST_CPU_TARGET}-{TEST_OS_TARGET}
|
||||
#TEST_OPT
|
||||
# Target dir where the ppu and binaries are created:
|
||||
TEST_OUTPUTDIR = :output:{TEST_FULL_TARGET}
|
||||
|
||||
TESTSUBDIRS = : :cg: :cg:cdecl: :units:system: :units:dos: :units:crt: :units:objects: :units:strings: :units:sysutils: :units:math:
|
||||
|
||||
DIRS = :webtbs: :webtbf: :tbs: :tbf: :test: :test:cg: :test:cg:cdecl: :test:units:system: :test:units:dos: :test:units:crt: :test:units:objects: :test:units:strings: :test:units:sysutils: :test:units:math:
|
||||
|
||||
################################
|
||||
# Utilities
|
||||
#
|
||||
:utils:dotest Ä :utils:dotest.pp
|
||||
"{FPC}" -WT "{OPT}" -FE:utils: :utils:dotest.pp
|
||||
|
||||
:utils:digest Ä :utils:digest.pp
|
||||
"{FPC}" -WT "{OPT}" -FE:utils: :utils:digest.pp
|
||||
|
||||
:utils:fail Ä :utils:fail.pp
|
||||
"{FPC}" -WT "{OPT}" -FE:utils: :utils:fail.pp
|
||||
|
||||
:utils:testfail Ä :utils:testfail.pp
|
||||
"{FPC}" -WT "{OPT}" -FE:utils: :utils:testfail.pp
|
||||
|
||||
utils Ä :utils:dotest :utils:digest :utils:fail :utils:testfail
|
||||
|
||||
################################
|
||||
# Units
|
||||
#
|
||||
|
||||
units Ä
|
||||
Set TEMP_FPC `Files -f "{TEST_FPC}"`
|
||||
Directory :units:
|
||||
Make all -f MPWMake -d FPC={TEMP_FPC} -d OPT={TEST_OPT} > Makeout ; Makeout
|
||||
Directory ::
|
||||
|
||||
################################
|
||||
# Copy test environment dependent files ctest.o to test/cg etc
|
||||
#
|
||||
|
||||
copyfiles Ä {TEST_OUTPUTDIR}
|
||||
Duplicate -y :test:cg:obj:{TEST_OS_TARGET}:{TEST_CPU_TARGET}:ctest.o :test:cg
|
||||
Set Exit 0
|
||||
NewFolder {TEST_OUTPUTDIR}:test
|
||||
NewFolder {TEST_OUTPUTDIR}:test:units
|
||||
NewFolder {TEST_OUTPUTDIR}:test:units:system
|
||||
Set Exit 1
|
||||
Duplicate -y :test:units:system:testÅ.txt {TEST_OUTPUTDIR}:test:units:system
|
||||
|
||||
################################
|
||||
# Preparation for tests
|
||||
#
|
||||
|
||||
testprep Ä testprep-stamp.{TEST_FULL_TARGET}
|
||||
|
||||
testprep-stamp.{TEST_FULL_TARGET} Ä {TEST_OUTPUTDIR} utils units copyfiles
|
||||
Echo `Date` > testprep-stamp.{TEST_FULL_TARGET}
|
||||
|
||||
{TEST_OUTPUTDIR} Ä
|
||||
Set Exit 0
|
||||
NewFolder {TEST_OUTPUTDIR}
|
||||
Set Exit 1
|
||||
|
||||
################################
|
||||
# Dotest options
|
||||
#
|
||||
|
||||
################################
|
||||
# Run tests
|
||||
#
|
||||
# Because MPW Make lacks some features, it has to be done as below:
|
||||
#
|
||||
|
||||
allexectest allexectbs allexectbf allexecwebtbs allexecwebtbf Ä testprep
|
||||
(Evaluate "{Targ}" =~ /allexec(Å)¨1/) > Dev:Null
|
||||
#Assembles, links and run tests of FreePascal
|
||||
Set testdir ":{¨1}"
|
||||
#Iterate through tests
|
||||
If {testdir} == :test
|
||||
Set subdirlist "{TESTSUBDIRS}"
|
||||
Else
|
||||
Set subdirlist :
|
||||
End
|
||||
Set Exit 0 # To handle the case, in the for stmt, when there is no match
|
||||
#
|
||||
For subdir In {subdirlist}
|
||||
For sourceWithExt In {testdir}{subdir}tÅ.pp #only test files, which begins with a 't'
|
||||
Set Exit 1 #Revert error handling
|
||||
#
|
||||
(Evaluate "{sourceWithExt}" =~ /(([Â.])*)¨1Å/) > Dev:Null
|
||||
Set apppath {¨1}
|
||||
(Evaluate "{apppath}" =~ /Å:([Â:]*)¨1/) > Dev:Null
|
||||
Set appname {¨1}
|
||||
#
|
||||
If NOT "`Exists :output:powerpc-macos{apppath}.elg`"
|
||||
# Compile and perform the test
|
||||
Echo Testing: "{apppath}"
|
||||
:utils:DoTest {DOTESTOPT} -E -X -C{TEST_FPC} "{apppath}.pp"
|
||||
End
|
||||
Set Exit 0 # To handle the case, in the for stmt, when there is no match
|
||||
End
|
||||
End
|
||||
Set Exit 1 #Revert error handling
|
||||
|
||||
allexectests Ä allexectest allexectbs allexectbf allexecwebtbs allexecwebtbf
|
||||
|
||||
################################
|
||||
# Clean
|
||||
#
|
||||
|
||||
clean_test Ä
|
||||
Set Exit 0 # To handle the case, when there is no match
|
||||
#
|
||||
Delete -y -i {TEST_OUTPUTDIR}
|
||||
#
|
||||
Delete -y -i testÅ.txt Å.tmp core
|
||||
#Delete -y #TODO shared library extension
|
||||
Delete -y -i ppas gmon.out testprep-stamp.*
|
||||
Delete -y -i Å_ppas
|
||||
#
|
||||
Set Exit 1 #Revert error handling
|
||||
|
||||
clean Ä clean_test
|
||||
Directory :units
|
||||
Make clean -f MPWMake > Makeout; Makeout
|
||||
Directory ::
|
||||
|
||||
distclean Ä clean
|
||||
Directory :utils
|
||||
Make clean -f MPWMake > Makeout; Makeout
|
||||
Directory ::
|
||||
|
||||
cleanall Ä clean
|
||||
Set Exit 0 # To handle the case, when there is no match
|
||||
Delete -y :utils:dotest :utils:digest :utils:fail :utils:testfail
|
||||
Set Exit 1 #Revert error handling
|
||||
# Directory :utils
|
||||
# Make cleanall -f MPWMake > Makeout; Makeout
|
||||
# Directory ::
|
||||
|
||||
################################
|
||||
# Main rules
|
||||
#
|
||||
|
||||
digest Ä utils
|
||||
:utils:digest {TEST_OUTPUTDIR}:log
|
||||
|
||||
all Ä allexectests
|
||||
|
||||
full Ä clean allexectests digest
|
40
tests/units/MPWMake
Normal file
40
tests/units/MPWMake
Normal file
@ -0,0 +1,40 @@
|
||||
FPC = ppcppc
|
||||
|
||||
rtl-stamp Ä
|
||||
Set Exit 0
|
||||
NewFolder powerpc-macos
|
||||
Set Exit 1
|
||||
Set TEMP_FPC `Files -f "{FPC}"`
|
||||
Set TEMP_OUTDIR "`Directory`powerpc-macos:"
|
||||
Directory :::rtl:macos
|
||||
Make all -f MPWMake -d FPC={TEMP_FPC} -d REDIR=-FE'"'{TEMP_OUTDIR}'"' -d OPT={OPT} > Makeout ; Makeout
|
||||
Directory :::tests:units
|
||||
Echo Compiled > :rtl-stamp
|
||||
|
||||
rtl Ä rtl-stamp
|
||||
|
||||
:powerpc-macos:erroru.ppu Ä :erroru.pp
|
||||
Set Exit 0
|
||||
NewFolder powerpc-macos
|
||||
Set Exit 1
|
||||
"{FPC}" -FE:powerpc-macos: :erroru.pp
|
||||
|
||||
:powerpc-macos:ptest.ppu Ä ::test:cg:ptest.pp
|
||||
Set Exit 0
|
||||
NewFolder powerpc-macos
|
||||
Set Exit 1
|
||||
"{FPC}" -FE:powerpc-macos: ::test:cg:ptest.pp
|
||||
|
||||
extra Ä :powerpc-macos:erroru.ppu :powerpc-macos:ptest.ppu
|
||||
|
||||
all Ä rtl extra
|
||||
|
||||
|
||||
|
||||
cleanrtlfcl Ä
|
||||
Set Exit 0 # To handle the case, when there is no match
|
||||
Delete -y powerpc-macos
|
||||
Delete -y -i rtl-stamp fcl-stamp
|
||||
Set Exit 1 #Revert error handling
|
||||
|
||||
clean Ä cleanrtlfcl
|
@ -18,6 +18,9 @@
|
||||
program dotest;
|
||||
uses
|
||||
dos,
|
||||
{$ifdef macos}
|
||||
macutils,
|
||||
{$endif}
|
||||
teststr,
|
||||
testu,
|
||||
redir;
|
||||
@ -38,7 +41,11 @@ const
|
||||
{$ifdef UNIX}
|
||||
ExeExt='';
|
||||
{$else UNIX}
|
||||
{$ifdef MACOS}
|
||||
ExeExt='';
|
||||
{$else MACOS}
|
||||
ExeExt='exe';
|
||||
{$endif MACOS}
|
||||
{$endif UNIX}
|
||||
|
||||
var
|
||||
@ -183,7 +190,7 @@ var
|
||||
i : longint;
|
||||
begin
|
||||
i:=Length(s);
|
||||
while (i>0) and not(s[i] in ['/','\']) do
|
||||
while (i>0) and not(s[i] in ['/','\'{$IFDEF MACOS},':'{$ENDIF}]) do
|
||||
dec(i);
|
||||
SplitPath:=Copy(s,1,i);
|
||||
end;
|
||||
@ -225,7 +232,7 @@ var
|
||||
begin
|
||||
if s='' then
|
||||
exit;
|
||||
if s[length(s)] in ['\','/'] then
|
||||
if s[length(s)] in ['\','/'{$IFDEF MACOS},':'{$ENDIF}] then
|
||||
hs:=Copy(s,1,length(s)-1)
|
||||
else
|
||||
hs:=s;
|
||||
@ -432,13 +439,21 @@ end;
|
||||
|
||||
function OutputFileName(Const s,ext:String):String;
|
||||
begin
|
||||
{$ifndef macos}
|
||||
OutputFileName:=OutputDir+'/'+ForceExtension(s,ext);
|
||||
{$else macos}
|
||||
OutputFileName:=ConcatMacPath(OutputDir,ForceExtension(s,ext));
|
||||
{$endif macos}
|
||||
end;
|
||||
|
||||
|
||||
function TestOutputFileName(Const s,ext:String):String;
|
||||
begin
|
||||
{$ifndef macos}
|
||||
TestOutputFileName:=TestOutputDir+'/'+ForceExtension(SplitFileName(s),ext);
|
||||
{$else macos}
|
||||
TestOutputFileName:=ConcatMacPath(TestOutputDir,ForceExtension(SplitFileName(s),ext));
|
||||
{$endif macos}
|
||||
end;
|
||||
|
||||
|
||||
@ -476,6 +491,9 @@ begin
|
||||
RunCompiler:=false;
|
||||
args:='-n -Fu'+RTLUnitsDir;
|
||||
args:=args+' -FE'+TestOutputDir;
|
||||
{$ifdef macos}
|
||||
args:=args+' -WT '; {tests should be compiled as MPWTool}
|
||||
{$endif macos}
|
||||
if ExtraCompilerOpts<>'' then
|
||||
args:=args+ExtraCompilerOpts;
|
||||
{$ifdef unix}
|
||||
@ -488,7 +506,14 @@ begin
|
||||
args:=args+' '+ppfile;
|
||||
Verbose(V_Debug,'Executing '+compilerbin+' '+args);
|
||||
{ also get the output from as and ld that writes to stderr sometimes }
|
||||
{$ifndef macos}
|
||||
execres:=ExecuteRedir(CompilerBin,args,'',CompilerLogFile,'stdout');
|
||||
{$else macos}
|
||||
{Due to that Toolserver is not reentrant, we have to asm and link via script.}
|
||||
execres:=ExecuteRedir(CompilerBin,'-s '+args,'',CompilerLogFile,'stdout');
|
||||
if execres then
|
||||
execres:=ExecuteRedir(TestOutputDir + ':ppas','','',CompilerLogFile,'stdout');
|
||||
{$endif macos}
|
||||
Verbose(V_Debug,'Exitcode '+ToStr(ExecuteResult));
|
||||
|
||||
{ Error during execution? }
|
||||
@ -523,7 +548,7 @@ begin
|
||||
exit;
|
||||
end;
|
||||
|
||||
{ Shoud the compile fail ? }
|
||||
{ Should the compile fail ? }
|
||||
if Config.ShouldFail then
|
||||
begin
|
||||
if ExecuteResult<>0 then
|
||||
@ -782,7 +807,7 @@ var
|
||||
writeln(' -T remove temporary files (executable,ppu,o)');
|
||||
writeln(' -P<path> path to the tests tree on the remote machine');
|
||||
writeln(' -U<remotepara>');
|
||||
writeln(' pass additional parameter to remove program. Multiple -U can be used');
|
||||
writeln(' pass additional parameter to remote program. Multiple -U can be used');
|
||||
writeln(' -V be verbose');
|
||||
writeln(' -W use putty compatible file names when testing (plink and pscp)');
|
||||
writeln(' -Y<opts> extra options passed to the compiler. Several -Y<opt> can be given.');
|
||||
@ -897,10 +922,18 @@ begin
|
||||
begin
|
||||
Res:=GetCompilerCPU;
|
||||
Res:=GetCompilerTarget;
|
||||
{$ifndef MACOS}
|
||||
RTLUnitsDir:='units/'+{$ifdef LIMIT83FS}CompilerTarget{$else}CompilerFullTarget{$endif};
|
||||
{$else MACOS}
|
||||
RTLUnitsDir:=':units:'+CompilerFullTarget;
|
||||
{$endif MACOS}
|
||||
if not PathExists(RTLUnitsDir) then
|
||||
Verbose(V_Abort,'Unit path "'+RTLUnitsDir+'" does not exists');
|
||||
{$ifndef MACOS}
|
||||
OutputDir:='output/'+{$ifdef LIMIT83FS}CompilerTarget{$else}CompilerFullTarget{$endif};
|
||||
{$else MACOS}
|
||||
OutputDir:=':output:'+CompilerFullTarget;
|
||||
{$endif MACOS}
|
||||
if not PathExists(OutputDir) then
|
||||
Verbose(V_Abort,'Output path "'+OutputDir+'" does not exists');
|
||||
{ Global log files }
|
||||
@ -909,11 +942,15 @@ begin
|
||||
FailLogFile:=OutputFileName('faillist','');
|
||||
{ Make subdir in output if needed }
|
||||
PPDir:=SplitPath(PPFile);
|
||||
if PPDir[length(PPDir)] in ['/','\'] then
|
||||
if PPDir[length(PPDir)] in ['/','\'{$ifdef MACOS},':'{$endif MACOS}] then
|
||||
Delete(PPDir,length(PPDir),1);
|
||||
if PPDir<>'' then
|
||||
begin
|
||||
{$ifndef MACOS}
|
||||
TestOutputDir:=OutputDir+'/'+PPDir;
|
||||
{$else MACOS}
|
||||
TestOutputDir:=OutputDir+PPDir;
|
||||
{$endif MACOS}
|
||||
mkdirtree(TestOutputDir);
|
||||
end
|
||||
else
|
||||
@ -1129,7 +1166,10 @@ begin
|
||||
end.
|
||||
{
|
||||
$Log$
|
||||
Revision 1.44 2005-01-06 16:32:04 florian
|
||||
Revision 1.45 2005-01-26 22:05:06 olle
|
||||
+ added support for macos
|
||||
|
||||
Revision 1.44 2005/01/06 16:32:04 florian
|
||||
+ skipemu added
|
||||
|
||||
Revision 1.43 2005/01/01 18:59:52 florian
|
||||
|
@ -43,6 +43,9 @@ Interface
|
||||
{$ifdef BSD}
|
||||
{$define implemented}
|
||||
{$endif}
|
||||
{$ifdef macos}
|
||||
{$define shell_implemented}
|
||||
{$endif}
|
||||
|
||||
{ be sure msdos is not set for FPC compiler }
|
||||
{$ifdef FPC}
|
||||
@ -57,7 +60,7 @@ Var
|
||||
|
||||
{------------------------------------------------------------------------------}
|
||||
procedure InitRedir;
|
||||
function ExecuteRedir (Const ProgName, ComLine, RedirStdIn, RedirStdOut, RedirStdErr : String) : boolean;
|
||||
function ExecuteRedir (Const ProgName, ComLine : String; RedirStdIn, RedirStdOut, RedirStdErr: String): boolean;
|
||||
procedure DosExecute(ProgName, ComLine : String);
|
||||
|
||||
function ChangeRedirOut(Const Redir : String; AppendToFile : Boolean) : Boolean;
|
||||
@ -104,9 +107,15 @@ Const
|
||||
listsep = [';',':'];
|
||||
exeext = '';
|
||||
{$else UNIX}
|
||||
{$ifdef MACOS}
|
||||
DirSep=':';
|
||||
listsep = [','];
|
||||
exeext = '';
|
||||
{$else MACOS}
|
||||
DirSep='\';
|
||||
listsep = [';'];
|
||||
exeext = '.exe';
|
||||
{$endif MACOS}
|
||||
{$endif UNIX}
|
||||
|
||||
|
||||
@ -685,7 +694,7 @@ end;
|
||||
|
||||
{............................................................................}
|
||||
|
||||
function ExecuteRedir (Const ProgName, ComLine, RedirStdIn, RedirStdOut, RedirStdErr : String) : boolean;
|
||||
function ExecuteRedir (Const ProgName, ComLine : String; RedirStdIn, RedirStdOut, RedirStdErr: String): boolean;
|
||||
Begin
|
||||
RedirErrorOut:=0; RedirErrorIn:=0; RedirErrorError:=0;
|
||||
ExecuteResult:=0;
|
||||
@ -787,8 +796,11 @@ begin
|
||||
LocateExeFile:=true;
|
||||
Exit;
|
||||
end;
|
||||
|
||||
{$ifdef macos}
|
||||
S:=GetEnv('Commands');
|
||||
{$else}
|
||||
S:=GetEnv('PATH');
|
||||
{$endif}
|
||||
While Length(S)>0 do
|
||||
begin
|
||||
i:=1;
|
||||
@ -808,24 +820,39 @@ begin
|
||||
end;
|
||||
end;
|
||||
|
||||
function ExecuteRedir (Const ProgName, ComLine, RedirStdIn, RedirStdOut, RedirStdErr: String): boolean;
|
||||
function ExecuteRedir (Const ProgName, ComLine : String; RedirStdIn, RedirStdOut, RedirStdErr: String): boolean;
|
||||
var
|
||||
CmdLine2: string;
|
||||
|
||||
begin
|
||||
{$ifdef macos}
|
||||
if Lowercase(RedirStdIn) = 'stdin' then RedirStdIn := 'Dev:StdIn';
|
||||
if Lowercase(RedirStdOut) = 'stdout' then RedirStdOut := 'Dev:Output';
|
||||
if Lowercase(RedirStdOut) = 'stderr' then RedirStdOut := 'Dev:Error';
|
||||
if Lowercase(RedirStdErr) = 'stdout' then RedirStdErr := 'Dev:Output';
|
||||
if Lowercase(RedirStdErr) = 'stderr' then RedirStdErr := 'Dev:Error';
|
||||
{$endif macos}
|
||||
|
||||
CmdLine2 := ComLine;
|
||||
if RedirStdIn <> '' then CmdLine2 := CmdLine2 + ' < ' + RedirStdIn;
|
||||
if RedirStdOut <> '' then CmdLine2 := CmdLine2 + ' > ' + RedirStdOut;
|
||||
if RedirStdErr <> '' then
|
||||
begin
|
||||
if RedirStdErr = RedirStdOut
|
||||
then CmdLine2 := CmdLine2 + ' 2>&1'
|
||||
else CmdLine2 := CmdLine2 + ' 2> ' + RedirStdErr;
|
||||
{$ifndef macos}
|
||||
if RedirStdErr = RedirStdOut then
|
||||
CmdLine2 := CmdLine2 + ' 2>&1'
|
||||
else
|
||||
CmdLine2 := CmdLine2 + ' 2> ' + RedirStdErr;
|
||||
{$else macos}
|
||||
CmdLine2 := CmdLine2 + ' ' + #179 + ' ' + RedirStdErr; {#179 is "greater or equal" char}
|
||||
{$endif macos}
|
||||
end;
|
||||
DosExecute (ProgName, CmdLine2);
|
||||
ExecuteRedir := true;
|
||||
ExecuteRedir:=(IOStatus=0) and (ExecuteResult=0);
|
||||
end;
|
||||
|
||||
{$ELSE SHELL_IMPLEMENTED}
|
||||
function ExecuteRedir (Const ProgName, ComLine, RedirStdIn, RedirStdOut, RedirStdErr : String) : boolean;
|
||||
function ExecuteRedir (Const ProgName, ComLine : String; RedirStdIn, RedirStdOut, RedirStdErr: String): boolean;
|
||||
begin
|
||||
ExecuteRedir:=false;
|
||||
end;
|
||||
@ -909,7 +936,6 @@ begin
|
||||
end;
|
||||
{$endif not implemented}
|
||||
|
||||
|
||||
{............................................................................}
|
||||
|
||||
procedure DosExecute(ProgName, ComLine : String);
|
||||
@ -951,8 +977,12 @@ end;
|
||||
Dos.Exec (Getenv('COMSPEC'),'/C '+FixPath(progname)+' '+Comline)
|
||||
else
|
||||
begin
|
||||
if LocateExeFile(progname) then
|
||||
if LocateExeFile(progname) then
|
||||
{$ifndef macos}
|
||||
Dos.Exec(ProgName,Comline)
|
||||
{$else}
|
||||
Dos.Exec(''''+ProgName+'''',Comline) {Quotes needed !}
|
||||
{$endif}
|
||||
else
|
||||
DosError:=2;
|
||||
end;
|
||||
@ -987,7 +1017,10 @@ finalization
|
||||
End.
|
||||
{
|
||||
$Log$
|
||||
Revision 1.19 2004-05-25 15:52:48 peter
|
||||
Revision 1.20 2005-01-26 22:05:06 olle
|
||||
+ added support for macos
|
||||
|
||||
Revision 1.19 2004/05/25 15:52:48 peter
|
||||
* executeresult changed to longint instead of word
|
||||
|
||||
Revision 1.18 2004/05/16 20:13:04 peter
|
||||
|
Loading…
Reference in New Issue
Block a user