Browse Source

* Added option to pass options to the compiler

git-svn-id: trunk@15873 -
joost 15 years ago
parent
commit
db2d55128c
3 changed files with 58 additions and 9 deletions
  1. 33 9
      utils/fppkg/fppkg.pp
  2. 2 0
      utils/fppkg/pkgfpmake.pp
  3. 23 0
      utils/fppkg/pkgoptions.pp

+ 33 - 9
utils/fppkg/fppkg.pp

@@ -168,15 +168,16 @@ procedure TMakeTool.ShowUsage;
 begin
 begin
   Writeln('Usage: ',Paramstr(0),' [options] <action> <package>');
   Writeln('Usage: ',Paramstr(0),' [options] <action> <package>');
   Writeln('Options:');
   Writeln('Options:');
-  Writeln('  -c --config       Set compiler configuration to use');
-  Writeln('  -h --help         This help');
-  Writeln('  -v --verbose      Show more information');
-  Writeln('  -d --debug        Show debugging information');
-  Writeln('  -g --global       Force installation to global (system-wide) directory');
-  Writeln('  -f --force        Force installation also if the package is already installed');
-  Writeln('  -r --recovery     Recovery mode, use always internal fpmkunit');
-  Writeln('  -b --broken       Do not stop on broken packages');
-  Writeln('  -l --showlocation Show if the packages are installed globally or locally');
+  Writeln('  -c --config        Set compiler configuration to use');
+  Writeln('  -h --help          This help');
+  Writeln('  -v --verbose       Show more information');
+  Writeln('  -d --debug         Show debugging information');
+  Writeln('  -g --global        Force installation to global (system-wide) directory');
+  Writeln('  -f --force         Force installation also if the package is already installed');
+  Writeln('  -r --recovery      Recovery mode, use always internal fpmkunit');
+  Writeln('  -b --broken        Do not stop on broken packages');
+  Writeln('  -l --showlocation  Show if the packages are installed globally or locally');
+  Writeln('  -o --options=value Pass extra options to the compiler');
   Writeln('Actions:');
   Writeln('Actions:');
   Writeln('  update            Update packages list');
   Writeln('  update            Update packages list');
   Writeln('  list              List available and installed packages');
   Writeln('  list              List available and installed packages');
@@ -243,9 +244,26 @@ procedure TMakeTool.ProcessCommandLine;
       end;
       end;
   end;
   end;
 
 
+  function SplitSpaces(var SplitString: string) : string;
+  var i : integer;
+  begin
+    i := pos(' ',SplitString);
+    if i > 0 then
+      begin
+        result := copy(SplitString,1,i-1);
+        delete(SplitString,1,i);
+      end
+    else
+      begin
+        result := SplitString;
+        SplitString:='';
+      end;
+  end;
+
 Var
 Var
   I : Integer;
   I : Integer;
   HasAction : Boolean;
   HasAction : Boolean;
+  OptString : String;
 begin
 begin
   I:=0;
   I:=0;
   HasAction:=false;
   HasAction:=false;
@@ -269,6 +287,12 @@ begin
         GlobalOptions.AllowBroken:=true
         GlobalOptions.AllowBroken:=true
       else if CheckOption(I,'l','showlocation') then
       else if CheckOption(I,'l','showlocation') then
         GlobalOptions.ShowLocation:=true
         GlobalOptions.ShowLocation:=true
+      else if CheckOption(I,'o','options') then
+        begin
+          OptString := OptionArg(I);
+          while OptString <> '' do
+            CompilerOptions.Options.Add(SplitSpaces(OptString));
+        end
       else if CheckOption(I,'h','help') then
       else if CheckOption(I,'h','help') then
         begin
         begin
           ShowUsage;
           ShowUsage;

+ 2 - 0
utils/fppkg/pkgfpmake.pp

@@ -290,6 +290,8 @@ begin
   AddOption('--compiler='+CompilerOptions.Compiler);
   AddOption('--compiler='+CompilerOptions.Compiler);
   AddOption('--cpu='+CPUToString(CompilerOptions.CompilerCPU));
   AddOption('--cpu='+CPUToString(CompilerOptions.CompilerCPU));
   AddOption('--os='+OSToString(CompilerOptions.CompilerOS));
   AddOption('--os='+OSToString(CompilerOptions.CompilerOS));
