packages feed

cabal-macosx 0.1.2.1 → 0.1.2.2

raw patch · 3 files changed

+48/−16 lines, 3 filesnew-component:exe:macosx-app

Files

Distribution/MacOSX.hs view
@@ -16,6 +16,7 @@  module Distribution.MacOSX (   appBundleBuildHook, appBundleInstallHook,+  makeAppBundle,   MacApp(..),   ChaseDeps(..),   Exclusions,@@ -40,6 +41,7 @@ import System.Directory (copyFile, createDirectoryIfMissing) import System.Exit +import Distribution.MacOSX.AppBuildInfo import Distribution.MacOSX.Common import Distribution.MacOSX.Dependencies @@ -54,7 +56,7 @@   -> BuildFlags -> PackageDescription -> LocalBuildInfo -> IO () appBundleBuildHook apps _ _ pkg localb =   if isMacOS-     then forM_ apps' $ makeAppBundle localb+     then forM_ apps' $ makeAppBundle . toAppBuildInfo localb      else putStrLn "Not OS X, so not building an application bundle."   where apps' = case apps of                       [] -> map mkDefault $ executables pkg@@ -76,7 +78,8 @@   let verbosity = fromFlagOrDefault normal (installVerbosity iflags)   createDirectoryIfMissing False applicationsDir   forM_ apps $ \app -> do-    let appPathSrc = getAppPath localb app+    let appInfo    = toAppBuildInfo localb app+        appPathSrc = appPath appInfo         appPathTgt = applicationsDir </> takeFileName appPathSrc         exe ap = ap </> pathInApp app (appName app)     installDirectoryContents verbosity appPathSrc appPathTgt@@ -99,11 +102,10 @@ isMacOS = os == "darwin"  -- | Given a 'MacApp' in context, make an application bundle in the--- build area.-makeAppBundle ::-  LocalBuildInfo -> MacApp -> IO ()-makeAppBundle localb app =-  do appPath <- createAppDir localb app+-- build area. (for internal use only)+makeAppBundle :: AppBuildInfo -> IO ()+makeAppBundle appInfo@(AppBuildInfo appPath _ app) =+  do createAppDir appInfo      maybeCopyPlist appPath app      maybeCopyIcon appPath app        `catch` \err -> putStrLn ("Warning: could not set up icon for " ++@@ -115,8 +117,8 @@ -- | Create application bundle directory structure in build directory -- and copy executable into it.  Returns path to newly created -- directory.-createAppDir :: LocalBuildInfo -> MacApp -> IO FilePath-createAppDir localb app =+createAppDir :: AppBuildInfo -> IO FilePath+createAppDir (AppBuildInfo appPath exeSrc app) =   do putStrLn $ "Creating application bundle directory " ++ appPath      createDirectoryIfMissing False appPath      createDirectoryIfMissing True  $ takeDirectory exeDest@@ -124,12 +126,7 @@      putStrLn $ "Copying executable " ++ appName app ++ " into place"      copyFile exeSrc exeDest      return appPath-  where appPath = getAppPath localb app-        exeDest = appPath </> pathInApp app (appName app)-        exeSrc = buildDir localb </> appName app </> appName app--getAppPath :: LocalBuildInfo -> MacApp -> FilePath-getAppPath localb app = buildDir localb </> appName app <.> "app"+  where exeDest = appPath </> pathInApp app (appName app)  -- | Include any external resources specified. includeResources ::
cabal-macosx.cabal view
@@ -1,5 +1,5 @@ Name:                   cabal-macosx-Version:                0.1.2.1+Version:                0.1.2.2 Stability:              Alpha Synopsis:               Cabal support for creating Mac OSX application bundles. Description:@@ -39,3 +39,9 @@                    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.5+               ,   filepath, MissingH, parsec, process
+ macosx-app.hs view
@@ -0,0 +1,29 @@+module Main where++import Distribution.MacOSX+import Distribution.MacOSX.AppBuildInfo+import System.Directory+import System.Environment+import System.FilePath++main = do+  pname <- getProgName+  xs    <- getArgs+  exe <- case xs of+           [x1] -> return x1 +           _    -> fail $ "Usage: " ++ pname ++ " <exe>"+  exeExists <- doesFileExist exe+  let macapp  = MacApp { appName   = takeFileName exe+                       , appIcon   = Nothing+                       , appPlist  = Nothing+                       , resources = []+                       , otherBins = []+                       , appDeps   = DoNotChase+                       } +      appInfo = AppBuildInfo { app        = macapp+                             , appPath    = appName macapp <.> "app"+                             , appOrigExe = exe+                             }+  if exeExists+     then makeAppBundle appInfo+     else fail $ exe ++ " does not exist"