Ticket #32542: auto-compiler-deps.diff

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

Patch adding automatic dependency management for configure.compiler.

  • 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.
     
    190190default compiler.fallback       {[portconfigure::get_compiler_fallback]}
    191191default compiler.blacklist      {}
    192192default compiler.whitelist      {}
     193option_proc configure.compiler portconfigure::set_compiler_dependencies
    193194
    194195set_ui_prefix
    195196
     
    388389
    389390# check if a compiler comes from a port
    390391proc portconfigure::compiler_is_port {compiler} {
    391     switch $compiler {
    392         clang -
    393         llvm-gcc-4.2 -
    394         gcc-4.2 -
    395         gcc-4.0 -
    396         gcc-3.3 {return no}
    397         default {return yes}
    398     }
     392    return [info exists portconfigure::compiler_name_map(${compiler})]
    399393}
    400394
    401395# maps compiler names to the port that provides them
     
    421415        macports-dragonegg-3.3  dragonegg-3.3
    422416}
    423417
     418# Add required dependencies when setting compiler.
     419proc portconfigure::set_compiler_dependencies {option action args} {
     420    # Lazily process default value on first read only; if default is
     421    # overriden, update dependencies on writes instead of reads.
     422    if {[string equal "read" ${action}] &&
     423            (![info exists ::option_defaults(configure.compiler)] ||
     424             [info exists portconfigure::compiler_port])
     425    } then {
     426        return
     427    }
     428
     429    if {[info exists portconfigure::compiler_port]} {
     430        depends_lib-delete port:${portconfigure::compiler_port}
     431        depends_build-delete port:${portconfigure::compiler_port}
     432        depends_skip_archcheck-delete ${portconfigure::compiler_port}
     433    }
     434
     435    # Default value must be substituted before use.
     436    set compiler [subst ${::configure.compiler}]
     437    if {![portconfigure::compiler_is_port ${compiler}]} {
     438        return
     439    }
     440    variable compiler_port $portconfigure::compiler_name_map(${compiler})
     441    if {[string match "macports-gcc*" ${compiler}]} {
     442        depends_lib-append port:${portconfigure::compiler_port}
     443    } else {
     444        depends_build-append port:${portconfigure::compiler_port}
     445    }
     446    if {[portconfigure::arch_flag_supported ${compiler}]} {
     447        depends_skip_archcheck-append ${portconfigure::compiler_port}
     448    }
     449}
     450
    424451# internal function to determine the default compiler
    425452proc portconfigure::configure_get_default_compiler {args} {
    426453    global compiler.blacklist compiler.whitelist compiler.fallback