Re: [Lazarus] Where to define conditionals for FPC

2020-05-08 Thread Bo Berglund via lazarus
On Fri, 8 May 2020 19:51:25 +0200, Sven Barth via lazarus
 wrote:

>However Delphi does not define a DELPHI define, so you'll have to use a
>negated check for FPC instead. In your example:
>
>{$IFNDEF FPC}
>  {$IFDEF USE_SUPERPRO}
>Sentinel,
>  {$ENDIF}
>{$ENDIF}
>

Thanks, I will use that instead!


-- 
Bo Berglund
Developer in Sweden

-- 
___
lazarus mailing list
lazarus@lists.lazarus-ide.org
https://lists.lazarus-ide.org/listinfo/lazarus


Re: [Lazarus] Where to define conditionals for FPC

2020-05-08 Thread Sven Barth via lazarus
Bo Berglund via lazarus  schrieb am Fr., 8.
Mai 2020, 18:03:

> Maybe I can just enclose the ifdef's in an outer layer ifdef DELPHI?
> Does the converter skip such sections during the conversion?
> Like:
>
> {$IFDEF DELPHI}
>   {$IFDEF USE_SUPERPRO}
> Sentinel,
>   {$ENDIF}
> {$ENDIF}
>
> Then Sentinel will only ever be used if built by Delphi and only if
> SUPERPRO is set, right?
>

I don't know how the converter works, so I can't tell whether any of this
will help.

However Delphi does not define a DELPHI define, so you'll have to use a
negated check for FPC instead. In your example:

{$IFNDEF FPC}
  {$IFDEF USE_SUPERPRO}
Sentinel,
  {$ENDIF}
{$ENDIF}

Regards,
Sven

>
-- 
___
lazarus mailing list
lazarus@lists.lazarus-ide.org
https://lists.lazarus-ide.org/listinfo/lazarus


Re: [Lazarus] Where to define conditionals for FPC

2020-05-08 Thread Bo Berglund via lazarus
On Fri, 8 May 2020 17:19:30 +0200, Sven Barth via lazarus
 wrote:

>Such an include file would need to be included in all units where a define
>might be needed.
>
>Alternatively if you always use LazSerial for FPC/Lazarus you could simply
>check with "$ifdef FPC" instead.

Well LazSerial was just an example...

I am going over the code to remove functionality that has been
outdated over the years and uses components that are hard to port.

I have created a bunch of conditionals which I can use to select or
block certain functions in the code. I have also at the same time
added the conditionals for FPC to switch between for example LazSerial
and the corresponding serial component in Windows (there are actually
two that can be selected between using another conditional in
Windows).

All of this works OK in Delphi 2007 when I use the GUI to set the
conditional variables.

But what is worrying me is that the Lazarus Delphi Converter will not
find these conditionals and then convert stuff that are to be Delphi
only...
As far as I have understood the converter does not read the dproj file
where Delphi stores these settings.
But I might be overly anxious? Maybe Lazarus Delphi Converter can read
the dproj file and find the settings?

I made a test conversion a number of weeks ago and it failed because
of a lot of dependencies on components with no FCP counterpart etc...
Then I had to backtrack a lot to get the project in working order
again and decided to try to make the code FPC aware via the
conditionals and still keep the way it works now.

Maybe I can just enclose the ifdef's in an outer layer ifdef DELPHI?
Does the converter skip such sections during the conversion?
Like:

{$IFDEF DELPHI}
  {$IFDEF USE_SUPERPRO}
Sentinel,
  {$ENDIF}
{$ENDIF}

Then Sentinel will only ever be used if built by Delphi and only if
SUPERPRO is set, right?


-- 
Bo Berglund
Developer in Sweden

-- 
___
lazarus mailing list
lazarus@lists.lazarus-ide.org
https://lists.lazarus-ide.org/listinfo/lazarus


Re: [Lazarus] Where to define conditionals for FPC

2020-05-08 Thread Sven Barth via lazarus
Bo Berglund via lazarus  schrieb am Fr., 8.
Mai 2020, 16:54:

