If you must maintain one package for several different versions of Delphi, then the usual way is
to have a new project for each version with a different {$LIBSUFFIX }
for the current version, i.e. for
Tokyo, the lib suffix is 250
, for Berlin it is 240
, etc.
It would be ideal, if we could have a {$LIBSUFFIX AUTO}
, so we could have a single package source and the IDE would add an appropriate suffix.
I tried using an include file with something like:
{$IFDEF VER320} {$LIBSUFFIX '250'} {$ENDIF}
and so on, and put that in the package source, but any change to the package would make the IDE
remove that and use the suffix (if any) it found in the .dproj file. If I put it back in, the compiled
package (let's call it MyPackage.dpk
) would indeed have that suffix (i.e. be compiled to MyPackage250.bpl
),
but the IDE was not aware of that, and would complain it could not install MyPackage.bpl
.
This problem is not new. It has been discussed various times on several forums and communities. On Stack Overflow, someone (called LaKraven) set out to create a wizard to solve this, but it can't be found anymore. All the websites that supposedly have it are up for grabs.
So I (re-)wrote this simple wizard myself. It adds a menu item to the project manager, with the title "Add Version Suffix", under
the "Rename" context menu item. This allows you to set the lib suffix for a package to the suffix that
is generally used for this version, so '250'
for Tokyo, '240'
for Berlin, etc.
Actually, this could be done automatically too, but not everyone wants that for every package, so now you have to change the suffix manually.
I only tested this in Delphi 10 Seattle, 10.1 Berlin and 10.2 Tokyo, but it probably works in older versions as well.
Just open the package AutoSuffix.dproj in your IDE, select the project in the Project Manager and
Select the Install
menu item from the context menu. If all is well, this installs the expert
and adds one menu item to the context menu of the Project Manager: Add Version Suffix
, under the Rename
item. This
menu item only appears if the project is a package.
File | Contents |
---|---|
.gitignore | Git ignores the files in this file |
AddAutoSuffixProjectMenu.pas | The main wizard that adds the menu item and sets the suffix |
AutoSuffix.dpk | The compiler project file |
AutoSuffix.dproj | The MSBUILD project file |
AutoSuffix.res | The resource file for this project |
LICENSE.md | The BSD two clause license for this project |
OpenTools.LocalMenus.pas | A stub implementation for IOTALocalMenu |
README.md | The readme for this project |