Преглед на файлове

+ 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 -

pierre преди 13 години
родител
ревизия
88b00552a2
променени са 3 файла, в които са добавени 126 реда и са изтрити 8 реда
  1. 122 7
      tests/utils/dotest.pp
  2. 0 1
      tests/utils/prepup.pp
  3. 4 0
      tests/utils/testu.pp

+ 122 - 7
tests/utils/dotest.pp

@@ -14,6 +14,7 @@
 
 
  **********************************************************************}
  **********************************************************************}
 {$H+}
 {$H+}
+{$mode objfpc}
 {$goto on}
 {$goto on}
 
 
 program dotest;
 program dotest;
@@ -707,9 +708,118 @@ begin
 end;
 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<length(opts)) do
+                    inc(endopt);
+                  Verbose(V_Debug,'Pattern match found "'+currentopt+'*" in "'+opts+'"');
+                  system.delete(opts,optpos,endopt-optpos+1);
+                  Verbose(V_Debug,'After opts="'+opts+'"');
+                end
+              else
+                begin
+                  if (endopt=length(opts)) or (opts[endopt]=' ') then
+                    begin
+                      Verbose(V_Debug,'Exact match found "'+currentopt+'" in "'+opts+'"');
+                      system.delete(opts,optpos,endopt-optpos+1);
+                      Verbose(V_Debug,'After opts="'+opts+'"');
+                    end
+                  else
+                    Verbose(V_Debug,'No exact match "'+currentopt+'" in "'+opts+'"');
+                end;
+
+            end;
+        until optpos=0;
+      end;
+  until pattern='';
+  DelOptions:=opts;
+end;
+
 function RunCompiler:boolean;
 function RunCompiler:boolean;
 var
 var
-  args,
+  args,LocalExtraArgs,
   wpoargs : string;
   wpoargs : string;
   passnr,
   passnr,
   passes  : longint;
   passes  : longint;
@@ -722,8 +832,13 @@ begin
   args:=args+' -FE'+TestOutputDir;
   args:=args+' -FE'+TestOutputDir;
   if TargetIsMacOS then
   if TargetIsMacOS then
     args:=args+' -WT ';  {tests should be compiled as MPWTool}
     args:=args+' -WT ';  {tests should be compiled as MPWTool}
-  if ExtraCompilerOpts<>'' 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
   if TargetIsUnix then
     begin
     begin
       { Add runtime library path to current dir to find .so files }
       { Add runtime library path to current dir to find .so files }
@@ -738,7 +853,7 @@ begin
         end;
         end;
     end;
     end;
   if Config.NeedOptions<>'' then
   if Config.NeedOptions<>'' then
-   args:=args+' '+Config.NeedOptions;
+   AppendOptions(Config.NeedOptions,args);
   wpoargs:='';
   wpoargs:='';
   if (Config.WpoPasses=0) or
   if (Config.WpoPasses=0) or
      (Config.WpoParas='') then
      (Config.WpoParas='') then
@@ -903,7 +1018,7 @@ begin
   close(t);
   close(t);
 end;
 end;
 
 
-function LibraryExists(const PPFile : string; var FileName : string) : boolean;
+function LibraryExists(const PPFile : string; out FileName : string) : boolean;
 begin
 begin
    { Check if a dynamic library XXX was created }
    { Check if a dynamic library XXX was created }
    { Windows XXX.dll style }
    { Windows XXX.dll style }
@@ -950,7 +1065,7 @@ begin
     end;
     end;
   LibraryExists:=false;
   LibraryExists:=false;
 end;
 end;
-function ExecuteRemote(const prog,args:string;var StartTicks,EndTicks : int64):boolean;
+function ExecuteRemote(const prog,args:string;out StartTicks,EndTicks : int64):boolean;
 const
 const
   MaxTrials = 5;
   MaxTrials = 5;
 var
 var
@@ -980,7 +1095,7 @@ begin
   ExecuteRemote:=res;
   ExecuteRemote:=res;
 end;
 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
 begin
   Verbose(V_Debug,'EmulatorExecuting '+Prog+' '+args);
   Verbose(V_Debug,'EmulatorExecuting '+Prog+' '+args);
   StartTicks:=GetMicroSTicks;
   StartTicks:=GetMicroSTicks;

+ 0 - 1
tests/utils/prepup.pp

@@ -30,7 +30,6 @@ procedure dosearch(const dir : string);
     Var
     Var
       Info : TSearchRec;
       Info : TSearchRec;
       hs : string;
       hs : string;
-      i : integer;
     begin
     begin
       If FindFirst (dir+DirectorySeparator+s,faAnyFile,Info)=0 then
       If FindFirst (dir+DirectorySeparator+s,faAnyFile,Info)=0 then
         begin
         begin

+ 4 - 0
tests/utils/testu.pp

@@ -14,6 +14,7 @@ type
 
 
   TConfig = record
   TConfig = record
     NeedOptions,
     NeedOptions,
+    DelOptions,
     NeedCPU,
     NeedCPU,
     SkipCPU,
     SkipCPU,
     SkipEmu,
     SkipEmu,
@@ -174,6 +175,9 @@ begin
               delete(s,1,1);
               delete(s,1,1);
               if GetEntry('OPT') then
               if GetEntry('OPT') then
                r.NeedOptions:=res
                r.NeedOptions:=res
+              else
+               if GetEntry('DELOPT') then
+                r.DelOptions:=res
               else
               else
                if GetEntry('TARGET') then
                if GetEntry('TARGET') then
                 r.NeedTarget:=res
                 r.NeedTarget:=res