Changeset 67209


Ignore:
Timestamp:
May 2, 2010, 8:23:03 PM (10 years ago)
Author:
raimue@…
Message:

Handle notes as a usual port option, which allows to use notes-append

Location:
trunk/base/src
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/base/src/port/port.tcl

    r67098 r67209  
    21692169        if {$portnotes ne {}} {
    21702170            ui_notice "$portname has the following notes:"
    2171             puts [wrap $portnotes 0 "  " 1]
     2171            foreach note $portnotes {
     2172                puts [wrap $note 0 "  " 1]
     2173            }
    21722174        } else {
    21732175            puts "$portname has no notes."
  • trunk/base/src/port1.0/portactivate.tcl

    r64816 r67209  
    6363
    6464proc portactivate::activate_main {args} {
    65     global env name version revision portvariants user_options portnotes
     65    global env name version revision portvariants user_options PortInfo
    6666    registry_activate $name "${version}_${revision}${portvariants}" [array get user_options]
    6767
    6868    # Display notes at the end of the activation phase.
    69     if {[info exists portnotes] && $portnotes ne {}} {
    70         # If env(COLUMNS) exists, limit each line's width to this width.
    71         if {[info exists env(COLUMNS)]} {
    72             set maxlen $env(COLUMNS)
     69    if {[info exists PortInfo(notes)] && $PortInfo(notes) ne {}} {
     70        ui_msg ""
     71        foreach note $PortInfo(notes) {
     72            # If env(COLUMNS) exists, limit each line's width to this width.
     73            if {[info exists env(COLUMNS)]} {
     74                set maxlen $env(COLUMNS)
    7375
    74             ui_msg ""
    75             foreach line [split $portnotes "\n"] {
    76                 set joiner ""
    77                 set lines ""
    78                 set newline ""
     76                foreach line [split $note "\n"] {
     77                    set joiner ""
     78                    set lines ""
     79                    set newline ""
    7980
    80                 foreach word [split $line " "] {
    81                     if {[string length $newline] + [string length $word] >= $maxlen} {
     81                    foreach word [split $line " "] {
     82                        if {[string length $newline] + [string length $word] >= $maxlen} {
     83                            lappend lines $newline
     84                            set newline ""
     85                            set joiner ""
     86                        }
     87                        append newline $joiner $word
     88                        set joiner " "
     89                    }
     90                    if {$newline ne {}} {
    8291                        lappend lines $newline
    83                         set newline ""
    84                         set joiner ""
    8592                    }
    86                     append newline $joiner $word
    87                     set joiner " "
     93                    ui_msg [join $lines "\n"]
    8894                }
    89                 if {$newline ne {}} {
    90                     lappend lines $newline
    91                 }
    92                 ui_msg [join $lines "\n"]
     95            } else {
     96                ui_msg $note
    9397            }
    94             ui_msg ""
    95         } else {
    96             ui_msg \n$portnotes\n
    9798        }
     99        ui_msg ""
    98100    }
    99101
  • trunk/base/src/port1.0/portmain.tcl

    r67048 r67209  
    4646# define options
    4747options prefix name version revision epoch categories maintainers
    48 options long_description description homepage license provides conflicts replaced_by
     48options long_description description homepage notes license provides conflicts replaced_by
    4949options worksrcdir filesdir distname portdbpath libpath distpath sources_conf os.platform os.subplatform os.version os.major os.arch os.endian platforms default_variants install.user install.group macosx_deployment_target
    5050options universal_variant os.universal_supported
     
    5353options compiler.cpath compiler.library_path
    5454
    55 # Export options via PortInfo
    56 options_export name version revision epoch categories maintainers platforms description long_description homepage license provides conflicts replaced_by
     55# Order of option_proc and option_export matters. Filter before exporting.
    5756
    5857# Assign option procedure to default_variants
    5958option_proc default_variants handle_default_variants
     59# Handle notes special for better formatting
     60option_proc notes handle_option_string
     61
     62# Export options via PortInfo
     63options_export name version revision epoch categories maintainers platforms description long_description notes homepage license provides conflicts replaced_by
    6064
    6165default workpath {[getportworkpath_from_buildpath $portbuildpath]}
  • trunk/base/src/port1.0/portutil.tcl

    r67194 r67209  
    448448}
    449449
    450 # Notes are displayed at (1) the end of the activation phase and (2) when
    451 # action_notes is executed.
    452 proc notes {args} {
    453     global PortInfo portnotes
    454 
    455     # Strip trailing empty lines
    456     set notes [string trim [join $args] "\n"]
    457     # Determine indent level
    458     set indent ""
    459     for {set i 0} {$i < [string length $notes]} {incr i} {
    460         set c [string index $notes $i]
    461         if {$c != " " && $c != "\t"} {
    462             break
    463         }
    464         append indent $c
    465     }
    466     # Remove indent on first line
    467     set notes [string replace $notes 0 [expr $i - 1]]
    468     # Remove indent on each other line
    469     set notes [string map "\"\n$indent\" \"\n\"" $notes]
    470 
    471     set PortInfo(notes) $notes
    472     set portnotes $PortInfo(notes)
     450##
     451# Filter options which take strings removing indent to ease Portfile writing
     452proc handle_option_string {option action args} {
     453    global $option
     454
     455    switch $action {
     456        set {
     457            set args [join $args]
     458
     459            set fulllist {}
     460            # args is a list of strings/list
     461            foreach arg $args {
     462                # Strip trailing empty lines
     463                set txt [string trim $arg "\n"]
     464
     465                # Determine indent level
     466                set indent ""
     467                for {set i 0} {$i < [string length $txt]} {incr i} {
     468                    set c [string index $txt $i]
     469                    if {$c != " " && $c != "\t"} {
     470                        break
     471                    }
     472                    append indent $c
     473                }
     474                # Remove indent on first line
     475                set txt [string replace $txt 0 [expr $i - 1]]
     476                # Remove indent on each other line
     477                set txt [string map "\"\n$indent\" \"\n\"" $txt]
     478
     479                lappend fulllist $txt
     480            }
     481
     482            set $option $fulllist
     483        }
     484    }
    473485}
    474486
Note: See TracChangeset for help on using the changeset viewer.