Sign in Join

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

Mailing lists / lazarus / 2015-07

Compiler Options - Conditionally add a package dependency?

13 messages · 5 people ·

Reply by email Subscribe to this list Your subscription

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

Graeme Geldenhuys

Hi,

I have two independent packages. I would like my project to toggle between either one (but never both at the same time). Both have a unit with the exact same name, hence both packages can't be added to the dependency list at the same time.

Is there a way with the Compiler Options -> Other (or Additions and Overrides) to include a specific package based on a compiler define?

eg:
if defined UsePackageA
PackageDependecy.Add(PackageA)
else
PackageDependency.Add(PackageB)

Well something like ,
- Graeme -

fpGUI Toolkit - a cross-platform GUI toolkit using Free Pascal http://fpgui.sourceforge.net/

Reply by email

Michael Van Canneyt
to Graeme Geldenhuys
Graeme Geldenhuys wrote 17 lines
Hi, I have two independent packages. I would like my project to toggle between either one (but never both at the same time). Both have a unit with the exact same name, hence both packages can't be added to the dependency list at the same time. Is there a way with the Compiler Options -> Other (or Additions and Overrides) to include a specific package based on a compiler define? eg: if defined UsePackageA PackageDependecy.Add(PackageA) else PackageDependency.Add(PackageB) Well something like would even go further, and have a package included or not depending on the OS.

Similar, I think it should be possible to include a unit in a package, depending on the OS.

In short, a set of conditions for package dependencies and contains lists.

Michael.

Reply by email

Graeme Geldenhuys
to Michael Van Canneyt
Michael Van Canneyt wrote
I would even go further, and have a package included or not depending on the OS. Similar, I think it should be possible to include a unit in a package, depending on the OS.

+1 on both counts. I've hit the issue of your second point many years ago with fpGUI packages and had to resort to using two packages of the same name, but in different OS directories.

Regards,
- Graeme -

fpGUI Toolkit - a cross-platform GUI toolkit using Free Pascal http://fpgui.sourceforge.net/

Reply by email

luiz americo pereira camara
to Michael Van Canneyt: Similar, I think it should be possible to include a unit in a package, depending on the…

2015-07-09 12:58 GMT-03:00 Michael Van Canneyt :

Show quoted text 14 lines
On Thu, 9 Jul 2015, Graeme Geldenhuys wrote: > > Is there a way with the Compiler Options -> Other (or Additions and > Overrides) to include a specific package based on a compiler define? > > > I would even go further, and have a package included or not depending on the OS.

+1.

I hit similar issue and tried to use the Conditionals script with the IDE Macro but could not get working .

My idea was do the following, but did not work:

  if SomeCondition then begin
    UsageSrcPath += GetIDEValue('$PkgSrcPath(''apackagname'')');
  end;

In my specific case the condition was the avaibility of a package. See thread "Check if a package is available through macros"

Luiz
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.lazarus.freepascal.org/pipermail/lazarus/attachments/20150709/2cc1f16c/attachment.html>

Reply by email

Marcos Douglas
to Michael Van Canneyt: Similar, I think it should be possible to include a unit in a package, depending on the…
Michael Van Canneyt wrote 29 lines
On Thu, 9 Jul 2015, Graeme Geldenhuys wrote: > Hi, > > I have two independent packages. I would like my project to toggle > between either one (but never both at the same time). Both have a unit > with the exact same name, hence both packages can't be added to the > dependency list at the same time. > > Is there a way with the Compiler Options -> Other (or Additions and > Overrides) to include a specific package based on a compiler define? > > eg: > if defined UsePackageA > PackageDependecy.Add(PackageA) > else > PackageDependency.Add(PackageB) > > Well something like that at least. I would even go further, and have a package included or not depending on the OS. Similar, I think it should be possible to include a unit in a package, depending on the OS. In short, a set of conditions for package dependencies and contains lists.

