Delphi – backwards compatibility: using {%File to add non-Delphi files to your project in the .dpr
Posted by jpluimers on 2009/07/27
When you add a non-Delphi file to your project, the current (Galileo based) IDE’s add them only to your .dproj file.
But older Delphi’s used to add them to the .dpr file using the (undocumented) {%File pseudo-directive.
When including the file ..\src\Defines.inc, you need this pseudo-directive: {%File ‘..\src\Defines.inc’}
The .dpr import wizard knows about it: if you have a lonely .dpr file using the {%File pseudo-directive, it will be correctly reflected in the .dproj file.
In order to maintain compatibility with old Delphi versions, or if you do not want to ship (version specific!) .dproj files, it can be wise to add your non-Delphi items manually using the {%File pseudo-directive.
Note there are more (equally undocumented) pseudo-directives like {%DelphiDotNetAssemblyCompiler, which I might get back to a later time.
Sample code:
[SourceCode language=’Delphi’]
program InterfacedDataModulesProject;
{%File ‘..\src\Defines.inc’}
uses
FastMM4 in ‘..\src\FastMM4.pas’,
FastMM4Messages in ‘..\src\FastMM4Messages.pas’,
MainUnit in ‘..\src\MainUnit.pas’,
Forms,
MainFormUnit in ‘..\src\MainFormUnit.pas’ {MainForm};
{$R *.res}
begin
Main();
end.
[/SourceCode]
This is the relevant section of the .dproj file:
[SourceCode language=’xml’]
[/SourceCode]
(Yes, I will post about FastMM in a future blog article, and about interfaces and datamodules even further on.)
–jeroen
Leave a Reply