+  if CompilerOptions.HasOptions then
+    AddOption('--options='+CompilerOptions.Options.DelimitedText);
   if IsSuperUser or GlobalOptions.InstallGlobal then
   if IsSuperUser or GlobalOptions.InstallGlobal then
     AddOption('--baseinstalldir='+CompilerOptions.GlobalInstallDir)
     AddOption('--baseinstalldir='+CompilerOptions.GlobalInstallDir)
   else
   else

+ 23 - 0
utils/fppkg/pkgoptions.pp

@@ -98,6 +98,8 @@ Type
     FCompilerCPU: TCPU;
     FCompilerCPU: TCPU;
     FCompilerOS: TOS;
     FCompilerOS: TOS;
     FOptionParser: TTemplateParser;
     FOptionParser: TTemplateParser;
+    FOptions: TStrings;
+    function GetOptions: TStrings;
     function GetOptString(Index: integer): String;
     function GetOptString(Index: integer): String;
     procedure SetOptString(Index: integer; const AValue: String);
     procedure SetOptString(Index: integer; const AValue: String);
     procedure SetCompilerCPU(const AValue: TCPU);
     procedure SetCompilerCPU(const AValue: TCPU);
@@ -112,6 +114,7 @@ Type
     procedure UpdateLocalRepositoryOption;
     procedure UpdateLocalRepositoryOption;
     Function LocalUnitDir:string;
     Function LocalUnitDir:string;
     Function GlobalUnitDir:string;
     Function GlobalUnitDir:string;
+    Function HasOptions: boolean;
     Property Dirty : Boolean Read FDirty;
     Property Dirty : Boolean Read FDirty;
     Property ConfigVersion : Integer read FConfigVersion;
     Property ConfigVersion : Integer read FConfigVersion;
   Published
   Published
@@ -120,6 +123,7 @@ Type
     Property CompilerVersion : String Index 3 Read GetOptString Write SetOptString;
     Property CompilerVersion : String Index 3 Read GetOptString Write SetOptString;
     Property GlobalInstallDir : String Index 4 Read GetOptString Write SetOptString;
     Property GlobalInstallDir : String Index 4 Read GetOptString Write SetOptString;
     Property LocalInstallDir : String Index 5 Read GetOptString Write SetOptString;
     Property LocalInstallDir : String Index 5 Read GetOptString Write SetOptString;
+    Property Options : TStrings read GetOptions;
     Property CompilerOS : TOS Read FCompilerOS Write SetCompilerOS;
     Property CompilerOS : TOS Read FCompilerOS Write SetCompilerOS;
     Property CompilerCPU : TCPU Read FCompilerCPU Write SetCompilerCPU;
     Property CompilerCPU : TCPU Read FCompilerCPU Write SetCompilerCPU;
   end;
   end;
@@ -398,6 +402,8 @@ end;
 destructor TCompilerOptions.Destroy;
 destructor TCompilerOptions.Destroy;
 begin
 begin
   FOptionParser.Free;
   FOptionParser.Free;
+  if assigned(FOptions) then
+    FreeAndNil(FOptions);
   inherited Destroy;
   inherited Destroy;
 end;
 end;
 
 
@@ -415,6 +421,17 @@ begin
   end;
   end;
 end;
 end;
 
 
+function TCompilerOptions.GetOptions: TStrings;
+begin
+  if not assigned(FOptions) then
+    begin
+      FOptions := TStringList.Create;
+      FOptions.Delimiter:=' ';
+    end;
+  Result := FOptions;
+end;
+
+
 procedure TCompilerOptions.SetOptString(Index: integer; const AValue: String);
 procedure TCompilerOptions.SetOptString(Index: integer; const AValue: String);
 begin
 begin
   If AValue=GetOptString(Index) then
   If AValue=GetOptString(Index) then
@@ -474,6 +491,12 @@ begin
 end;
 end;
 
 
 
 
+function TCompilerOptions.HasOptions: boolean;
+begin
+  result := assigned(FOptions);
+end;
+
+
 procedure TCompilerOptions.InitCompilerDefaults;
 procedure TCompilerOptions.InitCompilerDefaults;
 
 
 var
 var