如何使包依赖项/要求依赖于条件符号? [英] How to make package dependencies/requirements dependent on conditional symbols?
问题描述
我有一个软件包 Package1
,该软件包取决于软件包 PackDependency
。 Package1
的 .dpk 包含以下内容:
I have a package Package1
which depends on package PackDependency
. The .dpk of Package1
contains this:
requires
vcl,
rtl,
PackDependency,
dbrtl;
现在,仅当条件符号 CONDITION时,我才想拥有此依赖项
被定义。因此,我将 .dpk 文件手动更改为:
Now I want to have this dependeny only if a conditional symbol CONDITION
is defined. Thus I change the .dpk file manually to:
requires
vcl,
rtl,
{$IFDEF CONDITION}
PackDependency,
{$ENDIF}
dbrtl;
但这足够了吗?我担心 .dproj 文件。
But is this enough? I am worried about the .dproj files.
我想使用两个像 Package1
这样的软件包。其中之一在其 .dproj 文件中包含以下行:
I have two packages like Package1
I want to do the above with. One of them has the following line in its .dproj file:
<DCCReference Include="PackDependency.dcp"/>
其他软件包的 .dproj 不会 即使包也依赖于 PackDependency
,也要包含这一行。
The other packages' .dproj does not contain this line even though the package is also dependent on PackDependency
.
这引起了一些问题:
- 是否可以根据条件符号
要求
? - 如果是,我是否需要对.dproj文件做些事情?如果是的话,如果文件的某些区域被Delphi修改了,我会遇到麻烦吗?
- 为什么
< DCCReference Include ...> < $ li b
- 我怀疑从Delphi和使用msbuild从命令行构建时会出现不同的行为。前者可能会查看.dpk文件-但后者会吗?
我的最终目标是使用msbuild从命令行进行构建。因此,命令行和IDE之间的不同行为对我来说也是重要的信息。
My ultimate goal is building from command line using msbuild. So different behavior between command line and IDE is also important information for me.
推荐答案
这将很好地解决您在问题,直到您向包装中添加新单元!到那时,您的条件定义将被IDE自动删除,并且您必须再次将它们放入(这很烦人)。
This will work fine as you have explained in the question, until you add a new unit to the package! At that point, your conditional defines will be automatically erased by the IDE, and you'll have to put them in again (which is annoying).
我知道没有避免这种情况的好方法!
I know of no elegant way to avoid this!
不必太担心DPROJ文件...因为这些文件应该由IDE维护,因此可以删除其中的依赖项。 DPK源应(在编译时)删除DPROJ中的任何相应节点(在DPK中添加依赖项时,应在编译时将相应节点注入DPROJ中。)
Don't worry about the DPROJ files so much... as these are supposed to be maintained by the IDE, so removing a dependency in the DPK source should (upon compile) remove any corresponding nodes in the DPROJ (where adding dependencies in the DPK should, upon compile, inject the corresponding nodes into the DPROJ).
这篇关于如何使包依赖项/要求依赖于条件符号?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!