Hi folks,
With current Gtk+ windows bundles we have the problem that the cairo
binding fails to load in ghci, though it works fine for compiling
standalone .exes.
The source of the problem is that the ghc-pkg package registration
information is wrong, it ends up containing:
extra-libraries: z cairo
extra-ghci-libraries: libcairo-script-interpreter-2
when it should be:
extra-libraries: z cairo
extra-ghci-libraries: libcairo-2
Background: when the extra-ghci-libraries field is present then ghci
will use it instead of the extra-libraries field. This lets ghci cope
with the fact that the static lib is called libcairo.a while the dynamic
lib is called libcairo-2.dll.
The extra-ghci-libraries field is set in by a bit of code in the
Gtk2HsSetup.hs file which looks for a .dll file corresponding to the
main lib that is needed. It's pure guesswork based on file names. The
code currently falls over in the case that there's more than one .dll
file with the pattern libcairo-*.dll and with recent Gtk+ builds there's
actually 3. So that's why it's picking libcairo-script-interpreter-2
rather than libcairo-2.
The attached patch changes this heuristic so that if there's several
choices then we pick the one with the shortest file name. I don't claim
that's fool proof (obviously it isn't) but it's a lot better than just
picking randomly based on directory ordering as it does now.
BTW: I've only adjusted the cairo/Gtk2HsSetup.hs, and it's preferably to
keep them all in sync. Also, I've not actually tested the patch on
Windows but it looks "Obviously Correct"(tm) :-)
Duncan
1 patch for repository code.haskell.org:/srv/code/gtk2hs/:
Sun Sep 2 17:51:31 BST 2012 Duncan Coutts <dun...@community.haskell.org>
* Fix for finding the .dll names for ghci
Should fix the problem that the cairo package fails to load in ghci on Windows
New patches:
[Fix for finding the .dll names for ghci
Duncan Coutts <dun...@community.haskell.org>**20120902165131
Ignore-this: f2ca3b6959a1355ca708e8b7c091a50d
Should fix the problem that the cairo package fails to load in ghci on Windows
] hunk ./cairo/Gtk2HsSetup.hs 59
import Distribution.Verbosity
import Control.Monad (when, unless, filterM, liftM, forM, forM_)
import Data.Maybe ( isJust, isNothing, fromMaybe, maybeToList )
-import Data.List (isPrefixOf, isSuffixOf, nub)
+import Data.List (isPrefixOf, isSuffixOf, nub, minimumBy)
+import Data.Ord as Ord (comparing)
import Data.Char (isAlpha)
import qualified Data.Map as M
import qualified Data.Set as S
hunk ./cairo/Gtk2HsSetup.hs 104
fixLibs :: [FilePath] -> [String] -> [String]
fixLibs dlls = concatMap $ \ lib ->
case filter (("lib" ++ lib) `isPrefixOf`) dlls of
- dll:_ -> [dropExtension dll]
- _ -> if lib == "z" then [] else [lib]
+ dlls@(_:_) -> [dropExtension (pickDll dlls)]
+ _ -> if lib == "z" then [] else [lib]
+ where
+ -- If there are several .dll files matching the one we're after then we
+ -- just have to guess. For example for recent Windows cairo builds we get
+ -- libcairo-2.dll libcairo-gobject-2.dll libcairo-script-interpreter-2.dll
+ -- Our heuristic is to pick the one with the shortest name.
+ -- Yes this is a hack but the proper solution is hard: we would need to
+ -- parse the .a file and see which .dll file(s) it needed to link to.
+ pickDll = minimumBy (Ord.comparing length)
-- The following code is a big copy-and-paste job from the sources of
-- Cabal 1.8 just to be able to fix a field in the package file. Yuck.
Context:
[Gergely Risko's patch to make tryEvent more useful
Daniel Wagner <dan...@wagner-home.com>**20120708094322
Ignore-this: 526940ab1b2222de547f24dce4d95db4
Previously, tryEvent would catch pattern-match failure exceptions and Do The
Right Thing. However, it didn't catch the exception thrown when calling
"guard". This patch lets it behave the same when guards fail as when patterns
are exhausted.
]
[forgot to bump the gtk package number -- which explains why the build fixes
didn't make it to Hackage
Daniel Wagner <dan...@wagner-home.com>**20120617214149
Ignore-this: bf0869569fbe3a78a3ac57317b78fcec
]
[add a small demo of DND code
Daniel Wagner <dan...@wagner-home.com>**20120611224157
Ignore-this: 7f6658e7f84c4ad5292b20042b7757b8
]
[change gdk_threads_enter import from unsafe to safe
Daniel Wagner <dan...@wagner-home.com>**20120602235822
Ignore-this: cae9259155505b623b1afe09f4df2143
Safe imports have two uses: when a function may call back into Haskell, it must
be marked safe; and when a function may block (or take a long time to compute),
it may be marked safe to avoid blocking all other Haskell threads from making
progress. The cost of marking a function safe is decreased (serial)
performance.
Since the typical use case for gdk_threads_enter is to grab a lock in
concurrent code, it is important to ensure that other Haskell threads can make
progress -- especially since one of them may be holding the lock.
]
[use forward-compatible Foreign.C.Types imports
Daniel Wagner <dan...@wagner-home.com>**20120528182742
Ignore-this: 6c4a618a653ddbaef4bd6974e7177d45
Previously, the hierarchy generator used #if in an attempt to choose between
two choices for an import line. The one choice gives warnings on old GHC's; the
other gives warnings on new GHC's. However, the symbol used in the #if isn't
defined by gtk2hs' custom build system, so one of the two choices was the
defacto code. Until this patch, the defacto code was the one that produced
warnings on new GHC's.
It should be possible to revise the build system to define this symbol, but it
is becoming less and less likely I will have the energy to work out how to do
this correctly. Instead this patch makes the choice to prefer the import that
compiles cleanly on new GHC's, and let old GHC's print warnings.
]
[remove TreeStoreStatic
Daniel Wagner <dan...@wagner-home.com>**20120527215117
Ignore-this: 87504218d1864b1239985ee7fb4e3495
This module hasn't been touched in over five years; doesn't build; and wasn't
mentioned in the cabal file anyway.
]
[rename the HCAR report per Janis' instructions
Daniel Wagner <dan...@wagner-home.com>**20120517225052
Ignore-this: f687965d8d6149ff6dfb95e0ae64f55d
]
[Fix a memory leak in customStoreNew (#1251)
Takano Akio <al...@hyper.cx>**20120423230920
Ignore-this: 3940fee6a1c17c2a5951a7d9f6a6573b
]
[some "darcs log name -> real world name" translations to remember
Daniel Wagner <dan...@wagner-home.com>**20120426165039
Ignore-this: db0b53c299aa90ffcad5f1ce4fa9a758
]
[record carefully what I'm supposed to do when it comes time to make a release
Daniel Wagner <dan...@wagner-home.com>**20120422231212
Ignore-this: 74beca0a3c44929e5db7d03681b7e3ed
]
[add a surface type for raw data, plus a demo program showing how to use this
with SDL (code supplied by Eli Frey)
Daniel Wagner <dan...@wagner-home.com>**20120422195206
Ignore-this: 254fd58bd2322a9fecb5449741d7a697
]
[Add entryGet/SetBuffer functions.
adstark1...@yahoo.com**20120420133554
Ignore-this: 5e083fd21fc5e63986fa0bae6a7d5442
]
[Bindings for gtk_menu_item_get_label, gtk_menu_item_get_use_underline, and the
associated setters.
adstark1...@yahoo.com**20120411140517
Ignore-this: cc9d70d06e02b6ae93fe8e39daf96ea7
]
[added pixbufNewFromData
blackredt...@gmail.com**20120320190411
Ignore-this: e3bd65acdcad39fbe22258e53ec4ed22
]
[Add a note on how to connect to bufferInsertText.
axel.si...@in.tum.de**20120313141311
Ignore-this: c9a6011fbae46b14c6c18d92de9e6732
]
[TAG 0.12.3.1
Daniel Wagner <dan...@wagner-home.com>**20120527221608
Ignore-this: fba81e067f20815572c143782547944e
]
Patch bundle hash:
eae8c3c94d2ce130ded566b39bbbb7dc2e0544b3
------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and
threat landscape has changed and how IT managers can respond. Discussions
will include endpoint security, mobile security and the latest in malware
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
Gtk2hs-devel mailing list
Gtk2hs-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/gtk2hs-devel