Re: [Vala] Platform-specific .vala code and 'make dist'



On Thu, Jun 30, 2011 at 11:30 AM, Andrea Bolognani <eof kiyuko org> wrote:
On Thu, Jun 30, 2011 at 11:21:41AM +0100, Sam Thursfield wrote:

Hi everyone
I've just run across an interesting and unexpected problem, which I'd
like to share in case anyone has considered it before or to warn any
future victims. In a nutshell:

1. 'make dist' generates a platform-independent tarball which can be
compiled on any platform
2. Vala should not be required to build from a tarball, so the
generated .c files are dist'ed
3. I have some platform-specific #if OS_BEOS, #if OS_WIN32 etc. code
in my vala source

My dist tarball is therefore inconsistent, because to compile on
platforms other than the one that did the 'make dist' I actually still
need valac to regenerate the C files.

Are there plans to drop 2) once Vala's plans for world domination come
closer to fruition? Or is platform-specific Vala code discouraged?

The way I’ve worked around this when I found myself in the same situation
was to segregate platform–specific code to a bunch of small C routines,
using G_OS_* macros to detect the compilation platform, and calling those
routines from Vala.

It’s not the best way in the world, but it certainly works OK if you have
just a little amount of platform–specific code. Which, since you’re
using Vala and by extension the portable GLib library, should be the case.

I guess this is why I've not heard anything about this problem before.
Sadly for me, my platform-specific code is between D-Bus and the
Windows RPC system, and I'm sure you know how much simpler Vala makes
writing dbus code :)

Sam



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]