From 88b00552a232affe4ac1c04a09dba3b3d046ee98 Mon Sep 17 00:00:00 2001 From: pierre Date: Tue, 27 Mar 2012 14:26:24 +0000 Subject: [PATCH] + Add support for target specific options example: %OPT=-gl win32%-WN if % is found in OPT list, the string after % is only added to the compiler options if current target is contained in the list of the string before the % sign. + Add %DELOPT dotest option. can be used in two variants %DELOPT=-Crio will suppress -Criot from TEST_OPT if it appears exactly (-Criot will not match). %DELOPT=-C* will suppress all options starting with -C. git-svn-id: trunk@20640 - --- tests/utils/dotest.pp | 129 +++++++++++++++++++++++++++++++++++++++--- tests/utils/prepup.pp | 1 - tests/utils/testu.pp | 4 ++ 3 files changed, 126 insertions(+), 8 deletions(-) diff --git a/tests/utils/dotest.pp b/tests/utils/dotest.pp index e585f65138..0232d2053b 100644 --- a/tests/utils/dotest.pp +++ b/tests/utils/dotest.pp @@ -14,6 +14,7 @@ **********************************************************************} {$H+} +{$mode objfpc} {$goto on} program dotest; @@ -707,9 +708,118 @@ begin end; +{ Takes each option from AddOptions list + considered as a space separated list + and adds the option to args + unless option contains a percent sign, + in that case, the option after % will be added + to args only if CompilerTarget is listed in + the string part before %. + NOTE: this function does not check for + quoted options... + The list before % must of course contain no spaces. } + +procedure AppendOptions(AddOptions : string;var args : string); +var + endopt,percentpos : longint; + opttarget, currentopt : string; +begin + Verbose(V_Debug,'AppendOptions called with AddOptions="'+AddOptions+'"'); + AddOptions:=trimspace(AddOptions); + repeat + endopt:=pos(' ',AddOptions); + if endopt=0 then + endopt:=length(AddOptions); + currentopt:=trimspace(copy(AddOptions,1,endopt)); + AddOptions:=trimspace(copy(Addoptions,endopt+1,length(AddOptions))); + if currentopt<>'' then + begin + percentpos:=pos('%',currentopt); + if (percentpos=0) then + begin + Verbose(V_Debug,'Adding option="'+currentopt+'"'); + args:=args+' '+currentopt; + end + else + begin + opttarget:=lowercase(copy(currentopt,1,percentpos-1)); + if IsInList(CompilerTarget, opttarget) then + begin + Verbose(V_Debug,'Adding target specific option="'+currentopt+'" for '+opttarget); + args:=args+' '+copy(currentopt,percentpos+1,length(currentopt)) + end + else + Verbose(V_Debug,'No matching target "'+currentopt+'"'); + end; + end; + until AddOptions=''; +end; + +{ This function removes some incompatible + options from TEST_OPT before adding them to + the list of options passed to the compiler. + %DELOPT=XYZ will remove XYZ exactly + %DELOPT=XYZ* will remove all options starting with XYZ. + NOTE: This fuinction does not handle quoted options. } +function DelOptions(Pattern, opts : string) : string; +var + currentopt : string; + optpos, endopt, endpos : longint; + iswild : boolean; +begin + opts:=trimspace(opts); + pattern:=trimspace(pattern); + repeat + endpos:=pos(' ',pattern); + if endpos=0 then + endpos:=length(pattern); + currentopt:=trimspace(copy(pattern,1,endpos)); + pattern:=trimspace(copy(pattern,endpos+1,length(pattern))); + if currentopt<>'' then + begin + if currentopt[length(currentopt)]='*' then + begin + iswild:=true; + system.delete(currentopt,length(currentopt),1); + end + else + iswild:=false; + repeat + optpos:=pos(currentopt,opts); + if optpos>0 then + begin + endopt:=optpos+length(currentopt); + if iswild then + begin + while (opts[endopt]<>' ') and + (endopt'' then - args:=args+ExtraCompilerOpts; + if Config.DelOptions<>'' then + LocalExtraArgs:=DelOptions(Config.DelOptions,ExtraCompilerOpts) + else + LocalExtraArgs:=ExtraCompilerOpts; + + if LocalExtraArgs<>'' then + args:=args+' '+LocalExtraArgs; if TargetIsUnix then begin { Add runtime library path to current dir to find .so files } @@ -738,7 +853,7 @@ begin end; end; if Config.NeedOptions<>'' then - args:=args+' '+Config.NeedOptions; + AppendOptions(Config.NeedOptions,args); wpoargs:=''; if (Config.WpoPasses=0) or (Config.WpoParas='') then @@ -903,7 +1018,7 @@ begin close(t); end; -function LibraryExists(const PPFile : string; var FileName : string) : boolean; +function LibraryExists(const PPFile : string; out FileName : string) : boolean; begin { Check if a dynamic library XXX was created } { Windows XXX.dll style } @@ -950,7 +1065,7 @@ begin end; LibraryExists:=false; end; -function ExecuteRemote(const prog,args:string;var StartTicks,EndTicks : int64):boolean; +function ExecuteRemote(const prog,args:string;out StartTicks,EndTicks : int64):boolean; const MaxTrials = 5; var @@ -980,7 +1095,7 @@ begin ExecuteRemote:=res; end; -function ExecuteEmulated(const prog,args,FullExeLogFile:string;var StartTicks,EndTicks : int64):boolean; +function ExecuteEmulated(const prog,args,FullExeLogFile:string;out StartTicks,EndTicks : int64):boolean; begin Verbose(V_Debug,'EmulatorExecuting '+Prog+' '+args); StartTicks:=GetMicroSTicks; diff --git a/tests/utils/prepup.pp b/tests/utils/prepup.pp index 2f5480a42c..8b6408053f 100644 --- a/tests/utils/prepup.pp +++ b/tests/utils/prepup.pp @@ -30,7 +30,6 @@ procedure dosearch(const dir : string); Var Info : TSearchRec; hs : string; - i : integer; begin If FindFirst (dir+DirectorySeparator+s,faAnyFile,Info)=0 then begin diff --git a/tests/utils/testu.pp b/tests/utils/testu.pp index 4b5611702b..ae35da6e26 100644 --- a/tests/utils/testu.pp +++ b/tests/utils/testu.pp @@ -14,6 +14,7 @@ type TConfig = record NeedOptions, + DelOptions, NeedCPU, SkipCPU, SkipEmu, @@ -174,6 +175,9 @@ begin delete(s,1,1); if GetEntry('OPT') then r.NeedOptions:=res + else + if GetEntry('DELOPT') then + r.DelOptions:=res else if GetEntry('TARGET') then r.NeedTarget:=res