PDA

View Full Version : Eurekalog and Delphi


loris.luise
24-Nov-2010, 06:01 PM
Hello,
I think that Eurekalog has a odd behaviour when we have a Delphi DPR
file using conditional compilation.

Please consider this DPR

//
//
//{$define SERVICE}
//{$define ISAPI}
{$define APACHE2}

{$ifdef APACHE2}
{$E so} //change binary file extension from .dll to .so
{$LIBPREFIX 'mod_'} //prefix binary file name with mod_
library hydroweb;
{$else}
program HydroWeb;
{$endif}

uses
{$if not defined(APACHE2)}
FastMM4,
{$ifend}
{$if defined(APACHE2)}
IWInitApacheTwo,
ApacheTwoApp,
{$elseif defined(ISAPI)}
IWInitISAPI,
ISAPIApp,
{$elseif defined(SERVICE)}
IWInitService,
{$else}
Forms,
IWMain,
{$ifend}

IWUnitDmServerController in 'IWUnitDmServerController.pas' {IWServerController: TIWServerController},
IWUnitFrmMain in 'IWUnitFrmMain.pas' {frmMainForm: TIWAppForm};

{$ifdef APACHE2}
exports
apache_module name 'my_module';
{$endif}

{$R *.res}

begin

{$if defined(APACHE2)}
ModuleName := 'my_module';
Handler := 'mod_my-handler';

IWRun;
{$elseif defined(SERVICE)}
IWRun;
{$else}
try
Application.Initialize;
Application.Title := '';
Application.CreateForm(TformIWMain, formIWMain);
Application.Run;
finally
end;
{$ifend}
end.

and try to activate Eurekalog.... you'll never be able to compile it because
Eurekalog places USES in wrong position, too early. So, if I place dummy USES in non conditional compiled segments,
I can lately compile with success...
Watch this please...

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

//
//
//{$define SERVICE}
//{$define ISAPI}
{$define APACHE2}

{$ifdef APACHE2}
{$E so} //change binary file extension from .dll to .so
{$LIBPREFIX 'mod_'} //prefix binary file name with mod_
//uses ExceptionLog; <<<---- only for uncomment if i change CONDITIONAL DEFINES
library hydroweb;
{$else}
// dummy uses for EL in never compiled area
// to prevent EL to place uses ExceptionLog too early in wrong place
uses ExceptionLog;
program HydroWeb;
{$endif}

uses
{$if not defined(APACHE2)}
FastMM4,
{$ifend}
ExceptionLog,
{$if defined(APACHE2)}
IWInitApacheTwo,
ApacheTwoApp,
{$elseif defined(ISAPI)}
IWInitISAPI,
ISAPIApp,
{$elseif defined(SERVICE)}
IWInitService,
{$else}
Forms,
IWMain,
{$ifend}

IWUnitDmServerController in 'IWUnitDmServerController.pas' {IWServerController: TIWServerController},
IWUnitFrmMain in 'IWUnitFrmMain.pas' {frmMainForm: TIWAppForm};

{$ifdef APACHE2}
exports
apache_module name 'my_module';
{$endif}

{$R *.res}

begin

{$if defined(APACHE2)}
ModuleName := 'my_module';
Handler := 'mod_my-handler';

IWRun;
{$elseif defined(SERVICE)}
IWRun;
{$else}
try
Application.Initialize;
Application.Title := '';
Application.CreateForm(TformIWMain, formIWMain);
Application.Run;
finally
end;
{$ifend}
end.

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


Thanks

Alex
29-Nov-2010, 09:57 AM
Hi,

Sorry, but Delphi itself is not very good with complex IFDEFs in uses.

Consider this as a limitation of EurekaLog.

Kevin G. McCoy
29-Nov-2010, 02:59 PM
Loris,

If this is a recent version of Delphi, consider using a project group
with multiple projects inside it.

Each project can share code with the others, but uses a different DPR
file. That way you can avoid using $IFDEFs in the DPR. Each DPR makes a single version of your project.

I do this when I am creating a DLL version and an EXE version of the
same project, but you could do the same with ISAPI DLL and service EXE.

