[commit: ghc] master: Add OSiOS, and define and use platformUsesFrameworks; part of #7720 (ff1de4c)

Ian Lynagh igloo at earth.li
Sat Mar 2 15:43:44 CET 2013


Repository : http://darcs.haskell.org/ghc.git/

On branch  : master

http://hackage.haskell.org/trac/ghc/changeset/ff1de4cf60be4defda1945eb1dea55d056895c64

>---------------------------------------------------------------

commit ff1de4cf60be4defda1945eb1dea55d056895c64
Author: Ian Lynagh <ian at well-typed.com>
Date:   Sat Mar 2 13:57:10 2013 +0000

    Add OSiOS, and define and use platformUsesFrameworks; part of #7720

>---------------------------------------------------------------

 compiler/ghci/Linker.lhs        | 31 ++++++++++----------
 compiler/main/DriverPipeline.hs | 65 ++++++++++++++++++-----------------------
 compiler/utils/Platform.hs      | 13 ++++++++-
 3 files changed, 55 insertions(+), 54 deletions(-)

diff --git a/compiler/ghci/Linker.lhs b/compiler/ghci/Linker.lhs
index 03189e7..151c5cb 100644
--- a/compiler/ghci/Linker.lhs
+++ b/compiler/ghci/Linker.lhs
@@ -303,12 +303,12 @@ reallyInitDynLinker dflags =
 
           -- (e) Link any MacOS frameworks
         ; let platform = targetPlatform dflags
-        ; let framework_paths = case platformOS platform of
-                                OSDarwin -> frameworkPaths dflags
-                                _        -> []
-        ; let frameworks = case platformOS platform of
-                           OSDarwin -> cmdlineFrameworks dflags
-                           _        -> []
+        ; let framework_paths = if platformUsesFrameworks platform
+                                then frameworkPaths dflags
+                                else []
+        ; let frameworks = if platformUsesFrameworks platform
+                           then cmdlineFrameworks dflags
+                           else []
           -- Finally do (c),(d),(e)
         ; let cmdline_lib_specs = [ l | Just l <- classified_ld_inputs ]
                                ++ libspecs
@@ -389,13 +389,12 @@ preloadLib dflags lib_paths framework_paths lib_spec
                       Just mm -> preloadFailed mm lib_paths lib_spec
 
           Framework framework ->
-              case platformOS (targetPlatform dflags) of
-              OSDarwin ->
-                do maybe_errstr <- loadFramework framework_paths framework
-                   case maybe_errstr of
-                      Nothing -> maybePutStrLn dflags "done"
-                      Just mm -> preloadFailed mm framework_paths lib_spec
-              _ -> panic "preloadLib Framework"
+              if platformUsesFrameworks (targetPlatform dflags)
+              then do maybe_errstr <- loadFramework framework_paths framework
+                      case maybe_errstr of
+                         Nothing -> maybePutStrLn dflags "done"
+                         Just mm -> preloadFailed mm framework_paths lib_spec
+              else panic "preloadLib Framework"
 
   where
     platform = targetPlatform dflags
@@ -1156,9 +1155,9 @@ load_dyn dll = do r <- loadDLL dll
 
 loadFrameworks :: Platform -> InstalledPackageInfo_ ModuleName -> IO ()
 loadFrameworks platform pkg
-    = case platformOS platform of
-      OSDarwin -> mapM_ load frameworks
-      _        -> return ()
+    = if platformUsesFrameworks platform
+      then mapM_ load frameworks
+      else return ()
   where
     fw_dirs    = Packages.frameworkDirs pkg
     frameworks = Packages.frameworks pkg
diff --git a/compiler/main/DriverPipeline.hs b/compiler/main/DriverPipeline.hs
index 68957ca..0d86dcb 100644
--- a/compiler/main/DriverPipeline.hs
+++ b/compiler/main/DriverPipeline.hs
@@ -1100,14 +1100,12 @@ runPhase cc_phase input_fn dflags
              else getPackageExtraCcOpts dflags pkgs
 
         framework_paths <-
-            case platformOS platform of
-            OSDarwin ->
-                do pkgFrameworkPaths <- liftIO $ getPackageFrameworkPath dflags pkgs
-                   let cmdlineFrameworkPaths = frameworkPaths dflags
-                   return $ map ("-F"++)
-                                (cmdlineFrameworkPaths ++ pkgFrameworkPaths)
-            _ ->
-                return []
+            if platformUsesFrameworks platform
+            then do pkgFrameworkPaths <- liftIO $ getPackageFrameworkPath dflags pkgs
+                    let cmdlineFrameworkPaths = frameworkPaths dflags
+                    return $ map ("-F"++)
+                                 (cmdlineFrameworkPaths ++ pkgFrameworkPaths)
+            else return []
 
         let split_objs = gopt Opt_SplitObjs dflags
             split_opt | hcc && split_objs = [ "-DUSE_SPLIT_MARKERS" ]
