Package (BPL) Automatic Naming Suffix

3.2k views Asked by At

I write a lot of components and libraries for Delphi, most of which require the use of BPL Packaging so that they may be installed into the IDE.

This is simple enough and works well, right up until you want to maintain a single set of Package Project Files (in a single Project Group), but also want to compile and distribute those same packages for different Delphi versions.

Up to now I've been creating a different Package Project for each version of Delphi, and explicitly defining a Delphi Version Identifier as a suffix (e.g. Kinect_XE.bpl and Kinect_XE2.bpl).

I am aware that, in the Project Options for a Package Project, under Description, there are the fields LIB prefix and (more importantly for my needs) LIB suffix.

I am further aware that if I place a value in LIB suffix, it'll be appended to the end of the compiled BPL's filename.

My question, however, is first whether it is possible to have the IDE automatically populate the LIB suffix field with the IDE/RTL Version number, and if so... how?

I'm fairly certain this is possible, as it would appear that vcl120.bpl (and its counterparts for each respective version of Delphi) can be Referenced (as requirements) of your own packages using just vcl rather than having to type the full vcl120. It is, in fact, this same behaviour I'm hoping to achieve... where my packages can intra-reference eachother (as neccessary) without having to provide version-specific references to accommodate the suffixes.

Equally important is that resolving this will enable me to maintain a single set of Project Files in a single Project Group (with the obvious exception of XE2 where its Project Files don't necessarily behave very well with previous versions of Delphi due to the Platforms addition).

I suspect that I may need to put a value like $(VER) (or something similar) in the LIB suffix field, but this appears not to work and I've scoured Google looking for the correct solution.

Hope you can help!

UPDATE 1

I am now writing an IDE plugin to be used with (in the very least) Delphi 2007 to XE2, which gives DLL and BPL projects a new option called AutoSuffix. When toggled On, any IDE with the AutoSuffix plugin installed will immediately apply the correct IDE version suffix to the project.

The AutoSuffix plugin will be made available (freely) for everyone within the next 24 hours, and this question updated accordingly.

UPDATE 2

Okay... Delphi 2007 is being a pain! I've made AutoSuffix work with 2009 to XE2, so far, but 2007 requires a little more time (patience appreciated).

UPDATE 3

It would appear as though Embarcadero have heard our collective cry for simplier package unification between versions.

Mark is going to push this through to see if future versions of Delphi can accommodate a {$LIBSUFFIX AUTO} feature. I hope to hear back very soon whether this will be the case. If so, it certainly affects the way AutoSuffix will need to work on XE2 and older versions (as presently it doesn't provide the simple AUTO switch.. it has its own method).

My hope now is that EMB will take this request seriously, provide it as an integral feature going forward, so that it becomes a simple case of using AutoSuffix on existing versions to unify the process accross all versions!

4

There are 4 answers

2
Uwe Raabe On BEST ANSWER

AFAIK for Delphi up to XE2 there is no automatism for doing this.

Concerning the requires clause: when you require another package you are actually using the dcp, which doesn't inherit the LIBSUFFIX. Thus it is sufficient to require VCL.dcp during compile time, while VCL160.bpl is actually used during runtime. The DCP includes the complete BPL name to resolve that.

This makes the LIBSUFFIX approach superior to the simple "rename the package for each version of Delphi" one.

A solution like that suggested in QC83229 would make it easier to port a package to a newer Delphi version, but then you are still stuck with dproj files that are not backwards compatible.

I normally use different folders for each Delphi version, where only the project files are stored. For a new Delphi version I only have to copy a folder and change the LIBSUFFIX.

10
kludg On

LIBSUFFIX directive is in *.dpk file, and you can edit *.dpk file manually.

You can write, for example

{$IFDEF CONDITIONALEXPRESSIONS}
   {$IF CompilerVersion = 20.0}
{$LIBSUFFIX '120'}
   {$IFEND}
   {$IF CompilerVersion = 21.0}
{$LIBSUFFIX '140'}
   {$IFEND}
{$ENDIF}

The bad thing is that IDE does not respect your manual edits of *.dpk file and deletes them then you make changes in a package. That is why some component vendors that use conditional defines in *.dpk file say in installation instruction if asked to save changes say 'NO'.

0
Mattias Andersson On

My suggestion would be to add this as a configurable option to project option sets (see QC #86491.) Rather than updating all the packages it would be sufficient to update a single option set file.

In fact, it seems the DllSuffix tag is recognized by the option set files in Delphi XE/XE2. Adding <DllSuffix>160</DllSuffix> to the <PropertyGroup> section of an option set file will cause the suffix to be appended to the package in the project manager. However, you still have to open the project options and click OK in order for it to be saved to the .dpk file.

I agree that it would be extremely useful with this feature (I would think also for the packages in the RTL.)

0
zed On

{$LIBSUFFIX AUTO} feature was added in Delphi 10.4.1:

In previous versions (version 10.3 and earlier) of C++Builder and Delphi developers building packages needed to manually set their package’s library suffix setting. The DocWiki “What’s new in version 10.4.1” mentions a new IDE projects option for setting the library suffix:

“Package AUTO libsuffix: packages can now have an automatic version suffix, instead of manually updating and specifying the right version suffix with each new release. (The compiler quietly supported this in 10.4, but full support for the feature in the IDE and package project settings is introduced in 10.4.1.)”

enter image description here