包 (BPL) 自动命名后缀
我为Delphi编写了很多组件和库,其中大部分需要使用BPL打包才能安装到IDE中。
这非常简单并且运行良好,直到您想要维护一组包项目文件(在单个项目组中),而且还想要为不同的 Delphi 版本编译和分发这些相同的包。
到目前为止,我一直在为每个版本的 Delphi 创建不同的包项目,并明确定义 Delphi 版本标识符作为后缀(例如 Kinect_XE.bpl 和 Kinect_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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
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 requireVCL.dcp
during compile time, whileVCL160.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.
LIBSUFFIX
指令位于*.dpk文件中,您可以手动编辑*.dpk文件。例如,您可以这样写。
不好的是 IDE 不尊重您对 *.dpk 文件的手动编辑,并删除它们,然后您在包中进行更改。这就是为什么一些在 *.dpk 文件中使用条件定义的组件供应商在安装说明中说,如果要求保存更改,则说“否”。
LIBSUFFIX
directive is in *.dpk file, and you can edit *.dpk file manually.You can write, for example
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'.
我的建议是将其作为可配置选项添加到项目选项集中(请参阅 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.)
Delphi 10.4.1 中添加了 {$LIBSUFFIX AUTO} 功能:
{$LIBSUFFIX AUTO} feature was added in Delphi 10.4.1: