Changeset 152489


Ignore:
Timestamp:
Sep 11, 2016, 11:07:27 AM (4 years ago)
Author:
cal@…
Message:

mp-buildbot: Support variants in dependency calc

Adding a failcache to avoid wasting time requires a path per port that
we can use to cache the result of the last build. Since we're planning
to support variants in mp-buildbot, this path needs to be
variant-specific as well. In order to implement the fail cache, we thus
need working variant support first.

Fix a bug in the variant calculation of dependencies that would trigger
in the following situation:

port bar:

depends_lib port:foo

port foo:

default_variants +foo +bar

./tools/dependencies.tcl bar -bar

This setup used to print "foo +foo" only, but passing that to "port
install" would still install foo with the bar variant. With this change,
the correct value "foo -bar+foo" is printed instead.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • contrib/mp-buildbot/tools/dependencies.tcl

    r151083 r152489  
    3535
    3636if {[llength $::argv] == 0} {
    37     puts stderr "Usage: $argv0 <portname>"
     37    puts stderr "Usage: $argv0 <portname> \[(+|-)variant...\]"
    3838    exit 1
    3939}
     
    6060}
    6161
     62# parse the given variants from the command line
     63array set variants {}
     64foreach item [lrange $::argv 1 end] {
     65    foreach {_ sign variant} [regexp -all -inline -- {([-+])([[:alpha:]_]+[\w\.]*)} $item] {
     66        set variants($variant) $sign
     67    }
     68}
     69
    6270# open the port so we can run dependency calculation
    6371array set portinfo [lindex $result 1]
    6472#try -pass_signal {...}
    6573try {
    66     set mport [mportopen $portinfo(porturl) [list subport $portname] {}]
     74    set mport [mportopen $portinfo(porturl) [list subport $portname] [array get variants]]
    6775} catch {{*} eCode eMessage} {
    6876    ui_error "mportopen ${portinfo(porturl)} failed: $eMessage"
     
    8391## print dependencies with variants
    8492proc printdependency {ditem} {
     93    global variants
     94
    8595    array set depinfo [mportinfo $ditem]
    8696
    87     puts [string trim "$depinfo(name) $depinfo(canonical_active_variants)"]
     97    # There's a conceptual problem here: We need to calculate the string to
     98    # pass to port(1) to build this exact port with its variants, but the
     99    # active_variants array does not contain an entry for explicitly
     100    # deactivated default_variants.
     101    #
     102    # To calculate the correct string with the explicitly disabled default
     103    # variants, if any, we need the default variants first. Unfortunately the
     104    # only way to get the set of default variants is opening the port without
     105    # any.
     106    #
     107    # Given the active_variants of the current dependency calculation and the
     108    # ones from a pristine port without variants, calculate the required
     109    # string.
     110
     111    # open the port without variants to determine the default variants
     112    if {[llength [array get variants]] > 0} {
     113        #try -pass_signal {...}
     114        try {
     115            set result [mportlookup $depinfo(name)]
     116            if {[llength $result] < 2} {
     117                ui_error "No such port: $depinfo(name)"
     118                exit 1
     119            }
     120
     121            # open the port so we can calculate the default variants
     122            array set defaultvariant_portinfo [lindex $result 1]
     123            set defaultvariant_mport [mportopen $defaultvariant_portinfo(porturl) [list subport $depinfo(name)] {}]
     124            array set defaultvariant_info [mportinfo $defaultvariant_mport]
     125            array set default_variants $defaultvariant_info(active_variants)
     126            mportclose $defaultvariant_mport
     127        }
     128    } else {
     129        array set default_variants {}
     130    }
     131
     132    set variantstring ""
     133    array set active_variants $depinfo(active_variants)
     134
     135    set relevant_variants [lsort -unique [concat [array names active_variants] [array names default_variants]]]
     136    foreach variant $relevant_variants {
     137        if {[info exists active_variants($variant)]} {
     138            append variantstring "$active_variants($variant)$variant"
     139        } else {
     140            # the only case where this situation can occur is a default variant that was explicitly disabled
     141            append variantstring "-$variant"
     142        }
     143    }
     144
     145    puts [string trim "$depinfo(name) $variantstring"]
    88146}
    89147dlist_eval $dlist {} [list printdependency]
Note: See TracChangeset for help on using the changeset viewer.