Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / fpc-pascal / 2012-06

fpmake question

4 messages · 3 people · –

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Bernd

I have some questions about fpmake. I cannot find any real examples or helpful explanations about it, so I'm currently experimenting with the incomplete information from the wiki.

From what I have understood so far (might be completely wrong) I

assume that my fpmake.pp is the equivalent of the Makefile (containing all the targets, rules and other logic) and fppkg is the equivalent of the make command.

the folder structure I currently have (without fpmake) is here: https://github.com/prof7bit/TorChat/tree/

As you can see currently I have a bunch of small handcrafted makefiles. One top level makefile and the folders below src also have their own makefiles and the targets are just doing simple stuff and calling fpc with some options. Now I am investigating whether I could change this so that I am using fpmake instead of make.

I have now started experimenting with the folder 'src/core/' because this one is self-contained and does not have any dependencies (but other parts of the project will depend on it and use it. Note also that currently for example purpletorchat.lpi has all these core units as part of the project, I assume I need to remove them).

now I have started with the simple example from the wiki and put an fpmake.pas into the core folder (exactly next to all the other unit files in the core folder) containing this:

program fpmake;
uses fpmkunit;
Var
  P: TPackage;
  T: TTarget;
begin
  With Installer do begin
    P := AddPackage('core');
    P.Directory := '.';
    P.OSes := [win32,openbsd,netbsd,freebsd,darwin,linux];
    P.Targets.AddUnit('tc_interfaces');
    P.Targets.AddUnit('tc_client');
    // most other units still missing because I get errors alread,
    // don't understand how this is supposed to work.
    Run;
  end;
end.

now (while in the core folder) from the console I do fppkg build and this happens:

$ fppkg build
/usr/bin/ld: warning: link.res contains output sections; did you forget -T? Start building package core for target i386-linux. Warning: Source file "tc_interfaces" from package core not found for i386-linux Warning: Source file "tc_client" from package core not found for i386-linux The installer encountered the following error:
Could not compile target tc_interfaces from package core The FPC Package tool encountered the following error: [<currentdir>] Execution of FPMake build failed

I don't have the slightest idea what is going on here, why can't it find the units, what is the string argument in AddPackage() supposed to mean (is it a name or a directory), what does 'AddPackge' even mean (to *what* will the package be added? Can't I have a package without adding it to anything? I just want to compile the units and maybe (later) depending on the build environment do some other stuff before/after compiling. Is fpmake even the right tool to use or should I stick with makefiles?)

Bernd

Sven Barth
to Bernd
Bernd wrote
I have some questions about fpmake. I cannot find any real examples or helpful explanations about it, so I'm currently experimenting with the incomplete information from the wiki.

Currently the best examples seem to be the various fpmake.pp files in $fpcdir/packages/PACKAGENAME/ (because they are in production use ;) ).

> From what I have understood so far (might be completely wrong) I assume that my fpmake.pp is the equivalent of the Makefile (containing all the targets, rules and other logic) and fppkg is the equivalent of the make command.

Not quite. fppkg is a program to handle the installation and upgrading of packages (this includes compiling and then running the fpmake.pp file as well). So fpmake itself is basically the make command.

I can't help you with your remaining problem though as I'm not that deeply into fpmake yet.

Regards,
Sven

Bernd
to Sven Barth

Ok, I'm slowly making progress. The Targets.AddUnit() method needs the unit file name (with extension).

But there is another problem. fpmake is sloooooooowwww.

$ time fppkg build
Start building package torchat-core for target i386-linux. Compiling lnet-0.6.5/lcommon.pas
Compiling lnet-0.6.5/levents.pas
Compiling lnet-0.6.5/lnet.pas
Compiling tc_interface.pas
Compiling tc_misc.pas
Compiling tc_protocol.pas
Compiling tc_prot_add_me.pas
Compiling tc_prot_client.pas
Compiling tc_prot_message.pas
Compiling tc_prot_not_implemented.pas
Compiling tc_prot_not_implemented.pas
Compiling tc_prot_ping.pas
Compiling tc_prot_pong.pas
Compiling tc_prot_profile_avatar_alpha.pas
Compiling tc_prot_profile_avatar.pas
Compiling tc_prot_profile_name.pas
Compiling tc_prot_profile_text.pas
Compiling tc_prot_remove_me.pas
Compiling tc_prot_status.pas
Compiling tc_prot_version.pas
Compiling tc_buddy.pas
Compiling tc_client.pas
Compiling tc_config.pas
Compiling tc_conn.pas
Compiling tc_const.pas
Compiling tc_msgqueue.pas
Compiling tc_roster.pas
Compiling tc_templist.pas
Compiling tc_tor.pas
[100%] Built target torchat-core

real 0m16.933s
user 0m6.928s
sys 0m1.600s

There is something not quite right in fpmkunit, there is a Sleep(100) in it that makes it slow down extremely:
Line 1289 in packages/fpmkunit/src/fpmkunit.pp

    else
    begin
      // no data, wait 100 ms
      Sleep(100);
    end;

making this a Slep(1) or even removing it completely makes the above run more than two times faster:

$ time fppkg build
Start building package torchat-core for target i386-linux. [...]
[100%] Built target torchat-core

real 0m6.680s
user 0m4.280s
sys 0m1.216s

Reinier Olislagers
to Bernd
Bernd wrote
Ok, I'm slowly making progress. The Targets.AddUnit() method needs the unit file name (with extension). But there is another problem. fpmake is sloooooooowwww.

<snip>

Show quoted text 12 lines
There is something not quite right in fpmkunit, there is a Sleep(100) in it that makes it slow down extremely: Line 1289 in packages/fpmkunit/src/fpmkunit.pp else begin // no data, wait 100 ms Sleep(100); end; making this a Slep(1) or even removing it completely makes the above run more than two times faster:

Would it make sense to shorten or remove this Sleep call?

Are there any other improvements that can be made with fpmake?

Searching for open bugs with fpmake in them gives: 21230 feature (fpmake) Non-mandatory installation of .o files 21868 minor fpmake terminates while clean repo
21991 major Patch to compile from command-line using fpmake 21442 trivial [patch] `make clean` does not clean all files 21880 major Can't build fpc from latest svn.
18321 block fppkg: Package webdesign needs to be rebuild, dependency gecko is modified
20466 trivial MAKE CLEAN do not delete *.DBG files 21418 minor Can't install a cross FPC into the same prefix as regular FPC on Unix.
15222 minor Dummy instead of unix include files are used. 21074 minor Added documentation runmode
19144 minor fpdoc system requires correct order of units on the cmdline 20479 minor 'make distclean' don't clean all .o-files 18151 minor fpmkunit compile example programs
13885 feature Replace "Create Makefile" with "Create fpmake file"

I noticed these remarks in 13885
First fpmake must be extended, so that compiling codetools works including passing multiple -d flags.
Then fpmake must be extended and/or LCL restructured, so that compiling LCL is possible.
After that IDEIntf, SynEdit, IDE should be no problem.

Does this situation still apply?

Anything I may have missed? If I or somebody else wanted to look into improving fpmake so it could be used more widely, where would I need to look?

Thanks,
Reinier