Hi Simon,
On Sat, Jun 2, 2012 at 9:00 AM, Simon Werbeck
Listing an unused file as an input (or order-only input) is fine - the
only downside to over-specifying inputs is that it could limit
parallelism. The inputs you specify in the Tupfile aren't used for
determining when to rebuild, they are only used for ordering. So if I
understand your script correctly, all it would mean is that all .vapi
files are created before valac runs, even if there is technically a
valac that could run simultaneously with an unreleated vapi
generation.
The actual dependencies that determine when to rebuild are determined
by the file accesses of the process. The reason you see everything
rebuilding when an "unused" vapi file is regenerated is because valac
is actually reading from every vapi file. I suspect this is because
your script is specifying every .vapi file in the --use-fast-vapi
flag.
>
>> If the vala compiler is reading from every vapi file, presumably you
>> *want* to re-run the vala compiler every time any vapi file changes?
>> If not, why is the compiler reading from it if it has no effect on the
>> output?
> The purpose of fast-vapi files from what I can tell is, that they're
> `faster' parsable than .vala files, as they only contain interface
> definitions `local' to that single file. But since they contain no
> #include directives you have to pass every single one of them to every
> compilation command that might need it and the compiler then picks out
> the definitions it needs. That is also the recommended way according to
> this post (in combination with make dependenies, see below)
>
http://web.archiveorange.com/archive/v/vLjdSKbOYpjdV2gTRldx
Hmm, it seems tup is a little at odds with vala here, since it isn't
going to use their generated deps file. Tup makes the determination of
when to rebuild solely based on the files accessed by valac, which you
list explicitly with the --use-fast-vapi flag.
>
> valac has a --deps flag to output Makefile dependency information. I
> tried parsing them to generate the build rules. But they are only
> generated after compilation i.e. you can't generate them in a seperate
> step. As a result I ran into a cyclic dependency problem, so this is no
> option as well.
>
> Wheew, I hope some of that makes sense. In conclusion I think the
> options I have are:
> 1. For each vala file, maintain a handwritten deps file, parse it to
> generate build rules (kind of like #include rules in .c files)
> 2. Use valac's --deps flag, run a seperate script to generate build
> rules from that, modify by hand on changes in the source file
> 3. The afore mentioned `weak' order-only dependencies. They determine
> only order of execution but don't force a rebuild.
> 4. Recompile everything everytime (right now the easiest way)
>
> I think none of the options is optimal, so I'm thankful for any
> suggestion.
If I understand what you mean by "weak" dependencies, *every* input
link is "weak" in tup (internally, these are called sticky links). Tup
will upgrade a sticky link to a normal link if the sub-process
actually reads from the file. Note that a regular input vs. order-only
input doesn't matter here - the only difference between those is that
regular inputs show up in %-flags (like %f), but order-only inputs do
not.
So, I think you could leave the script to list every vapi file as an
input without much concern (maybe it would get slow if you have lots
and lots of vala files in a single directory). The focus should
probably be on finding a way to only list the --use-fast-vapi flags
that are actually necessary, so that valac will only read from those
files. This might need to be something like option 1) - which as you
said would be similar to writing #includes. Though instead of going in
the vala file, maybe they would just go in the Tupfile:
# includes for foo.vala
VALAFLAGS_foo.vala += --use-fast-vapi=bar.vapi
# includes for bar.vala
VALAFLAGS_bar.vala += --use-fast-vapi=baz.vapi
VALAFLAGS_bar.vala += --use-fast-vapi=baz2.vapi
: foreach *.vala | *.vapi |> valac %f $(VALAFLAGS_%f) ... |> ...
You could put those VALAFLAGS definitions in their own files (like
foo.inc, bar.inc, or whatever you want to call it) if you don't want
them all in a single file. I don't really know how this will play out
in practice. Please post back if you get a nice working set of
rules/scripts that work with vala (I'm sure this would help others),
or if you get stuck again maybe there are other things we can try.
Thanks,
-Mike