cabal-macosx 0.2.3.1 → 0.2.3.2
raw patch · 5 files changed
+163/−61 lines, 5 filesdep +HUnitdep +cabal-macosxdep +temporarydep ~basePVP: minor bump suggested
API additions: PVP suggests at least a minor version bump
Dependencies added: HUnit, cabal-macosx, temporary, test-framework, test-framework-hunit
Dependency ranges changed: base
API changes (from Hackage documentation)
+ Distribution.MacOSX.Common: ChaseWith :: Exclusions -> ChaseDeps
+ Distribution.MacOSX.Common: ChaseWithDefaults :: ChaseDeps
+ Distribution.MacOSX.Common: DoNotChase :: ChaseDeps
+ Distribution.MacOSX.Common: MacApp :: String -> Maybe FilePath -> Maybe FilePath -> [FilePath] -> [FilePath] -> ChaseDeps -> MacApp
+ Distribution.MacOSX.Common: [appDeps] :: MacApp -> ChaseDeps
+ Distribution.MacOSX.Common: [appIcon] :: MacApp -> Maybe FilePath
+ Distribution.MacOSX.Common: [appName] :: MacApp -> String
+ Distribution.MacOSX.Common: [appPlist] :: MacApp -> Maybe FilePath
+ Distribution.MacOSX.Common: [otherBins] :: MacApp -> [FilePath]
+ Distribution.MacOSX.Common: [resources] :: MacApp -> [FilePath]
+ Distribution.MacOSX.Common: data ChaseDeps
+ Distribution.MacOSX.Common: data MacApp
+ Distribution.MacOSX.Common: defaultExclusions :: Exclusions
+ Distribution.MacOSX.Common: instance GHC.Classes.Eq Distribution.MacOSX.Common.ChaseDeps
+ Distribution.MacOSX.Common: instance GHC.Classes.Eq Distribution.MacOSX.Common.MacApp
+ Distribution.MacOSX.Common: instance GHC.Show.Show Distribution.MacOSX.Common.ChaseDeps
+ Distribution.MacOSX.Common: instance GHC.Show.Show Distribution.MacOSX.Common.MacApp
+ Distribution.MacOSX.Common: pathInApp :: MacApp -> FilePath -> FilePath
+ Distribution.MacOSX.Common: type Exclusions = [String]
+ Distribution.MacOSX.Internal: osxIncantations :: FilePath -> MacApp -> IO ()
Files
- Distribution/MacOSX.hs +16/−46
- Distribution/MacOSX/Internal.hs +72/−0
- cabal-macosx.cabal +38/−15
- tests/Distribution/MacOSX/Internal/Tests.hs +28/−0
- tests/Main.hs +9/−0
Distribution/MacOSX.hs view
@@ -1,22 +1,23 @@ {-# LANGUAGE OverloadedStrings #-}-{- | Cabal support for creating Mac OSX application bundles.+ {- | Cabal support for creating Mac OSX application bundles. -GUI applications on Mac OSX should be run as application /bundles/;-these wrap an executable in a particular directory structure which can-also carry resources such as icons, program metadata, images, other-binaries, and copies of shared libraries.+ GUI applications on Mac OSX should be run as application /bundles/;+ these wrap an executable in a particular directory structure which can+ also carry resources such as icons, program metadata, images, other+ binaries, and copies of shared libraries. -This module provides a Cabal post-build hook for creating such-application bundles, and controlling their contents.+ This module provides a Cabal post-build hook for creating such+ application bundles, and controlling their contents. -For more information about OSX application bundles, look for the-/Bundle Programming Guide/ on the /Apple Developer Connection/-website, <http://developer.apple.com/>.+ For more information about OSX application bundles, look for the+ /Bundle Programming Guide/ on the /Apple Developer Connection/+ website, <http://developer.apple.com/>. --}+ -} module Distribution.MacOSX (- appBundleBuildHook, appBundleInstallHook,+ appBundleBuildHook,+ appBundleInstallHook, makeAppBundle, MacApp(..), ChaseDeps(..),@@ -26,15 +27,14 @@ import Control.Exception import Prelude hiding ( catch )-import Control.Monad (forM_, when, filterM)+import Control.Monad (forM_, when) import Data.List ( isPrefixOf ) import Data.Text ( Text ) import System.Cmd (system) import System.Exit import System.FilePath import System.Info (os)-import System.Directory (copyFile, createDirectoryIfMissing, doesDirectoryExist,- getHomeDirectory)+import System.Directory (copyFile, createDirectoryIfMissing, getHomeDirectory) import qualified Data.Text as T import qualified Data.Text.IO as T @@ -49,6 +49,7 @@ import Distribution.Simple.Utils (installDirectoryContents, installExecutableFile) import Distribution.Verbosity (normal) +import Distribution.MacOSX.Internal import Distribution.MacOSX.AppBuildInfo import Distribution.MacOSX.Common import Distribution.MacOSX.Dependencies@@ -229,37 +230,6 @@ copyFile icPath $ appPath </> "Contents/Resources" </> takeFileName icPath Nothing -> return ()---- | Perform various magical OS X incantations for turning the app--- directory into a bundle proper.-osxIncantations ::- FilePath -- ^ Path to application bundle root.- -> MacApp -> IO ()-osxIncantations appPath app =- do dtools <- developerTools- let rez = dtools </> "Rez"- setFile = dtools </> "SetFile"- putStrLn "Running Rez, etc."- ExitSuccess <- system $ rez ++ " Carbon.r -o " ++- appPath </> pathInApp app (appName app)- writeFile (appPath </> "PkgInfo") "APPL????"- -- Tell Finder about the icon.- ExitSuccess <- system $ setFile ++ " -a C " ++ appPath </> "Contents"- return ()---- | Path to the developer tools directory, if one exists-developerTools :: IO FilePath-developerTools =- do ds <- filterM doesDirectoryExist cands- case ds of- [] -> do putStrLn $ "Can't find the developer tools directory. Have you installed the Developer tools?\n"- ++ "I tried looking for:\n" ++ unlines (map ("* " ++) cands)- exitWith (ExitFailure 1)- (d:_) -> return d- where- cands = [ "/Applications/XCode.app/Contents/Developer/Tools"- , "/Developer/Tools"- ] -- | Default plist template, based on that in macosx-app from wx (but -- with version stuff removed).
+ Distribution/MacOSX/Internal.hs view
@@ -0,0 +1,72 @@+{-# LANGUAGE OverloadedStrings #-}+{- | Cabal support for creating Mac OSX application bundles.++GUI applications on Mac OSX should be run as application /bundles/;+these wrap an executable in a particular directory structure which can+also carry resources such as icons, program metadata, images, other+binaries, and copies of shared libraries.++This module provides a Cabal post-build hook for creating such+application bundles, and controlling their contents.++For more information about OSX application bundles, look for the+/Bundle Programming Guide/ on the /Apple Developer Connection/+website, <http://developer.apple.com/>.++-}++module Distribution.MacOSX.Internal (+ osxIncantations+) where++import Control.Exception+import Prelude hiding ( catch )+import System.Cmd ( system )+import System.Exit+import System.FilePath+import Control.Monad (filterM)+import System.Directory (doesDirectoryExist)++import Distribution.MacOSX.Common++-- | Perform various magical OS X incantations for turning the app+-- directory into a bundle proper.+osxIncantations ::+ FilePath -- ^ Path to application bundle root.+ -> MacApp -> IO ()+osxIncantations appPath app =+ do dtools <- developerTools++ let rezExec = dtools </> "Rez Carbon.r -o " ++ appPath </> pathInApp app (appName app)+ runCommand rezExec++ writeFile (appPath </> "PkgInfo") "APPL????"++ -- Tell Finder about the icon.+ let setFileExec = dtools </> "SetFile -a C " ++ appPath </> "Contents"+ runCommand setFileExec++ return ()++runCommand :: String -> IO ()+runCommand commandExec =+ do putStrLn $ "Running: " ++ commandExec+ exitValue <- system commandExec+ case exitValue of+ ExitSuccess -> return ()+ _ -> putStrLn $ "Warning - Could not run the command \""+ ++ commandExec ++ "\". Please check your local `XCode` configuration."++-- | Path to the developer tools directory, if one exists+developerTools :: IO FilePath+developerTools =+ do ds <- filterM doesDirectoryExist cands+ case ds of+ [] -> do putStrLn $ "Can't find the developer tools directory. Have you installed the Developer tools?\n"+ ++ "I tried looking for:\n" ++ unlines (map ("* " ++) cands)+ exitWith (ExitFailure 1)+ (d:_) -> return d+ where+ cands = [ "/Applications/XCode.app/Contents/Developer/Tools"+ , "/Developer/Tools"+ ]
cabal-macosx.cabal view
@@ -1,5 +1,5 @@ Name: cabal-macosx-Version: 0.2.3.1+Version: 0.2.3.2 Stability: Alpha Synopsis: Cabal support for creating Mac OSX application bundles. Description:@@ -24,25 +24,48 @@ Maintainer: Daniele Francesconi <dfrancesconi12@gmail.com> Homepage: http://github.com/danfran/cabal-macosx Build-Type: Simple-Cabal-Version: >=1.6+Cabal-Version: >=1.8 Source-Repository head Type: git Location: http://github.com/danfran/cabal-macosx Library- Build-Depends: base >= 4 && < 5, Cabal >= 1.6, directory- , fgl >= 5.4.2.2 && < 5.6- , filepath, parsec, process, text- Exposed-modules: Distribution.MacOSX- Other-modules: Distribution.MacOSX.Common,- Distribution.MacOSX.AppBuildInfo,- Distribution.MacOSX.Dependencies,- Distribution.MacOSX.DG- ghc-options: -fwarn-tabs -Wall+ Build-Depends: base >= 4 && < 5+ , Cabal >= 1.6, directory+ , fgl >= 5.4.2.2 && < 5.6+ , filepath+ , parsec+ , process+ , text+ Exposed-modules: Distribution.MacOSX,+ Distribution.MacOSX.Internal,+ Distribution.MacOSX.Common+ Other-modules: Distribution.MacOSX.AppBuildInfo,+ Distribution.MacOSX.Dependencies,+ Distribution.MacOSX.DG+ ghc-options: -fwarn-tabs -Wall Executable macosx-app- Main-is: macosx-app.hs- Build-Depends: base >= 4 && < 5, Cabal >= 1.6, directory- , fgl >= 5.4.2.2 && < 5.6- , filepath, parsec, process, text+ Main-is: macosx-app.hs+ Build-Depends: base >= 4 && < 5+ , Cabal >= 1.6+ , directory+ , fgl >= 5.4.2.2 && < 5.6+ , filepath+ , parsec+ , process+ , text++test-suite tests+ ghc-options: -Wall+ hs-source-dirs: tests+ Main-is: Main.hs+ Type: exitcode-stdio-1.0+ Other-modules: Distribution.MacOSX.Internal.Tests+ Build-depends: base >= 4 && < 4.9+ , HUnit >= 1.2 && < 1.4+ , cabal-macosx+ , test-framework == 0.8.*+ , test-framework-hunit == 0.3.*+ , temporary
+ tests/Distribution/MacOSX/Internal/Tests.hs view
@@ -0,0 +1,28 @@+module Distribution.MacOSX.Internal.Tests where++import Test.HUnit (Assertion, assertEqual)+import Test.Framework (Test, mutuallyExclusive, testGroup)+import Test.Framework.Providers.HUnit (testCase)+import Distribution.MacOSX.Internal (osxIncantations)+import Distribution.MacOSX.Common+import System.IO.Temp (withSystemTempDirectory)+import Control.Exception++macosxInternalTests :: Test+macosxInternalTests = testGroup "Distribution.MacOSX.Internal"+ [ mutuallyExclusive $ testGroup "MacOSX Internal"+ [ testOsxIncantations+ ]+ ]++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++ withSystemTempDirectory "DummyAppPath" $ \tmpDir+ -> osxIncantations tmpDir macApp++ return ()
+ tests/Main.hs view
@@ -0,0 +1,9 @@+module Main (main) where++import Test.Framework (defaultMain)+import Distribution.MacOSX.Internal.Tests (macosxInternalTests)++main :: IO ()+main = defaultMain+ [ macosxInternalTests+ ]