When I "build all" in my Delphi project, both the DLL and the EXE are built, with all the proper USES units and other code.

I can also select just one project (DLL or EXE) and make that one
without rebuilding the other one. This can save a little rebuild time.

Note that you may be able to manually edit the DPR and move the
EurekaLog units to the top of the USES list. Recent versions of Delphi
seem to place any newly added units at the _bottom_ of the DPR USES
list, so it *should* leave your changes to the top of the list alone.

EL seems to only care if its unit is somewhere in the USES list. If it
sees its unit there, then it doesn't try to add it again or move it to a new spot.

HTH!

Kevin G. McCoy

On 11/24/2010 11:01 AM, loris.luise wrote:
Hello,
I think that Eurekalog has a odd behaviour when we have a Delphi DPR
file using conditional compilation.

Please consider this DPR

//
//
//{$define SERVICE}
//{$define ISAPI}
{$define APACHE2}

{$ifdef APACHE2}
{$E so} //change binary file extension from .dll to .so {$LIBPREFIX 'mod_'} //prefix binary file name with mod_ library hydroweb;
{$else}
program HydroWeb;
{$endif}

uses
{$if not defined(APACHE2)} FastMM4,
{$ifend} {$if defined(APACHE2)} IWInitApacheTwo,
ApacheTwoApp,
{$elseif defined(ISAPI)} IWInitISAPI,
ISAPIApp,
{$elseif defined(SERVICE)} IWInitService,
{$else} Forms,
IWMain,
{$ifend} IWUnitDmServerController in 'IWUnitDmServerController.pas' {IWServerController: TIWServerController},
IWUnitFrmMain in 'IWUnitFrmMain.pas' {frmMainForm: TIWAppForm};

{$ifdef APACHE2}
exports
apache_module name 'my_module';
{$endif}

{$R *.res}

begin

{$if defined(APACHE2)} ModuleName := 'my_module';
Handler := 'mod_my-handler';

IWRun;
{$elseif defined(SERVICE)} IWRun;
{$else} try Application.Initialize;
Application.Title := '';
Application.CreateForm(TformIWMain, formIWMain);
Application.Run;
finally end;
{$ifend} end.

and try to activate Eurekalog.... you'll never be able to compile it because Eurekalog places USES in wrong position, too early. So, if I place dummy USES in non conditional compiled segments,
I can lately compile with success...
Watch this please...

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

//
//
//{$define SERVICE}
//{$define ISAPI}
{$define APACHE2}

{$ifdef APACHE2}
{$E so} //change binary file extension from .dll to .so {$LIBPREFIX 'mod_'} //prefix binary file name with mod_ //uses ExceptionLog;<<<---- only for uncomment if i change CONDITIONAL DEFINES library hydroweb;
{$else}
// dummy uses for EL in never compiled area
// to prevent EL to place uses ExceptionLog too early in wrong place
uses ExceptionLog;
program HydroWeb;
{$endif}

uses
{$if not defined(APACHE2)} FastMM4,
{$ifend} ExceptionLog,
{$if defined(APACHE2)} IWInitApacheTwo,
ApacheTwoApp,
{$elseif defined(ISAPI)} IWInitISAPI,
ISAPIApp,
{$elseif defined(SERVICE)} IWInitService,
{$else} Forms,
IWMain,
{$ifend} IWUnitDmServerController in 'IWUnitDmServerController.pas' {IWServerController: TIWServerController},
IWUnitFrmMain in 'IWUnitFrmMain.pas' {frmMainForm: TIWAppForm};

{$ifdef APACHE2}
exports
apache_module name 'my_module';
{$endif}

{$R *.res}

begin

{$if defined(APACHE2)} ModuleName := 'my_module';
Handler := 'mod_my-handler';

IWRun;
{$elseif defined(SERVICE)} IWRun;
{$else} try Application.Initialize;
Application.Title := '';
Application.CreateForm(TformIWMain, formIWMain);
Application.Run;
finally end;
{$ifend} end.

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


Thanks