从Visual Studio Code构建Delphi项目 [英] Building Delphi project from Visual Studio Code

查看:2188
本文介绍了从Visual Studio Code构建Delphi项目的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经通过FPC和GDB在Visual Studio Code中设置了对象Pascal的构建和调试环境,但是我只是通过以下方式使仅包含1个.pas文件的程序的构建过程正常工作

I have already set up build and debug environment for Object Pascal inside Visual Studio Code via FPC and GDB, but I just made build process work for programs containing only 1 .pas file via

"command": "fpc",
"args": [ "-g", "-Px86_64", "helloWorld.pas" ],

现在,我需要建立一个很大的Delphi项目组(类似于解决方案?),它包含主项目文件.groupproj.

Now, I need to build quite big Delphi project group (something like solution?) and it contains main project file .groupproj.

是否有某种方式可以通过FPC构建.groupproj?
还是至少有一些解决方法,例如转换为.lpi,然后通过FPC进行构建?
或者至少从VS Code调用Delphi编译器/生成器并通过它构建整个项目组? (但是我不喜欢这个选项,因为我不想使用Delphi)

Is there a way to build the .groupproj via FPC somehow?
Or at least some workaround like conversion to .lpi and then build via FPC?
Or at least call Delphi compiler/builder from VS Code and build the whole project group via it? (but I don't like this option, because I prefer to not use Delphi)

推荐答案

为其他可能会偶然发现此问题的人弄清事实:

To get some facts straight for other people that might stumble on this:

  • FPC支持Delphi源文件(.lpr/.dpr,.pp/.pas和.inc).仍然不是Delphi版本依赖的Delphi元信息(.dproj/.dof/.bpg/.cfg/.groupproj).
  • Lazarus转换工具还转换.dfms.基本上,它是一个.dfm清洁程序和Uses子句增强器,就像某些Delphi版本之间的转换工具一样.但是,默认情况下,它也会进行替换,从而将Delphi代码(在FPC的Delphi(-Sd)模式下工作)更改为Lazarus首选的objfpc方言(-S2模式).尝试之前,请务必进行备份,并彻底检查转换工具的配置.
  • FPC和Delphi命令行参数不同.
  • FPC不支持Lazarus元数据格式,例如.lpi.但是,Lazarus实用程序Lazbuild支持从命令行构建Lazarus项目.

但幸运的是基本知识是相同的

But luckily the basics are the same

  1. 主程序或库文件文件
  2. 一组单位(.pas文件)并包括目录(.inc文件). FPC可以区分两者,而delphi则不能.
  3. 必须将自动创建的表单添加到项目中.
  4. 任何其他命令行开关,例如定义设置,范围检查优化选项.

因此,在最坏的情况下,请检查Delphi项目(在IDE或texteditor中)中的目录和开关,并创建手动buildscript或lazarus(.lpi)项目.

So in worst case, examine the Delphi projects (either in IDE or texteditor) for directories and switches and create either a manual buildscript or a lazarus (.lpi) project.

但是请务必记住,默认FPC模式不是Delphi模式,因此始终在执行FPC时确保手动启用Delphi模式(-Sd)

However it is vital to keep in mind that the default FPC mode is NOT Delphi mode, so always when executing FPC make sure you manually enable Delphi mode (-Sd)

Lazarus中的团队项目支持是非常新的(几个月以来),并且afaik甚至还没有稳定版本.虽然,如果您创建了一堆.lpis,则可以在.lpis上执行带有lazbuild命令序列的批处理文件/shellscript.

Group project support within Lazarus is very new (as in months), and afaik not even in stable versions yet. Though if you create a bunch of .lpis, a batch file/shellscript with a sequence of lazbuild commands on .lpis might do it.

P.s.将VSCode扔到公交车下,然后使用拉撒路.

P.s. throw the VSCode under the bus and use Lazarus.

这篇关于从Visual Studio Code构建Delphi项目的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