Including port groups multiple times (was: Re: passing variants to dependencies; pre-activate check)

David Strubbe dstrubbe at macports.org
Thu Oct 15 12:21:22 PDT 2015


Hi Rainer,

Do you have a suggestion of how to accomplish that? That could potentially
be a simpler approach than adding include guards.

If we do go with include guards, anyone want to comment on my particular
implementation?

Index: dports/_resources/port1.0/group/active_variants-1.1.tcl
===================================================================
--- dports/_resources/port1.0/group/active_variants-1.1.tcl     (revision
141271)
+++ dports/_resources/port1.0/group/active_variants-1.1.tcl     (working
copy)
@@ -87,6 +87,12 @@
 #     dependencies, e.g., require_active_variants path:foo/bar:standardport
 #     variant

+default active_variants_included {}
+
+# only include this PortGroup once
+if {${active_variants_included} == ""} {
+    set active_variants_included "yes"
+
 proc active_variants {depspec required {forbidden {}}} {
        # get the port which will provide $depspec; this allows us to
support e.g.,
        # path-style dependencies. This comes from port1.0/portutil.tcl and
should
@@ -278,3 +284,5 @@
 pre-activate {
         _check_require_active_variants activate
 }
+
+}

David

On Wed, Oct 14, 2015 at 9:19 AM, Rainer Müller <raimue at macports.org> wrote:

> On 2015-10-14 05:49, Ryan Schmidt wrote:
> > You're right, it's probably important for portgroup to guard against
> multiple inclusion.
> >
> > https://en.wikipedia.org/wiki/Include_guard
> >
> > "port lint" will warn you if you include a portgroup more than once, but
> that won't check portgroup inclusion in files other than the portfile
> itself, can give false positives for portgroups that are included in
> conditionals (including subports), and even ignores lines with leading
> whitespace.
> >
> > We should develop a standard include guard for portgroups (possibly the
> one you suggested) and use it in every portgroup.
>
> If we decide that there is no use case for including a port group
> multiple times, we could prevent this in base when evaluating PortGroup
> statements.
>
> Rainer
> _______________________________________________
> macports-dev mailing list
> macports-dev at lists.macosforge.org
> https://lists.macosforge.org/mailman/listinfo/macports-dev
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.macosforge.org/pipermail/macports-dev/attachments/20151015/7bd05bb7/attachment.html>


More information about the macports-dev mailing list