6

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)

Lukas Salich
  • 959
  • 2
  • 12
  • 30
  • But I can't find, how to do it (still searching google, but Object Pascal, Delphi and FPC are new for me). – Lukas Salich Apr 12 '17 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. – David Heffernan Apr 12 '17 at 14:25
  • http://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. – dummzeuch Apr 12 '17 at 14:32
  • @DavidHeffernan No, it doesn't make sense with the edit. I want to build Delphi project using FPC, not build Lazarus project using FPC. I wouldn't even include freepascal tag, but stackoverflow changes FPC to freepascal, which also isn't correct. – Lukas Salich Apr 12 '17 at 14:32
  • You can't build a Delphi project with FPC. They are different things. Lazarus is different again. FPC is Free Pascal, a compiler. Lazarus is an IDE that uses FPC. Delphi is entirely different. You are not using dcc32 or dcc64. You are using fpc. The Delphi tag is for the Embarcadero compiler, which you are not using. – David Heffernan Apr 12 '17 at 14:37
  • @dummzeuch Thanks, there is also a guide right for VS Code, but I would like not to use Delphi or it's compiler. But yes, maybe it will be the only solution. http://blog.omnipascal.com/how-to-attach-the-build-process-to-visual-studio-code/ – Lukas Salich Apr 12 '17 at 14:37
  • It should be easy enough to modify the scripts at http://blog.omnipascal.com/how-to-attach-the-build-process-to-visual-studio-code/ to call fpc instead of msbuild – David Heffernan Apr 12 '17 at 14:46
  • @DavidHeffernan Both FPC and DCC compile Object Pascal, the code is both FPC and DCC compatible and I would much rather use FPC than DCC. Problem is the project file .groupproject which is maybe only Delphi compatible. – Lukas Salich Apr 12 '17 at 14:52
  • Well, I give up. I was trying to work this out, but you can't seem to make up your mind what compiler you are using. You want to use fpc, but you insist that the question is tagged Delphi. Sorry, I can't make any sense of that. You want to use both compilers. I want the question tagged Delphi, but I don't want to use Delphi. It's making no sense at all. Anyway, if you insist that this is the question, I'll do something else then. Good luck. – David Heffernan Apr 12 '17 at 14:58
  • @DavidHeffernan Thanks, I want to build Delphi project (.groupproj) with FPC, so using scripts from that blog I can either use Delphi builder (but I don't want to) or use (.lpi) with FPC. So if I don't want to use DCC and FPC can't use .groupproj, I will try to convert .groupproj to .lpi and if I won't be successful, I will really use the DCC :( Thanks anyway. – Lukas Salich Apr 12 '17 at 15:04
  • If you have a delphi project, it will use delphi arguments, delphi files, and delphi libraries, trying to get someone elses compiler to do that would be hard - whats wrong with using delphi? – BugFinder Apr 12 '17 at 15:04
  • No, I cannot make any sense of this. Have it your way. – David Heffernan Apr 12 '17 at 15:07
  • Compiling Delphi code using FPC is like trying to shoot knives out of a gun. Sure, with extensive modifications, you might be able to eventually pull it off. But is it really worth the effort? – Jerry Dodge Apr 12 '17 at 15:09
  • Ok, now I learned, that Delphi projects are very different from Lazarus projects. Maybe I should add earlier, that the whole project is developed both in Delphi and Lazarus, but I said that the code is both FPC and DCC compatible. Part of the team develops it in Delphi, part in Lazarus and the Lazarus part has some hacks... Anyway imagining shooting knives from a gun is cool! – Lukas Salich Apr 12 '17 at 15:17
  • 2
    [Lazarus has a converter](http://wiki.freepascal.org/Delphi_Converter_in_Lazarus) for converting Delphi projects to Lazarus projects. – Remy Lebeau Apr 12 '17 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. – Marco van de Voort Apr 13 '17 at 20:25

1 Answers1

3

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.

Marco van de Voort
  • 25,628
  • 5
  • 56
  • 89
  • 1
    I want to use VS Code, because I already use it for C++ development. – Lukas Salich Apr 14 '17 at 16:41
  • 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. – Marco van de Voort Apr 14 '17 at 16:57
  • 2
    It has support for Object Pascal via Omnipascal and Language Pascal extensions. – Lukas Salich Apr 14 '17 at 18:25
  • 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. – Lukas Salich Apr 19 '17 at 15:48
  • Why was this downvoted? It is a summary of facts of what FPC supports or doesn't support.wrt Delphi project meta files. – Marco van de Voort Apr 22 '17 at 17:37
  • Maybe some Delphi funs :D I dunno and voted +1, btw I will maybe accept it, just don't have the time to finish my Object Pascal build process. – Lukas Salich Apr 22 '17 at 17:43
  • @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. – m93a Nov 02 '17 at 07:27
  • It answers the questions that you can't use a Delphi build enviroment (if it even existed standalone) on top of FPC with context. – Marco van de Voort Nov 02 '17 at 13:25