clean valac error for "using XYZ" when xyz-dev package is not installed
Submitted by Martin Olsson
Link to original bug (#591991)
Description
When a certain package is not installed Vala generates C code which is not compilable. For newbies these errors will be non-intuitive and they force people to deal with the "implementation detail" that is C.
Besides a pony, I also wish for a feature in Vala that detects un-installed libraries and prints a nice newbie friendly error message.
To repro the issue, make sure that "libgoocanvas3" is not installed on your machine. and then compile this Vala code:
using Goo; int main(string[] args) { var x = new Goo.Canvas(); return 0; }
You'll see something like:
$ valac --pkg goocanvas --pkg gtk+-2.0 main.vala main.vala:5.6-5.25: warning: local variable `x' declared but never used var x = new Goo.Canvas(); ^^^^^^^^^^^^^^^^^^^^ /some/path/main.vala.c:4:23: error: goocanvas.h: No such file or directory /some/path/main.vala.c: In function ‘_main’: /some/path/main.vala.c:17: error: ‘GooCanvas’ undeclared (first use in this function) /some/path/main.vala.c:17: error: (Each undeclared identifier is reported only once /some/path/main.vala.c:17: error: for each function it appears in.) /some/path/main.vala.c:17: error: ‘x’ undeclared (first use in this function) /some/path/main.vala.c:18: error: expected expression before ‘)’ token error: cc exited with status 256 Compilation failed: 1 error(s), 1 warning(s)
The change I would like to request is that valac stops compilation right at "using Goo" (whenever the vapi is available but the .pc file is not installed or something along those lines) and then just print "error: Development files for library 'Goo' is not installed."
The Vala program should see a Vala equivalent to "error: goocanvas.h: No such file or directory" instead of making it through Vala compilation and being left with some obscure C compiler error instead.
Version: 0.7.x