packages feed

cabal-macosx 0.2.3.2 → 0.2.3.3

raw patch · 5 files changed

+102/−33 lines, 5 filesdep +containersPVP: minor bump suggested

API additions: PVP suggests at least a minor version bump

Dependencies added: containers

API changes (from Hackage documentation)

+ Distribution.MacOSX.Internal: getMacAppsForBuildableExecutors :: [MacApp] -> [Executable] -> [MacApp]

Files

Distribution/MacOSX.hs view
@@ -34,18 +34,15 @@ import System.Exit import System.FilePath import System.Info (os)-import System.Directory (copyFile, createDirectoryIfMissing, getHomeDirectory)+import System.Directory (doesDirectoryExist, copyFile, createDirectoryIfMissing, getHomeDirectory) import qualified Data.Text as T import qualified Data.Text.IO as T -import Distribution.PackageDescription (PackageDescription(..),-                                        Executable(..))+import Distribution.PackageDescription (PackageDescription(..), Executable(..)) import Distribution.Simple import Distribution.Simple.InstallDirs (bindir, prefix, CopyDest(NoCopyDest)) import Distribution.Simple.LocalBuildInfo (absoluteInstallDirs, LocalBuildInfo(..))-import Distribution.Simple.Setup (BuildFlags, InstallFlags,-                                  fromFlagOrDefault, installVerbosity-                                 )+import Distribution.Simple.Setup (BuildFlags, InstallFlags, fromFlagOrDefault, installVerbosity) import Distribution.Simple.Utils (installDirectoryContents, installExecutableFile) import Distribution.Verbosity (normal) @@ -65,12 +62,10 @@   -> BuildFlags -> PackageDescription -> LocalBuildInfo -> IO () appBundleBuildHook apps _ _ pkg localb =   if isMacOS-     then forM_ apps' $ makeAppBundle . toAppBuildInfo localb+     then do let buildDirLbi = buildDir localb+             let macApps = getMacAppsForBuildableExecutors apps (executables pkg)+             forM_ macApps (makeAppBundle . createAppBuildInfo buildDirLbi)      else putStrLn "Not OS X, so not building an application bundle."-  where apps' = case apps of-                      [] -> map mkDefault $ executables pkg-                      xs -> xs-        mkDefault x = MacApp (exeName x) Nothing Nothing [] [] DoNotChase  -- | Post-install hook for OS X application bundles.  Copies the -- application bundle (assuming you are also using the appBundleBuildHook)@@ -180,7 +175,7 @@      createDirectoryIfMissing False appPath      createDirectoryIfMissing True  $ takeDirectory exeDest      createDirectoryIfMissing True  $ appPath </> "Contents/Resources"-     putStrLn $ "Copying executable " ++ appName app ++ " into place"+     putStrLn $ "Copying executable " ++ appName app ++ " into place from " ++ exeSrc ++ " to " ++ exeDest      copyFile exeSrc exeDest      return appPath   where exeDest = appPath </> pathInApp app (appName app)
Distribution/MacOSX/AppBuildInfo.hs view
@@ -23,8 +23,13 @@ -- | @toAppBuildInfo l m@ returns information for an application bundle --   within the @l@ build directory toAppBuildInfo :: LocalBuildInfo -> MacApp -> AppBuildInfo-toAppBuildInfo localb app = AppBuildInfo-  { abAppPath    = buildDir localb </> appName app <.> "app"-  , abAppOrigExe = buildDir localb </> appName app </> appName app+toAppBuildInfo localb app = createAppBuildInfo (buildDir localb) app++-- | @createAppBuildInfo d m@ returns information for an application bundle+--   within the @d@ build directory from LocalBuildInfo+createAppBuildInfo :: FilePath -> MacApp -> AppBuildInfo+createAppBuildInfo buildDirLocalBuildInfo app = AppBuildInfo+  { abAppPath    = buildDirLocalBuildInfo </> appName app <.> "app"+  , abAppOrigExe = buildDirLocalBuildInfo </> appName app </> appName app   , abApp        = app   }
Distribution/MacOSX/Internal.hs view
@@ -16,19 +16,38 @@ -}  module Distribution.MacOSX.Internal (+  getMacAppsForBuildableExecutors,   osxIncantations ) where -import Control.Exception-import Prelude hiding ( catch )+import Prelude hiding ( catch, lookup ) import System.Cmd ( system ) import System.Exit import System.FilePath import Control.Monad (filterM) import System.Directory (doesDirectoryExist)+import Data.Foldable ( foldl )+import Data.Map ( empty, insert, lookup )+import Distribution.PackageDescription (BuildInfo(..), Executable(..))  import Distribution.MacOSX.Common +getMacAppsForBuildableExecutors :: [MacApp] -> [Executable] -> [MacApp]+getMacAppsForBuildableExecutors macApps executables =+  case macApps of+    [] -> map mkDefault buildables+    xs -> filter buildableApp xs+  where -- Make a default MacApp in absence of explicit from Setup.hs+        mkDefault x = MacApp (exeName x) Nothing Nothing [] [] DoNotChase++        -- Check if a MacApp is in that list of buildable executables.+        buildableApp :: MacApp -> Bool+        buildableApp app = any (\e -> exeName e == appName app) buildables++        -- List of buildable executables from .cabal file.+        buildables :: [Executable]+        buildables = filter (buildable . buildInfo) executables+ -- | Perform various magical OS X incantations for turning the app -- directory into a bundle proper. osxIncantations ::@@ -54,8 +73,9 @@      exitValue <- system commandExec      case exitValue of         ExitSuccess -> return ()-        _ -> putStrLn $ "Warning - Could not run the command \""-                        ++ commandExec ++ "\". Please check your local `XCode` configuration."+        _ -> do putStrLn $ "Warning - Could not run the command \""+                           ++ commandExec ++ "\". Please check your local `XCode` configuration."+                exitFailure  -- | Path to the developer tools directory, if one exists developerTools :: IO FilePath
cabal-macosx.cabal view
@@ -1,5 +1,5 @@ Name:                   cabal-macosx-Version:                0.2.3.2+Version:                0.2.3.3 Stability:              Alpha Synopsis:               Cabal support for creating Mac OSX application bundles. Description:@@ -38,6 +38,7 @@                     , parsec                     , process                     , text+                    , containers   Exposed-modules:  Distribution.MacOSX,                     Distribution.MacOSX.Internal,                     Distribution.MacOSX.Common@@ -56,6 +57,7 @@                     , parsec                     , process                     , text+                    , containers  test-suite tests   ghc-options:      -Wall@@ -69,3 +71,4 @@                     , test-framework == 0.8.*                     , test-framework-hunit == 0.3.*                     , temporary+                    , Cabal >= 1.6
tests/Distribution/MacOSX/Internal/Tests.hs view
@@ -1,28 +1,74 @@ module Distribution.MacOSX.Internal.Tests where +import System.IO.Temp (withSystemTempDirectory)+import Control.Exception (SomeException, catch)+import Prelude hiding (catch) import Test.HUnit (Assertion, assertEqual) import Test.Framework (Test, mutuallyExclusive, testGroup) import Test.Framework.Providers.HUnit (testCase)-import Distribution.MacOSX.Internal (osxIncantations)+import Distribution.PackageDescription (BuildInfo(..), Executable(..), emptyBuildInfo)++import Distribution.MacOSX.Internal (osxIncantations, getMacAppsForBuildableExecutors) import Distribution.MacOSX.Common-import System.IO.Temp (withSystemTempDirectory)-import Control.Exception  macosxInternalTests :: Test macosxInternalTests = testGroup "Distribution.MacOSX.Internal"     [ mutuallyExclusive $ testGroup "MacOSX Internal"-        [ testOsxIncantations+        [ testCase "should exit with an exit-failure as Xcode's Carbon Tools fail to run" testCarbonTools,+          -- I should consider to use QuickCheck maybe... :)+          testCase "given nothing then should not try to build any mac-app" testBuildMacApp_noInput,+          testCase "given no executables then should not try to build any mac-app" testBuildMacApp_noExecutables,+          testCase "given only two executables then should try to build two mac-apps" testBuildMacApp_twoBuildableExecutables,+          testCase "given only two executables and one not executable then should try to build one mac-app" testBuildMacApp_twoExcetuablesOneBuildableandOneNot,+          testCase "given two executables and one not executable and two apps then should try to build one mac-app" testBuildMacApp_twoAppsAndTwoExecutablesOneBuildableOneNot         ]     ] -testOsxIncantations :: Test-testOsxIncantations = testCase "should not throw any exception even if Xcode's Carbon Tools fail to run" testCarbonTools-  where-    testCarbonTools :: Assertion-    testCarbonTools = do-        let macApp = MacApp "DummyApp" Nothing Nothing [] [] DoNotChase+testCarbonTools :: Assertion+testCarbonTools = do+    let macApp = MacApp "DummyApp" Nothing Nothing [] [] DoNotChase -        withSystemTempDirectory "DummyAppPath" $ \tmpDir-            -> osxIncantations tmpDir macApp+    withSystemTempDirectory "DummyAppPath" $ \tmpDir+        -> osxIncantations tmpDir macApp -- some problems here to add `assertFailure` after+             `catch`+                 (\e -> putStrLn $ "Catched: " ++ show (e :: SomeException)) -        return ()+testBuildMacApp_noInput :: Assertion+testBuildMacApp_noInput = do+    let actual = getMacAppsForBuildableExecutors [] []+    let expected = []+    assertEqual "nothing should be built" expected actual++testBuildMacApp_noExecutables :: Assertion+testBuildMacApp_noExecutables = do+    let apps = [MacApp "Dummy App" Nothing Nothing [] [] DoNotChase]+    let actual = getMacAppsForBuildableExecutors apps []+    let expected = []+    assertEqual "nothing should be built" expected actual++testBuildMacApp_twoBuildableExecutables :: Assertion+testBuildMacApp_twoBuildableExecutables = do+    let execs = [ Executable "Dummy One" "/tmp" emptyBuildInfo+                  , Executable "Dummy Two" "/tmp" emptyBuildInfo ]+    let actual = getMacAppsForBuildableExecutors [] execs+    let expected = [ MacApp "Dummy One" Nothing Nothing [] [] DoNotChase+                     , MacApp "Dummy Two" Nothing Nothing [] [] DoNotChase ]+    assertEqual "two mac-apps should be built" expected actual++testBuildMacApp_twoExcetuablesOneBuildableandOneNot :: Assertion+testBuildMacApp_twoExcetuablesOneBuildableandOneNot = do+    let execs = [ Executable "Dummy One" "/tmp" (emptyBuildInfo { buildable = False })+                  , Executable "Dummy Two" "/tmp" emptyBuildInfo ]+    let actual = getMacAppsForBuildableExecutors [] execs+    let expected = [ MacApp "Dummy Two" Nothing Nothing [] [] DoNotChase ]+    assertEqual "two mac-apps should be built" expected actual++testBuildMacApp_twoAppsAndTwoExecutablesOneBuildableOneNot :: Assertion+testBuildMacApp_twoAppsAndTwoExecutablesOneBuildableOneNot = do+    let execs = [ Executable "Dummy One" "/tmp" (emptyBuildInfo { buildable = False })+                  , Executable "Dummy Two" "/tmp" emptyBuildInfo ]+    let apps = [ MacApp "Dummy One" Nothing Nothing [] [] DoNotChase+                 , MacApp "Dummy Two" Nothing Nothing [] [] DoNotChase ]+    let actual = getMacAppsForBuildableExecutors apps execs+    let expected = [ MacApp "Dummy Two" Nothing Nothing [] [] DoNotChase ]+    assertEqual "one mac-app should be built" expected actual