PDA

View Full Version : FPC/Lazarus/Delphi project cleaning utility



jdarling
18-02-2010, 09:58 PM
I've always been annoyed at how much crap FPC throws into your project folder (at least in Delphi you could set a junk folder). And I've always hated getting a project ready to deploy to the public by having to write then run a cleanup script, praying that I remember to add strip for all of the exe's, dll's, so's, whatever...

There used to be a really good project for doing this for Delphi, and being the stubborn fool that I am I went ahead and wrote a new project that is very similar for Delphi, FPC, and Lazarus projects. Really, it could be used for any project or programming language, but these were my direct targets.

The app is command line based and I recommend placing it into your path for eased use. It should work on Windows, Linux, Mac, or anything else you can compile for with FPC/Lazarus. Of course, it also includes full source code.

Basic usage is; download package, extract some place, add to your systems PATH variable (not required), edit the ini file as you see fit, and run it with:
clean <projectFolder> [options]

The options are basically anything in the ini file preceded by a -

So, in as an example if you wanted to override the clean.exe setting from the command line:
clean MyProject -clean.exe *.exe;*.dll
OR
clean MyProject -clean.exe=*.exe;*.dll

Default settings out of the box are:
strip.exe=C:\lazarus\fpc\2.2.2\bin\i386-win32\strip
strip.mask=*\bin\*.exe;*\bin\*.dll
projects.path=C:\lazarus\projects\
erase.exe=erase
erase.mask=*.ppu;*.o;*.compiled;*.~*;*.dcu;*.bak;* .a;*.or;*.res;*.rst

Download it at: http://www.eonclash.com/execleaner/cleaner.zip

grudzio
20-02-2010, 11:25 PM
Actually, FPC comes with a utility for doing cleanup - delp (http://www.freepascal.org/tools/delp.var). It is not configurable at the moment, so point for You :).

On Linux one can also use fpcmake to create makefiles, to enjoy the full power of the GNU make.

Ñuño Martínez
24-02-2010, 09:23 AM
I've always been annoyed at how much crap FPC throws into your project folder (at least in Delphi you could set a junk folder). May be you should read again the command-line options, specially the "-F" familly (http://lazarus-ccr.sourceforge.net/fpcdoc/user/usersu14.html#x37-440005.1.3). ;)

I recommend you to use -FE* and -FU* options. -Fu*, -Fi*, -Fo* and -Fl* can help you to keep things in order too.

I use a directory tree similar than GNU's one and a makefile scripts. You can download my project template (http://www.burdjia.com/proyecto/archivo.php?nombre=makeproject-10.1.tar.gz) which includes few useful scripts.

jdarling
24-02-2010, 02:40 PM
Neither FI nor FU place only the .o, .res, .a, etc files into a junk folder while still leaving the binary file in the desired binary output folder. Setting FU to your /bin folder will still result in all of the junk files (IE the files you don't need for distribution) being placed with the exe.

I've read all of the command line options and paid very close attention to what they do to the output files. I've had conversations with the dev team (granted many moons ago) and the general thought was different then mine, and I'm ok with that. Up till recently I've done the cleanup with a simple batch file and just decided to replace that with something a bit easier to call/configure (considering I had to have a bash version for MAC and Linux).

I've seen your template before (and if you have ever looked at any of the projects I've posted here you will notice that I follow a very strict folder setup myself), and prefer my own way of doing it where I have independent project files for Linux, Windows, and MAC. This way I can simply compile from the NAS in all 3 at the same time with no problems and no param switching.

I hadn't seen delp before and it would have been a good starting point, but I've already done this part so I think I'll just stick with it.

- Jeremy

PS: I hate make, every time I have to touch make files I cringe, and I have to touch them quite a bit for micro and C/C++ projects I do.

Ñuño Martínez
24-02-2010, 02:57 PM
Neither FI nor FU place only the .o, .res, .a, etc files into a junk folder while still leaving the binary file in the desired binary output folder. Setting FU to your /bin folder will still result in all of the junk files (IE the files you don't need for distribution) being placed with the exe.
Well, using the next line:


fpc $(FLAGS) -Fu$(SRCDIR) -FU$(OBJDIR) program.pas -o$(BINDIR)program


I have the sources in the SRCDIR directory, .o, .ppu and .a files in the OBJDIR directory and the binary "program" in the BINDIR directory. Didn't test it with ".res" files.



I've seen your template before (...), and prefer my own way of doing it where I have independent project files for Linux, Windows, and MAC.
It's another way. ;) I didn't see your work (I mean sources) so I don't know how do you work. Anyone has its own style. :)


PS: I hate make, every time I have to touch make files I cringe, and I have to touch them quite a bit for micro and C/C++ projects I do.
I know. That's why I did the templates. Also, the "makefile.list" does generates a list of sources "on-the-fly". Of course it doesn't work in all cases. Actually I had to rewrite it in a very different way for one of my (unfinished) projects.