On Mon, Apr 28, 2014 at 8:52 PM, Al Thomas <[email protected]> wrote:

> I've just got this error that made me wonder about valac's hidden
> capabilities:
>
> error: test.g is not a supported source file type. Only .vala, .vapi, .gs,
> and .c files are supported.
>
> I assume a .c file is passed straight through to the C compiler along with
> the generated C files from .vala and .gs files. Is this a recommended way
> of creating a combined C with Vala/Genie project?
>
>
First create vala/gs -> C files, then also specify other C files, and
finally compile all C files with gcc. Autotools does all that for you.


> I note XFCE decided to combine C with Vala. From a couple of blog post
> [1][2] it looks as though they use automake to create C files from Vala and
> then distribute and compile those files for the whole project. The argument
> being different versions of valac can produce different C files so it is
> more stable for a distributed version to build from the generated C files.
>

It's true that it's more stable to compile directly the C files, but #if
conditions in vala won't get evaluated then. That is, once you have
compiled vala down to C, the #if conditions *in vala* can't be re-evaluated
anymore. That's a huge tradeoff you should care about.
I don't suggest to compile directly the distributed C files, rather compile
Vala. You can conditionate your code to run, e.g., with vala 0.22, 0.24...
to fix incompatibilities.


>
> I also found the Parallel Builds [3] page. This is an interesting approach
> with, as I understand it, an intermediate object file for each vala file.
> These could be linked with object files from C or C++.
>

No the intermediate file is a special vapi file, those are not object files
understood by gcc.


>
> Then there is the --compile option of valac to produce object files.
>

Use valac only to generate C, not as a build tool.


>
> So at the moment I'm thinking for large, mixed language projects, it is
> better to create object files and link outside of valac.
>
> I am writing some documentation for Genie and was about to finish the
> attached diagram with arrows when I stumbled upon valac accepting .c files.
> At present I'm thinking this feature isn't too useful and it is better to
> create object files and link using another tool. This is also useful for
> GIR and using Vala/Genie binaries in Python, node.js, PHP, etc. So it is
> probably better for documentation to introduce the more general process.
>

Drop the idea to create a large project by using valac as build tool. Use
autotools. There's plenty of projecs out there to look at, first of all the
sample vala project: https://github.com/tadeboro/Sampala
_______________________________________________
vala-list mailing list
[email protected]
https://mail.gnome.org/mailman/listinfo/vala-list

Reply via email to