RFR: 7903755: multi header support and special syntax for header file

Maurizio Cimadamore mcimadamore at openjdk.org
Wed Jun 19 16:00:38 UTC 2024


On Wed, 19 Jun 2024 10:01:08 GMT, Athijegannathan Sundararajan <sundar at openjdk.org> wrote:

> jextract currently supports only one header file. If the user wants to extract more than one header file, s/he has to create a containing header that includes multiple headers and jextract the containing header.
> 
> With the current change, jextract supports more than one header file in the command line.
> When multiple headers are specified in command line, --header-class-name option is mandatory and it is enforced.
> 
> In addition to normal file names for header file names, a special syntax such as "<stdio.h>" is also supported. With this, user does not have to write long file name including directories such as /usr/include/stdio.h.
> 
> jextract generates multiple headers by generating a temporary header file. If the command line argument is of the form "<stdio.h>" then jextract generates "#include <stdio.h>" in the auto-generated containing header. If the header specified in of the normal/existing form (say foo.h), then containing header will have #include "foo.h" line.

Samples are much better - all the scripts are easier to understand.
I think we need to update the guide - as some of the command line option have changed:
* e.g. we now accept multiple headers
* headers can be provided with two different syntax (e.g. plain and "<>")
* if there's multiple headers, then the header class name option *must* be used

doc/GUIDE.md line 989:

> 987: | `--version`                                                  | print version information and exit |
> 988: 
> 989: jextract accepts one or more header files. When multiple header files are specified,

Suggestion:

Jextract accepts one or more header files. When multiple header files are specified,

doc/GUIDE.md line 990:

> 988: 
> 989: jextract accepts one or more header files. When multiple header files are specified,
> 990: --header-class-name option is mandatory. Header files can be specified in two different ways.

Suggestion:

the `--header-class-name` option is mandatory. Header files can be specified in two different ways:

doc/GUIDE.md line 992:

> 990: --header-class-name option is mandatory. Header files can be specified in two different ways.
> 991: 
> 992:    1. simple header file name like "foo.h" or header file path like "bar/foo.h"

Suggestion:

   1. Simple header file name like "foo.h" or header file path like "bar/foo.h"

src/main/java/org/openjdk/jextract/JextractTool.java line 89:

> 87:     }
> 88: 
> 89:     private static Path generateTmpSource(List<String> headers) {

This creates a temp file. It would be good to avoid this and maybe use clang APIs to parse in-memory files?

-------------

PR Review: https://git.openjdk.org/jextract/pull/249#pullrequestreview-2127796808
PR Review Comment: https://git.openjdk.org/jextract/pull/249#discussion_r1646454470
PR Review Comment: https://git.openjdk.org/jextract/pull/249#discussion_r1646454942
PR Review Comment: https://git.openjdk.org/jextract/pull/249#discussion_r1646455393
PR Review Comment: https://git.openjdk.org/jextract/pull/249#discussion_r1645871770


More information about the jextract-dev mailing list