* Added option to pass options to the compiler

git-svn-id: trunk@15873 -
This commit is contained in:
joost 2010-08-22 12:07:12 +00:00
parent 9a4238dea9
commit db2d55128c
3 changed files with 58 additions and 9 deletions

View File

@ -168,15 +168,16 @@ procedure TMakeTool.ShowUsage;
begin
Writeln('Usage: ',Paramstr(0),' [options] <action> <package>');
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(' update Update packages list');
Writeln(' list List available and installed packages');
@ -243,9 +244,26 @@ procedure TMakeTool.ProcessCommandLine;
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
I : Integer;
HasAction : Boolean;
OptString : String;
begin
I:=0;
HasAction:=false;
@ -269,6 +287,12 @@ begin
GlobalOptions.AllowBroken:=true
else if CheckOption(I,'l','showlocation') then
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
begin
ShowUsage;

View File

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

View File

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