Lazarus - 如何创建自己的 $(CustomRelativeUnitPath)

Lazarus - How to create an own $(CustomRelativeUnitPath)

正如在 header 中提到的那样,有人可以告诉我,我如何为 lazarus IDE(版本:2.0.6)创建自己的 custom-relative-unit-path。

IDE 已经有一些内部 $(RelativePaths) 但我想创建自己的 $(RelativePaths) 并在 "other unit paths" 中设置它们,当然最后使用它们 ^^

我想做这样的事情:“$(MyCustomPath) = C:\Lazarus(someotherpathhere..)”

并将 $(MyCustompath) 放入 "other unit" 行并让它工作 ^^

低于我希望看到的:-)

此致

Shpendicus

enter image description here

我认为这样做的方法可能是使用 Lazarus IDE 宏。

有关完整文档,请参阅 https://wiki.freepascal.org/IDE_Macros_in_paths_and_filenames

IDE 宏 部分中说

IDE macros: they can be used in almost all IDE fields, e.g. search paths, custom options, file names, run parameters. They are replaced with their value before calling external tools like the compiler or the debugger. They are case insensitive.

IDE宏格式部分包括一些已经定义的示例。

这里解释了创建宏:https://wiki.freepascal.org/Macros_and_Conditionals

要为当前项目设置宏,请执行以下操作:

  • 转到项目 |项目选项 |编译器选项 |添加和覆盖
  • 在右侧,单击添加,然后从下拉菜单中单击 select IDE 宏 这将在下面的编辑器中打开一个 IDE 宏行。在其中,替换 MyCustomPath 的 MacroName 和任何你喜欢的值。我用了 D:\Lazarus2\MA
  • 关闭项目选项弹出窗口

接下来,在MyCustomPath指向的目录中,创建一个单元,例如Test.Pas 包括一个像 !我用了

unit Test

interface
!
implementation

end.

将 Test.Pas 添加到项目的使用列表并尝试编译。编译器应该抱怨找不到 Test.Pas.

接下来,打开项目 |项目选项 |编译器选项 |路径并在顶部的 Other unit files 框中插入 $(MyCustomPath)

关闭项目选项并编译 - 现在编译应该继续进行直到遇到编译停止!在 Test.Pas