MWE: Applied target OS patch from "Vincent Snijders" <vslist@zonnet.nl>

It addresses two things.
1. Setting a OS_TARGET for building lazarus in the Build Lazarus dialog.
2. Specifying the Target OS in the compiler options dialog.

git-svn-id: trunk@3372 -
This commit is contained in:
lazarus 2002-09-24 20:10:09 +00:00
parent aa4633fc58
commit 50a2d314da
3 changed files with 95 additions and 16 deletions

View File

@ -51,6 +51,7 @@ type
fCleanAll: boolean; fCleanAll: boolean;
fMakeFilename: string; fMakeFilename: string;
fExtraOptions: string; fExtraOptions: string;
fTargetOS: string;
public public
constructor Create; constructor Create;
procedure Load(XMLConfig: TXMLConfig; const Path: string); procedure Load(XMLConfig: TXMLConfig; const Path: string);
@ -65,6 +66,7 @@ type
property CleanAll: boolean read fCleanAll write fCleanAll; property CleanAll: boolean read fCleanAll write fCleanAll;
property MakeFilename: string read fMakeFilename write fMakeFilename; property MakeFilename: string read fMakeFilename write fMakeFilename;
property ExtraOptions: string read fExtraOptions write fExtraOptions; property ExtraOptions: string read fExtraOptions write fExtraOptions;
property TargetOS: string read fTargetOS write fTargetOS;
end; end;
TConfigureBuildLazarusDlg = class(TForm) TConfigureBuildLazarusDlg = class(TForm)
@ -78,6 +80,8 @@ type
BuildExamplesRadioGroup: TRadioGroup; BuildExamplesRadioGroup: TRadioGroup;
OptionsLabel: TLabel; OptionsLabel: TLabel;
OptionsEdit: TEdit; OptionsEdit: TEdit;
TargetOSLabel: TLabel;
TargetOSEdit: TEdit;
OkButton: TButton; OkButton: TButton;
CancelButton: TButton; CancelButton: TButton;
procedure BuildAllButtonClick(Sender: TObject); procedure BuildAllButtonClick(Sender: TObject);
@ -142,12 +146,14 @@ function BuildLazarus(Options: TBuildLazarusOptions;
var var
Tool: TExternalToolOptions; Tool: TExternalToolOptions;
procedure SetMakeParams(MakeMode: TMakeMode; ExtraOpts: string); procedure SetMakeParams(MakeMode: TMakeMode; ExtraOpts: string; TargetOS: string);
begin begin
if MakeMode=mmBuild then if MakeMode=mmBuild then
Tool.CmdLineParams:='all' Tool.CmdLineParams:='all'
else else
Tool.CmdLineParams:='clean all'; Tool.CmdLineParams:='clean all';
if TargetOS<>'' then
Tool.CmdLineParams:= 'OS_TARGET='+ TargetOS+' '+Tool.CmdLineParams;
if ExtraOpts<>'' then if ExtraOpts<>'' then
Tool.CmdLineParams:='OPT='''+ExtraOpts+''' '+Tool.CmdLineParams; Tool.CmdLineParams:='OPT='''+ExtraOpts+''' '+Tool.CmdLineParams;
end; end;
@ -168,6 +174,8 @@ begin
Tool.Title:='Clean Lazarus Source'; Tool.Title:='Clean Lazarus Source';
Tool.WorkingDirectory:='$(LazarusDir)'; Tool.WorkingDirectory:='$(LazarusDir)';
Tool.CmdLineParams:='cleanall'; Tool.CmdLineParams:='cleanall';
// if Options.TargetOS<>'' then
// Tool.CmdLineParams:= 'OS_TARGET='+ Options.TargetOS+' '+Tool.CmdLineParams;
Result:=ExternalTools.Run(Tool,Macros); Result:=ExternalTools.Run(Tool,Macros);
if Result<>mrOk then exit; if Result<>mrOk then exit;
end; end;
@ -175,7 +183,7 @@ begin
// build lcl // build lcl
Tool.Title:='Build LCL'; Tool.Title:='Build LCL';
Tool.WorkingDirectory:='$(LazarusDir)/lcl'; Tool.WorkingDirectory:='$(LazarusDir)/lcl';
SetMakeParams(Options.BuildLCL,Options.ExtraOptions); SetMakeParams(Options.BuildComponents,Options.ExtraOptions,Options.TargetOS);
Result:=ExternalTools.Run(Tool,Macros); Result:=ExternalTools.Run(Tool,Macros);
if Result<>mrOk then exit; if Result<>mrOk then exit;
end; end;
@ -183,7 +191,7 @@ begin
// build components // build components
Tool.Title:='Build Component'; Tool.Title:='Build Component';
Tool.WorkingDirectory:='$(LazarusDir)/components'; Tool.WorkingDirectory:='$(LazarusDir)/components';
SetMakeParams(Options.BuildComponents,Options.ExtraOptions); SetMakeParams(Options.BuildComponents,Options.ExtraOptions,Options.TargetOS);
Result:=ExternalTools.Run(Tool,Macros); Result:=ExternalTools.Run(Tool,Macros);
if Result<>mrOk then exit; if Result<>mrOk then exit;
end else begin end else begin
@ -191,7 +199,7 @@ begin
// build SynEdit // build SynEdit
Tool.Title:='Build SynEdit'; Tool.Title:='Build SynEdit';
Tool.WorkingDirectory:='$(LazarusDir)/components/synedit'; Tool.WorkingDirectory:='$(LazarusDir)/components/synedit';
SetMakeParams(Options.BuildSynEdit,Options.ExtraOptions); SetMakeParams(Options.BuildComponents,Options.ExtraOptions,Options.TargetOS);
Result:=ExternalTools.Run(Tool,Macros); Result:=ExternalTools.Run(Tool,Macros);
if Result<>mrOk then exit; if Result<>mrOk then exit;
end; end;
@ -199,7 +207,7 @@ begin
// build CodeTools // build CodeTools
Tool.Title:='Build CodeTools'; Tool.Title:='Build CodeTools';
Tool.WorkingDirectory:='$(LazarusDir)/components/codetools'; Tool.WorkingDirectory:='$(LazarusDir)/components/codetools';
SetMakeParams(Options.BuildCodeTools,Options.ExtraOptions); SetMakeParams(Options.BuildComponents,Options.ExtraOptions,Options.TargetOS);
Result:=ExternalTools.Run(Tool,Macros); Result:=ExternalTools.Run(Tool,Macros);
if Result<>mrOk then exit; if Result<>mrOk then exit;
end; end;
@ -212,6 +220,8 @@ begin
Tool.CmdLineParams:='OPT='''+Options.ExtraOptions+''' ' Tool.CmdLineParams:='OPT='''+Options.ExtraOptions+''' '
else else
Tool.CmdLineParams:=''; Tool.CmdLineParams:='';
if Options.TargetOS<>'' then
Tool.CmdLineParams:= 'OS_TARGET='+ Options.TargetOS+' '+Tool.CmdLineParams;
if Options.BuildIDE=mmBuild then if Options.BuildIDE=mmBuild then
Tool.CmdLineParams:=Tool.CmdLineParams+'ide' Tool.CmdLineParams:=Tool.CmdLineParams+'ide'
else else
@ -223,7 +233,7 @@ begin
// build Examples // build Examples
Tool.Title:='Build Examples'; Tool.Title:='Build Examples';
Tool.WorkingDirectory:='$(LazarusDir)/examples'; Tool.WorkingDirectory:='$(LazarusDir)/examples';
SetMakeParams(Options.BuildExamples,Options.ExtraOptions); SetMakeParams(Options.BuildComponents,Options.ExtraOptions,Options.TargetOS);
Result:=ExternalTools.Run(Tool,Macros); Result:=ExternalTools.Run(Tool,Macros);
if Result<>mrOk then exit; if Result<>mrOk then exit;
end; end;
@ -241,7 +251,7 @@ begin
inherited Create(AnOwner); inherited Create(AnOwner);
if LazarusResources.Find(Classname)=nil then begin if LazarusResources.Find(Classname)=nil then begin
Width:=350; Width:=350;
Height:=415; Height:=435;
Position:=poScreenCenter; Position:=poScreenCenter;
Caption:='Configure "Build Lazarus"'; Caption:='Configure "Build Lazarus"';
OnResize:=@ConfigureBuildLazarusDlgResize; OnResize:=@ConfigureBuildLazarusDlgResize;
@ -370,6 +380,28 @@ begin
Visible:=true; Visible:=true;
end; end;
TargetOSLabel:=TLabel.Create(Self);
with TargetOSLabel do begin
Name:='TargetOSLabel';
Parent:=Self;
SetBounds(10,
OptionsLabel.Top+OptionsLabel.Height+12,
80,Height);
Caption:='Target OS:';
Visible:=true;
end;
TargetOSEdit:=TEdit.Create(Self);
with TargetOSEdit do begin
Name:='TargetOSEdit';
Parent:=Self;
SetBounds(TargetOSLabel.Left+TargetOSLabel.Width+5,
TargetOSLabel.Top,
OptionsEdit.Width,
Height);
Visible:=true;
end;
OkButton:=TButton.Create(Self); OkButton:=TButton.Create(Self);
with OkButton do begin with OkButton do begin
Parent:=Self; Parent:=Self;
@ -445,6 +477,13 @@ begin
OptionsLabel.Top, OptionsLabel.Top,
BuildExamplesRadioGroup.Width-OptionsLabel.Width-5, BuildExamplesRadioGroup.Width-OptionsLabel.Width-5,
OptionsEdit.Height); OptionsEdit.Height);
TargetOSLabel.SetBounds(10,
OptionsLabel.Top+OptionsLabel.Height+12,
80,TargetOsLabel.Height);
TargetOSEdit.SetBounds(TargetOSLabel.Left+TargetOSLabel.Width+5,
TargetOSLabel.Top,
OptionsEdit.Width,
TargetOSEdit.Height);
OkButton.SetBounds(Self.ClientWidth-180,Self.ClientHeight-38,80,25); OkButton.SetBounds(Self.ClientWidth-180,Self.ClientHeight-38,80,25);
CancelButton.SetBounds(Self.ClientWidth-90,OkButton.Top, CancelButton.SetBounds(Self.ClientWidth-90,OkButton.Top,
OkButton.Width,OkButton.Height); OkButton.Width,OkButton.Height);
@ -470,6 +509,7 @@ begin
BuildIDERadioGroup.ItemIndex:=MakeModeToInt(Options.BuildIDE); BuildIDERadioGroup.ItemIndex:=MakeModeToInt(Options.BuildIDE);
BuildExamplesRadioGroup.ItemIndex:=MakeModeToInt(Options.BuildExamples); BuildExamplesRadioGroup.ItemIndex:=MakeModeToInt(Options.BuildExamples);
OptionsEdit.Text:=Options.ExtraOptions; OptionsEdit.Text:=Options.ExtraOptions;
TargetOSEdit.Text:=Options.TargetOS;
end; end;
procedure TConfigureBuildLazarusDlg.Save(Options: TBuildLazarusOptions); procedure TConfigureBuildLazarusDlg.Save(Options: TBuildLazarusOptions);
@ -483,6 +523,7 @@ begin
Options.BuildIDE:=IntToMakeMode(BuildIDERadioGroup.ItemIndex); Options.BuildIDE:=IntToMakeMode(BuildIDERadioGroup.ItemIndex);
Options.BuildExamples:=IntToMakeMode(BuildExamplesRadioGroup.ItemIndex); Options.BuildExamples:=IntToMakeMode(BuildExamplesRadioGroup.ItemIndex);
Options.ExtraOptions:=OptionsEdit.Text; Options.ExtraOptions:=OptionsEdit.Text;
Options.TargetOS:=TargetOSEdit.Text;
end; end;
function TConfigureBuildLazarusDlg.MakeModeToInt(MakeMode: TMakeMode): integer; function TConfigureBuildLazarusDlg.MakeModeToInt(MakeMode: TMakeMode): integer;
@ -515,6 +556,7 @@ begin
XMLConfig.SetValue(Path+'BuildExamples/Value',MakeModeNames[fBuildExamples]); XMLConfig.SetValue(Path+'BuildExamples/Value',MakeModeNames[fBuildExamples]);
XMLConfig.SetValue(Path+'CleanAll/Value',fCleanAll); XMLConfig.SetValue(Path+'CleanAll/Value',fCleanAll);
XMLConfig.SetValue(Path+'ExtraOptions/Value',fExtraOptions); XMLConfig.SetValue(Path+'ExtraOptions/Value',fExtraOptions);
XMLConfig.SetValue(Path+'TargetOS/Value',fTargetOS);
XMLConfig.SetValue(Path+'MakeFilename/Value',fMakeFilename); XMLConfig.SetValue(Path+'MakeFilename/Value',fMakeFilename);
end; end;
@ -534,6 +576,7 @@ begin
MakeModeNames[fBuildExamples])); MakeModeNames[fBuildExamples]));
fCleanAll:=XMLConfig.GetValue(Path+'CleanAll/Value',fCleanAll); fCleanAll:=XMLConfig.GetValue(Path+'CleanAll/Value',fCleanAll);
fExtraOptions:=XMLConfig.GetValue(Path+'ExtraOptions/Value',fExtraOptions); fExtraOptions:=XMLConfig.GetValue(Path+'ExtraOptions/Value',fExtraOptions);
fTargetOS:=XMLConfig.GetValue(Path+'TargetOS/Value',fTargetOS);
fMakeFilename:=XMLConfig.GetValue(Path+'MakeFilename/Value',fMakeFilename); fMakeFilename:=XMLConfig.GetValue(Path+'MakeFilename/Value',fMakeFilename);
end; end;

View File

@ -80,6 +80,7 @@ type
fVarsInReg: Boolean; fVarsInReg: Boolean;
fUncertainOpt: Boolean; fUncertainOpt: Boolean;
fOptLevel: Integer; fOptLevel: Integer;
fTargetOS: String;
fGenDebugInfo: Boolean; fGenDebugInfo: Boolean;
fGenDebugDBX: Boolean; fGenDebugDBX: Boolean;
@ -168,6 +169,7 @@ type
property VariablesInRegisters: Boolean read fVarsInReg write fVarsInReg; property VariablesInRegisters: Boolean read fVarsInReg write fVarsInReg;
property UncertainOptimizations: Boolean read fUncertainOpt write fUncertainOpt; property UncertainOptimizations: Boolean read fUncertainOpt write fUncertainOpt;
property OptimizationLevel: Integer read fOptLevel write fOptLevel; property OptimizationLevel: Integer read fOptLevel write fOptLevel;
property TargetOS: string read fTargetOS write fTargetOS;
property GenerateDebugInfo: Boolean read fGenDebugInfo write fGenDebugInfo; property GenerateDebugInfo: Boolean read fGenDebugInfo write fGenDebugInfo;
property GenerateDebugDBX: Boolean read fGenDebugDBX write fGenDebugDBX; property GenerateDebugDBX: Boolean read fGenDebugDBX write fGenDebugDBX;
@ -291,6 +293,8 @@ type
radOptLevel2: TRadioButton; radOptLevel2: TRadioButton;
radOptLevel3: TRadioButton; radOptLevel3: TRadioButton;
TargetOSRadioGroup: TRadioGroup;
{ Linking Controls } { Linking Controls }
grpDebugging: TGroupBox; grpDebugging: TGroupBox;
chkDebugGDB: TCheckBox; chkDebugGDB: TCheckBox;
@ -466,6 +470,7 @@ begin
VariablesInRegisters := XMLConfigFile.GetValue('CompilerOptions/CodeGeneration/Optimizations/VariablesInRegisters/Value', false); VariablesInRegisters := XMLConfigFile.GetValue('CompilerOptions/CodeGeneration/Optimizations/VariablesInRegisters/Value', false);
UncertainOptimizations := XMLConfigFile.GetValue('CompilerOptions/CodeGeneration/Optimizations/UncertainOptimizations/Value', false); UncertainOptimizations := XMLConfigFile.GetValue('CompilerOptions/CodeGeneration/Optimizations/UncertainOptimizations/Value', false);
OptimizationLevel := XMLConfigFile.GetValue('CompilerOptions/CodeGeneration/Optimizations/OptimizationLevel/Value', 1); OptimizationLevel := XMLConfigFile.GetValue('CompilerOptions/CodeGeneration/Optimizations/OptimizationLevel/Value', 1);
TargetOS := XMLConfigFile.GetValue('CompilerOptions/CodeGeneration/TargetOS/Value', 'linux');
{ Linking } { Linking }
GenerateDebugInfo := XMLConfigFile.GetValue('CompilerOptions/Linking/Debugging/GenerateDebugInfo/Value', false); GenerateDebugInfo := XMLConfigFile.GetValue('CompilerOptions/Linking/Debugging/GenerateDebugInfo/Value', false);
@ -568,6 +573,7 @@ begin
XMLConfigFile.SetValue('CompilerOptions/CodeGeneration/Optimizations/VariablesInRegisters/Value', VariablesInRegisters); XMLConfigFile.SetValue('CompilerOptions/CodeGeneration/Optimizations/VariablesInRegisters/Value', VariablesInRegisters);
XMLConfigFile.SetValue('CompilerOptions/CodeGeneration/Optimizations/UncertainOptimizations/Value', UncertainOptimizations); XMLConfigFile.SetValue('CompilerOptions/CodeGeneration/Optimizations/UncertainOptimizations/Value', UncertainOptimizations);
XMLConfigFile.SetValue('CompilerOptions/CodeGeneration/Optimizations/OptimizationLevel/Value', OptimizationLevel); XMLConfigFile.SetValue('CompilerOptions/CodeGeneration/Optimizations/OptimizationLevel/Value', OptimizationLevel);
XMLConfigFile.SetValue('CompilerOptions/CodeGeneration/TargetOS/Value', TargetOS);
{ Linking } { Linking }
XMLConfigFile.SetValue('CompilerOptions/Linking/Debugging/GenerateDebugInfo/Value', GenerateDebugInfo); XMLConfigFile.SetValue('CompilerOptions/Linking/Debugging/GenerateDebugInfo/Value', GenerateDebugInfo);
@ -629,9 +635,8 @@ begin
Ext:=ExtractFileExt(Result); Ext:=ExtractFileExt(Result);
Result:=copy(Result,1,length(Result)-length(Ext)); Result:=copy(Result,1,length(Result)-length(Ext));
Result:=lowercase(Result); Result:=lowercase(Result);
{$IFDEF win32} if fTargetOS = 'win32'
Result:=Result+'.exe'; then Result:=Result+'.exe';
{$ENDIF}
Result:=ExtractFilePath(MainSourceFileName)+Result; Result:=ExtractFilePath(MainSourceFileName)+Result;
end else end else
Result:=''; Result:='';
@ -933,6 +938,15 @@ begin
3: switches := switches + 'p3'; 3: switches := switches + 'p3';
end; end;
{ Target OS
GO32V1 = DOS and version 1 of the DJ DELORIE extender (no longer maintained).
GO32V2 = DOS and version 2 of the DJ DELORIE extender.
LINUX = LINUX.
OS2 = OS/2 (2.x) using the EMX extender.
WIN32 = Windows 32 bit. }
{ Only linux and win32 are in the dialog at this moment}
if TargetOS<>'' then
switches := switches + ' -T' + TargetOS;
{ --------------- Linking Tab ------------------- } { --------------- Linking Tab ------------------- }
{ Debugging } { Debugging }
@ -1087,12 +1101,6 @@ begin
-uxxx = Undefine symbol name xxx -uxxx = Undefine symbol name xxx
-s = Do not call assembler or linker. Write ppas.bat/ppas.sh script. -s = Do not call assembler or linker. Write ppas.bat/ppas.sh script.
-T = Target OS
GO32V1 = DOS and version 1 of the DJ DELORIE extender (no longer maintained).
GO32V2 = DOS and version 2 of the DJ DELORIE extender.
LINUX = LINUX.
OS2 = OS/2 (2.x) using the EMX extender.
WIN32 = Windows 32 bit.
-Xc = Link with C library (LINUX only) -Xc = Link with C library (LINUX only)
@ -1226,6 +1234,7 @@ begin
fVarsInReg := false; fVarsInReg := false;
fUncertainOpt := false; fUncertainOpt := false;
fOptLevel := 1; fOptLevel := 1;
fTargetOS := 'linux';
fGenDebugInfo := false; fGenDebugInfo := false;
fGenDebugDBX := false; fGenDebugDBX := false;
@ -1298,6 +1307,7 @@ begin
fVarsInReg := CompOpts.fVarsInReg; fVarsInReg := CompOpts.fVarsInReg;
fUncertainOpt := CompOpts.fUncertainOpt; fUncertainOpt := CompOpts.fUncertainOpt;
fOptLevel := CompOpts.fOptLevel; fOptLevel := CompOpts.fOptLevel;
fTargetOS := CompOpts.fTargetOS;
fGenDebugInfo := CompOpts.fGenDebugInfo; fGenDebugInfo := CompOpts.fGenDebugInfo;
fGenDebugDBX := CompOpts.fGenDebugDBX; fGenDebugDBX := CompOpts.fGenDebugDBX;
@ -1595,6 +1605,9 @@ begin
i:=LCLWidgetTypeRadioGroup.Items.IndexOf(CompilerOpts.LCLWidgetType); i:=LCLWidgetTypeRadioGroup.Items.IndexOf(CompilerOpts.LCLWidgetType);
if i<0 then i:=0; if i<0 then i:=0;
LCLWidgetTypeRadioGroup.ItemIndex:=i; LCLWidgetTypeRadioGroup.ItemIndex:=i;
i:=TargetOSRadioGroup.Items.IndexOf(CompilerOpts.TargetOS);
if i<0 then i:=0;
TargetOSRadioGroup.ItemIndex:=i;
end; end;
{------------------------------------------------------------------------------} {------------------------------------------------------------------------------}
@ -1723,6 +1736,10 @@ begin
i:=LCLWidgetTypeRadioGroup.Itemindex; i:=LCLWidgetTypeRadioGroup.Itemindex;
if i<0 then i:=0; if i<0 then i:=0;
CompilerOpts.LCLWidgetType:= LCLWidgetTypeRadioGroup.Items[i]; CompilerOpts.LCLWidgetType:= LCLWidgetTypeRadioGroup.Items[i];
i:=TargetOSRadioGroup.Itemindex;
if i<0 then i:=0;
CompilerOpts.TargetOS:= TargetOSRadioGroup.Items[i];
end; end;
{------------------------------------------------------------------------------} {------------------------------------------------------------------------------}
@ -2229,6 +2246,24 @@ begin
Visible := True; Visible := True;
end; end;
TargetOSRadioGroup:=TRadioGroup.Create(Self);
with TargetOSRadioGroup do begin
Name:='TargetOSRadioGroup';
Parent:=nbMain.Page[Page];
Left := grpOtherUnits.Left;
Top:=grpOptimizations.Top+grpOptimizations.Height+5;
Width:=150;
Height:=45;
Caption:=dlgTargetOS;
with Items do begin
Add('linux');
Add('win32');
end;
Columns:=2;
ItemIndex:=0;
Visible:=true;
end;
end; end;
{------------------------------------------------------------------------------} {------------------------------------------------------------------------------}

View File

@ -508,6 +508,7 @@ resourcestring
dlgLevel1Opt = 'Level 1 (Quick Optimizations)'; dlgLevel1Opt = 'Level 1 (Quick Optimizations)';
dlgLevel2Opt = 'Level 2 (Level 1 + Slower Optimizations)'; dlgLevel2Opt = 'Level 2 (Level 1 + Slower Optimizations)';
dlgLevel3Opt = 'Level 3 (Level 2 + Uncertain)'; dlgLevel3Opt = 'Level 3 (Level 2 + Uncertain)';
dlgTargetOS = 'Target OS';
dlgCODebugging = 'Debugging:'; dlgCODebugging = 'Debugging:';
dlgCOGDB = 'Generate Debugging Info For GDB (Slows Compiling)'; dlgCOGDB = 'Generate Debugging Info For GDB (Slows Compiling)';
dlgCODBX = 'Generate Debugging Info For DBX (Slows Compiling)'; dlgCODBX = 'Generate Debugging Info For DBX (Slows Compiling)';