@@ -1640,9 +1638,9 @@ mkNoteObjsToLinkIntoBinary dflags dep_packages = do
 getLinkInfo :: DynFlags -> [PackageId] -> IO String
 getLinkInfo dflags dep_packages = do
    package_link_opts <- getPackageLinkOpts dflags dep_packages
-   pkg_frameworks <- case platformOS (targetPlatform dflags) of
-                     OSDarwin -> getPackageFrameworks dflags dep_packages
-                     _        -> return []
+   pkg_frameworks <- if platformUsesFrameworks (targetPlatform dflags)
+                     then getPackageFrameworks dflags dep_packages
+                     else return []
    let extra_ld_inputs = ldInputs dflags
    let
       link_info = (package_link_opts,
@@ -1787,38 +1785,31 @@ linkBinary dflags o_files dep_packages = do
     pkg_link_opts <- getPackageLinkOpts dflags dep_packages
 
     pkg_framework_path_opts <-
-        case platformOS platform of
-        OSDarwin ->
-            do pkg_framework_paths <- getPackageFrameworkPath dflags dep_packages
-               return $ map ("-F" ++) pkg_framework_paths
-        _ ->
-            return []
+        if platformUsesFrameworks platform
+        then do pkg_framework_paths <- getPackageFrameworkPath dflags dep_packages
+                return $ map ("-F" ++) pkg_framework_paths
+        else return []
 
     framework_path_opts <-
-        case platformOS platform of
-        OSDarwin ->
-            do let framework_paths = frameworkPaths dflags
-               return $ map ("-F" ++) framework_paths
-        _ ->
-            return []
+        if platformUsesFrameworks platform
+        then do let framework_paths = frameworkPaths dflags
+                return $ map ("-F" ++) framework_paths
+        else return []
 
     pkg_framework_opts <-
-        case platformOS platform of
-        OSDarwin ->
-            do pkg_frameworks <- getPackageFrameworks dflags dep_packages
-               return $ concat [ ["-framework", fw] | fw <- pkg_frameworks ]
-        _ ->
-            return []
+        if platformUsesFrameworks platform
+        then do pkg_frameworks <- getPackageFrameworks dflags dep_packages
+                return $ concat [ ["-framework", fw] | fw <- pkg_frameworks ]
+        else return []
 
     framework_opts <-
-        case platformOS platform of
-        OSDarwin ->
-            do let frameworks = cmdlineFrameworks dflags
-               -- reverse because they're added in reverse order from
-               -- the cmd line:
-               return $ concat [ ["-framework", fw] | fw <- reverse frameworks ]
-        _ ->
-            return []
+        if platformUsesFrameworks platform
+        then do let frameworks = cmdlineFrameworks dflags
+                -- reverse because they're added in reverse order from
+                -- the cmd line:
+                return $ concat [ ["-framework", fw]
+                                | fw <- reverse frameworks ]
+        else return []
 
         -- probably _stub.o files
     let extra_ld_inputs = ldInputs dflags
diff --git a/compiler/utils/Platform.hs b/compiler/utils/Platform.hs
index 090ce41..9e21326 100644
--- a/compiler/utils/Platform.hs
+++ b/compiler/utils/Platform.hs
@@ -10,7 +10,8 @@ module Platform (
         ArmABI(..),
 
         target32Bit,
-        osElfTarget
+        osElfTarget,
+        platformUsesFrameworks,
 )
 
 where
@@ -60,6 +61,7 @@ data OS
         = OSUnknown
         | OSLinux
         | OSDarwin
+        | OSiOS
         | OSSolaris2
         | OSMinGW32
         | OSFreeBSD
@@ -107,6 +109,7 @@ osElfTarget OSOpenBSD   = True
 osElfTarget OSNetBSD    = True
 osElfTarget OSSolaris2  = True
 osElfTarget OSDarwin    = False
+osElfTarget OSiOS       = False
 osElfTarget OSMinGW32   = False
 osElfTarget OSKFreeBSD  = True
 osElfTarget OSHaiku     = True
@@ -120,3 +123,11 @@ osElfTarget OSUnknown   = False
  -- portability, otherwise we have to answer this question for every
  -- new platform we compile on (even unreg).
 
+osUsesFrameworks :: OS -> Bool
+osUsesFrameworks OSDarwin = True
+osUsesFrameworks OSiOS    = True
+osUsesFrameworks _        = False
+
+platformUsesFrameworks :: Platform -> Bool
+platformUsesFrameworks = osUsesFrameworks . platformOS
+





More information about the ghc-commits mailing list