I would even go further even more:
If we have two units with the same name, would be better if were possible to create an alias namespace for each unit, like C# does.

https://msdn.microsoft.com/en-us/library/aa664765(v=vs.71).aspx

But you, guys, will talk about "an Unit is a namespace" -- we know this is true -- and this is not necessary... anyway.

Best regards,
Marcos Douglas

Reply by email

Michael Van Canneyt
to Marcos Douglas
Marcos Douglas wrote 40 lines
On Thu, Jul 9, 2015 at 12:58 PM, Michael Van Canneyt wrote: > > > On Thu, 9 Jul 2015, Graeme Geldenhuys wrote: > >> Hi, >> >> I have two independent packages. I would like my project to toggle >> between either one (but never both at the same time). Both have a unit >> with the exact same name, hence both packages can't be added to the >> dependency list at the same time. >> >> Is there a way with the Compiler Options -> Other (or Additions and >> Overrides) to include a specific package based on a compiler define? >> >> eg: >> if defined UsePackageA >> PackageDependecy.Add(PackageA) >> else >> PackageDependency.Add(PackageB) >> >> Well something like that at least. > > > I would even go further, and have a package included or not depending on the > OS. > Similar, I think it should be possible to include a unit in a package, > depending on the OS. > > In short, a set of conditions for package dependencies and contains lists. I would even go further even more: If we have two units with the same name, would be better if were possible to create an alias namespace for each unit, like C# does. https://msdn.microsoft.com/en-us/library/aa664765(v=vs.71).aspx But you, guys, will talk about "an Unit is a namespace" -- we know this is true -- and this is not necessary... anyway.

This is not correct.

We have support for dotted unit names. The only thing missing is a namespace directive.

Michael.

Reply by email

Marcos Douglas
to Michael Van Canneyt
Michael Van Canneyt wrote 55 lines
On Thu, 9 Jul 2015, Marcos Douglas wrote: > On Thu, Jul 9, 2015 at 12:58 PM, Michael Van Canneyt > wrote: >> >> >> >> On Thu, 9 Jul 2015, Graeme Geldenhuys wrote: >> >>> Hi, >>> >>> I have two independent packages. I would like my project to toggle >>> between either one (but never both at the same time). Both have a unit >>> with the exact same name, hence both packages can't be added to the >>> dependency list at the same time. >>> >>> Is there a way with the Compiler Options -> Other (or Additions and >>> Overrides) to include a specific package based on a compiler define? >>> >>> eg: >>> if defined UsePackageA >>> PackageDependecy.Add(PackageA) >>> else >>> PackageDependency.Add(PackageB) >>> >>> Well something like that at least. >> >> >> >> I would even go further, and have a package included or not depending on >> the >> OS. >> Similar, I think it should be possible to include a unit in a package, >> depending on the OS. >> >> In short, a set of conditions for package dependencies and contains >> lists. > > > I would even go further even more: > If we have two units with the same name, would be better if were > possible to create an alias namespace for each unit, like C# does. > > https://msdn.microsoft.com/en-us/library/aa664765(v=vs.71).aspx > > But you, guys, will talk about "an Unit is a namespace" -- we know > this is true -- and this is not necessary... anyway. This is not correct. We have support for dotted unit names. The only thing missing is a namespace directive.

I know we have support for dotted unit names -- and this is not so important, ie, what the difference between MyUnitName to my.unit.name? -- the real problem, IMHO, is the names collisions between packages.

Marcos Douglas

Reply by email

