7

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)

16
  • But I can't find, how to do it (still searching google, but Object Pascal, Delphi and FPC are new for me). Commented Apr 12, 2017 at 14:24
  • 1
    This is a Free Pascal question, not a Delphi question. It is misleading to include a Delphi tag because of that. Commented Apr 12, 2017 at 14:25
  • delphi.wikia.com/wiki/Compile_from_Commandline won't help you compile it with fpc (I am pretty sure that won't work easily, but maybe help you understand how to build it in Delphi. Commented Apr 12, 2017 at 14:32
  • 2
    Lazarus has a converter for converting Delphi projects to Lazarus projects. Commented Apr 12, 2017 at 16:45
  • 1
    Remy: The convertor works on .dpr (and from that down into the rest of the source). To my best knowledge it ignores any purely configuration files (like .cfg, .dproj, .groupproj and the like). For the rest you might also want to add -Sd parameter to enforce compiler delphi language compatibility. Commented Apr 13, 2017 at 20:25

2 Answers 2

2

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.

Sign up to request clarification or add additional context in comments.

8 Comments

I want to use VS Code, because I already use it for C++ development.
That is because it understands C++ and probably allow proper syntactical navigation and other editor/IDE functions for it. It won't with Pascal however, but Lazarus will.
It has support for Object Pascal via Omnipascal and Language Pascal extensions.
Btw, the VS Code already works with .lpi-s and I can debug the FPC output executable from VS Code using GDB, but I still have problems with building .dproj-s, because I always get error when running the output executable.
@MarcovandeVoort It's downvoted because it's a summary of facts only vaguely related to the actual question. A good answer responds directly to the questions asked by OP. Maybe it's also because you're hating cool new VSCode and advertising old-looking Lazarus with horrible UI.
|
0
  1. Make sure Delphi is installed on your computer.
  2. Open your project folder in Visual Studio Code.
  3. Open the Terminal within Visual Studio Code.
  4. Use one of the below commands:

Win32 Compiler

dcc32 "C:/Folder_Path_To_Your_Project/Your_Project_Name.dpr"

Win64 Compiler

dcc64 "C:/Folder_Path_To_Your_Project/Your_Project_Name.dpr"

That'll start the Delphi Compiler within Visual Studio Code and compile your code 😁

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.