Author Topic: Compiling JCF as a standalone utility on Linux  (Read 3852 times)


  • Full Member
  • ***
  • Posts: 172
Compiling JCF as a standalone utility on Linux
« on: September 22, 2013, 12:59:00 am »
Hey all,
I'm new to Pascal and Lazarus, and having a great time learning.  I got a wild hair recently to compile the Jedi Code Formatter as a standalone utility for Linux (yes, I know it's built in to Lazarus, but I'm attempting a learning experience).  I thought since there was a Lazarus project for it, it shouldn't be too hard.  As you can imagine, I've run into a few hangups.

I downloaded the JCF code from the SourceForge site and the first time I attempted to compile, I got:
JCF.lpr(3,2) Warning: APPTYPE is not supported by the target OS
JCF.lpr(1,1) Fatal: Unit FileUtils searched but FileUtil found
Well, Utils/FileUtils.pas doesn't exist, so I commented out the 'FileUtils' uses line in JCF.lpr (couldn't hurt to try, right?), and it compiled successfully (yay!).

After that, I played with my shiny new executable and it works well, but I tired of the need to pass the settings file path in the options every time (which I found at /usr/lib/lazarus/1.0.10/components/jcf2/JCFSettings.cfg).  Sure, I could just put the command in a shell script, but it seems to me there might be a way to pass the path to the config file automagically the way the current Windows code gets it from the Registry.  I've worked up some test code with GetAppConfigFile and OnGetApplicationName that works to return a path to the configuration file ($HOME/.config/jcf/JCFSettings.cfg ought to work fine), but only in my test code; I'm rather unclear where to stick it in the project.  Maybe in the registry read code with the appropriate {ifdef}?

After I get that tackled, I'd like to port the GUI to Lazarus/Linux as well, but first things first.

Any help with this wild goose chase will be appreciated; jeering and mockery will be cheerfully returned, minus tax. ;)
All children left unattended will be given a mocha and a puppy.

Arch (though I may go back to Debian)| FreePascal 3.2.2 + Lazarus 2.2.4, GTK2+ and Qt.  Mostly Qt...


  • Hero Member
  • *****
  • Posts: 595
Re: Compiling JCF as a standalone utility on Linux
« Reply #1 on: September 17, 2022, 02:59:49 pm »
Lack of decent command line formatters for free pascal source code has been impeding my wanting to get into using free pascal for software projects...

I had used pascal a lot in the 80s and 90s, most of the latter with Delphi.

But after revisiting pascal a few years ago and being so use to other languages that have decent command line reformatters (C/C++, python, go, rust, ...) it was very frustrating to find so much else I liked, but that I'd have to reformat code manually...

I did not know the name, JCF, until recently, before this post... out of frustration I tried to see if something in Lazarus would do it (I'm not a GUI guy for development, only use a good text editor and command line tools, works great for all the other languages I mention above...)

Anyways, poked around in Lazarus after finding I could reformat via the GUI and configure through the GUI... Then found I could run lazbuild on the project...

To make a long story short... I finally have a decent formatter from the command that I can tweak the config file as needed and include it with my software projects... (but occasionally I need to go into the GUI, but that will be minimized over time, because for most simple things I can just edit the config file...)

If this (lack of decent reformatters from the command line, and PTOP pukes out garbage for so many things...) was a such a barrier of entry for me, I wonder if it has been for others...


  • Hero Member
  • *****
  • Posts: 13274
Re: Compiling JCF as a standalone utility on Linux
« Reply #2 on: September 17, 2022, 03:02:56 pm »
Actually, in my opinion, for FPC and all its syntaxes, JCF is much worse than Ptop with correct options.
The reason being that JCF is rather focused on Delphi syntax and especially older Delphi syntax ( say, D7)
I actually get compliments for being rude... (well, Dutch, but that is the same)


  • Hero Member
  • *****
  • Posts: 595
Re: Compiling JCF as a standalone utility on Linux
« Reply #3 on: September 17, 2022, 03:09:55 pm »
But now, even for systems I'm logged into over the command line with no GUI, I can install Lazarus (just for this) and build the formatter from the command line...

It would be nice if this was in the standard FPC command line utilities (and not left as an exercise to the reader) as not everyone who wants to use pascal is a GUI developer...

As far as Ptop for me it pukes on simple stuff like

      on e: exception do

(the surrounding code is syntactically correct, it is the on e: exception do that Ptop seems to puke on...
And the rest of the code following that is mangled in the ptop output...

A few years ago I tried to make ptop work for an went through all the options...

A few clicks in the GUI config for Jedi Code Formatter and got mostly what I was looking for. A few runs on various soruces, a few more tweaks to config file, and it working great, as I expected... And I spend far less time fiddling with options for JCF than I did with ptop a few years back...
« Last Edit: September 17, 2022, 05:59:39 pm by Bogen85 »


  • Hero Member
  • *****
  • Posts: 595
Re: Compiling JCF as a standalone utility on Linux
« Reply #4 on: September 17, 2022, 03:24:57 pm »
Everything I'm doing with FPC is new in the past few years.

Code: [Select]
That is the only flavor I've need using, I've not seen a use for other flavors... (for what I've using FPC for...)

Code: [Select]
-Xc -XD -Xi -Sm -Sg -Os -gl -Mobjfpc -vnewh -Senwh -Sh
So yeah, I can see why you said JCF favors Delphi... which is basically I guess how I've using FPC, as the Delphi syntax was what I'd grown accustomed to when I last used Pascal a lot..


TinyPortal © 2005-2018