Some experiments to improve wagic on linux

If you have a question about the git repository and the code, or if you have code to propose then please post in this forum.
Do not post request here.
Post Reply
Zoby
Posts: 2
Joined: Sat Nov 12, 2011 8:27 am

Some experiments to improve wagic on linux

Post by Zoby » Sat Nov 12, 2011 12:34 pm

Hi there,

I've downloaded and experimented with the code some time ago and found some possible improvements for the project on linux. I've done the most of it to a private version of the code. Since I'm using git, the code base I used may be to old. I also restructured the project and removed some code. You would have a hard time to copy&paste my code or apply patches. So I will list them and give a link to my changes if possible:

- It would be really nice if someone would remove fmod3.75 from the includes (maybe with a preprocessor directive) when building on desktops (at least when building on 64 bit architectures). That's because there is no 64 bit version of fmod prior to version 4.xx and it will build fine without it.

- It would also be fine if there is a possibility to use code that is already delivered by the platform instead of the code that comes with the project (like tinyXML, SDL, Freetype, zlib, libpng). Imagine there is a 32bit and a 64bit version of third-party code and you include just the 32bit one. It's hard to get the code compiling on 64bit withous messing with the code. There is a neat way to do this with cmake build scripts, what leads me to my next point.

- Can someone please include cmake scripts? They can search for dependencies, produce platform-specific makefiles and build the project just fine (at least on linux machines). At the time of writing this, I can build it by the following commands (on a fresh debian-testing installation - there is no difference between 32 and 64 bit):

Code: Select all

#install the cmake build system, git, ssh, make and compilers
$ aptitude install cmake git ssh make gcc g++
#get the source (you cannot access it without my passphrase, see below)
$ git clone ssh://loto@login.tu-chemnitz.de/~/PUBLIC/repos/wagic.git
$ mkdir wagic/build
$ cd wagic/build
#install missing dependencies 
$ aptitude install libboost-all-dev libx11-dev qt-sdk libreetype6-dev libz-dev libpng-dev  libjpeg-dev libgif-dev libtinyxml-dev xdg-basedir-dev
#generate makefiles (this will tell me missing dependencies, it also asks me for the build-type, installation dirs of files,...)
$ cmake -i ..
#finally build it
$ make
#install it (if build-type is release)
$ make install
As you will notice, there is currently no mechanism to exclude linux-only stuff on windows-machines (like xdg-basedir) nor to choose between the pure SDL, the Qt and the other versions (it uses Qt atm) nor to add menu items or man pages. But that is easy to add.
It is also not possible to download the source like I did, because It used the private university's storage and not a public project hoster to be on the safe side (see the last point far below). To speedup compilation time, ccache is a good option.

So, cmake is probably a bit more complex, but way more flexible than pure handwritten makefiles.

It also supports installation so you can easily make deb-packages for debian. And: It can generate a configure header at compile time that can be included to deliver preprocessor constants (like LINUX, WIN32, ARCH, USERPATH, DATAPATH, and so on) to the source code.

