Ticket #32542: auto-compiler-deps.2.diff

File auto-compiler-deps.2.diff, 3.9 KB (added by larryv (Lawrence Velázquez), 12 years ago)

part deux

  • trunk/base/src/port1.0/portconfigure.tcl

    diff --git a/trunk/base/src/port1.0/portconfigure.tcl b/trunk/base/src/port1.0/portconfigure.tcl
    a b  
    22# portconfigure.tcl
    33# $Id$
    44#
    5 # Copyright (c) 2007 - 2012 The MacPorts Project
     5# Copyright (c) 2007 - 2013 The MacPorts Project
    66# Copyright (c) 2007 Markus W. Weissmann <mww@macports.org>
    77# Copyright (c) 2002 - 2003 Apple Inc.
    88# All rights reserved.
     
    186186default configure.f90           {[portconfigure::configure_get_compiler f90]}
    187187default configure.fc            {[portconfigure::configure_get_compiler fc]}
    188188default configure.javac         {[portconfigure::configure_get_compiler javac]}
    189 default configure.compiler      {[portconfigure::configure_get_default_compiler]}
    190189default compiler.fallback       {[portconfigure::get_compiler_fallback]}
    191190default compiler.blacklist      {}
    192191default compiler.whitelist      {}
     192# configure.compiler has been moved towards the end of the file so that
     193# all procs are available when its option_proc is triggered on initial
     194# write.
    193195
    194196set_ui_prefix
    195197
     
    757759    return $ret
    758760}
    759761
     762# Helper function for set_compiler_dependencies.  Used to force
     763# "depends_FOO" to act like "depends_FOO-append"; otherwise portfiles
     764# would overwrite the automatic compiler dependencies with their
     765# "depends_FOO" statements.
     766proc portconfigure::hijack_option {option} {
     767    if {[exists $option]} {return}
     768    interp alias {} $option {} handle_option-append $option
     769}
     770
     771# Automatically add the necessary dependency when setting the compiler.
     772proc portconfigure::set_compiler_dependencies {option action args} {
     773    switch $action {
     774        read {
     775            if {$option ne "configure.compiler"} {return}
     776            if {![info exists ::option_defaults(configure.compiler)]} {return}
     777            if {[info exists portconfigure::compiler_port]} {return}
     778        }
     779        set {
     780            if {$option ne "configure.compiler" &&
     781                ![info exists ::option_defaults(configure.compiler)]
     782            } then {
     783                return
     784            }
     785        }
     786    }
     787
     788    if {[info exists portconfigure::compiler_port]} {
     789        depends_lib-delete port:$portconfigure::compiler_port
     790        depends_build-delete port:$portconfigure::compiler_port
     791        depends_skip_archcheck-delete $portconfigure::compiler_port
     792        unset portconfigure::compiler_port
     793    }
     794
     795    global configure.compiler
     796    set compiler [subst ${configure.compiler}]
     797
     798    # For the compiler lists, triggering the configure.compiler read
     799    # trace is sufficient.
     800    if {$option ne "configure.compiler" || ![compiler_is_port $compiler]} {
     801        return
     802    }
     803
     804    variable compiler_port $portconfigure::compiler_name_map($compiler)
     805    if {[string match "macports-gcc*" $compiler]} {
     806        hijack_option depends_lib
     807        depends_lib-append port:$portconfigure::compiler_port
     808    } else {
     809        hijack_option depends_build
     810        depends_build-append port:$portconfigure::compiler_port
     811    }
     812    if {[arch_flag_supported $compiler]} {
     813        hijack_option depends_skip_archcheck
     814        depends_skip_archcheck-append $portconfigure::compiler_port
     815    }
     816}
     817
     818# Set traces on all values that might affect the compiler selection.
     819option_proc compiler.fallback  portconfigure::set_compiler_dependencies
     820option_proc compiler.blacklist portconfigure::set_compiler_dependencies
     821option_proc compiler.whitelist portconfigure::set_compiler_dependencies
     822option_proc configure.compiler portconfigure::set_compiler_dependencies
     823
     824default configure.compiler {[portconfigure::configure_get_default_compiler]}
     825
     826
    760827proc portconfigure::configure_main {args} {
    761828    global [info globals]
    762829    global worksrcpath use_configure use_autoreconf use_autoconf use_automake use_xmkmf