Dear (wx)Haskellers, I have recently been switching some of my GUI software to Cabal (from my clunky ad-hoc Makefiles). As you might aware, wxhaskell apps on MacOS X require the macosx-app script to be run on the executable or else the GUI doesn't respond at all; it just sits there looking pretty. (if anybody wants to fill me in on the technical details, I would be curious/interested).
Attached is a Setup.lhs file which uses an install hook to run that script once you have installed your program. Note that it optionally allows to specify what script to run, in case you have a special version, which for example, attaches as icon to your app. Any comments, suggestions for improvements, simpler means of going about the same task? Thanks, -- Eric Kow http://www.loria.fr/~kow PGP Key ID: 08AC04F9 Merci de corriger mon français.
#!/usr/bin/env runhaskell
This Cabal setup script is meant to be used with programs that use the
wxHaskell toolkit. The problem is that on MacOS X, you have to post
process each GUI with the 'macosx-app' shell script (from wxhaskell) so
that it actually responds to user input instead of just sitting there
looking pretty.
> import Control.Monad (foldM)
> import System.Cmd
> import System.Exit
> import System.Info (os)
>
> import Distribution.PackageDescription
> import Distribution.Setup
> import Distribution.Simple
> import Distribution.Simple.LocalBuildInfo
Configure this stuff
--------------------
Put here the list of executables which contain a GUI. If they all
contain a GUI (or you don't really care that much), just put Nothing
> mRestrictTo :: Maybe [String]
> mRestrictTo = Just ["geni"]
Normally, this should just be "macosx-app"
> macosxApp :: String
> macosxApp = "etc/macstuff/macosx-app"
Nothing to configure from here on
---------------------------------
Note that we assume anybody running on Darwin is running OS X, probably
not the right thing to do, but frankly... who runs Darwin anyway? Note
also that this script is equivalent to the vanilla one if you're running
on other operating systems.
> main :: IO ()
> main =
> do case os of
> "darwin" -> defaultMainWithHooks (defaultUserHooks { postInst =
> macifyHook })
> _ -> defaultMain
> macifyHook _ _ pkg localb =
> foldM (next $ macify.binPath) ExitSuccess guiExes
> where
> allExes = map exeName $ executables pkg
> guiExes = case mRestrictTo of
> Nothing -> allExes
> Just rs -> filter (`elem` rs) allExes
> next f x@(ExitFailure _) _ = return x
> next f _ b = macify (binPath b)
> binPath x = prefix localb /// bindir localb /// x
> macify :: FilePath -> IO ExitCode
> macify x = system $ macosxApp ++ " " ++ x
This handly little FilePath concatenation function was stolen from
darcs. Note that darcs is GPL; if this bothers you, ask David Roundy.
> (///) :: FilePath -> FilePath -> FilePath
> ""///b = b
> a///"" = a
> a///b = a ++ "/" ++ b
pgpSuuzyJZI8o.pgp
Description: PGP signature
------------------------------------------------------------------------- Take Surveys. Earn Cash. Influence the Future of IT Join SourceForge.net's Techsay panel and you'll get the chance to share your opinions on IT & business topics through brief surveys-and earn cash http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________ wxhaskell-users mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/wxhaskell-users
