Sign in Join

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

Mailing lists / fpc-pascal / 2008-02

Compiler API specification

6 messages · 4 people ·

Reply by email Subscribe to this list Your subscription

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

Skybuck Flying

Hello,

Here is my idea for a compiler application programming interface (api) / specification:

type
 // informs which file was tried by compiler, if successfull error text
should be nil, else it should contain some kind of error messages
 TcompilerFileTriedCallback = procedure( FullFilename : Pchar; ErrorText :
Pchar );
// returns true on success, false on failure
function SetSearchPath( SearchPath : Pchar ) : boolean;
// returns true on success, false on failure
function SetFileTriedCallback( Callback : TcompilerFileTriedCallback ) :
boolean;
// returns zero for successfull compile, or some value for number of errors
function CompileFile( FullFilename : Pchar ) : integer;

String/Pchar notes:

all strings terminated with null terminator character.

Path notes:

FullFilename example:

c:\delphi\units\somefile.pas

SearchPath example:

c:\delphi\units\somefolder1;c:\delphi\units\somefolder2

; = seperator

Error notes:

ErrorText should not contain null terminators except at the end.

Memory notes:

User/Programmer provides memory for api calls/strings, unless otherwise mentioned.

Compiler interface provides memory for callbacks/strings, unless otherwise mentioned.

(API untested but looks ok)

It works as follows:

1. Programmer loads the DLL or whatever.

2. Programmer sets the search path to be used.

3. Programmer sets the callback when feedback from compiler is wanted.

4. Programmer calls CompileFile to compile a file.

5. The compiler start compiling the file and all other files the file needs.

6. For each file the compiler compiles, the compiler performs a callback to let the programmer know that a file was tried/compiled or failed. Additionally the compiler returns error text, containing the errors for the tried file.

7. Finally the compiler returns zero for a successfull compile, or the number of errors.

What you think of this specification ?

Is it doable ?

I might try and implement a little dll myself in Delphi by simply using the fpc.exe and parsing it's output.

Somebody with advanced knowledge of the compiler sources, might be able to make a better/more robust implementation in free pascal.

Bye,
Skybuck.

Marco van de Voort
to Skybuck Flying
Is it doable ?

If you don't want to set any parameters ( in other words no compiler options dialogue)

Show quoted text 5 lines
I might try and implement a little dll myself in Delphi by simply using the fpc.exe and parsing it's output. Somebody with advanced knowledge of the compiler sources, might be able to make a better/more robust implementation in free pascal.

Not really. Nobody uses Delphi like this. Maybe you should do a first attempt to see how far you can come, and then report your findings here when you really have something to report.

It makes no sense to embark on an adventure to heavily change the FPC compiler for a project that doesn't exist yet.

Marco van de Voort
to Jonas Maebe
Show quoted text 7 lines
On 14 Feb 2008, at 07:15, Skybuck Flying wrote: > Here is my idea for a compiler application programming interface > (api) / specification: The comphook unit in combination with the compiler unit already provides such an api. It is used by the text more IDE.

The comphook unit uses ansistrings, textfile record and exceptions in the interface. This is not suitable for interfacing a FPC compiler dll from Delphi as Skybuck (or e.g. CrossFPC) wants.

Florian Klaempfl
to Marco van de Voort
Show quoted text 10 lines
> On 14 Feb 2008, at 07:15, Skybuck Flying wrote: > >> Here is my idea for a compiler application programming interface >> (api) / specification: > The comphook unit in combination with the compiler unit already > provides such an api. It is used by the text more IDE. The comphook unit uses ansistrings, textfile record and exceptions in the interface. This is not suitable for interfacing a FPC compiler dll from Delphi as Skybuck (or e.g. CrossFPC) wants.

Yes, but one can build easily a wrapper around it which exports everything in a dll compatible way.