Lukas Salich
Lukas Salich

Reputation: 1000

Building Delphi project from Visual Studio Code

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" ],

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

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)

Upvotes: 7

Views: 11098

Answers (1)

Marco van de Voort
Marco van de Voort

Reputation: 26376

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

  • FPC supports Delphi source files (.lpr/.dpr, .pp/.pas and .inc). Not Delphi meta information (.dproj/.dof/.bpg/.cfg/.groupproj) which is Delphi version dependent anyway.
  • Lazarus conversion tool also converts .dfms. Basically it is a .dfm cleaner and Uses clause enhancer, just like some conversion tools between Delphi versions. It by default however also does substitutions that change Delphi code (that works in FPC's Delphi (-Sd) mode) into the objfpc dialect (-S2 mode) preferred by Lazarus . Always make a backup before trying, and check the configuration of the conversion tool thoroughly.
  • FPC and Delphi commandline parameters are different.
  • FPC does not support Lazarus metadata formats like .lpi. The Lazarus utility Lazbuild however does support building Lazarus projects from the commandline.

But luckily the basics are the same

  1. a main program or library file files)
  2. a set of unit (.pas files) and include directories (.inc files). FPC differentiates between the two, delphi doesn't.
  3. autocreated forms must be added to the project.
  4. any additional commandline switches like defines to set, range checking optimization options.

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.

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)

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. throw the VSCode under the bus and use Lazarus.

Upvotes: 3

Related Questions