Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Update wxcore build for separated wxc

Ignore-this: f6a30cd378270717ad11aeda1c3973ce

This patch brings in the changes needed to build wxcore with a separated wxc. It has
been virtually impossible to separate out the individual patches from Dave Tapley's
branch which make up this change, but as well as bumping the version to 0.15, at
least the following are implicated:

* Set wxcore Setup.hs to use System.FilePath instead of System.FilePath.Posix
  (jeremy.odonoghue@gmail.com Tue Jan 31 2012)
* Make wxcore link with an rpath to wxc. This fixes the problem I described
  here http://comments.gmane.org/gmane.comp.lang.haskell.libraries/16807 and
  listed as "the only major remaining problem" here:
  http://www.mail-archive.com/wxhaskell-devel@lists.sourceforge.net/msg00722.html.
  (dukedave@gmail.com Tue Jan 3 2012))
* Missed modified files in the previous patch. This is the second part of the patch
  "Move compilation of C++ code to new wxc project and use a shared library for it"
  Unfortunately I missed these important files modifications and darcs was waiting
  forever when I tried to unrecord or amend that patch.
  For further information please see email [wxhaskell-devel] Using a shared library
  for the C++ in wxhaskell. http://sourceforge.net/mailarchive/message,php?msg_id=28515489.
  (dukedave@gmail.com Wed Dec 14 2011)
* Move compilation of C++ code to new wxc project and use a shared library for it.
  (dukedave@gmail.com Wed Dec 14 2011)
* wxcore: no more Eiffel
  Just use the autogenerated (and now manually maintained) Haskell module instead
  wxEiffel seems to be a dead project at the time of this patch, so we're not
  exactly getting a cross-project refactor out of this. Haveing the Eiffel around
  just creates the impression of complexity for little gain.
  (eric.kow@gmail.com Thu Nov 3 2011)

darcs-hash:20120318112715-75908-6f768323635d985dde10f88a428dace5b2aed2ea.gz
  • Loading branch information...
commit 6a747f4cdb874a66ccc22b4c314a7a81593dd5cd 1 parent af2e67f
@jodonoghue authored
Showing with 48 additions and 66 deletions.
  1. +46 −65 wxcore/Setup.hs
  2. +2 −1  wxcore/wxcore.cabal
