包 (BPL) 自动命名后缀

发布于 2024-12-26 06:51:34 字数 1662 浏览 1 评论 0原文

我为Delphi编写了很多组件和库,其中大部分需要使用BPL打包才能安装到IDE中。

这非常简单并且运行良好,直到您想要维护一组包项目文件(在单个项目组中),而且还想要为不同的 Delphi 版本编译和分发这些相同的包。

到目前为止,我一直在为每个版本的 Delphi 创建不同的包项目,并明确定义 Delphi 版本标识符作为后缀(例如 Kinect_XE.bplKinect_XE2.bpl)。

我知道,在包项目的项目选项中,描述下,有字段LIB前缀和(更重要的是对于我的需要)LIB 后缀

我进一步意识到,如果我在LIB 后缀中放置一个值,它将被附加到编译后的 BPL 文件名的末尾。

然而,我的问题首先是,IDE 是否可以自动使用 IDE/RTL 版本号填充 LIB 后缀 字段,如果可以的话...如何实现?

我相当确定这是可能的,因为 vcl120.bpl及其每个 Delphi 版本的对应版本)可以被引用(根据要求)您自己的包只需使用 vcl 而不必键入完整的 vcl120。事实上,我希望实现同样的行为......我的包可以相互引用(根据需要),而不必提供特定于版本的引用来适应后缀。

同样重要的是,解决这个问题将使我能够在单个项目组中维护一组项目文件(XE2 是一个明显的例外,由于 平台添加)。

我怀疑我可能需要在 LIB 后缀 字段中输入类似 $(VER) (或类似的值)的值,但这似乎不起作用,我已经谷歌搜索寻找正确的解决方案。

希望您能帮忙!

更新 1

我现在正在编写一个 IDE 插件,用于(至少)Delphi 2007 到 XE2,它为 DLL 和 BPL 项目提供了一个名为 自动后缀。当切换为开时,任何安装了 AutoSuffix 插件的 IDE 都会立即将正确的 IDE 版本后缀应用于项目。

AutoSuffix 插件将在接下来的 24 小时内向所有人免费提供,此问题也会相应更新。

更新 2

好吧...Delphi 2007 太痛苦了!到目前为止,我已经使 AutoSuffix 能够与 2009 年到 XE2 兼容,但 2007 年需要更多时间(请耐心等待)。

更新 3

看来 Embarcadero 已经听到了我们对版本之间更简单的软件包统一的集体呼声。

Mark 将推动这一点,看看 Delphi 的未来版本是否可以容纳 {$LIBSUFFIX AUTO} 功能。我希望很快就能收到回复,是否会出现这种情况。如果是这样,它肯定会影响 AutoSuffix 在 XE2 和旧版本上工作的方式(因为目前它不提供简单的 AUTO 开关..它有自己的方法)。

我现在希望 EMB 能够认真对待这一请求,将其作为一个完整的功能提供,以便它成为在现有版本上使用 AutoSuffix 来统一所有版本的流程的简单案例!

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!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

浅笑依然 2025-01-02 06:51:35

AFAIK 对于 Delphi 到 XE2 来说,没有自动执行此操作。

关于requires子句:当您require另一个包时,您实际上正在使用dcp,它不继承LIBSUFFIX。因此,在编译时需要 VCL.dcp 就足够了,而 VCL160.bpl 实际上是在运行时使用的。 DCP 包含完整的 BPL 名称来解决该问题。

这使得 LIBSUFFIX 方法优于简单的“为每个版本的 Delphi 重命名包”方法。

QC83229 中建议的解决方案将使移植包变得更容易到较新的 Delphi 版本,但您仍然会遇到不向后兼容的 dproj 文件。

我通常为每个 Delphi 版本使用不同的文件夹,其中仅存储项目文件。对于新的 Delphi 版本,我只需复制一个文件夹并更改 LIBSUFFIX。

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.

几味少女 2025-01-02 06:51:35

LIBSUFFIX指令位于*.dpk文件中,您可以手动编辑*.dpk文件。

例如,您可以这样写。

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

不好的是 IDE 不尊重您对 *.dpk 文件的手动编辑,并删除它们,然后您在包中进行更改。这就是为什么一些在 *.dpk 文件中使用条件定义的组件供应商在安装说明中说,如果要求保存更改,则说“否”。

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

烙印 2025-01-02 06:51:35

我的建议是将其作为可配置选项添加到项目选项集中(请参阅 QC # 86491。)无需更新所有包,更新单个选项集文件就足够了。

事实上,Delphi XE/XE2 中的选项集文件似乎可以识别 DllSuffix 标记。将 160 添加到选项集文件的 部分将导致后缀被附加到项目管理器中的包中。但是,您仍然需要打开项目选项并单击“确定”才能将其保存到 .dpk 文件中。

我同意这个功能非常有用(我认为对于 RTL 中的包也非常有用。)

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

遇到 2025-01-02 06:51:35

Delphi 10.4.1 中添加了 {$LIBSUFFIX AUTO} 功能:

在 C++Builder 的早期版本(版本 10.3 及更早版本)中
Delphi 开发人员构建包需要手动设置
包的库后缀设置。 DocWiki“版本中的新增内容
10.4.1”提到了一个用于设置库后缀的新 IDE 项目选项:

“软件包自动 libsuffix:软件包现在可以有一个自动版本
后缀,而不是手动更新并指定正确的版本
每个新版本的后缀。 (编译器悄悄地支持了这一点
10.4,但 10.4.1 中引入了对 IDE 和包项目设置中的功能的完全支持。)”

在此处输入图像描述

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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文