[138269] branches/gsoc15-dependency/base/src/macports1.0/macports_libsolv. tcl
ijackson at macports.org
ijackson at macports.org
Fri Jul 3 12:05:04 PDT 2015
Revision: 138269
https://trac.macports.org/changeset/138269
Author: ijackson at macports.org
Date: 2015-07-03 12:05:04 -0700 (Fri, 03 Jul 2015)
Log Message:
-----------
Code optimization: Adding dependency information to solv
Use $fields to set fieldname(type of dependency in portindex),
deptype and marker value. Iterate over these $fields instead of
running if{[info exits ...]}{} on each type of dependency.
Modified Paths:
--------------
branches/gsoc15-dependency/base/src/macports1.0/macports_libsolv.tcl
Modified: branches/gsoc15-dependency/base/src/macports1.0/macports_libsolv.tcl
===================================================================
--- branches/gsoc15-dependency/base/src/macports1.0/macports_libsolv.tcl 2015-07-03 18:55:08 UTC (rev 138268)
+++ branches/gsoc15-dependency/base/src/macports1.0/macports_libsolv.tcl 2015-07-03 19:05:04 UTC (rev 138269)
@@ -66,6 +66,16 @@
proc create_pool {} {
variable pool
variable portindexinfo
+
+ ## set fields for adding dependency information to the solv's by looping over $fields.
+ set fields [list]
+ lappend fields "depends_fetch" $solv::SOLVABLE_REQUIRES [list 1]
+ lappend fields "depends_extract" $solv::SOLVABLE_REQUIRES [list 1]
+ lappend fields "depends_build" $solv::SOLVABLE_REQUIRES [list 1]
+ lappend fields "depends_lib" $solv::SOLVABLE_REQUIRES [list -1]
+ lappend fields "depends_run" $solv::SOLVABLE_REQUIRES [list -1]
+ lappend fields "conflicts" $solv::SOLVABLE_CONFLICTS [list]
+ lappend fields "replaced_by" $solv::SOLVABLE_OBSOLETES [list]
## Check if libsolv cache (pool) is already created or not.
if {![info exists pool]} {
@@ -120,60 +130,16 @@
if {[info exists portinfo(categories)]} {
$repodata set_str $solvid $solv::SOLVABLE_CATEGORY $portinfo(categories)
}
+
## Add dependency information to solvable using portinfo
# $marker i.e last arg to add_deparray is set to 1 for build dependencies
# and -1 for runtime dependencies
- ## Add Build dependencies:
- if {[info exists portinfo(depends_fetch)]} {
- foreach dep $portinfo(depends_fetch) {
- set dep_name [lindex [split $dep :] end]
- $solvable add_deparray $solv::SOLVABLE_REQUIRES \
- [$pool str2id $dep_name 1] 1
+ foreach {fieldname deptype marker} $fields {
+ if {[info exists portinfo($fieldname)]} {
+ set dep_name [lindex [split $portinfo($fieldname) :] end]
+ $solvable add_deparray $deptype [$pool str2id $dep_name 1] {*}$marker
}
}
- if {[info exists portinfo(depends_extract)]} {
- foreach dep $portinfo(depends_extract) {
- set dep_name [lindex [split $dep :] end]
- $solvable add_deparray $solv::SOLVABLE_REQUIRES \
- [$pool str2id $dep_name 1] 1
- }
- }
- if {[info exists portinfo(depends_build)]} {
- foreach dep $portinfo(depends_build) {
- set dep_name [lindex [split $dep :] end]
- $solvable add_deparray $solv::SOLVABLE_REQUIRES \
- [$pool str2id $dep_name 1] 1
- }
- }
- ## Add Runtime dependencies
- if {[info exists portinfo(depends_lib)]} {
- foreach dep $portinfo(depends_lib) {
- set dep_name [lindex [split $dep :] end]
- $solvable add_deparray $solv::SOLVABLE_REQUIRES \
- [$pool str2id $dep_name 1] -1
- }
- }
- if {[info exists portinfo(depends_run)]} {
- foreach dep $portinfo(depends_run) {
- set dep_name [lindex [split $dep :] end]
- $solvable add_deparray $solv::SOLVABLE_REQUIRES \
- [$pool str2id $dep_name 1] -1
- }
- }
- ## Add Conflicts to the solvables
- if {[info exists portinfo(conflicts)]} {
- foreach conf $portinfo(conflicts) {
- $solvable add_deparray $solv::SOLVABLE_CONFLICTS \
- [$pool str2id $conf 1]
- }
- }
- ## Add Obsoletes(replaced_by) to the solvables
- if {[info exists portinfo(replaced_by)]} {
- foreach conf $portinfo(replaced_by) {
- $solvable add_deparray $solv::SOLVABLE_OBSOLETES \
- [$pool str2id $conf 1]
- }
- }
## Set portinfo of each solv object. Map it to correct solvid.
set portindexinfo([$solvable cget -id]) $line
@@ -284,11 +250,15 @@
## Dependency calculation using libsolv
proc dep_calc {portname} {
+ variable pool
ui_msg -nonewline "$macports::ui_prefix Computing dependencies for $portname using libsolv"
set jobs [list]
foreach arg $portname {
- lappend jobs [$solv::pool_Job $solv::Job_SOLVER_SOLVABLE [$arg cget -id]]
- puts "Jobs = $jobs"
+ # lappend jobs [$solv::Pool_Job $solv::Job_SOLVER_SOLVABLE [$arg cget -id]]
+ # puts "Jobs = $jobs"
+ set portid [$pool str2id $portname]
+ set dep_results [[$sel solvables] lookup_deparray $portid]
+ puts "Dep list = $dep_results"
}
}
}
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.macosforge.org/pipermail/macports-changes/attachments/20150703/397b6787/attachment.html>
More information about the macports-changes
mailing list