[108037] trunk/base/src/port1.0/portconfigure.tcl

larryv at macports.org larryv at macports.org
Wed Jul 10 19:11:02 PDT 2013


Revision: 108037
          https://trac.macports.org/changeset/108037
Author:   larryv at macports.org
Date:     2013-07-10 19:11:02 -0700 (Wed, 10 Jul 2013)
Log Message:
-----------
portconfigure.tcl: Rewrite initial compiler check more compactly.

Also sort list alphabetically and rearrange conditionals in
configure_get_compiler to match.

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

Modified: trunk/base/src/port1.0/portconfigure.tcl
===================================================================
--- trunk/base/src/port1.0/portconfigure.tcl	2013-07-11 00:58:19 UTC (rev 108036)
+++ trunk/base/src/port1.0/portconfigure.tcl	2013-07-11 02:11:02 UTC (rev 108037)
@@ -207,37 +207,35 @@
 set_ui_prefix
 
 proc portconfigure::configure_start {args} {
-    global UI_PREFIX configure.compiler
-    
+    global UI_PREFIX
+
     ui_notice "$UI_PREFIX [format [msgcat::mc "Configuring %s"] [option subport]]"
 
-    set name ""
-    switch -exact ${configure.compiler} {
-        cc { set name "System cc" }
-        gcc { set name "System GCC" }
-        gcc-3.3 { set name "Mac OS X GCC 3.3" }
-        gcc-4.0 { set name "Mac OS X GCC 4.0" }
-        gcc-4.2 { set name "Mac OS X GCC 4.2" }
-        llvm-gcc-4.2 { set name "Mac OS X LLVM-GCC 4.2" }
-        clang { set name "Mac OS X Clang" }
-        apple-gcc-4.0 { set name "MacPorts Apple GCC 4.0" }
-        apple-gcc-4.2 { set name "MacPorts Apple GCC 4.2" }
-        macports-gcc     { set name "MacPorts GCC (port select)" }
-        macports-llvm-gcc-4.2 { set name "MacPorts LLVM-GCC 4.2" }
-        macports-clang { set name "MacPorts Clang (port select)" }
-        default {
-            if {[regexp {macports-clang-(.*)\.(.*)} ${configure.compiler} -> major minor]} {
-                set name "MacPorts Clang ${major}.${minor}"
-            } elseif {[regexp {macports-dragonegg-(.*)\.(.*)} ${configure.compiler} -> major minor]} {
-                set name "MacPorts DragonEgg ${major}.${minor}"
-            } elseif {[regexp {macports-gcc-(.*)\.(.*)} ${configure.compiler} -> major minor]} {
-                set name "MacPorts GCC ${major}.${minor}"
-            } else {
-                return -code error "Invalid value for configure.compiler: ${configure.compiler}"
-            }
+    set compiler [option configure.compiler]
+    set valid_compilers {
+        {^apple-gcc-(4\.[02])$}                 {MacPorts Apple GCC %s}
+        {^cc$}                                  {System cc}
+        {^clang$}                               {Xcode Clang}
+        {^gcc$}                                 {System GCC}
+        {^gcc-(3\.3|4\.[02])$}                  {Xcode GCC %s}
+        {^llvm-gcc-4\.2$}                       {Xcode LLVM-GCC 4.2}
+        {^macports-clang$}                      {MacPorts Clang (port select}
+        {^macports-clang-(\d+\.\d+)$}           {MacPorts Clang %s}
+        {^macports-dragonegg-(\d+\.\d+)$}       {MacPorts DragonEgg %s}
+        {^macports-gcc$}                        {MacPorts GCC (port select)}
+        {^macports-gcc-(\d+\.\d+)$}             {MacPorts GCC %s}
+        {^macports-llvm-gcc-4\.2$}              {MacPorts LLVM-GCC 4.2}
+    }
+    foreach {re fmt} $valid_compilers {
+        if {[set matches [regexp -inline $re $compiler]] ne {}} {
+            set compiler_name [eval [linsert [lrange $matches 1 end] 0 format $fmt]]
+            break
         }
     }
-    ui_debug "Using compiler '$name'"
+    if {![info exists compiler_name]} {
+        return -code error "Invalid value for configure.compiler: $compiler"
+    }
+    ui_debug "Using compiler '$compiler_name'"
 
     # Additional ccache directory setup
     global configure.ccache ccache_dir ccache_size macportsuser
@@ -505,22 +503,18 @@
         set compiler ${configure.compiler}
     }
     # Tcl 8.4's switch doesn't support -matchvar.
-    if {[regexp {^gcc(-3\.3|-4\.0|-4\.2)?$} $compiler -> suffix]} {
+    if {[regexp {^apple-gcc(-4\.[02])$} $compiler -> suffix]} {
         switch $type {
             cc      -
-            objc    { return [find_developer_tool "gcc${suffix}"] }
+            objc    { return ${prefix}/bin/gcc-apple${suffix} }
             cxx     -
-            objcxx  { return [find_developer_tool "g++${suffix}"] }
-            cpp     { return [find_developer_tool "cpp${suffix}"] }
+            objcxx  {
+                if {$suffix == "-4.2"} {
+                    return ${prefix}/bin/g++-apple${suffix}
+                }
+            }
+            cpp     { return ${prefix}/bin/cpp-apple${suffix} }
         }
-    } elseif {[regexp {^llvm-gcc-4\.2$} $compiler]} {
-        switch $type {
-            cc      -
-            objc    { return [find_developer_tool llvm-gcc-4.2] }
-            cxx     -
-            objcxx  { return [find_developer_tool llvm-g++-4.2] }
-            cpp     { return [find_developer_tool llvm-cpp-4.2] }
-        }
     } elseif {[regexp {^clang$} $compiler]} {
         switch $type {
             cc      -
@@ -534,42 +528,24 @@
                 return [find_developer_tool llvm-g++-4.2]
             }
         }
-    } elseif {[regexp {^apple-gcc(-4\.0|-4\.2)$} $compiler -> suffix]} {
+    } elseif {[regexp {^gcc(-3\.3|-4\.[02])?$} $compiler -> suffix]} {
         switch $type {
             cc      -
-            objc    { return ${prefix}/bin/gcc-apple${suffix} }
+            objc    { return [find_developer_tool "gcc${suffix}"] }
             cxx     -
-            objcxx  {
-                if {$suffix == "-4.2"} {
-                    return ${prefix}/bin/g++-apple${suffix}
-                }
-            }
-            cpp     { return ${prefix}/bin/cpp-apple${suffix} }
+            objcxx  { return [find_developer_tool "g++${suffix}"] }
+            cpp     { return [find_developer_tool "cpp${suffix}"] }
         }
-    } elseif {[regexp {^macports-gcc(-\d+\.\d+)?$} $compiler -> suffix]} {
-        if {[string length $suffix]} {
-            set suffix "-mp${suffix}"
-        }
+    } elseif {[regexp {^llvm-gcc-4\.2$} $compiler]} {
         switch $type {
             cc      -
-            objc    { return ${prefix}/bin/gcc${suffix} }
+            objc    { return [find_developer_tool llvm-gcc-4.2] }
             cxx     -
-            objcxx  { return ${prefix}/bin/g++${suffix} }
-            cpp     { return ${prefix}/bin/cpp${suffix} }
-            fc      -
-            f77     -
-            f90     { return ${prefix}/bin/gfortran${suffix} }
+            objcxx  { return [find_developer_tool llvm-g++-4.2] }
+            cpp     { return [find_developer_tool llvm-cpp-4.2] }
         }
-    } elseif {[regexp {^macports-llvm-gcc-4\.2$} $compiler]} {
-        switch $type {
-            cc      -
-            objc    { return ${prefix}/bin/llvm-gcc-4.2 }
-            cxx     -
-            objcxx  { return ${prefix}/bin/llvm-g++-4.2 }
-            cpp     { return ${prefix}/bin/llvm-cpp-4.2 }
-        }
     } elseif {[regexp {^macports-clang(-\d+\.\d+)?$} $compiler -> suffix]} {
-        if {[string length $suffix]} {
+        if {$suffix ne {}} {
             set suffix "-mp${suffix}"
         }
         switch $type {
@@ -589,6 +565,28 @@
             f77     -
             f90     { return ${prefix}/bin/dragonegg${infix}-gfortran }
         }
+    } elseif {[regexp {^macports-gcc(-\d+\.\d+)?$} $compiler -> suffix]} {
+        if {$suffix ne {}} {
+            set suffix "-mp${suffix}"
+        }
+        switch $type {
+            cc      -
+            objc    { return ${prefix}/bin/gcc${suffix} }
+            cxx     -
+            objcxx  { return ${prefix}/bin/g++${suffix} }
+            cpp     { return ${prefix}/bin/cpp${suffix} }
+            fc      -
+            f77     -
+            f90     { return ${prefix}/bin/gfortran${suffix} }
+        }
+    } elseif {[regexp {^macports-llvm-gcc-4\.2$} $compiler]} {
+        switch $type {
+            cc      -
+            objc    { return ${prefix}/bin/llvm-gcc-4.2 }
+            cxx     -
+            objcxx  { return ${prefix}/bin/llvm-g++-4.2 }
+            cpp     { return ${prefix}/bin/llvm-cpp-4.2 }
+        }
     }
     # Fallbacks
     switch $type {
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/macports-changes/attachments/20130710/c4746061/attachment-0001.html>


More information about the macports-changes mailing list