Package (BPL) Automatic Naming Suffix
Asked Answered
T

4

19

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!

Toadstool answered 9/1, 2012 at 16:51 Comment(10)
Not the compiler version but rather an IDE/RTL version.Crossquestion
Correct... edited accordingly! A silly mistake on my part!Toadstool
I get Either there is no report #83229, or you are not authorized to see that report. when I try to access it (logged in)Toadstool
Sorry, private report. I add the content to my answer.Scammony
@UweRaabe: it seems the report is private. Are you in any position to get it to a public state? Coz I can't view it either but would vote for it if I could.Lysippus
@Marjan, I cannot do it by myself, but I think I know someone who can. I'll give it a try.Scammony
@UweRaabe Thanks, holler if you are successful and I'll run to the voting board :)Lysippus
@Marjan: qc.embarcadero.com/wc/qcmain.aspx?d=83229Scammony
@UweRaabe: Thanks! Voted through desktop QC client so I could give it 10 votes (through the web client you have a 10 vote total).Lysippus
LIBSUFFIX AUTO has apparently been implemented in Delphi 10.4.1 (maybe even earlier).Garrek
S
7

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.

Scammony answered 9/1, 2012 at 19:40 Comment(2)
@Serg: yes, but private for the time being. see comments to questionLysippus
I'm building a plugin to address the problem as we speak!Toadstool
A
3

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'.

Alpert answered 9/1, 2012 at 17:23 Comment(10)
Also stored in the .dproj file under property name DllSuffix. I have no idea which setting wins and why it is duplicated.Lorenzalorenzana
Also, those directive should be at very bottom of package source since System is not in the scope until the end of contains.Crossquestion
The whole package installation in Delphi is a hell. With Delphi 7 you have had 2 files for package information (*.dpk and *.res), now you have 3 files, with duplication, though 1 file is more than enough. Unfortunately Embarcadero don't care.Alpert
The .DPROJ files are required for MSBUILD (and the "Galileo" IDEs), where-as the DPR is used by Delphi's compiler. It's an annoying duplication, for sure!Toadstool
@Serg not sure if you can do this, but I've submitted an edit to your answer. If you can approve it, I'll the modified answer as correct!Toadstool
@Toadstool - your edit already received 1 reject vote (not from me), I can't approve it. I copied your edit and can paste it myself, but I just don't understand the solution you are about to test.Alpert
@Serg I'm producing (and going to publicly release) a plugin for at least Delphi 2007 to XE2 to automagically manage the suffix value specified in the DPROJ file. This will, of course, support Toggling (so you can turn automatic suffixing on/off easily via the Project Manager's Context Menu for BPL/DLL projects).Toadstool
@Toadstool - That would be interesting, but in this case you are better to answer your question yourself.Alpert
Has anybody tried to put these directives in an include file and include that in de dpk? That way at least the IDE should leave them alone?Lysippus
As was written in my edited version of this answer (rejected)... if you place the directives in a unit of their own, and simply include that unit as part of the package... this particular issue is overcome (and replaced with an even worse problem in the Galileo IDEs (2005 and newer))Toadstool
A
2

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.)

Asinine answered 20/5, 2012 at 15:39 Comment(0)
E
0

{$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

Evacuee answered 8/3, 2022 at 13:34 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.