> On Fri, 8 May 2020 16:34:49 +0200, Gabor Boros via lazarus
>  wrote:
>
> >2020. 05. 08. 14:07 keltezéssel, Bo Berglund via lazarus írta:
> >> I know that you can define "custom options" in Lazarus
> >> Project/Options/CompilerOptions/CustomOptions/Defines
> >>
> >> These can then be used in constructs like this example:
> >>
> >> {$IFDEF USE_LAZSERIAL}
> >> //Code pertaining to LazSerial
> >> {$ELSE}
> >> //Code pertaining to AsyncPro
> >> {$ENDIF}
> >>
> >> But if I do not want to use Lazarus, how do I set the conditionals I
> >> want to use?
> >
> >
> >Compile with "fpc ... -dUSE_LAZSERIAL".
> >
>
> I am trying to find a way to mmake the code build both in Delphi 2007
> and Lazarus and since I have used conditionals to adapt the code to
> different components and environments I need to handle these in a
> consistent manner.
> I know that I can use the Delphi and Lazarus GUI to set these
> conditional variables, but in the end I need the Delphi code (I have
> still not reached FPC/Lazarus for the complete project) to be accepted
> by the Lazarus Delphi Conversion function and then everything I think
> is read from the project sources.
> In this case since Delphi 2007 stores the settings in the dproj file
> and since the Converter does not read that file I am trying to find a
> way to set the conditionals directly in the code...
>
> Maybe in an include file, but where should that be included?


Such an include file would need to be included in all units where a define
might be needed.

Alternatively if you always use LazSerial for FPC/Lazarus you could simply
check with "$ifdef FPC" instead.

Regards,
Sven
-- 
___
lazarus mailing list
lazarus@lists.lazarus-ide.org
https://lists.lazarus-ide.org/listinfo/lazarus


Re: [Lazarus] Where to define conditionals for FPC

2020-05-08 Thread Bo Berglund via lazarus
On Fri, 8 May 2020 16:34:49 +0200, Gabor Boros via lazarus
 wrote:

>2020. 05. 08. 14:07 keltezéssel, Bo Berglund via lazarus írta:
>> I know that you can define "custom options" in Lazarus
>> Project/Options/CompilerOptions/CustomOptions/Defines
>> 
>> These can then be used in constructs like this example:
>> 
>> {$IFDEF USE_LAZSERIAL}
>> //Code pertaining to LazSerial
>> {$ELSE}
>> //Code pertaining to AsyncPro
>> {$ENDIF}
>> 
>> But if I do not want to use Lazarus, how do I set the conditionals I
>> want to use?
>
>
>Compile with "fpc ... -dUSE_LAZSERIAL".
>

I am trying to find a way to mmake the code build both in Delphi 2007
and Lazarus and since I have used conditionals to adapt the code to
different components and environments I need to handle these in a
consistent manner.
I know that I can use the Delphi and Lazarus GUI to set these
conditional variables, but in the end I need the Delphi code (I have
still not reached FPC/Lazarus for the complete project) to be accepted
by the Lazarus Delphi Conversion function and then everything I think
is read from the project sources.
In this case since Delphi 2007 stores the settings in the dproj file
and since the Converter does not read that file I am trying to find a
way to set the conditionals directly in the code...

Maybe in an include file, but where should that be included?

The dpr file only contains this after the uses file list:

begin
  {$i conditionals.inc}  //<== Can it be here? Will it be global then?
  if not Application.DelayInitialize or Application.Installing then
Application.Initialize;
  Application.CreateForm(TRemoteServer, RemoteServer);
  Application.Run;
end.


-- 
Bo Berglund
Developer in Sweden

-- 
___
lazarus mailing list
lazarus@lists.lazarus-ide.org
https://lists.lazarus-ide.org/listinfo/lazarus


Re: [Lazarus] Where to define conditionals for FPC

2020-05-08 Thread Gabor Boros via lazarus

2020. 05. 08. 14:07 keltezéssel, Bo Berglund via lazarus írta:

I know that you can define "custom options" in Lazarus
Project/Options/CompilerOptions/CustomOptions/Defines

These can then be used in constructs like this example:

{$IFDEF USE_LAZSERIAL}
//Code pertaining to LazSerial
{$ELSE}
//Code pertaining to AsyncPro
{$ENDIF}

But if I do not want to use Lazarus, how do I set the conditionals I
want to use?



Compile with "fpc ... -dUSE_LAZSERIAL".

