Ignore:
Timestamp:
May 31, 2011, 9:26:12 PM (9 years ago)
Author:
derek@…
Message:

Check gcc version by calling gcc -v

  • Added proc macports::setgccinfo
  • Added deferred variable macports::gccversion
  • Added trace which calls setgccinfo when macports::gccversion is first read
File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/gsoc11-statistics/base/src/macports1.0/macports.tcl

    r78939 r79065  
    4444        portarchivetype portautoclean \
    4545        porttrace portverbose keeplogs destroot_umask variants_conf rsync_server rsync_options \
    46         rsync_dir startupitem_type place_worksymlink xcodeversion xcodebuildcmd \
     46        rsync_dir startupitem_type place_worksymlink xcodeversion xcodebuildcmd gccversion \
    4747        mp_remote_url mp_remote_submit_url configureccache ccache_dir ccache_size configuredistcc configurepipe buildnicevalue buildmakejobs \
    4848        applications_dir frameworks_dir developer_dir universal_archs build_arch macosx_deployment_target \
     
    6262    # they are not exported to the trace thread.
    6363    # they are not exported to the interpreter in system_options array.
    64     variable portinterp_deferred_options "xcodeversion xcodebuildcmd"
     64    variable portinterp_deferred_options "xcodeversion xcodebuildcmd gccversion"
    6565
    6666    variable open_mports {}
     
    408408}
    409409
     410# deferred and on-need extraction of gcc version.
     411proc macports::setgccinfo {name1 name2 op} {
     412    global macports::gccversion
     413
     414    trace remove variable macports::gccversion read macports::setgccinfo
     415   
     416    # Default value
     417    set macports::gccversion "none"
     418   
     419    # Find gcc in path
     420    if {[catch {set gccpath [binaryInPath "gcc"]}] != 0} {
     421        # Failed
     422        return
     423    }
     424   
     425    # Call gcc -v - Note that output will be on stderr not stdout
     426    # This succeeds if catch returns nonzero
     427    if { [catch { exec $gccpath -v } gccinfo] == 0} {
     428        # Failed
     429        return
     430    }
     431   
     432   
     433    # Extract version
     434    if {[regexp {gcc version ([0-9.]+)} $gccinfo - gcc_v] == 1} {
     435        # Set gcc version
     436        set macports::gccversion $gcc_v
     437    } else {
     438        ui_warn "gcc exists but could not read version information"
     439    }
     440}
     441
    410442proc mportinit {{up_ui_options {}} {up_options {}} {up_variations {}}} {
    411443    if {$up_ui_options eq ""} {
     
    458490    global macports::xcodebuildcmd
    459491    global macports::xcodeversion
     492    global macports::gccversion
    460493    global macports::configureccache
    461494    global macports::ccache_dir
     
    845878        trace add variable macports::xcodeversion read macports::setxcodeinfo
    846879        trace add variable macports::xcodebuildcmd read macports::setxcodeinfo
     880    }
     881   
     882    # Add trace for gcc version check
     883    if {![info exists gccversion]} {
     884        # We'll resolve these later (if needed)
     885        trace add variable macports::gccversion read macports::setgccinfo
    847886    }
    848887
Note: See TracChangeset for help on using the changeset viewer.