I have had a go at doing the two .cabal files trick and it seems
to work.  I have pushed the results here...

  http://patch-tag.com/r/hamish/gtk2hs

You will probably need to "darcs rollback" or "darcs obliterate"
the two gtk3 patches you added to the main repo before it will work.

I think obliterate might be better, although people will have to
pull do the same (or do a clean get).  It should make the history
cleaner.

The repo has three gtk.cabal files

  gtk.cabal-0 = Version 0.X and defaults to -f-gtk3
  gtk.cabal-3 = Version 3.X and defaults to -fgtk3
  gtk.cabal   = Just a copy of gtk.cabal-3

I added a package.sh file that you can run like this...
  ./package.sh
or
  sh -ex package.sh

It installs source packages locally with cabal-src, then builds them
to make sure they work.

I think the current gtk (0.12.4) in hackage is broken
 * Gtk2 fails because Region is imported from Cairo and clashes
 * Gtk3 fails because heirachy3.list is not included

I have included fixes for both of these issues.

Packages that can be built with gtk2 or gtk3 should
can include something like this in build-depends...

  gtk (>=0.12.4.1 && <0.13) || (>=3.12.4.1 && <3.13)

Then when building you can choose the gtk version with 
 cabal install --constraint='gtk<3'
or
 cabal install --constraint='gtk>=3'

To call a different function when using Gtk3 use CPP
like this...

  #if MIN_VERSION_gtk(3,0,0)

On 26 May 2013, at 04:36, Daniel Wagner <wagne...@seas.upenn.edu> wrote:

> On 2013-05-25 11:54, Hamish Mackenzie wrote:
>> pkg-config treats gtk3 as a whole new package, so it might make sense
>> for gtk2hs to do the same.  But I think we could consider using the
>> major version.  We could call the new one gtk-3.12.x. Cabal should
>> let you install both gtk-0.12 and gtk-3.12 at the same time.
> 
> Sure, I have no strong feelings about using version number vs. package 
> name.
> 
>> Am I right in thinking you are building a nice clean Gtk3 source tree
>> that has no 2.X specific code and #ifdefs (and a Gtk2 one without the
>> Gtk3 code)?
> 
> Right, that's the idea.
> 
>> If you are worried about duplicating all the code then another option
>> would be to stick with the status quo and release two packages
>> to Hackage with exactly the same code but different .cabal files.
> 
> Well, this is a very cool idea. I like it a lot.
> 
>> The only difference between these would be how the -fgtk3 flag worked.
>> We could remove it and hard code the behaviour in the .cabal files.
>> 
>>  gtk.cabal with version 0.12.x - would work like -f-gtk3
>>  gtk.cabal with version 3.12.x - would work like -fgtk3
>> 
>> I don't have any strong feelings either way. I suspect a clean Gtk3
>> source tree will make adding more Gtk3 support easier and #ifdefs
>> would make keeping Gtk2 code up to date easier.
>> 
>> For gtksourceview and webkit I think multple .cabal files with shared
>> code using #ifdefs might be best as there is a lot less Gtk3 specific
>> code in those repos.
> 
> Right, that seems reasonable.
> ~d
> 
> ------------------------------------------------------------------------------
> Try New Relic Now & We'll Send You this Cool Shirt
> New Relic is the only SaaS-based application performance monitoring service 
> that delivers powerful full stack analytics. Optimize and monitor your
> browser, app, & servers with just a few lines of code. Try New Relic
> and get this awesome Nerd Life shirt! http://p.sf.net/sfu/newrelic_d2d_may
> _______________________________________________
> Gtk2hs-devel mailing list
> Gtk2hs-devel@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/gtk2hs-devel


------------------------------------------------------------------------------
This SF.net email is sponsored by Windows:

Build for Windows Store.

http://p.sf.net/sfu/windows-dev2dev
_______________________________________________
Gtk2hs-devel mailing list
Gtk2hs-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/gtk2hs-devel

Reply via email to