Michael Van Canneyt
to Marcos Douglas
Marcos Douglas wrote 61 lines
On Thu, Jul 9, 2015 at 2:58 PM, Michael Van Canneyt wrote: > > > On Thu, 9 Jul 2015, Marcos Douglas wrote: > >> On Thu, Jul 9, 2015 at 12:58 PM, Michael Van Canneyt >> wrote: >>> >>> >>> >>> On Thu, 9 Jul 2015, Graeme Geldenhuys wrote: >>> >>>> Hi, >>>> >>>> I have two independent packages. I would like my project to toggle >>>> between either one (but never both at the same time). Both have a unit >>>> with the exact same name, hence both packages can't be added to the >>>> dependency list at the same time. >>>> >>>> Is there a way with the Compiler Options -> Other (or Additions and >>>> Overrides) to include a specific package based on a compiler define? >>>> >>>> eg: >>>> if defined UsePackageA >>>> PackageDependecy.Add(PackageA) >>>> else >>>> PackageDependency.Add(PackageB) >>>> >>>> Well something like that at least. >>> >>> >>> >>> I would even go further, and have a package included or not depending on >>> the >>> OS. >>> Similar, I think it should be possible to include a unit in a package, >>> depending on the OS. >>> >>> In short, a set of conditions for package dependencies and contains >>> lists. >> >> >> I would even go further even more: >> If we have two units with the same name, would be better if were >> possible to create an alias namespace for each unit, like C# does. >> >> https://msdn.microsoft.com/en-us/library/aa664765(v=vs.71).aspx >> >> But you, guys, will talk about "an Unit is a namespace" -- we know >> this is true -- and this is not necessary... anyway. > > > This is not correct. > > We have support for dotted unit names. The only thing missing is a namespace > directive. I know we have support for dotted unit names -- and this is not so important, ie, what the difference between MyUnitName to my.unit.name? -- the real problem, IMHO, is the names collisions between packages.

I repeat:
"The only thing missing is a namespace directive."

And then you have what you need.

Michael.

Reply by email

silvioprog
to Marcos Douglas: On Thu, Jul 9, 2015 at 2:58 PM, Michael Van Canneyt I know we have support for dotted…
On Thu, Jul 9, 2015 at 2:58 PM, Michael Van Canneyt wrote:

[...]

We have support for dotted unit names. The only thing missing is a namespace directive.

Is there any plan for implementing the -NS[1] compiler parameter? This option allows to use scoped unit names, that is very good for dotted unit names, e.g:

MyCompany.SysUtils; // <scope>.<unitname>

...

uses
  SysUtils; // this is an 'alias' for my 'MyCompany.SysUtils' unit ...
$ fpc -NSMyCompany (it could be enabled via Lazarus package too)

This option also enables the 'UseUnitScopeNames' directive, so you can use a unit declaration like 'uses {$IFNDEF
UseUnitScopeNames}MyCompany.{$ENDIF}SysUtils'.

P.S.: you can pass two or more scopes via this options, e.g: -NSMyCompany;OtherCompany;SomeLib

[1] http://docwiki.embarcadero.com/RADStudio/XE8/en/Delphi_Compiler

Silvio Cl?cio My public projects - github.com/silvioprog -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.lazarus.freepascal.org/pipermail/lazarus/attachments/20150709/57eef27c/attachment.html>

Reply by email

