mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-15 20:39:14 +02:00
LazBuild: Allow --opt option to be specified multiple times to add compiler options
This commit is contained in:
parent
fc90be95ce
commit
eba189ea8c
@ -172,9 +172,9 @@ resourcestring
|
|||||||
'info file after build. If not specified, build number will be incremented '+
|
'info file after build. If not specified, build number will be incremented '+
|
||||||
'if configured.';
|
'if configured.';
|
||||||
|
|
||||||
lisExtraOpts = 'Pass additional options to the compiler. If compilation '+
|
lisExtraOpts = 'Pass additional options to the compiler, can be specified '+
|
||||||
'options are also specified in --build-ide, then the options from --opt '+
|
'multiple times. If compilation options are also specified in --build-ide, '+
|
||||||
'will be added after them.';
|
'then the options from --opt will be added after them.';
|
||||||
lisGetExpandText = 'Print the result of substituting macros in the text. '+
|
lisGetExpandText = 'Print the result of substituting macros in the text. '+
|
||||||
'The absence of macros in the text means the name of the macro. '+
|
'The absence of macros in the text means the name of the macro. '+
|
||||||
'By default, active build mode is used.';
|
'By default, active build mode is used.';
|
||||||
|
@ -119,6 +119,7 @@ type
|
|||||||
protected
|
protected
|
||||||
function GetParams(Index: Integer): String; override;
|
function GetParams(Index: Integer): String; override;
|
||||||
function GetParamCount: Integer; override;
|
function GetParamCount: Integer; override;
|
||||||
|
function HasCustomCompilerOpts(out aValue: string): boolean;
|
||||||
|
|
||||||
// Builds project or package, depending on extension.
|
// Builds project or package, depending on extension.
|
||||||
// Packages can also be specified by package name if they are known to the IDE.
|
// Packages can also be specified by package name if they are known to the IDE.
|
||||||
@ -401,6 +402,33 @@ begin
|
|||||||
Result := ToolParamCount;
|
Result := ToolParamCount;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
function TLazBuildApplication.HasCustomCompilerOpts(out aValue: string): boolean;
|
||||||
|
var
|
||||||
|
p: string; // current parameter
|
||||||
|
v: string; // value of current parameter
|
||||||
|
i: Integer;
|
||||||
|
begin
|
||||||
|
aValue := '';
|
||||||
|
for i := 1 to GetParamCount do
|
||||||
|
begin
|
||||||
|
p := GetParams(i);
|
||||||
|
if LazStartsText('--opt=', p) then
|
||||||
|
begin
|
||||||
|
// get value
|
||||||
|
v := copy(p, length('--opt=') + 1, length(p));
|
||||||
|
// remove quotes
|
||||||
|
if length(v) >= 2 then
|
||||||
|
if ((v[1] = '"' ) and (v[length(v)] = '"' )) or
|
||||||
|
((v[1] = '''') and (v[length(v)] = ''''))
|
||||||
|
then
|
||||||
|
v := copy(v, 2, length(v) - 2);
|
||||||
|
// append
|
||||||
|
aValue := MergeCustomOptions(aValue, v);
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
result := aValue <> '';
|
||||||
|
end;
|
||||||
|
|
||||||
function TLazBuildApplication.BuildFile(Filename: string): boolean;
|
function TLazBuildApplication.BuildFile(Filename: string): boolean;
|
||||||
var
|
var
|
||||||
OriginalFilename: string;
|
OriginalFilename: string;
|
||||||
@ -499,7 +527,7 @@ begin
|
|||||||
APackage.CompilerOptions.TargetCPU:=CPUOverride;
|
APackage.CompilerOptions.TargetCPU:=CPUOverride;
|
||||||
if SubtargetOverride then
|
if SubtargetOverride then
|
||||||
APackage.CompilerOptions.Subtarget:=SubtargetOverrideValue;
|
APackage.CompilerOptions.Subtarget:=SubtargetOverrideValue;
|
||||||
if HasLongOptIgnoreCase('opt', S) then
|
if HasCustomCompilerOpts(S) then
|
||||||
with APackage.CompilerOptions do
|
with APackage.CompilerOptions do
|
||||||
CustomOptions := MergeCustomOptions(CustomOptions, S);
|
CustomOptions := MergeCustomOptions(CustomOptions, S);
|
||||||
|
|
||||||
@ -613,7 +641,7 @@ begin
|
|||||||
if BuildIDEOptions <> '' then
|
if BuildIDEOptions <> '' then
|
||||||
CurProf.ExtraOptions := MergeCustomOptions(CurProf.ExtraOptions, BuildIDEOptions);
|
CurProf.ExtraOptions := MergeCustomOptions(CurProf.ExtraOptions, BuildIDEOptions);
|
||||||
// add parameters from the --opt option after --build-ide, as higher priority
|
// add parameters from the --opt option after --build-ide, as higher priority
|
||||||
if HasLongOptIgnoreCase('opt', s) then
|
if HasCustomCompilerOpts(s) then
|
||||||
CurProf.ExtraOptions := MergeCustomOptions(CurProf.ExtraOptions, s);
|
CurProf.ExtraOptions := MergeCustomOptions(CurProf.ExtraOptions, s);
|
||||||
|
|
||||||
if BuildAll then
|
if BuildAll then
|
||||||
@ -811,7 +839,7 @@ var
|
|||||||
MatrixOption.MacroName:='LCLWidgetType';
|
MatrixOption.MacroName:='LCLWidgetType';
|
||||||
MatrixOption.Value:=WidgetSetOverride;
|
MatrixOption.Value:=WidgetSetOverride;
|
||||||
end;
|
end;
|
||||||
if HasLongOptIgnoreCase('opt', S) then
|
if HasCustomCompilerOpts(S) then
|
||||||
with Project1.CompilerOptions do
|
with Project1.CompilerOptions do
|
||||||
CustomOptions := MergeCustomOptions(CustomOptions, S);
|
CustomOptions := MergeCustomOptions(CustomOptions, S);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user