Gabor
--
___
lazarus mailing list
lazarus@lists.lazarus-ide.org
https://lists.lazarus-ide.org/listinfo/lazarus


Re: [Lazarus] Help! Lazarus compile fails.

2020-05-08 Thread Bo Berglund via lazarus
On Fri, 8 May 2020 12:05:47 +0200, Giuliano Colla via lazarus
 wrote:

>Il 07/05/2020 13:55, Bo Berglund via lazarus ha scritto:
>> I would not "upgrade" an installation, rather I would install a new
>> version along side of the existing one.
>> And I always install fpc/lazarus inside of the home dir instead of
>> using a global installation.
>
>I just gave a quick information. I do exactly the same as you, and I 
>still have all my versions around. But whatever I do,I succeed 
>installing  Lazarus, but I fail rebuilding it. I'm afraid my environment 
>has become too old, but I'd been glad to learn that is not the case, and 
>there's a simpler way, than switching to CentOs 7 or something.
>

Just to clarify:
I assume you have one config dir for *each* Lazarus version in your
home? Like this:

~ $ ll | grep .laza
drwxr-xr-x  4 pi   pi 4096 Nov  2  2019 .lazarus_2.0.2
drwxr-xr-x  4 pi   pi 4096 Nov 24 00:33 .lazarus_2.0.4
drwxr-xr-x  4 pi   pi 4096 Feb  5 18:24 .lazarus_2.0.6
drwxr-xr-x  4 pi   pi 4096 May  2 08:11 .lazarus_2.0.8

I made once a "shortcut" when installing a new Lazarus version by
copying an earlier config dir into the new name and then starting
Lazarus.
But Lazarus discovered that it was using an older config and offered
to update it, so it seemed to work OK.

However, there were still settings lingering that pointed back to the
old config dir, for example the packages downloaded via online package
manager were there but the config pointed to the previous
directory
Caused a lot of confusion until I understood how it worked.

The reason I did the copy was that I wanted my IDE settings to migrate
to the new Lazarus so I don't have to tediously customize the IDE
etc...

So whatever you do, do *not* copy the entire config dir to a new name
and use it with the new Lazarus!!!
Instead create a new *empty* dir to use instead and if needed copy the
editoroptions.xml file and perhaps some other settings file you use
after you have run Lazarus the first time with this pcp target.


-- 
Bo Berglund
Developer in Sweden

-- 
___
lazarus mailing list
lazarus@lists.lazarus-ide.org
https://lists.lazarus-ide.org/listinfo/lazarus


[Lazarus] Where to define conditionals for FPC

2020-05-08 Thread Bo Berglund via lazarus
I know that you can define "custom options" in Lazarus
Project/Options/CompilerOptions/CustomOptions/Defines

These can then be used in constructs like this example:

{$IFDEF USE_LAZSERIAL}
//Code pertaining to LazSerial
{$ELSE}
//Code pertaining to AsyncPro
{$ENDIF}

But if I do not want to use Lazarus, how do I set the conditionals I
want to use?

Something like:
{$DEFINE USE_LAZSERIAL}

written directly in a source file could perhaps be used?

But where do I put this so it will apply to the whole application?
And so that Delphi will also read it if I use the source in Delphi...


-- 
Bo Berglund
Developer in Sweden

-- 
___
lazarus mailing list
lazarus@lists.lazarus-ide.org
https://lists.lazarus-ide.org/listinfo/lazarus


Re: [Lazarus] Help! Lazarus compile fails.

2020-05-08 Thread Giuliano Colla via lazarus

Il 07/05/2020 13:55, Bo Berglund via lazarus ha scritto:

I would not "upgrade" an installation, rather I would install a new
version along side of the existing one.
And I always install fpc/lazarus inside of the home dir instead of
using a global installation.


I just gave a quick information. I do exactly the same as you, and I 
still have all my versions around. But whatever I do,I succeed 
installing  Lazarus, but I fail rebuilding it. I'm afraid my environment 
has become too old, but I'd been glad to learn that is not the case, and 
there's a simpler way, than switching to CentOs 7 or something.


Giuliano

--
Do not do to others as you would have them do to you.They might have different 
tastes.

--
___
lazarus mailing list
lazarus@lists.lazarus-ide.org
https://lists.lazarus-ide.org/listinfo/lazarus