diff options
| author | joost <joost@3ad0048d-3df7-0310-abae-a5850022a9f2> | 2010-11-14 15:16:34 +0000 |
|---|---|---|
| committer | joost <joost@3ad0048d-3df7-0310-abae-a5850022a9f2> | 2010-11-14 15:16:34 +0000 |
| commit | f3be2cb03c00897a358acb195024ee3307559696 (patch) | |
| tree | eb6f3b5de8d18930883f9b3f71ddccccad752655 /packages/fpmkunit | |
| parent | 79e36de820eaea35962d3939fc33f7aaad1da7b8 (diff) | |
| download | fpc-f3be2cb03c00897a358acb195024ee3307559696.tar.gz | |
* Added ability to add custom command-line options for fpmake
git-svn-id: http://svn.freepascal.org/svn/fpc/trunk@16346 3ad0048d-3df7-0310-abae-a5850022a9f2
Diffstat (limited to 'packages/fpmkunit')
| -rw-r--r-- | packages/fpmkunit/src/fpmkunit.pp | 55 |
1 files changed, 55 insertions, 0 deletions
diff --git a/packages/fpmkunit/src/fpmkunit.pp b/packages/fpmkunit/src/fpmkunit.pp index f8edeac00c..bcfd8a1d64 100644 --- a/packages/fpmkunit/src/fpmkunit.pp +++ b/packages/fpmkunit/src/fpmkunit.pp @@ -957,6 +957,8 @@ Function IsRelativePath(const APath : String) : boolean; Procedure ChangeDir(const APath : String); Function Substitute(Const Source : String; Macros : Array of string) : String; Procedure SplitCommand(Const Cmd : String; Var Exe,Options : String); +Procedure AddCustomFpmakeCommandlineOption(const ACommandLineOption, HelpMessage : string); +Function GetCustomFpmakeCommandlineOptionValue(const ACommandLineOption : string) : string; Implementation @@ -968,6 +970,10 @@ type function Add(const S: string): Integer; override; end; +var + CustomFpmakeCommandlineOptions: TStrings; + CustomFpMakeCommandlineValues: TStrings; + ResourceString SErrInvalidCPU = 'Invalid CPU name "%s"'; SErrInvalidOS = 'Invalid OS name "%s"'; @@ -1520,6 +1526,21 @@ begin Options:=Trim(S); end; +procedure AddCustomFpmakeCommandlineOption(const ACommandLineOption, HelpMessage : string); +begin + if not assigned(CustomFpmakeCommandlineOptions) then + CustomFpmakeCommandlineOptions := TStringList.Create; + CustomFpmakeCommandlineOptions.Values[ACommandLineOption]:=HelpMessage; +end; + +function GetCustomFpmakeCommandlineOptionValue(const ACommandLineOption: string): string; +begin + if not assigned(CustomFpMakeCommandlineValues) then + result := '' + else + result := CustomFpMakeCommandlineValues.Values[ACommandLineOption]; +end; + Function OptionListToString(L : TStrings) : String; var @@ -2857,6 +2878,25 @@ procedure TCustomInstaller.AnalyzeOptions; Result:=(O='-'+short) or (O='--'+long) or (copy(O,1,Length(Long)+3)=('--'+long+'=')); end; + Function CheckCustomOption(Index : Integer; out CustOptName: string): Boolean; + var + O : String; + i : integer; + begin + result := false; + CustOptName:=''; + O:=Paramstr(Index); + if copy(O,1,2)<>'--' then + Exit; + i := pos('=',O); + if i=0 then + Exit; + O:=copy(O,3,i-3); + CustOptName:=O; + Result:=CustomFpmakeCommandlineOptions.IndexOfName(O)>-1; + end; + + Function CheckCommand(Index : Integer;const Short,Long : String): Boolean; var O : String; @@ -2912,6 +2952,7 @@ Var I : Integer; DefaultsFileName : string; OptString : string; + CustOptName : string; begin I:=0; FListMode:=False; @@ -2965,6 +3006,12 @@ begin Defaults.Compiler:=OptionArg(I) else if CheckOption(I,'f','config') then DefaultsFileName:=OptionArg(I) + else if assigned(CustomFpmakeCommandlineOptions) and CheckCustomOption(I,CustOptName) then + begin + if not assigned(CustomFpMakeCommandlineValues) then + CustomFpMakeCommandlineValues := TStringList.Create; + CustomFpMakeCommandlineValues.Values[CustOptName]:=OptionArg(I) + end else begin Usage(SErrInValidArgument,[I,ParamStr(I)]); @@ -2993,6 +3040,8 @@ procedure TCustomInstaller.Usage(const FMT: String; Args: array of const); Log(vlInfo,Format(' -%s --%-20s %s',[C,LC+'='+SValue,MSG])); end; +var + i: Integer; begin // Force the Usage to be displayed Include(FLogLevels,vlInfo); @@ -3021,6 +3070,8 @@ begin LogArgOption('r','compiler',SHelpCompiler); LogArgOption('f','config',SHelpConfig); LogArgOption('o','options',SHelpOptions); + for i := 0 to CustomFpmakeCommandlineOptions.Count-1 do + LogArgOption(' ',CustomFpmakeCommandlineOptions.Names[i],CustomFpmakeCommandlineOptions.ValueFromIndex[i]); Log(vlInfo,''); If (FMT<>'') then halt(1) @@ -5338,8 +5389,12 @@ end; Initialization OnGetApplicationName:=@GetFPMakeName; + CustomFpmakeCommandlineOptions:=nil; + CustomFpMakeCommandlineValues:=nil; Finalization + FreeAndNil(CustomFpMakeCommandlineValues); + FreeAndNil(CustomFpmakeCommandlineOptions); FreeAndNil(DefInstaller); FreeAndNil(Dictionary); FreeAndNil(Defaults); |
