Import and Export of package compiler options

git-svn-id: trunk@4626 -
This commit is contained in:
mattias 2003-09-15 15:03:06 +00:00
parent 5d83374da5
commit 86428e4837
7 changed files with 90 additions and 29 deletions

View File

@ -3,6 +3,15 @@
<Package>
<Name Value="GTKOpenGL"/>
<Author Value="Mattias Gaertner, Satan"/>
<CompilerOptions>
<SearchPaths>
<UnitOutputDirectory Value="lib"/>
<LCLWidgetType Value="gtk"/>
</SearchPaths>
<Other>
<CompilerPath Value="$(CompPath)"/>
</Other>
</CompilerOptions>
<Description Value="OpenGL for LCL - components: TGtkGlAreaControl
Please make sure that you link to the right libgtkgl. If you accidently link to libgtkgl-2.0 then you will mix gtk1 and gtk2 libraries, which will result in strange errors, up to freezing your windowmanager."/>
<License Value="LGPL-2"/>
@ -50,13 +59,4 @@ Please make sure that you link to the right libgtkgl. If you accidently link to
<UseExcludeFileFilter Value="True"/>
</PublishOptions>
</Package>
<CompilerOptions>
<SearchPaths>
<UnitOutputDirectory Value="lib/"/>
<LCLWidgetType Value="gtk"/>
</SearchPaths>
<Other>
<CompilerPath Value="$(CompPath)"/>
</Other>
</CompilerOptions>
</CONFIG>

View File

