Skip to content

Commit

Permalink
Patch from Eric Kow:
Browse files Browse the repository at this point in the history
Mon Apr 16 09:25:24 BST 2012  Eric Kow <eric.kow@gmail.com>
 * Try a little harder to find wxc install directory.

 Users of cabal-dev may find that the wxc include dir does not have
 wxc anywhere in its path, eg.
   /home/moi/my-package/cabal-dev//lib//include
 So instead we try looking for the wxc.h file itself.

Fixes jodonoghue#5
  • Loading branch information
jodonoghue committed Apr 18, 2012
1 parent 8911d0a commit fa88a6e
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 8 deletions.
18 changes: 11 additions & 7 deletions wxcore/Setup.hs
@@ -1,4 +1,4 @@
import Control.Monad (when)
import Control.Monad (when, filterM)
import Data.List (foldl', intersperse, intercalate, nub, lookup, isPrefixOf, isInfixOf, find)
import Data.Maybe (fromJust)
import Distribution.PackageDescription hiding (includeDirs)
Expand Down Expand Up @@ -34,12 +34,16 @@ wxcoreDirectory = "src/haskell/Graphics/UI/WXCore"
-- It works by finding the wxc package's installation info, then finding the include directory
-- which contains wxc's headers (amongst the wxWidgets include dirs) and then going up a level.
-- It would be nice the path was park of InstalledPackageInfo, but it isn't.
wxcInstallDir :: LocalBuildInfo -> FilePath
wxcInstallDir :: LocalBuildInfo -> IO FilePath
wxcInstallDir lbi =
case searchByName (installedPkgs lbi) "wxc" of
Unambiguous wxc_pkgs -> case find (isInfixOf "wxc") . includeDirs . head $ wxc_pkgs of
Just wxcIncludeDir -> takeDirectory wxcIncludeDir
Nothing -> error "wxcInstallDir: Couldn't find wxc include dir"
Unambiguous (wxc_pkg:_) -> do
wxc <- filterM (doesFileExist . (</> "wxc.h")) (includeDirs wxc_pkg)
case wxc of
[wxcIncludeDir] -> return (takeDirectory wxcIncludeDir)
[] -> error "wxcInstallDir: couldn't find wxc include dir"
_ -> error "wxcInstallDir: I'm confused. I see more than one wxc include directory from the same package"
Unambiguous [] -> error "wxcInstallDir: Cabal says wxc is installed but gives no package info for it"
_ -> error "wxcInstallDir: Couldn't find wxc package in installed packages"

-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
Expand All @@ -49,8 +53,8 @@ myConfHook (pkg0, pbi) flags = do
createDirectoryIfMissing True wxcoreDirectory

lbi <- confHook simpleUserHooks (pkg0, pbi) flags
let wxcDirectory = wxcInstallDir lbi
wxcoreIncludeFile = wxcDirectory </> "include/wxc.h"
wxcDirectory <- wxcInstallDir lbi
let wxcoreIncludeFile = wxcDirectory </> "include/wxc.h"

putStrLn "Generating class type definitions from .h files"
system $ "wxdirect -t --wxc " ++ wxcDirectory ++ " -o " ++ wxcoreDirectory ++ " " ++ wxcoreIncludeFile
Expand Down
2 changes: 1 addition & 1 deletion wxcore/wxcore.cabal
@@ -1,5 +1,5 @@
name: wxcore
version: 0.90
version: 0.90.0.1
license: OtherLicense
license-file: LICENSE
author: Daan Leijen
Expand Down

0 comments on commit fa88a6e

Please sign in to comment.