GNOME Bugzilla – Bug 731322
Output incorrect header file name when generate internal vapi
Last modified: 2018-01-19 07:15:24 UTC
Incorrect header file name is output in 'CCode' section of vapi file which was generated by valac with options: '-H' , '-h' and '--internal-vapi'. STEPS TO REPRODUCE ------------------- 1) Create the following source code file: -- test.vala -- private class Foo1 { } private class N1.Foo2 { } private class N1.N2.Foo3 { } ---- 2) Compile the code by valac with following options: valac -H foo.h -h internal-foo.h --internal-vapi=foo.vapi -c test.vala ACTUAL RESULTS --------------- The internal vapi file 'foo.vapi' is generated, but 'CCode' section's file names in the file are incorrect. The C header file name of the class N1.N2.Foo3 is "internal-internal-internal-foo.h", and the class N1.Foo2 is "internal-internal-foo.h". Only the class Foo1's C header file name is correct; "internal-foo.h" ADDITIONAL INFORMATION ----------------------- I think that valac replace recursively the internal header file name by (public) header file name. The recursive count seem to depend on namespace depth. And this replacement process would be cause of this problem. I tryed the following command which was changed the parameter of internal-header from "internal-foo.h" to "internal-bar.h" which was not contain the (public) header name keyword "foo.h". valac -H foo.h -h internal-bar.h --internal-vapi=foo.vapi -c test.vala In the result that internal header file names in the vapi file are correct. I tryed valac versions 0.22.1 and 0.24.0, these were same result.
This might have something to do with the header arguments having paths or not as well. I was trying to wrangle meson into generating internal VAPI, and it was generating arguments for --header/-H like "path/to/lib.h". For the internal VAPI I was manually adding the argument "--internal-header=path/to/lib-internal.h" to match, but the internal VAPI was still generated referencing the public header, not the internal one. To make it work I had to override meson's argument for the public header so both argument's values were path-free, eg: "--header=lib.h --internal-header=lib-internal.h", then copy the headers back to the expected location. This caused the internal VAPI to correctly reference the internal header.
Created attachment 367048 [details] [review] codewriter: Don't use string.replace() to apply header_to_override The underlying regex causes faulty replacements.
Attachment 367048 [details] pushed as 5a7300d - codewriter: Don't use string.replace() to apply header_to_override