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

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

third time’s the charm

  • 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]} {
     768        return
     769    }
     770    interp alias {} $option {} handle_option-append $option
     771}
     772
     773# Automatically add the necessary dependency when setting the compiler.
     774proc portconfigure::set_compiler_dependencies {option action args} {
     775    global option_defaults configure.compiler portconfigure::cc_should_eval \
     776        portconfigure::compiler_port portconfigure::compiler_name_map
     777
     778    if {![info exists cc_should_eval]} {
     779        set cc_should_eval yes
     780    }
     781    set cc_is_default [info exists option_defaults(configure.compiler)]
     782
     783    switch $option {
     784        configure.compiler {
     785            if {$action eq "read" && !($cc_is_default && $cc_should_eval)} {
     786                return
     787            }
     788            if {[info exists compiler_port]} {
     789                depends_lib-delete port:$compiler_port
     790                depends_build-delete port:$compiler_port
     791                depends_skip_archcheck-delete port:$compiler_port
     792                unset compiler_port
     793            }
     794            # The default value requires substitution before use.
     795            set compiler [subst ${configure.compiler}]
     796            if {![compiler_is_port $compiler]} {
     797                return
     798            }
     799            set compiler_port $compiler_name_map($compiler)
     800            if {[string match "macports-gcc-*" $compiler]} {
     801                hijack_option depends_lib
     802                depends_lib-append port:$compiler_port
     803            } else {
     804                hijack_option depends_build
     805                depends_build-append port:$compiler_port
     806            }
     807            if {[arch_flag_supported $compiler]} {
     808                hijack_option depends_skip_archcheck
     809                depends_skip_archcheck-append $compiler_port
     810            }
     811            set cc_should_eval no
     812        }
     813        default {
     814            if {$action eq "read" || !$cc_is_default} {
     815                return
     816            }
     817            set cc_should_eval yes
     818            # This is solely to trigger the variable trace.
     819            expr {${configure.compiler}}
     820        }
     821    }
     822}
     823
     824# Set traces on all values that might affect the compiler selection.
     825option_proc compiler.fallback  portconfigure::set_compiler_dependencies
     826option_proc compiler.blacklist portconfigure::set_compiler_dependencies
     827option_proc compiler.whitelist portconfigure::set_compiler_dependencies
     828option_proc configure.compiler portconfigure::set_compiler_dependencies
     829
     830default configure.compiler {[portconfigure::configure_get_default_compiler]}
     831
     832
    760833proc portconfigure::configure_main {args} {
    761834    global [info globals]
    762835    global worksrcpath use_configure use_autoreconf use_autoconf use_automake use_xmkmf