@ -83,6 +83,7 @@ function DoImportComilerOptions(CompOptsDialog: TfrmCompilerOptions;
CompilerOpts: TBaseCompilerOptions; const Filename: string): TModalResult;
function DoExportComilerOptions(CompOptsDialog: TfrmCompilerOptions;
CompilerOpts: TBaseCompilerOptions; const Filename: string): TModalResult;
function GetXMLPathForCompilerOptionsInFile(const Filename: string): string;
implementation
@ -106,6 +107,7 @@ function DoImportComilerOptions(CompOptsDialog: TfrmCompilerOptions;
var
XMLConfig: TXMLConfig;
FreeCompilerOpts: Boolean;
Path: String;
begin
Result:=mrCancel;
try
@ -123,7 +125,8 @@ begin
CompilerOpts:=TBaseCompilerOptions.Create(nil);
FreeCompilerOpts:=true;
end;
CompilerOpts.LoadFromXMLConfig(XMLConfig,'CompilerOptions/');
Path:=GetXMLPathForCompilerOptionsInFile(Filename);
CompilerOpts.LoadFromXMLConfig(XMLConfig,Path+'CompilerOptions/');
if CompOptsDialog<>nil then
CompOptsDialog.GetCompilerOptions(CompilerOpts);
finally
@ -138,6 +141,7 @@ function DoExportComilerOptions(CompOptsDialog: TfrmCompilerOptions;
var
XMLConfig: TXMLConfig;
FreeCompilerOpts: Boolean;
Path: String;
begin
FreeCompilerOpts:=false;
if (CompOptsDialog<>nil) then begin
@ -150,7 +154,8 @@ begin
try
XMLConfig:=TXMLConfig.Create(Filename);
try
CompilerOpts.SaveToXMLConfig(XMLConfig,'CompilerOptions/');
Path:=GetXMLPathForCompilerOptionsInFile(Filename);
CompilerOpts.SaveToXMLConfig(XMLConfig,Path+'CompilerOptions/');
XMLConfig.Flush;
finally
XMLConfig.Free;
@ -168,6 +173,33 @@ begin
end;
end;
function ReadIntFromXMLConfig(const Filename, Path: string;
DefaultValue, ValueForReadError: integer): integer;
var
XMLConfig: TXMLConfig;
begin
Result:=ValueForReadError;
if FileExists(Filename) then
try
XMLConfig:=TXMLConfig.Create(Filename);
Result:=XMLConfig.GetValue(Path,DefaultValue);
except
Result:=ValueForReadError;
end;
end;
function GetXMLPathForCompilerOptionsInFile(const Filename: string): string;
var
FileVersion: Integer;
begin
Result:='';
if CompareFileExt(Filename,'.lpk',false)=0 then begin
FileVersion:=ReadIntFromXMLConfig(Filename,'Package/Version',0,2);
if FileVersion>=2 then
Result:='Package/';
end;
end;
{ TImExportCompOptsDlg }
procedure TImExportCompOptsDlg.ImExportCompOptsDlgCREATE(Sender: TObject);

View File

@ -500,6 +500,7 @@ type
function DoOpenProjectFile(AFileName: string; Flags: TOpenFlags): TModalResult;
function DoPublishProject(Flags: TSaveFlags;
ShowDialog: boolean): TModalResult;
function DoImExportCompilerOptions(Sender: TObject): TModalResult; override;
function DoShowProjectInspector: TModalResult; override;
function DoAddActiveUnitToProject: TModalResult;
function DoRemoveFromProjectDialog: TModalResult;
@ -5329,6 +5330,27 @@ begin
GetProjPublishDir);
end;
function TMainIDE.DoImExportCompilerOptions(Sender: TObject): TModalResult;
var
CompOptsDialog: TfrmCompilerOptions;
ImExportResult: TImExportCompOptsResult;
Filename: string;
begin
Result:=mrOk;
if not (Sender is TfrmCompilerOptions) then
RaiseException('TMainIDE.OnCompilerOptionsImExport');
CompOptsDialog:=TfrmCompilerOptions(Sender);
ImExportResult:=ShowImExportCompilerOptionsDialog(
CompOptsDialog.CompilerOpts,Filename);
if (ImExportResult=iecorCancel) or (Filename='') then exit;
if ImExportResult=iecorImport then
Result:=DoImportComilerOptions(CompOptsDialog,CompOptsDialog.CompilerOpts,
Filename)
else if ImExportResult=iecorExport then
Result:=DoExportComilerOptions(CompOptsDialog,CompOptsDialog.CompilerOpts,
Filename);
end;
function TMainIDE.DoShowProjectInspector: TModalResult;
begin
if ProjInspector=nil then begin
@ -9215,20 +9237,8 @@ begin
end;
procedure TMainIDE.OnCompilerOptionsImExport(Sender: TObject);
var
CompOptsDialog: TfrmCompilerOptions;
ImExportResult: TImExportCompOptsResult;
Filename: string;
begin
if not (Sender is TfrmCompilerOptions) then exit;
CompOptsDialog:=TfrmCompilerOptions(Sender);
ImExportResult:=ShowImExportCompilerOptionsDialog(
CompOptsDialog.CompilerOpts,Filename);
if (ImExportResult=iecorCancel) or (Filename='') then exit;
if ImExportResult=iecorImport then
DoImportComilerOptions(CompOptsDialog,CompOptsDialog.CompilerOpts,Filename)
else if ImExportResult=iecorExport then
DoExportComilerOptions(CompOptsDialog,CompOptsDialog.CompilerOpts,Filename);
DoImExportCompilerOptions(Sender);
end;
procedure TMainIDE.ProjInspectorOpen(Sender: TObject);
@ -9782,6 +9792,9 @@ end.
{ =============================================================================
$Log$
Revision 1.647 2003/09/15 15:03:05 mattias
Import and Export of package compiler options
Revision 1.646 2003/09/10 12:13:48 mattias
implemented Import and Export of compiler options

View File

@ -409,6 +409,7 @@ type
const AFilename: string): TModalResult; virtual;
function DoShowProjectInspector: TModalResult; virtual; abstract;
function DoImExportCompilerOptions(Sender: TObject): TModalResult; virtual; abstract;
function PrepareForCompile: TModalResult; virtual; abstract;
function DoBuildLazarus(Flags: TBuildLazarusFlags): TModalResult; virtual; abstract;

View File

@ -684,7 +684,7 @@ type
const
LazPkgXMLFileVersion = 1;
LazPkgXMLFileVersion = 2;
PkgFileTypeNames: array[TPkgFileType] of string = (
'pftUnit', 'pftVirtualUnit', 'pftLFM', 'pftLRS', 'pftInclude', 'pftText',
@ -2068,7 +2068,6 @@ var
begin
Flags:=Flags+[lpfLoading];
FileVersion:=XMLConfig.GetValue(Path+'Version',0);
if FileVersion=1 then ;
OldFilename:=Filename;
BeginUpdate;
Clear;
@ -2076,10 +2075,11 @@ begin
LockModified;
PathDelimChanged:=XMLConfig.GetValue(Path+'PathDelim/Value','/')<>'/';
Name:=XMLConfig.GetValue(Path+'Name/Value','');
FPackageType:=LazPackageTypeIdentToType(XMLConfig.GetValue(Path+'Type/Value',
LazPackageTypeIdents[lptRunTime]));
FAuthor:=XMLConfig.GetValue(Path+'Author/Value','');
FAutoUpdate:=NameToAutoUpdatePolicy(
XMLConfig.GetValue(Path+'AutoUpdate/Value',''));
FCompilerOptions.LoadFromXMLConfig(XMLConfig,Path+'CompilerOptions/');
FDescription:=XMLConfig.GetValue(Path+'Description/Value','');
FLicense:=XMLConfig.GetValue(Path+'License/Value','');
FVersion.LoadFromXMLConfig(XMLConfig,Path+'Version/',FileVersion);
@ -2088,13 +2088,15 @@ begin
OutputStateFile:=SwitchPathDelims(
XMLConfig.GetValue(Path+'OutputStateFile/Value',''),
PathDelimChanged);
FPackageType:=LazPackageTypeIdentToType(XMLConfig.GetValue(Path+'Type/Value',
LazPackageTypeIdents[lptRunTime]));
LoadFiles(Path+'Files/',FFiles);
UpdateSourceDirectories;
LoadFlags(Path);
LoadPkgDependencyList(XMLConfig,Path+'RequiredPkgs/',
FFirstRequiredDependency,pdlRequires,Self,false);
if FileVersion<2 then
FCompilerOptions.LoadFromXMLConfig(XMLConfig,'CompilerOptions/')
else
FCompilerOptions.LoadFromXMLConfig(XMLConfig,Path+'CompilerOptions/');
FUsageOptions.LoadFromXMLConfig(XMLConfig,Path+'UsageOptions/',
PathDelimChanged);
fPublishOptions.LoadFromXMLConfig(XMLConfig,Path+'PublishOptions/',
@ -2127,6 +2129,7 @@ procedure TLazPackage.SaveToXMLConfig(XMLConfig: TXMLConfig; const Path: string
end;
begin
XMLConfig.SetValue(Path+'Version',LazPkgXMLFileVersion);
XMLConfig.SetDeleteValue(Path+'PathDelim/Value',PathDelim,'/');
XMLConfig.SetDeleteValue(Path+'Name/Value',FName,'');
XMLConfig.SetDeleteValue(Path+'Author/Value',FAuthor,'');

View File

@ -198,6 +198,7 @@ type
FOnFreeEditor: TOnFreePkgEditor;
FOnGetIDEFileInfo: TGetIDEFileStateEvent;
FOnGetUnitRegisterInfo: TOnGetUnitRegisterInfo;
FOnImExportCompilerOptions: TNotifyEvent;
FOnInstallPackage: TOnInstallPackage;
FOnOpenFile: TOnOpenFile;
FOnOpenPackage: TOnOpenPackage;
@ -262,6 +263,8 @@ type
write FOnUninstallPackage;
property OnDeleteAmbigiousFiles: TOnDeleteAmbigiousFiles
read FOnDeleteAmbigiousFiles write FOnDeleteAmbigiousFiles;
property OnImExportCompilerOptions: TNotifyEvent
read FOnImExportCompilerOptions write FOnImExportCompilerOptions;
end;
var
@ -1033,6 +1036,8 @@ var
begin
CompilerOptsDlg:=TfrmCompilerOptions.Create(Self);
CompilerOptsDlg.CompilerOpts:=LazPackage.CompilerOptions;
CompilerOptsDlg.OnImExportCompilerOptions:=
PackageEditors.OnImExportCompilerOptions;
with CompilerOptsDlg do begin
GetCompilerOptions;
Caption:=Format(lisPckEditCompilerOptionsForPackage, [LazPackage.IDAsString]

View File

@ -82,6 +82,7 @@ type
procedure OnPackageEditorGetUnitRegisterInfo(Sender: TObject;
const AFilename: string; var TheUnitName: string;
var HasRegisterProc: boolean);
procedure OnPackageEditorImExportCompilerOptions(Sender: TObject);
// package graph
function PackageGraphExplorerOpenPackage(Sender: TObject;
APackage: TLazPackage): TModalResult;
@ -401,6 +402,11 @@ begin
DoGetUnitRegisterInfo(AFilename,TheUnitName,HasRegisterProc,true);
end;
procedure TPkgManager.OnPackageEditorImExportCompilerOptions(Sender: TObject);
begin
MainIDE.DoImExportCompilerOptions(Sender);
end;
function TPkgManager.OnPackageEditorOpenPackage(Sender: TObject;
APackage: TLazPackage): TModalResult;
begin
@ -1369,6 +1375,7 @@ begin
PackageEditors.OnInstallPackage:=@OnPackageEditorInstallPackage;
PackageEditors.OnUninstallPackage:=@OnPackageEditorUninstallPackage;
PackageEditors.OnDeleteAmbigiousFiles:=@OnPackageEditorDeleteAmbigiousFiles;
PackageEditors.OnImExportCompilerOptions:=@OnPackageEditorImExportCompilerOptions;
// package macros
CodeToolBoss.DefineTree.MacroFunctions.AddExtended(