After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 731322 - Output incorrect header file name when generate internal vapi
Output incorrect header file name when generate internal vapi
Status: RESOLVED FIXED
Product: vala
Classification: Core
Component: general
0.35.x
Other All
: High normal
: 1.0
Assigned To: Vala maintainers
Vala maintainers
Depends on:
Blocks:
 
 
Reported: 2014-06-06 09:18 UTC by Yusuke Ishida
Modified: 2018-01-19 07:15 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
codewriter: Don't use string.replace() to apply header_to_override (1.08 KB, patch)
2018-01-18 22:14 UTC, Rico Tzschichholz
committed Details | Review

Description Yusuke Ishida 2014-06-06 09:18:33 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.
Comment 1 Michael Gratton 2017-12-15 03:26:24 UTC
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.
Comment 2 Rico Tzschichholz 2018-01-18 22:14:03 UTC
Created attachment 367048 [details] [review]
codewriter: Don't use string.replace() to apply header_to_override

The underlying regex causes faulty replacements.
Comment 3 Rico Tzschichholz 2018-01-19 07:15:18 UTC
Attachment 367048 [details] pushed as 5a7300d - codewriter: Don't use string.replace() to apply header_to_override