-
Notifications
You must be signed in to change notification settings - Fork 11
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Package SFML as a self contained dependency #8
Comments
Sure. I suppose the description in the .cabal file should be changed then. |
Brill! A. |
Wait, for some reason I misread your initial post. I thought you wanted to merge SFML and SFML-Control into one big package, which is why I said the description in the .cabal file should then be changed, so as to explain what's going on. As far as my understanding goes, shipping SFML + CSFML is not an option. The reason is that CSFML is not C, it's just unmangled C++, and cabal cannot deal with C++ files, at least the last time I checked. |
I suppose we could get around with some Setup.hs hacking, compiling SFML and CSFML and then the bindings themselves. However, that would still require the user to previously install cmake, since it is needed to build SFML. I suppose it's doable, but do you think it's worth the hassle? |
Hi :) As regards the topic itself I'm just looking forward to the adoption of these bindings. Every application willing to use Haskell and SFML for game dev would need sooner or later to package the game as a standalone app, via static linking, and I'm not sure that our current setup will allow it (but I'm ignorant on the topic). |
Well, I have been modifying the .cabal file and added a Setup.hs to compile SFML and CSFML. Since static linking with CSFML is a no-go, I am faced with two problems:
Let's see if I find a way to get around these problems. |
I still have to wrap my head around these problem, but as soon as I do I'll try to help with the troubleshooting. I hear you though, dealing with this stuff is always tricky :) |
The problem is that, no matter what you do, the user will ultimately have to copy the shared libs / dlls somewhere in their PATH. I can't do this from the build script because I don't know where to copy to. Plus, even though cabal creates its own .cabal directory, a vanilla installation of cabal / haskell platform does not set up any paths other than those for ghc and mingw on windows, which in any case would require root to touch. I have come up with a mixed solution that would offer several ways to build the library:
What do you think ? Edit: of course, if we do it this way all those steps would be documented in the installation manual. |
Hi Marc. |
Hmm, how exactly do I check the version of an existing SFML installation ? |
that's a very good question. Some possibilities on top of my mind: a) We ask on the SFML forum for hints (parse the headers perhaps?) |
Success! I have managed to statically link with SFML and CSFML on Linux. I had to edit some include files because cmake was creating libraries with mangled names. All the demos are working flawlessly, and the user's .cabal file need not worry about anything because SFML's .cabal file does everything for you. The only problem now is that one has to run "cabal copy" to get SFML/CSFML static libs copied over to cabal's installation directory. If I can find a way to hook the build process to do this automatically, then it'll be pretty much done. |
Great job! Can I help with the Mac OS X side of things? |
Yeah, I can do linux and windows. I still have to figure out how to avoid the copy hook. I'll push the changes when I get everything working under linux. |
fantastic, really happy of the outcome :) |
I have written a build hook that takes the C++ libs and the haskell lib, unpacks everything and repacks all the objects into one master static lib that overwrites the haskell static lib. Now, applications only have to link with the haskell SFML static lib, there are no C++ static libs lying around, and SFML code should work in ghci since everything is cointained inside the haskell lib. Plus, running 'cabal install' is now enough, no need to call "cabal copy" or anything like that. Still have to fix some rough edges. I'll let you know when I'm done. |
It sounds marvellous, looking forward to seeing the final code :) |
Ok, got everything working under Linux. My opinion is that HSSFML should allow two installation scenarios: a) [default] The user runs 'cabal install'. HSSFML assumes that SFML is already installed in the system, like it does now. b) The user passes a custom flag to 'cabal install'. This builds both HSSFML and the version of SFML that we ship with it. The reason I wouldn't make b) the default is that it requires a c++ compiler and standard library, cmake, and all of SFML's dependencies: pthread, GL, GLU, GLEW, X11, Xrandr, Xi, openal, jpeg, freetype, and sndfile. Also, I still have to think of a way to check version compatibility in case a). What do you think? |
Hi Marc, What you reckon? |
Ugh, right, you need those libraries anyway. Also, SFML's cmake does not install its own dependencies, you're expected to have them available. I'll make b) the default and a) optional then. Let me test the build script on Windows and I'll push the changes. Edit: some linux distributions (ubuntu) keep runtime libraries and header files in separate packages. For option b) you would also have to install the development packages (abc-dev), but I suppose it's still a non-issue. |
It's a pretty standardised thing in linux to install the dev versions, yes :) |
What do you think about shipping pre-compiled libraries for windows? I'm finding that compiling SFML here is a bloody mess, especially if you have cygwin binaries and other stuff in your path. Additionally, SFML ships with pre-compiled DLLs for its dependencies, and those must be copied to the path, so just providing everything pre-compiled seems like a reasonable choice. |
I would say; why we don't go further and we ship pre-compiled SFML for Mac OS X too? Probably we can't do that for Linux because distros might be slightly different (do they?) but when I think about "self-contained" I think "pre-compiled" :) EDIT: Sorry, I think I misunderstood you. You meant pre-compiled HSSFML don't you? |
I meant pre-compiled SFML. How should we ship all of the dependencies then? They amount to a couple 50-60 MB. |
very good point, let's think about that :) |
I just got this working on windows using precompiled DLLs for SFML and CSFML. The only issues at the moment are:
|
This makes me wonder we should split things up, perhaps having an hierarchy of packages on hackage like:
and then use the appropriate package dependencies using ghc conditional flags, (ala c preprocessor directives) to Example pseudocode: build-depends: do you think it's feasible ? |
The problem is that depending on a particular package like sfml-win32 will only get it cabal installed, and the user must still run cabal copy. Also, having so many packages on hackage looks a bit messy. I think that what we can do is a copy hook that wget's the DLLs from some online mirror. The copy hook would only download those libs matching your system. To deal with windows, we could ship a little wget.exe with HSSFML. What do you think? |
uhm, this I think depends on different school of thoughts. From my experience, trying to have a core package with a series of backend packages is a very common practice, even in the Haskell world. To my knowledge, is very rare to fetch things from internet, also because wget is not standard (so is curl) on every system, and this will just complicate things further. |
Fine by me. I just find it weird to have hackage packages devoted to storing DLLs, but if that's something conventional and they have no problems with hosting those kinds of packages then it is indeed the easiest solution. The question, now, is: should we still compile SFML/CSFML from source on Linux? SFML/CSFML are available as precompiled shared libs for linux too. And if so, should we still have a flag to be able to decide whether to compile them or to link with the system (or hackage) libraries? |
Yes, my preference would be to ship with each platform-specific package the precompiled libs, so that we are resiliant to api changes and everything is self contained. |
Ok. I'll get my hands on it and let you know when I'm done. |
Great, once you lay out a common pattern I can help with mac os x. |
I've been working on this and I think I may have something doable for Linux. Only problem is that the CSFML 2.3 precompiled libs are for some reason linked to SFML 2.2 instead of 2.3. Trying to clarify what's going on with SFML devs. |
I've noticed the same issue. Doing an
|
It would be extremely cool, in the same vein of packages like hipmunk, to ship the complete self contained SFML + CSFML with this bindings, allowing end user to not bother with external dependencies.
Do you think it would be feasible?
The text was updated successfully, but these errors were encountered: