[102932] trunk/base/src

cal at macports.org cal at macports.org
Sun Feb 10 18:01:56 PST 2013


Revision: 102932
          https://trac.macports.org/changeset/102932
Author:   cal at macports.org
Date:     2013-02-10 18:01:56 -0800 (Sun, 10 Feb 2013)
Log Message:
-----------
Automatically add dependency on MacPorts-provided compilers, if chosen as configure.compiler. Closes #32542.

This also adds a generic machanism to register callbacks to be run after
sourcing the Portfile and evaluating the variants. This callback
mechanism can probably be used to simplify other parts of port1.0, e.g.
automatically adding a dependency on autoconf when use_autoreconf is set
to yes, automatically adding a dependency on bsdmake when build.type is
bsd, etc.

For ports that blacklist all Xcode-provided compilers using
compiler.blacklist (so a fallback from MacPorts is used) the dependency
information recoded in the PortIndex will be missing these automatic
dependencies, because the PortIndex is usually generated on a server
without Xcode.

Modified Paths:
--------------
    trunk/base/src/macports1.0/macports.tcl
    trunk/base/src/port1.0/port.tcl
    trunk/base/src/port1.0/portconfigure.tcl

Modified: trunk/base/src/macports1.0/macports.tcl
===================================================================
--- trunk/base/src/macports1.0/macports.tcl	2013-02-11 02:01:51 UTC (rev 102931)
+++ trunk/base/src/macports1.0/macports.tcl	2013-02-11 02:01:56 UTC (rev 102932)
@@ -1617,6 +1617,8 @@
         error "Error evaluating variants"
     }
 
+    $workername eval port::run_callbacks
+
     ditem_key $mport provides [$workername eval return \$subport]
 
     return $mport

Modified: trunk/base/src/port1.0/port.tcl
===================================================================
--- trunk/base/src/port1.0/port.tcl	2013-02-11 02:01:51 UTC (rev 102931)
+++ trunk/base/src/port1.0/port.tcl	2013-02-11 02:01:56 UTC (rev 102932)
@@ -32,6 +32,33 @@
 # standard package load
 package provide port 1.0
 
+# Provide a callback registration mechanism for port subpackages. This needs to
+# be done _before_ loading the subpackages.
+namespace eval port {
+	variable _callback_list [list]
+
+	# Append a new procedure to a list of callbacks to be called when
+	# port::run_callbacks is called from macports1.0 after evaluating
+	# a Portfile
+	proc register_callback {callback} {
+		variable _callback_list
+		lappend _callback_list ${callback}
+	}
+	
+	# Run the callbacks registered in the callback list. Called from
+	# macports1.0 in the child interpreter after evaluating the Portfile and
+	# the variants. Clears the list of callbacks.
+	proc run_callbacks {} {
+		variable _callback_list
+		foreach callback ${_callback_list} {
+			ui_debug "Running callback ${callback}"
+			${callback}
+			ui_debug "Finished running callback ${callback}"
+		}
+		set _callback_list [list]
+	}
+}
+
 package require mp_package 1.0
 package require portmain 1.0
 package require portdepends 1.0

Modified: trunk/base/src/port1.0/portconfigure.tcl
===================================================================
--- trunk/base/src/port1.0/portconfigure.tcl	2013-02-11 02:01:51 UTC (rev 102931)
+++ trunk/base/src/port1.0/portconfigure.tcl	2013-02-11 02:01:56 UTC (rev 102932)
@@ -757,6 +757,37 @@
     return $ret
 }
 
+# Automatically called from macports1.0 after evaluating the Portfile
+# Some of the compilers we use are provided by MacPorts itself; ensure we
+# automatically add a dependency when needed
+proc portconfigure::add_automatic_compiler_dependencies {} {
+    global configure.compiler portconfigure::compiler_name_map
+
+    # The default value requires substitution before use.
+    set compiler [subst ${configure.compiler}]
+    if {![compiler_is_port $compiler]} {
+        return
+    }
+
+    ui_debug "Chosen compiler ${compiler} is provided by a port, adding dependency"
+
+    set compiler_port $compiler_name_map($compiler)
+    if {[string first "macports-gcc-" $compiler] == 0} {
+        ui_debug "  Adding depends_lib port:$compiler_port"
+        depends_lib-append port:$compiler_port
+    } else {
+        ui_debug "  Adding depends_build port:$compiler_port"
+        depends_build-append port:$compiler_port
+    }
+
+    if {[arch_flag_supported $compiler]} {
+        ui_debug "  Adding depends_skip_archcheck port:$compiler_port"
+        depends_skip_archcheck-append $compiler_port
+    }
+}
+# Register the above procedure as a callback after Portfile evaluation
+port::register_callback portconfigure::add_automatic_compiler_dependencies
+
 proc portconfigure::configure_main {args} {
     global [info globals]
     global worksrcpath use_configure use_autoreconf use_autoconf use_automake use_xmkmf
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/macports-changes/attachments/20130210/4d7df599/attachment.html>


More information about the macports-changes mailing list