Changeset 2118 for trunk/base
- Timestamp:
- Mar 1, 2003, 11:37:04 PM (21 years ago)
- Location:
- trunk/base/src/port1.0
- Files:
-
- 15 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/base/src/port1.0/portbuild.tcl
r1651 r2118 34 34 35 35 set com.apple.build [target_new com.apple.build build_main] 36 ${com.apple.build} provides build 37 ${com.apple.build} requires main fetch extract checksum patch configure 38 ${com.apple.build} deplist depends_build depends_lib 39 ${com.apple.build} set prerun build_start 36 target_provides ${com.apple.build} build 37 target_requires ${com.apple.build} main fetch extract checksum patch configure 38 target_prerun ${com.apple.build} build_start 40 39 41 40 # define options … … 49 48 default build.target "all" 50 49 51 52 50 set UI_PREFIX "---> " 53 51 54 52 proc build_getmaketype {args} { 55 global build.type build.cmd os.platform 56 57 if ![info exists build.type] { 53 if {![exists build.type]} { 58 54 return make 59 55 } 60 switch -exact -- ${build.type}{56 switch -exact -- [option build.type] { 61 57 bsd { 62 if { ${os.platform}== "darwin"} {58 if {[option os.platform] == "darwin"} { 63 59 return bsdmake 64 60 } else { … … 67 63 } 68 64 gnu { 69 if { ${os.platform}== "darwin"} {65 if {[option os.platform] == "darwin"} { 70 66 return gnumake 71 67 } else { … … 77 73 } 78 74 default { 79 ui_warn "[format [msgcat::mc "Unknown build.type %s, using 'gnumake'"] ${build.type}]"75 ui_warn "[format [msgcat::mc "Unknown build.type %s, using 'gnumake'"] [option build.type]]" 80 76 return gnumake 81 77 } … … 84 80 85 81 proc build_start {args} { 86 global UI_PREFIX portname build.target82 global UI_PREFIX 87 83 88 ui_msg "$UI_PREFIX [format [msgcat::mc "Building %s with target %s"] ${portname} ${build.target}]"84 ui_msg "$UI_PREFIX [format [msgcat::mc "Building %s with target %s"] [option portname] [option build.target]]" 89 85 } 90 86 -
trunk/base/src/port1.0/portchecksum.tcl
r1638 r2118 34 34 35 35 set com.apple.checksum [target_new com.apple.checksum checksum_main] 36 ${com.apple.checksum} provideschecksum37 ${com.apple.checksum} requiresmain fetch38 ${com.apple.checksum} set prerunchecksum_start36 target_provides ${com.apple.checksum} checksum 37 target_requires ${com.apple.checksum} main fetch 38 target_prerun ${com.apple.checksum} checksum_start 39 39 40 40 # define options … … 65 65 66 66 proc dmd5 {file} { 67 global checksums 68 69 foreach {name type sum} $checksums { 67 foreach {name type sum} [option checksums] { 70 68 if {$name == $file} { 71 69 return $sum … … 82 80 83 81 proc checksum_main {args} { 84 global checksumsdistpath all_dist_files UI_PREFIX82 global distpath all_dist_files UI_PREFIX 85 83 86 84 # If no files have been downloaded there is nothing to checksum … … 89 87 } 90 88 91 if ![info exists checksums]{89 if {![exists checksums]} { 92 90 ui_error "[msgcat::mc "No checksums statement in Portfile. File checksums are:"]" 93 91 foreach distfile $all_dist_files { … … 98 96 99 97 # Optimization for the 2 argument case for checksums 100 if {[llength $checksums] == 2 && [llength $all_dist_files] == 1} {101 set checksums [linsert $checksums0 $all_dist_files]98 if {[llength [option checksums]] == 2 && [llength $all_dist_files] == 1} { 99 option checksums [linsert [option checksums] 0 $all_dist_files] 102 100 } 103 101 -
trunk/base/src/port1.0/portclean.tcl
r1638 r2118 36 36 37 37 set com.apple.clean [target_new com.apple.clean clean_main] 38 ${com.apple.clean} set runtype always 39 ${com.apple.clean} provides clean 40 ${com.apple.clean} requires main 41 ${com.apple.clean} set prerun clean_start 38 target_runtype ${com.apple.clean} always 39 target_provides ${com.apple.clean} clean 40 target_requires ${com.apple.clean} main 41 target_prerun ${com.apple.clean} clean_start 42 43 set UI_PREFIX "--->" 42 44 43 45 proc clean_start {args} { 44 global UI_PREFIX portname46 global UI_PREFIX 45 47 46 ui_msg "$UI_PREFIX [format [msgcat::mc "Cleaning %s"] $portname]"48 ui_msg "$UI_PREFIX [format [msgcat::mc "Cleaning %s"] [option portname]]" 47 49 } 48 50 49 51 proc clean_main {args} { 50 global workpath 51 exec rm -rf [file join ${workpath}] 52 exec rm -rf [file join [option workpath]] 52 53 return 0 53 54 } -
trunk/base/src/port1.0/portconfigure.tcl
r1638 r2118 34 34 35 35 set com.apple.configure [target_new com.apple.configure configure_main] 36 ${com.apple.configure} provides configure 37 ${com.apple.configure} requires main fetch extract checksum patch 38 ${com.apple.configure} deplist depends_build depends_lib 39 ${com.apple.configure} set prerun configure_start 36 target_provides ${com.apple.configure} configure 37 target_requires ${com.apple.configure} main fetch extract checksum patch 38 target_prerun ${com.apple.configure} configure_start 40 39 41 40 # define options … … 54 53 55 54 proc configure_start {args} { 56 global UI_PREFIX portname55 global UI_PREFIX 57 56 58 ui_msg "$UI_PREFIX [format [msgcat::mc "Configuring %s"] $portname]"57 ui_msg "$UI_PREFIX [format [msgcat::mc "Configuring %s"] [option portname]]" 59 58 } 60 59 -
trunk/base/src/port1.0/portcontents.tcl
r1638 r2118 34 34 35 35 set com.apple.contents [target_new com.apple.contents contents_main] 36 ${com.apple.contents} set runtypealways37 ${com.apple.contents} providestoc38 ${com.apple.contents} requiresmain36 target_runtype ${com.apple.contents} always 37 target_provides ${com.apple.contents} toc 38 target_requires ${com.apple.contents} main 39 39 40 40 set UI_PREFIX "---> " -
trunk/base/src/port1.0/portdepends.tcl
r1642 r2118 37 37 38 38 # define options 39 options depends_ fetch depends_build depends_run depends_extractdepends_lib39 options depends_build depends_run depends_lib 40 40 # Export options via PortInfo 41 options_export depends_ lib depends_run41 options_export depends_build depends_lib depends_run 42 42 43 option_proc depends_fetch handle_depends_options 44 option_proc depends_build handle_depends_options 45 option_proc depends_run handle_depends_options 46 option_proc depends_extract handle_depends_options 47 option_proc depends_lib handle_depends_options 43 option_proc depends_build validate_depends_options 44 option_proc depends_run validate_depends_options 45 option_proc depends_lib validate_depends_options 48 46 49 proc handle_depends_options {option action args} {47 proc validate_depends_options {option action args} { 50 48 global targets 51 49 switch -regex $action { 52 set|append {50 set|append|delete { 53 51 foreach depspec $args { 54 52 if {[regexp {([A-Za-z\./0-9]+):([A-Za-z0-9_/\-\.$^\?\+\(\)\|\\]+):([-A-Za-z\./0-9_]+)} "$depspec" match deppath depregex portname] == 1} { 55 53 switch $deppath { 56 lib { set obj [libportfile_new $portname $depregex] } 57 bin { set obj [binportfile_new $portname $depregex] } 58 path { set obj [pathportfile_new $portname $depregex] } 59 } 60 if {[info exists obj]} { 61 $obj append provides $option portfile-$portname 62 lappend targets $obj 63 foreach obj [depspec_get_matches $targets deplist $option] { 64 $obj append requires portfile-$portname 65 } 66 } else { 67 return -code error [format [msgcat::mc "unknown depspec type: %s"] $deppath] 54 lib {} 55 bin {} 56 path {} 57 default {return -code error [format [msgcat::mc "unknown depspec type: %s"] $deppath]} 68 58 } 69 59 } else { … … 72 62 } 73 63 } 74 delete {75 # xxx: need to delete requirement from each item in the deplist76 }77 64 } 78 65 } -
trunk/base/src/port1.0/portextract.tcl
r1766 r2118 34 34 35 35 set com.apple.extract [target_new com.apple.extract extract_main] 36 ${com.apple.extract} set init extract_init 37 ${com.apple.extract} provides extract 38 ${com.apple.extract} requires fetch checksum 39 ${com.apple.extract} deplist depends_extract 40 ${com.apple.extract} set prerun extract_start 36 target_init ${com.apple.extract} extract_init 37 target_provides ${com.apple.extract} extract 38 target_requires ${com.apple.extract} fetch checksum 39 target_prerun ${com.apple.extract} extract_start 41 40 42 41 # define options … … 59 58 global extract.only extract.dir extract.cmd extract.pre_args extract.post_args distfiles use_bzip2 use_zip workpath 60 59 61 if [ infoexists use_bzip2] {62 setextract.cmd bzip263 } elseif [ infoexists use_zip] {64 setextract.cmd unzip65 setextract.pre_args -q66 set extract.post_args "-d ${extract.dir}"60 if [exists use_bzip2] { 61 option extract.cmd bzip2 62 } elseif [exists use_zip] { 63 option extract.cmd unzip 64 option extract.pre_args -q 65 option extract.post_args "-d [option extract.dir]" 67 66 } 68 67 } 69 68 70 69 proc extract_start {args} { 71 global UI_PREFIX portname70 global UI_PREFIX 72 71 73 ui_msg "$UI_PREFIX [format [msgcat::mc "Extracting %s"] $portname]"72 ui_msg "$UI_PREFIX [format [msgcat::mc "Extracting %s"] [option portname]]" 74 73 } 75 74 76 75 proc extract_main {args} { 77 global portname distname distpath distfiles use_bzip2 extract.only extract.cmd extract.before_args extract.after_args extract.argsUI_PREFIX76 global UI_PREFIX 78 77 79 if {![ info exists distfiles] && ![infoexists extract.only]} {78 if {![exists distfiles] && ![exists extract.only]} { 80 79 # nothing to do 81 80 return 0 82 81 } 83 82 84 foreach distfile ${extract.only}{83 foreach distfile [option extract.only] { 85 84 ui_info "$UI_PREFIX [format [msgcat::mc "Extracting %s"] $distfile] ... " -nonewline 86 set extract.args "$distpath/$distfile"85 option extract.args "[option distpath]/$distfile" 87 86 if [catch {system "[command extract]"} result] { 88 87 return -code error "$result" -
trunk/base/src/port1.0/portfetch.tcl
r1924 r2118 34 34 35 35 set com.apple.fetch [target_new com.apple.fetch fetch_main] 36 ${com.apple.fetch} set init fetch_init 37 ${com.apple.fetch} provides fetch 38 ${com.apple.fetch} requires main 39 ${com.apple.fetch} deplist depends_fetch 40 ${com.apple.fetch} set prerun fetch_start 36 target_init ${com.apple.fetch} fetch_init 37 target_provides ${com.apple.fetch} fetch 38 target_requires ${com.apple.fetch} main 39 target_prerun ${com.apple.fetch} fetch_start 41 40 42 41 # define options: distname master_sites -
trunk/base/src/port1.0/portinstall.tcl
r2075 r2118 34 34 35 35 set com.apple.install [target_new com.apple.install install_main] 36 ${com.apple.install} set runtype always 37 ${com.apple.install} provides install 38 ${com.apple.install} requires main fetch extract checksum patch configure build 39 ${com.apple.install} deplist depends_run depends_lib 40 ${com.apple.install} set prerun install_start 41 ${com.apple.install} set postrun install_registry 36 target_runtype ${com.apple.install} always 37 target_provides ${com.apple.install} install 38 target_requires ${com.apple.install} main fetch extract checksum patch configure build 39 target_prerun ${com.apple.install} install_start 40 target_postrun ${com.apple.install} install_registry 42 41 43 42 # define options -
trunk/base/src/port1.0/portmain.tcl
r1790 r2118 37 37 38 38 set com.apple.main [target_new com.apple.main main] 39 ${com.apple.main} providesmain39 target_provides ${com.apple.main} main 40 40 41 41 # define options -
trunk/base/src/port1.0/portmpkg.tcl
r2059 r2118 34 34 35 35 set com.apple.mpkg [target_new com.apple.mpkg mpkg_main] 36 ${com.apple.mpkg} set runtypealways37 ${com.apple.mpkg} providesmpkg38 ${com.apple.mpkg} requirespackage36 target_runtype ${com.apple.mpkg} always 37 target_provides ${com.apple.mpkg} mpkg 38 target_requires ${com.apple.mpkg} package 39 39 40 40 # define options -
trunk/base/src/port1.0/portpackage.tcl
r2059 r2118 34 34 35 35 set com.apple.package [target_new com.apple.package package_main] 36 ${com.apple.package} set runtypealways37 ${com.apple.package} providespackage38 ${com.apple.package} requiresinstall36 target_runtype ${com.apple.package} always 37 target_provides ${com.apple.package} package 38 target_requires ${com.apple.package} install 39 39 40 40 # define options … … 77 77 system "mkbom ${destpath} ${pkgpath}/Contents/Archive.bom" 78 78 system "cd ${pkgpath}/Contents/Resources/ && ln -fs ../Archive.bom ${portname}-${portversion}.bom" 79 system "cd ${destpath} && pax - w -z . > ${pkgpath}/Contents/Archive.pax.gz"79 system "cd ${destpath} && pax -x cpio -w -z . > ${pkgpath}/Contents/Archive.pax.gz" 80 80 system "cd ${pkgpath}/Contents/Resources/ && ln -fs ../Archive.pax.gz ${portname}-${portversion}.pax.gz" 81 81 -
trunk/base/src/port1.0/portpatch.tcl
r1638 r2118 34 34 35 35 set com.apple.patch [target_new com.apple.patch patch_main] 36 ${com.apple.patch} provides patch 37 ${com.apple.patch} requires main fetch checksum extract 38 ${com.apple.patch} deplist depends_build depends_lib 36 target_provides ${com.apple.patch} patch 37 target_requires ${com.apple.patch} main fetch checksum extract 39 38 40 39 set UI_PREFIX "---> " … … 48 47 49 48 proc patch_main {args} { 50 global portname patchfiles distpath filespath workpath worksrcpathUI_PREFIX49 global UI_PREFIX 51 50 52 51 # First make sure that patchfiles exists and isn't stubbed out. 53 if ![info exists patchfiles]{52 if {![exists patchfiles]} { 54 53 return 0 55 54 } 56 55 57 foreach patch $patchfiles{58 if [file exists $filespath/$patch] {59 lappend patchlist $filespath/$patch60 } elseif [file exists $distpath/$patch] {61 lappend patchlist $distpath/$patch56 foreach patch [option patchfiles] { 57 if [file exists [option filespath]/$patch] { 58 lappend patchlist [option filespath]/$patch 59 } elseif [file exists [option distpath]/$patch] { 60 lappend patchlist [option distpath]/$patch 62 61 } 63 62 } … … 65 64 return -code error [msgcat::mc "Patch files missing"] 66 65 } 67 cd ${worksrcpath}66 cd [option worksrcpath] 68 67 foreach patch $patchlist { 69 68 ui_info "$UI_PREFIX [format [msgcat::mc "Applying %s"] $patch]" -
trunk/base/src/port1.0/portuninstall.tcl
r1888 r2118 34 34 35 35 set com.apple.uninstall [target_new com.apple.uninstall uninstall_main] 36 ${com.apple.uninstall} set runtypealways37 ${com.apple.uninstall} providesuninstall38 ${com.apple.uninstall} requiresmain39 ${com.apple.uninstall} set prerununinstall_start36 target_runtype ${com.apple.uninstall} always 37 target_provides ${com.apple.uninstall} uninstall 38 target_requires ${com.apple.uninstall} main 39 target_prerun ${com.apple.uninstall} uninstall_start 40 40 41 41 # define options -
trunk/base/src/port1.0/portutil.tcl
r2070 r2118 32 32 package provide portutil 1.0 33 33 package require Pextlib 1.0 34 package require darwinports_dlist 1.0 34 35 package require msgcat 35 36 … … 44 45 45 46 namespace eval options { 47 } 48 49 # option 50 # This is an accessor for Portfile options. Targets may use 51 # this in the same style as the standard Tcl "set" procedure. 52 # name - the name of the option to read or write 53 # value - an optional value to assign to the option 54 55 proc option {name args} { 56 # XXX: right now we just transparently use globals 57 # eventually this will need to bridge the options between 58 # the Portfile's interpreter and the target's interpreters. 59 global $name 60 if {[llength $args] > 0} { 61 ui_debug "setting option $name to $args" 62 set $name [lindex $args 0] 63 } 64 return [set $name] 65 } 66 67 # exists 68 # This is an accessor for Portfile options. Targets may use 69 # this procedure to test for the existence of a Portfile option. 70 # name - the name of the option to test for existence 71 72 proc exists {name} { 73 # XXX: right now we just transparently use globals 74 # eventually this will need to bridge the options between 75 # the Portfile's interpreter and the target's interpreters. 76 global $name 77 return [info exists $name] 46 78 } 47 79 … … 253 285 set args [lrange $args 0 [expr $len - 2]] 254 286 255 set obj[variant_new "temp-variant"]287 set ditem [variant_new "temp-variant"] 256 288 257 289 # mode indicates what the arg is interpreted as. … … 265 297 requires { set mode "requires" } 266 298 conflicts { set mode "conflicts" } 267 default { $obj append$mode $arg }299 default { ditem_append $ditem $mode $arg } 268 300 } 269 301 } 270 $obj set name "[join [$obj getprovides] -]"302 ditem_key $ditem name "[join [ditem_key $ditem provides] -]" 271 303 272 304 # make a user procedure named variant-blah-blah 273 305 # we will call this procedure during variant-run 274 makeuserproc "variant-[ $obj getname]" \{$code\}275 lappend all_variants $ obj306 makeuserproc "variant-[ditem_key $ditem name]" \{$code\} 307 lappend all_variants $ditem 276 308 277 309 # Export provided variant to PortInfo 278 lappend PortInfo(variants) [ $obj getprovides]310 lappend PortInfo(variants) [ditem_key $ditem provides] 279 311 } 280 312 … … 400 432 ########### Internal Dependancy Manipulation Procedures ########### 401 433 402 # returns a depspec by name 403 proc dlist_get_by_name {dlist name} { 404 set result "" 405 foreach d $dlist { 406 if {[$d get name] == $name} { 407 set result $d 408 break 409 } 410 } 411 return $result 412 } 413 414 # returns a list of depspecs that contain the given name in the given key 415 proc depspec_get_matches {dlist key value} { 416 set result [list] 417 foreach d $dlist { 418 foreach val [$d get $key] { 419 if {$val == $value} { 420 lappend result $d 421 } 422 } 423 } 424 return $result 425 } 426 427 # Count the unmet dependencies in the dlist based on the statusdict 428 proc dlist_count_unmet {dlist statusdict names} { 429 upvar $statusdict upstatusdict 430 set unmet 0 431 foreach name $names { 432 # Service was provided, check next. 433 if {[info exists upstatusdict($name)] && $upstatusdict($name) == 1} { 434 continue 435 } else { 436 incr unmet 437 } 438 } 439 return $unmet 440 } 441 442 # Returns true if any of the dependencies are pending in the dlist 443 proc dlist_has_pending {dlist uses} { 444 foreach name $uses { 445 if {[llength [depspec_get_matches $dlist provides $name]] > 0} { 446 return 1 447 } 448 } 449 return 0 450 } 451 452 # Get the name of the next eligible item from the dependency list 453 proc generic_get_next {dlist statusdict} { 454 set nextitem "" 455 # arbitrary large number ~ INT_MAX 456 set minfailed 2000000000 457 upvar $statusdict upstatusdict 458 459 foreach obj $dlist { 460 # skip if unsatisfied hard dependencies 461 if {[dlist_count_unmet $dlist upstatusdict [$obj get requires]]} { continue } 462 463 # favor item with fewest unment soft dependencies 464 set unmet [dlist_count_unmet $dlist upstatusdict [$obj get uses]] 465 466 # delay items with unmet soft dependencies that can be filled 467 if {$unmet > 0 && [dlist_has_pending $dlist [$obj get uses]]} { continue } 468 469 if {$unmet >= $minfailed} { 470 # not better than our last pick 471 continue 472 } else { 473 # better than our last pick 474 set minfailed $unmet 475 set nextitem $obj 476 } 477 } 478 return $nextitem 479 } 480 481 482 # Evaluate the list of depspecs, running each as it becomes eligible. 483 # dlist is a collection of depspec objects to be run 484 # get_next_proc is used to determine the best item to run 485 proc dlist_evaluate {dlist get_next_proc} { 486 global portname 487 488 # status - keys will be node names, values will be {-1, 0, 1}. 489 array set statusdict [list] 490 491 # XXX: Do we want to evaluate this dynamically instead of statically? 492 foreach obj $dlist { 493 if {[$obj test] == 1} { 494 foreach name [$obj get provides] { 495 set statusdict($name) 1 496 } 497 ldelete dlist $obj 498 } 499 } 500 501 # loop for as long as there are nodes in the dlist. 502 while (1) { 503 set obj [$get_next_proc $dlist statusdict] 504 505 if {$obj == ""} { 506 break 507 } else { 508 catch {$obj run} result 509 # depspec->run returns an error code, so 0 == success. 510 # translate this to the statusdict notation where 1 == success. 511 foreach name [$obj get provides] { 512 set statusdict($name) [expr $result == 0] 513 } 514 515 # Delete the item from the waiting list. 516 ldelete dlist $obj 517 } 518 } 519 520 if {[llength $dlist] > 0} { 521 # somebody broke! 522 ui_info "Warning: the following items did not execute (for $portname): " 523 foreach obj $dlist { 524 ui_info "[$obj get name] " -nonewline 525 } 526 ui_info "" 527 return 1 528 } 529 return 0 530 } 531 532 proc target_run {this} { 434 proc target_run {ditem} { 533 435 global target_state_fd portname 534 436 set result 0 535 set procedure [ $this getprocedure]437 set procedure [ditem_key $ditem procedure] 536 438 if {$procedure != ""} { 537 set name [ $this getname]538 539 if {[ $this hasinit]} {540 set result [catch {[ $this getinit] $name} errstr]439 set name [ditem_key $ditem name] 440 441 if {[ditem_contains $ditem init]} { 442 set result [catch {[ditem_key $ditem init] $name} errstr] 541 443 } 542 444 … … 546 448 } elseif {$result == 0} { 547 449 # Execute pre-run procedure 548 if {[ $this hasprerun]} {549 set result [catch {[ $this getprerun] $name} errstr]450 if {[ditem_contains $ditem prerun]} { 451 set result [catch {[ditem_key $ditem prerun] $name} errstr] 550 452 } 551 453 552 454 if {$result == 0} { 553 foreach pre [ $this getpre] {455 foreach pre [ditem_key $ditem pre] { 554 456 ui_debug "Executing $pre" 555 457 set result [catch {$pre $name} errstr] … … 564 466 565 467 if {$result == 0} { 566 foreach post [ $this getpost] {468 foreach post [ditem_key $ditem post] { 567 469 ui_debug "Executing $post" 568 470 set result [catch {$post $name} errstr] … … 571 473 } 572 474 # Execute post-run procedure 573 if {[ $this haspostrun] && $result == 0} {574 set postrun [ $this getpostrun]475 if {[ditem_contains $ditem postrun] && $result == 0} { 476 set postrun [ditem_key $ditem postrun] 575 477 ui_debug "Executing $postrun" 576 478 set result [catch {$postrun $name} errstr] … … 578 480 } 579 481 if {$result == 0} { 580 if {[ $this getruntype] != "always"} {482 if {[ditem_key $ditem runtype] != "always"} { 581 483 write_statefile target $name $target_state_fd 582 484 } … … 595 497 596 498 proc eval_targets {target} { 597 global targets target_state_fd 499 global targets target_state_fd portname 598 500 set dlist $targets 599 600 501 502 # Select the subset of targets under $target 601 503 if {$target != ""} { 602 set matches [depspec_get_matches $dlist provides $target] 504 set matches [dlist_search $dlist provides $target] 505 603 506 if {[llength $matches] > 0} { 604 605 606 607 507 set dlist [dlist_append_dependents $dlist [lindex $matches 0] [list]] 508 # Special-case 'all' 509 } elseif {$target != "all"} { 510 ui_info "unknown target: $target" 608 511 return 1 609 512 } 610 513 } 611 514 612 515 # Restore the state from a previous run. 613 516 set target_state_fd [open_statefile] 614 517 615 set ret [dlist_evaluate $dlist generic_get_next] 616 518 set dlist [dlist_eval $dlist "" target_run] 519 520 if {[llength $dlist] > 0} { 521 # somebody broke! 522 ui_info "Warning: the following items did not execute (for $portname): " 523 foreach ditem $dlist { 524 ui_info "[ditem_key $ditem name] " -nonewline 525 } 526 ui_info "" 527 set result 1 528 } else { 529 set result 0 530 } 531 617 532 close $target_state_fd 618 return $ret619 }620 621 # returns the names of dependents of <name> from the <itemlist>622 proc dlist_append_dependents {dlist obj result} {623 624 # Append the item to the list, avoiding duplicates625 if {[lsearch $result $obj] == -1} {626 lappend result $obj627 }628 629 # Recursively append any hard dependencies630 foreach dep [$obj get requires] {631 foreach provider [depspec_get_matches $dlist provides $dep] {632 set result [dlist_append_dependents $dlist $provider $result]633 }634 }635 # XXX: add soft-dependencies?636 533 return $result 637 534 } … … 759 656 set selected [list] 760 657 761 foreach obj$dlist {658 foreach ditem $dlist { 762 659 # Enumerate through the provides, tallying the pros and cons. 763 660 set pros 0 764 661 set cons 0 765 662 set ignored 0 766 foreach flavor [ $obj getprovides] {663 foreach flavor [ditem_key $ditem provides] { 767 664 if {[info exists upvariations($flavor)]} { 768 665 if {$upvariations($flavor) == "+"} { … … 779 676 780 677 if {$pros > 0 && $ignored == 0} { 781 lappend selected $ obj678 lappend selected $ditem 782 679 } 783 680 } … … 785 682 } 786 683 787 proc variant_run { this} {788 set name [ $this getname]789 ui_debug "Executing $name provides [ $this getprovides]"684 proc variant_run {ditem} { 685 set name [ditem_key $ditem name] 686 ui_debug "Executing $name provides [ditem_key $ditem provides]" 790 687 791 688 # test for conflicting variants 792 foreach v [ $this getconflicts] {689 foreach v [ditem_key $ditem conflicts] { 793 690 if {[variant_isset $v]} { 794 691 ui_error "Variant $name conflicts with $v" … … 823 720 } 824 721 825 dlist_eval uate $newlist generic_get_next722 dlist_eval $newlist "" variant_run 826 723 827 724 # Make sure the variations match those stored in the statefile. … … 852 749 } 853 750 854 ##### DEPSPEC #####855 856 # Object-Oriented Depspecs857 #858 # Each depspec will have its data stored in an array859 # (indexed by field name) and its procedures will be860 # called via the dispatch procedure that is returned861 # from depspec_new.862 #863 # sample usage:864 # set obj [depspec_new]865 # $obj set name "hello"866 #867 868 # Depspec869 # str name870 # str provides[]871 # str requires[]872 # str uses[]873 874 global depspec_uniqid875 set depspec_uniqid 0876 877 # Depspec class definition.878 global depspec_vtbl879 set depspec_vtbl(test) depspec_test880 set depspec_vtbl(run) depspec_run881 set depspec_vtbl(get) depspec_get882 set depspec_vtbl(set) depspec_set883 set depspec_vtbl(has) depspec_has884 set depspec_vtbl(append) depspec_append885 886 # constructor for abstract depspec class887 proc depspec_new {name} {888 global depspec_uniqid889 set id [incr depspec_uniqid]890 891 # declare the array of data892 set data dpspc_data_${id}893 set disp dpspc_disp_${id}894 895 global $data896 set ${data}(name) $name897 set ${data}(_vtbl) depspec_vtbl898 899 eval "proc $disp {method args} { \n \900 global $data \n \901 eval return \\\[depspec_dispatch $disp $data \$method \$args\\\] \n \902 }"903 904 return $disp905 }906 907 proc depspec_get {this prop} {908 set data [$this _data]909 global $data910 if {[eval info exists ${data}($prop)]} {911 eval return $${data}($prop)912 } else {913 return ""914 }915 }916 917 proc depspec_set {this prop args} {918 set data [$this _data]919 global $data920 eval "set ${data}($prop) \"$args\""921 }922 923 proc depspec_has {this prop} {924 set data [$this _data]925 global $data926 eval return \[info exists ${data}($prop)\]927 }928 929 proc depspec_append {this prop args} {930 set data [$this _data]931 global $data932 set vals [join $args " "]933 eval lappend ${data}($prop) $vals934 }935 936 # is the only proc to get direct access to the object's data937 # so the _data accessor has to be defined here. all other938 # methods are looked up in the virtual function table,939 # and are called with {$this $args}.940 proc depspec_dispatch {this data method args} {941 global $data942 if {$method == "_data"} { return $data }943 eval set vtbl $${data}(_vtbl)944 global $vtbl945 if {[info exists ${vtbl}($method)]} {946 eval set function $${vtbl}($method)947 eval "return \[$function $this $args\]"948 } else {949 ui_error "unknown method: $method"950 }951 return ""952 }953 954 proc depspec_test {this} {955 return 0956 }957 958 proc depspec_run {this} {959 return 0960 }961 962 ##### target depspec subclass #####963 964 751 # Target class definition. 965 global target_vtbl 966 array set target_vtbl [array get depspec_vtbl] 967 set target_vtbl(run) target_run 968 set target_vtbl(provides) target_provides 969 set target_vtbl(requires) target_requires 970 set target_vtbl(uses) target_uses 971 set target_vtbl(deplist) target_deplist 972 set target_vtbl(prerun) target_prerun 973 set target_vtbl(postrun) target_postrun 974 975 # constructor for target depspec class 752 753 # constructor for target object 976 754 proc target_new {name procedure} { 977 755 global targets 978 set obj [depspec_new $name]979 980 $obj set _vtbl target_vtbl 981 $obj setprocedure $procedure982 983 lappend targets $ obj984 985 return $ obj986 } 987 988 proc target_provides { thisargs} {756 set ditem [ditem_create] 757 758 ditem_key $ditem name $name 759 ditem_key $ditem procedure $procedure 760 761 lappend targets $ditem 762 763 return $ditem 764 } 765 766 proc target_provides {ditem args} { 989 767 global targets 990 768 # Register the pre-/post- hooks for use in Portfile. … … 993 771 # Thus if the user code breaks, dependent targets will not execute. 994 772 foreach target $args { 995 set origproc [ $this getprocedure]996 set ident [ $this getname]773 set origproc [ditem_key $ditem procedure] 774 set ident [ditem_key $ditem name] 997 775 if {[info commands $target] != ""} { 998 ui_debug " [$this get name]registered provides \'$target\', a pre-existing procedure. Target override will not be provided"776 ui_debug "$ident registered provides \'$target\', a pre-existing procedure. Target override will not be provided" 999 777 } else { 1000 778 eval "proc $target {args} \{ \n\ 1001 $this setprocedure proc-${ident}-${target}779 ditem_key $ditem procedure proc-${ident}-${target} 1002 780 eval \"proc proc-${ident}-${target} \{name\} \{ \n\ 1003 781 if \{\\\[catch userproc-${ident}-${target} result\\\]\} \{ \n\ … … 1012 790 } 1013 791 eval "proc pre-$target {args} \{ \n\ 1014 $this appendpre proc-pre-${ident}-${target}792 ditem_append $ditem pre proc-pre-${ident}-${target} 1015 793 eval \"proc proc-pre-${ident}-${target} \{name\} \{ \n\ 1016 794 if \{\\\[catch userproc-pre-${ident}-${target} result\\\]\} \{ \n\ … … 1023 801 \}" 1024 802 eval "proc post-$target {args} \{ \n\ 1025 $this appendpost proc-post-${ident}-${target}803 ditem_append $ditem post proc-post-${ident}-${target} 1026 804 eval \"proc proc-post-${ident}-${target} \{name\} \{ \n\ 1027 805 if \{\\\[catch userproc-post-${ident}-${target} result\\\]\} \{ \n\ … … 1034 812 \}" 1035 813 } 1036 eval "depspec_append $this provides $args" 1037 } 1038 1039 proc target_requires {this args} { 1040 eval "depspec_append $this requires $args" 1041 } 1042 1043 proc target_uses {this args} { 1044 eval "depspec_append $this uses $args" 1045 } 1046 1047 proc target_deplist {this args} { 1048 eval "depspec_append $this deplist $args" 1049 } 1050 1051 proc target_prerun {this args} { 1052 eval "depspec_append $this prerun $args" 1053 } 1054 1055 proc target_postrun {this args} { 1056 eval "depspec_append $this postrun $args" 1057 } 1058 1059 ##### variant depspec subclass ##### 1060 1061 # Variant class definition. 1062 global variant_vtbl 1063 array set variant_vtbl [array get depspec_vtbl] 1064 set variant_vtbl(run) variant_run 1065 1066 # constructor for target depspec class 814 eval "ditem_append $ditem provides $args" 815 } 816 817 proc target_requires {ditem args} { 818 eval "ditem_append $ditem requires $args" 819 } 820 821 proc target_uses {ditem args} { 822 eval "ditem_append $ditem uses $args" 823 } 824 825 proc target_deplist {ditem args} { 826 eval "ditem_append $ditem deplist $args" 827 } 828 829 proc target_prerun {ditem args} { 830 eval "ditem_append $ditem prerun $args" 831 } 832 833 proc target_postrun {ditem args} { 834 eval "ditem_append $ditem postrun $args" 835 } 836 837 proc target_runtype {ditem args} { 838 eval "ditem_append $ditem runtype $args" 839 } 840 841 proc target_init {ditem args} { 842 eval "ditem_append $ditem init $args" 843 } 844 845 ##### variant class ##### 846 847 # constructor for variant objects 1067 848 proc variant_new {name} { 1068 set obj [depspec_new $name] 1069 1070 $obj set _vtbl variant_vtbl 1071 1072 return $obj 849 set ditem [ditem_create] 850 ditem_key $ditem name $name 851 return $ditem 1073 852 } 1074 853 … … 1091 870 } 1092 871 1093 ##### portfile depspec subclass #####1094 global portfile_vtbl1095 array set portfile_vtbl [array get depspec_vtbl]1096 set portfile_vtbl(run) portfile_run1097 set portfile_vtbl(test) portfile_test1098 1099 proc portfile_new {name} {1100 set obj [depspec_new $name]1101 1102 $obj set _vtbl portfile_vtbl1103 1104 return $obj1105 }1106 1107 # portfile primitive that calls portexec_int with newworkpath == ${workpath}1108 proc portexec {portname target} {1109 global workpath1110 portexec_int $portname $target $workpath1111 }1112 1113 # build the specified portfile with default workpath1114 proc portfile_run {this} {1115 set portname [$this get name]1116 if {![catch {portexec_int $portname install} result]} {1117 portexec_int $portname clean1118 }1119 return $result1120 }1121 872 1122 873 # builds the specified port (looked up in the index) to the specified target … … 1157 908 } 1158 909 1159 proc portfile_test {this} {1160 set receipt [registry_exists [$this get name]]1161 if {$receipt != ""} {1162 ui_debug "Found Dependency: receipt: $receipt"1163 return 11164 } else {1165 return 01166 }1167 }1168 1169 910 proc portfile_search_path {depregex search_path} { 1170 911 set found 0 … … 1184 925 } 1185 926 1186 1187 1188 ##### lib portfile depspec subclass #####1189 # Search registry, then library path for regex1190 global libportfile_vtbl1191 array set libportfile_vtbl [array get portfile_vtbl]1192 set libportfile_vtbl(test) libportfile_test1193 1194 proc libportfile_new {name match} {1195 set obj [portfile_new $name]1196 1197 $obj set _vtbl libportfile_vtbl1198 $obj set depregex $match1199 1200 return $obj1201 }1202 927 1203 928 # XXX - Architecture specific … … 1243 968 } 1244 969 1245 ##### bin portfile depspec subclass #####1246 # Search registry, then binary path for regex1247 global binportfile_vtbl1248 array set binportfile_vtbl [array get portfile_vtbl]1249 set binportfile_vtbl(test) binportfile_test1250 1251 proc binportfile_new {name match} {1252 set obj [portfile_new $name]1253 1254 $obj set _vtbl binportfile_vtbl1255 $obj set depregex $match1256 1257 return $obj1258 }1259 1260 970 proc binportfile_test {this} { 1261 971 global env prefix … … 1275 985 return [portfile_search_path $depregex $search_path] 1276 986 } 1277 }1278 1279 ##### path portfile depspec subclass #####1280 # Search registry, then search specified absolute or1281 # ${prefix} relative path for regex1282 global pathportfile_vtbl1283 array set pathportfile_vtbl [array get portfile_vtbl]1284 set pathportfile_vtbl(test) pathportfile_test1285 1286 proc pathportfile_new {name match} {1287 set obj [portfile_new $name]1288 1289 $obj set _vtbl pathportfile_vtbl1290 $obj set depregex $match1291 return $obj1292 987 } 1293 988
Note: See TracChangeset
for help on using the changeset viewer.