View
111 wxcore/Setup.hs
@@ -1,14 +1,22 @@
-import Data.List (foldl', intercalate, nub)
-import Data.Maybe (fromJust)
-import Distribution.PackageDescription
+import Control.Monad (when)
+import Data.List (foldl', intersperse, intercalate, nub, lookup, isPrefixOf, isInfixOf, find)
+import Data.Maybe (fromJust)
+import Distribution.PackageDescription hiding (includeDirs)
+import Distribution.InstalledPackageInfo(installedPackageId, sourcePackageId, includeDirs)
import Distribution.Simple
-import Distribution.Simple.LocalBuildInfo (LocalBuildInfo, localPkgDescr)
-import Distribution.Simple.Setup (ConfigFlags)
-import System.Cmd (system)
-import System.FilePath.Posix ((</>), (<.>))
-import System.Directory (createDirectoryIfMissing)
-import System.Info (os)
-import System.Process (readProcess)
+import Distribution.Simple.LocalBuildInfo (LocalBuildInfo, localPkgDescr, installedPkgs, withPrograms, buildDir)
+import Distribution.Simple.PackageIndex(SearchResult (..), searchByName, allPackages )
+import Distribution.Simple.Program (ConfiguredProgram (..), lookupProgram, runProgram, simpleProgram, locationPath)
+import Distribution.Simple.Program.Types
+import Distribution.Simple.Setup (ConfigFlags, BuildFlags)
+import Distribution.System (OS (..), Arch (..), buildOS, buildArch)
+import Distribution.Verbosity (normal, verbose)
+import System.Cmd (system)
+import System.Directory (createDirectoryIfMissing, doesFileExist, getCurrentDirectory, getModificationTime)
+import System.Environment (getEnv)
+import System.FilePath ((</>), (<.>), replaceExtension, takeFileName, dropFileName, addExtension, takeDirectory)
+import System.IO.Unsafe (unsafePerformIO)
+import System.Process (readProcess)
-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
@@ -17,79 +25,52 @@ main = defaultMainWithHooks simpleUserHooks { confHook = myConfHook }
-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
-sourceDirectory :: FilePath
-includeDirectory :: FilePath
wxcoreDirectory :: FilePath
-
-sourceDirectory = "src"
-includeDirectory = sourceDirectory </> "include"
-wxcoreDirectory = sourceDirectory </> "haskell/Graphics/UI/WXCore"
+wxcoreDirectory = "src/haskell/Graphics/UI/WXCore"
-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
-wxcoreIncludeFile :: FilePath
-wxcoreIncludeFile = includeDirectory </> "wxc.h"
-
+-- |This slightly dubious function obtains the install path for the wxc package we are using.
+-- 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 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"
+ _ -> error $ "wxcInstallDir: Couldn't find wxc package in installed packages."
-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
-- Comment out type signature because of a Cabal API change from 1.6 to 1.7
myConfHook (pkg0, pbi) flags = do
createDirectoryIfMissing True wxcoreDirectory
- system $ "wxdirect -t --wxc " ++ sourceDirectory ++ " -o " ++ wxcoreDirectory ++ " " ++ wxcoreIncludeFile
- system $ "wxdirect -i --wxc " ++ sourceDirectory ++ " -o " ++ wxcoreDirectory ++ " " ++ wxcoreIncludeFile
- system $ "wxdirect -c --wxc " ++ sourceDirectory ++ " -o " ++ wxcoreDirectory ++ " " ++ wxcoreIncludeFile
- -- ver <- fmap (head . drop 1 . splitBy (== '.')) (readProcess "wx-config" ["--version"] "")
- let extra_wx_libs = if os == "mingw32"
- then [ "-lwxmsw28ud_media", "-lwxmsw28ud_richtext", "-lwxmsw28ud_aui"
- , "-lwxmsw28ud_xrc", "-lstdc++" ]
- else [ "-lstdc++" ]
- wx_cfg_parms = if os == "mingw32"
- then [ "--unicode", "--libs", "gl,stc", "--cppflags" ]
- else [ "--libs", "std,gl,stc,xrc,richtext,aui,media", "--cppflags" ]
- wx <- fmap parseWxConfig (readProcess "wx-config" wx_cfg_parms "")
lbi <- confHook simpleUserHooks (pkg0, pbi) flags
+ let wxcDirectory = wxcInstallDir lbi
+ wxcoreIncludeFile = wxcDirectory </> "include/wxc.h"
- let lpd = localPkgDescr lbi
- let lib = fromJust (library lpd)
- let libbi = libBuildInfo lib
+ putStrLn "Generating class type definitions from .h files"
+ system $ "wxdirect -t --wxc " ++ wxcDirectory ++ " -o " ++ wxcoreDirectory ++ " " ++ wxcoreIncludeFile
+ putStrLn "Generating class info definitions"
+ system $ "wxdirect -i --wxc " ++ wxcDirectory ++ " -o " ++ wxcoreDirectory ++ " " ++ wxcoreIncludeFile
+ putStrLn "Generating class method definitions from .h files"
+ system $ "wxdirect -c --wxc " ++ wxcDirectory ++ " -o " ++ wxcoreDirectory ++ " " ++ wxcoreIncludeFile
+
+ let lpd = localPkgDescr lbi
+ let lib = fromJust (library lpd)
+ let libbi = libBuildInfo lib
+ let custom_bi = customFieldsBI libbi
let libbi' = libbi
- { extraLibDirs = extraLibDirs libbi ++ extraLibDirs wx
- , extraLibs = extraLibs libbi ++ extraLibs wx
- , ldOptions = ldOptions libbi ++ ldOptions wx ++ extra_wx_libs
- , frameworks = frameworks libbi ++ frameworks wx
- , includeDirs = includeDirs libbi ++ includeDirs wx
- , ccOptions = ccOptions libbi ++ ccOptions wx ++ ["-DwxcREFUSE_MEDIACTRL"]
- }
+ { extraLibDirs = extraLibDirs libbi ++ [wxcDirectory]
+ , extraLibs = extraLibs libbi ++ ["wxc"]
+ , ldOptions = ldOptions libbi ++ ["-Wl,-rpath," ++ wxcDirectory] }
let lib' = lib { libBuildInfo = libbi' }
let lpd' = lpd { library = Just lib' }
return $ lbi { localPkgDescr = lpd' }
--- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
-
-parseWxConfig :: String -> BuildInfo
-parseWxConfig s =
- helper emptyBuildInfo (words s)
- where
- helper b ("-framework":w:ws) = helper (b { frameworks = w : frameworks b }) ws
- helper b (w:ws) = helper (f b w) ws
- helper b [] = b
- f b w =
- case w of
- ('-':'L':v) -> b { extraLibDirs = v : extraLibDirs b }
- ('-':'l':v) -> b { extraLibs = v : extraLibs b }
- ('-':'I':v) -> b { includeDirs = v : includeDirs b }
- ('-':'D':_) -> b { ccOptions = w : ccOptions b }
- _ -> b
-
--- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
-
-splitBy :: (a -> Bool) -> [a] -> [[a]]
-splitBy pred l = case dropWhile pred l of
- [] -> []
- l' -> x : splitBy pred xs
- where (x, xs) = break pred l'
View
3  wxcore/wxcore.cabal
@@ -1,5 +1,5 @@
name: wxcore
-version: 0.13.2.1
+version: 0.15
license: OtherLicense
license-file: LICENSE
author: Daan Leijen
@@ -198,6 +198,7 @@ library
filepath,
parsec,
stm,
+ wxc,
wxdirect > 0.12.1.2,
directory,
time
Please sign in to comment.
Something went wrong with that request. Please try again.