Marcos Douglas
to Michael Van Canneyt: I repeat: "The only thing missing is a namespace directive." And then you have what you…
Michael Van Canneyt wrote 79 lines
On Thu, 9 Jul 2015, Marcos Douglas wrote: > On Thu, Jul 9, 2015 at 2:58 PM, Michael Van Canneyt > wrote: >> >> >> >> On Thu, 9 Jul 2015, Marcos Douglas wrote: >> >>> On Thu, Jul 9, 2015 at 12:58 PM, Michael Van Canneyt >>> wrote: >>>> >>>> >>>> >>>> >>>> On Thu, 9 Jul 2015, Graeme Geldenhuys wrote: >>>> >>>>> Hi, >>>>> >>>>> I have two independent packages. I would like my project to toggle >>>>> between either one (but never both at the same time). Both have a unit >>>>> with the exact same name, hence both packages can't be added to the >>>>> dependency list at the same time. >>>>> >>>>> Is there a way with the Compiler Options -> Other (or Additions and >>>>> Overrides) to include a specific package based on a compiler define? >>>>> >>>>> eg: >>>>> if defined UsePackageA >>>>> PackageDependecy.Add(PackageA) >>>>> else >>>>> PackageDependency.Add(PackageB) >>>>> >>>>> Well something like that at least. >>>> >>>> >>>> >>>> >>>> I would even go further, and have a package included or not depending >>>> on >>>> the >>>> OS. >>>> Similar, I think it should be possible to include a unit in a package, >>>> depending on the OS. >>>> >>>> In short, a set of conditions for package dependencies and contains >>>> lists. >>> >>> >>> >>> I would even go further even more: >>> If we have two units with the same name, would be better if were >>> possible to create an alias namespace for each unit, like C# does. >>> >>> https://msdn.microsoft.com/en-us/library/aa664765(v=vs.71).aspx >>> >>> But you, guys, will talk about "an Unit is a namespace" -- we know >>> this is true -- and this is not necessary... anyway. >> >> >> >> This is not correct. >> >> We have support for dotted unit names. The only thing missing is a >> namespace >> directive. > > > I know we have support for dotted unit names -- and this is not so > important, ie, what the difference between MyUnitName to my.unit.name? > -- the real problem, IMHO, is the names collisions between packages. I repeat: "The only thing missing is a namespace directive." And then you have what you need.

Ok.

To get ideas, Graeme has created this years ago:
http://wiki.lazarus.freepascal.org/Namespaces

Regards,
Marcos Douglas

Reply by email

silvioprog
to silvioprog: [...] Is there any plan for implementing the -NS[1] compiler parameter? This option…

On Thu, Jul 9, 2015 at 4:05 PM, silvioprog wrote: [...]

Show quoted text 5 lines
This option also enables the 'UseUnitScopeNames' directive, so you can use > a unit declaration like 'uses {$IFNDEF > UseUnitScopeNames}MyCompany.{$ENDIF}SysUtils'.

Oops,

"... so you can use an unit declaration like 'uses {$IFNDEF UseUnitScopeNames}MyCompany.{$ENDIF}SysUtils'", that is very useful for keep support for legacy codes.

Silvio Cl?cio My public projects - github.com/silvioprog -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.lazarus.freepascal.org/pipermail/lazarus/attachments/20150709/f1ad5cba/attachment.html>

Reply by email

luiz americo pereira camara
to silvioprog

Guys, i suggest to create another thread to discuss namespace.

This thread is a different topic, related to the IDE, while namespace is a compiler thing.

Luiz

"silvioprog" wrote 25 lines
On Thu, Jul 9, 2015 at 4:05 PM, silvioprog wrote: [...] > This option also enables the 'UseUnitScopeNames' directive, so you can >> use a unit declaration like 'uses {$IFNDEF >> UseUnitScopeNames}MyCompany.{$ENDIF}SysUtils'. > > Oops, "... so you can use an unit declaration like 'uses {$IFNDEF UseUnitScopeNames}MyCompany.{$ENDIF}SysUtils'", that is very useful for keep support for legacy codes. -- Silvio Cl?cio My public projects - github.com/silvioprog -- _______________________________________________ Lazarus mailing list http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.lazarus.freepascal.org/pipermail/lazarus/attachments/20150709/453b5dd3/attachment-0001.html>

Reply by email

Michael Van Canneyt
to silvioprog: [...] Is there any plan for implementing the -NS[1] compiler parameter? This option…
silvioprog wrote 9 lines
On Thu, Jul 9, 2015 at 2:58 PM, Michael Van ?wrote: [...]? We have support for dotted unit names. The only thing missing is a namespace?directive. Is there any plan for implementing the -NS[1] compiler parameter? This option allows to use scoped unit names, that is very good for dotted unit names, e.g: MyCompany.SysUtils; // <scope>.<unitname>

That is what I am talking about, this is the missing piece. Patches welcome :-)

Michael.

Reply by email