Difference between revisions of "InstantFPC"

From Lazarus wiki
Jump to navigationJump to search
Line 32: Line 32:
 
It compares the source with the stored file in cache and if it differs compiles the source, given the parameters in the shebang line (the first line of the script after #!).
 
It compares the source with the stored file in cache and if it differs compiles the source, given the parameters in the shebang line (the first line of the script after #!).
 
After successful compile it executes the program.
 
After successful compile it executes the program.
 +
If compilation fails it writes the fpc output to stdout.
  
=Get current version=
+
=Parameters=
  
instantfpc -v
+
*-v: Print current version and exit
 +
*--get-cache: Print current cache directory and exit
 +
*-h: print help and exit
 +
*-B: always compile even if cache is valid.
  
=Get current cache directory=
+
=Passing parameters to the compiler=
  
instantfpc --get-cache
+
Compiler parameters can be passed in the shebang line:
  
=Help=
+
<Delphi>
 
+
#!/usr/bin/env instantfpc -O1 -Ci
instantfpc -h
+
begin
 +
end.
 +
</Delphi>

Revision as of 18:34, 27 March 2011

Overview

This tool allows to run pascal program like scripts under unix like OS (Linux, BSD, OS X). For example:

<Delphi>

  1. !/usr/bin/env instantfpc

begin

 writeln('Hello fpc user');

end. </Delphi>

Save the file as hello.pas, set the permission to execute and run it:

[]$ chmod a+x hello.pas
[]$ ./hello.pas
Hello fpc user

Download

From svn

svn co https://lazarus-ccr.svn.sourceforge.net/svnroot/lazarus-ccr/applications/instantfpc instantfpc

Installation

  1. Compile the instantfpc.lpi with Lazarus or lazbuild. Or compile directly with fpc instantfpc.lpr.
  2. Put the executable into PATH, for example /usr/bin:
sudo cp instantfpc /usr/bin/

How it works

It uses a cache directory to compile. Default is $HOME/.cache/instantfpc. If HOME is not set it gives an error. You can override the directory by setting the environment variable INSTANTFPCCACHE. It compares the source with the stored file in cache and if it differs compiles the source, given the parameters in the shebang line (the first line of the script after #!). After successful compile it executes the program. If compilation fails it writes the fpc output to stdout.

Parameters

  • -v: Print current version and exit
  • --get-cache: Print current cache directory and exit
  • -h: print help and exit
  • -B: always compile even if cache is valid.

Passing parameters to the compiler

Compiler parameters can be passed in the shebang line:

<Delphi>

  1. !/usr/bin/env instantfpc -O1 -Ci

begin end. </Delphi>