[fpc-pascal] Alternative to Makefiles for fpGUI

Michael Van Canneyt michael at freepascal.org
Fri Aug 10 14:34:56 CEST 2007



On Fri, 10 Aug 2007, Graeme Geldenhuys wrote:

> On 10/08/07, Michael Van Canneyt <michael at freepascal.org> wrote:
> 
> >     T:=Targets.AddUnit('myunit');
> >     T.ResourceStrings:=True;
> >     T:=Targets.AddUnit('myprogram');
> >     T.AddDependency('myunit');
> 
> Does this take directories as well?

Not like this. 

You'll have to do this with the unit path:

  Case OS of
    Windows : begin
              T.UnitPath:='corelib/gdi';
              T.AddDependency('gfx_gdi');
              end;
    linux   : begin
              T.UnitPath:='corelib/x11';
              T.AddDependency('gfx_x11');
              end;
    // etc.
  end;

Obviously, the fpmake program is a normal pascal program, so you can do
complicated stuff like this:

-----------------------------------------------------------------------

program fpmake;

Type 
  TWidgetSet = (wsGDI,wsX,wCarbon);

Var
  WidgetSet : TWidgetSet;

procedure DetermineWidgetSet;

Var
  I : Integer;

begin
  Case Installer.OS of
    Windows : WidgetSet:=wsGDI;
    Linux : Widgetset:=wsX;
    macos : WidgetSet:=wsCarbon
  end;
  // Check paramstr() to see if the widgetset was overridedn on the commandline;
  For I:=1 to ParamCount do
    If ParamStr(i)='--widgetset=X' then
      WidgetSet:=wsX;
end; 

begin
  DetermineWidgetSet;
  With Installer do
   /// .... 
   Case WidgetSet of
    wsGDI : T.UnitPath:='corelib/gdi';
    wsX   : T.UnitPath:='corelib/x11';
    // etc.
   end;
  ...
  Run;
  end;

-----------------------------------------------------------------------


> Here is a fpGUI layout example:
> 
> Windows:
>    src/corelib/gdi/gfx_gdi.pas
> 
> Linux:
>    src/corelib/x11/gfx_x11.pas
> 
> Carbon:
>    src/corelib/carbon/gfx_carbon.pas
> 
> Common to all platforms:
>    src/corelib/fpgui.pas
>    src/corelib/gfxbase.pas
>    src/gui/gui_*.pas
> 
> 
> > The idea is that everyone who programs pascal, knows pascal,
> > and so the 'make' tool should also be in pascal...
> 
> That's a fair assumption. :)
> 
> 
> > ./fpmake --install
> >
> > will install it.
> 
> Install to where?

Default for the FPC installation, or to installdir
You can do a 

  fpmake --baseinstalldir='c:\program files\my package';

or set the default directory in the fpmake source code.

It's super configurable. 

A 

./fpmake --help 

will give you all options, in good unix tradition :-)

Michael.



More information about the fpc-pascal mailing list