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.
_______________________________________________
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal

Reply via email to