RFR: 7903731: Jextract should support macOS frameworks [v6]

Jorn Vernee jvernee at openjdk.org
Wed Mar 5 16:26:27 UTC 2025


On Wed, 5 Mar 2025 15:57:41 GMT, Nizar Benalla <nbenalla at openjdk.org> wrote:

>> Read the JBS issue for more detail.
>> 
>> This patch adds two new mac specific options, to make it easier to use frameworks and remove the need of a `compile_flags.txt` file. An exception is thrown if those options are used from an other platform, the error message is inspired from `jpackage`
>
> Nizar Benalla has updated the pull request incrementally with one additional commit since the last revision:
> 
>   -search custom framework dirs
>   -rename options

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

> 364:         parser.accepts("--version", "help.version", false);
> 365:         parser.accepts("-framework", "help.mac.framework", true);
> 366:         parser.accepts("-F", "help.framework.library.path", true);

I think these should be the other way around. `-F` specifies the search path, and `-framework` accepts the name of the framework you want to link against (e.g. `-framework OpenGL`).

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

> 394:                 Files.lines(compileFlagsTxt).forEach(opt -> {
> 395:                     builder.addClangArg(opt);
> 396:                     frameworkDirs.add(opt.substring(2).trim());

Compile flags can also contain other flags, so we have to explicitly look for `-F` options here for this to work.

But, I'd also be okay just ignoring the `-F` flags in `compile_flags`. We can tell people to use the builtin `-F`.

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

> 457:             optionSet.valuesOf("-framework").forEach(
> 458:                     p -> {
> 459:                         builder.addClangArg("-F" + p);

See the mismatch here. Both should be `-F`.

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

> 621: 
> 622:         String publicPath = String.format("/System/Library/Frameworks/%1$s.framework/", optionString);
> 623:         String privatePath = String.format("/System/Library/PrivateFrameworks/%1$s.framework/", optionString);

Also, shouldn't this default just use the result of `inferMacOSFrameworkPath`?

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

PR Review Comment: https://git.openjdk.org/jextract/pull/268#discussion_r1981746423
PR Review Comment: https://git.openjdk.org/jextract/pull/268#discussion_r1981753440
PR Review Comment: https://git.openjdk.org/jextract/pull/268#discussion_r1981755874
PR Review Comment: https://git.openjdk.org/jextract/pull/268#discussion_r1981750743


More information about the jextract-dev mailing list