- Also, it would be really neat if you can use xdg-basedir to set the user-directory to ~/.local/share/wagic. This will improve backupping and installation a lot and removes the data-stuff from the installation-folder which is needed to fit the debian-file-system-convention-stuff. (You probably wouldn't get permission to get wagic into a debian repository otherwise).
Basicly you add in jge/JFileSystem.cpp an JFileSystem::JFileSyste(...) below the Adroid pecific code:

Code: Select all

...
#elif defined LINUX
    userPath =  string(xdgDataHome(0)) + string("/wagic/");
#else
...
And include with:

Code: Select all

...
#ifdef LINUX
#include <basedir.h>

#endif
...
Note: This code assumes that there is a LINUX preprocessor constat defined.

- To come back to whats in the repo: I'm not sure about boost being in the repository. Shouldn't there be a nice way for every platform to install it? Generally removing some third party stuff from the project will reduce the space needed, shorten the time searching for specific stuff and checking the repository out, avoid licensing confusion and so on.

- A personal taste: I like to use git instead of svn, because it is somewhat faster and supports rapid branching. There are a lot of parallel developments and big changes from one day to the next in the code, so it's hard to keep own changes up to date before committing. But svn is of course fine too.

- More of a coding habit: Please do not use include-directives with relative paths that travel upwards, like:

Code: Select all

#include "../../src/jge/<whatever"
It's cooler to just include that pathes to the compiler-invocation and include with:

Code: Select all

#include "jge/<whatever>"
//or
#include "<whatever>"
Thats because it seems that jge is a sdk/engine and is going to get moved into a seperate project. So mtg should not rely on jge being in at specific place.

- I also implemented some sort of a desktop-version of the deck-editor. It is a bit ugly but displays 12 cards in a grid to speed up deck-construction on big screens and with mouse-support. In my version, I've accidentally overwritten the psp deck-editor.

- It would also be nice if someone could add a doxyfile so every developer can easily generate a source code documentation.


Please don't shout at me if some points are already implemented or are just foolish. Like I said, I used a snapshot of the code to test some ideas of mine quite some time ago.

A last point: Is it OK if I upload the whole project with my changes to gitorious so you can just look at changes in the code, or would that mess anything up (license stuff)?


Best regards,

Zoby



PS: Keep up the good work and thanks for hundred of hours mgt fun on nearly all machines I have :D.

wololo
Site Admin
Posts: 3727
Joined: Wed Oct 15, 2008 12:42 am
Location: Japan

Re: Some experiments to improve wagic on linux

Post by wololo » Sun Nov 13, 2011 12:05 pm

Hello and many thanks for the detailed suggestions.

Depending on your own motivation, would it make sense if I gave you svn access to start submitting some of those improvements? Most of the effort for linux was made by one person back in 2008, and that guy hasn't been actively involved in the project since then. We kind of maintain it as much as we can, but since none of the active devs is actually playing Wagic on linux (as far as I know), there's a lack of motivation on our side...

Wagic's license is BSD, so it is ok for you to submit your code to gitorious (however do not submit images/sounds/anything from the Res folder there, as they are using different licenses). My only worry would be that it "splits" the efforts if for some reason other people start using that repository to work on some kind of "fork". Again, may I convince you to submit some of your changes directly to our svn?

About including Boost/png/etc... directly in our codebase... this is a choice I made very early when creating the project. I assumed most of the people helping on the project would not be professional programmers, and would like something working out of the box. This is currently what's happening on Wagic, you get the contents of the repository, you build, and it works (at least, for the platforms I can personally test, which are windows, PSP, and Android). The drawback is that people can't easily use the latest version of these libs, and as you said, it adds some maintenance burden for us. If there was a way for us to update the documentation so that it's "doable" for people to retrieve all the necessary libs for all platforms... that would be quite some effort though (libpng for example on Android is a build that we tweaked quite a lot, as far as I remember)

Overall I'm not very good at packaging/makefiles/libs, and it shows in the entire project. If some people are motivated to work on those tasks to improve the code base, I'm more than happy to give them svn access :)

Djardin
Posts: 129
Joined: Sat Sep 04, 2010 11:40 am

Re: Some experiments to improve wagic on linux

Post by Djardin » Sun Nov 13, 2011 7:27 pm

- Wololo seems to forget that I'm fully developing on Linux... I only use my Windows box to verify that I didn't break too much the M$ project
- I do that not using those old-fashion makefiles but directly using .pro (wagic-qt.pro). I don't often commit this file. But I've got versions working for Windows, Linux desktop, Maemo, Meego, Symbian and Android. I refreshed the last one with the latest Necessitas release. I can commit some update if you want.
- The Qt project only uses fmod on Windows, on all the other platforms, it uses phonon
- The Qt project does not use any of the third-party libs from the Wagic tree. The main reasons are that they are either useless or pointless when Qt is present. Boost usage is limited to header files mostly because it causes some serious trouble on Symbian
- Regarding CMake, I don't really care as long as I don't have to maintain it =)
- About Debian packages, maybe you could reuse some of the packaging job I did for Harmattan and Maemo which are both Debian based...
- About xdg-basedir, I think we need to be carefull cause LINUX is defined on Linux desktop, maemo, meego, Android ... It might even be defined on iOS
- About doxyfile ... I'm not sure what you expect with that. I rarely saw code as complex and as poorly documented than the Wagic code =)

wololo
Site Admin
Posts: 3727
Joined: Wed Oct 15, 2008 12:42 am
Location: Japan

Re: Some experiments to improve wagic on linux

Post by wololo » Sun Nov 13, 2011 11:30 pm

Djardin wrote:I rarely saw code as complex and as poorly documented than the Wagic code =)
You should have a look at mtgforge source code then :)

Zoby
Posts: 2
Joined: Sat Nov 12, 2011 8:27 am

Re: Some experiments to improve wagic on linux

Post by Zoby » Mon Nov 14, 2011 11:05 am

Thank you very much for offering me write access to the repository but I don't think that I have that much to contribute.

I totally agree with you, that if qmake is working as statet, there is really no need to use cmake.

Regarding xdg-basedir, maybe there is a better preprocessor constant defined somewhere.

Post Reply