Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add the native stdlib and platform libraries from K/N distribution #3145

Closed
wants to merge 1 commit into from

Conversation

vmishenev
Copy link
Contributor

@vmishenev vmishenev commented Aug 27, 2023

This current hack is temporary under the property org.jetbrains.dokka.classpath.excludePlatformDependencyFiles=true.
Some stable API is needed from KGP.

Dokka reuses a compiler frontend. From this point of view, Dokka needs the same classpath as the compiler. Dokka extracts the classpath from Compilations in KGP plugin.

KGP's pipeline: Compilation --> KotlinTool (Compile task) --> run a compiler process with CLI arguments.
For classpath, KGP transforms KotlinTool.libraries (or compilation.compileDependencyFiles) to -library CLI argument. (see, e.g. for Native - here). The compiler arguments can be printed if --info flag is used in Gradle.

Dokka already uses KotlinTool.libraries that KGP passes to the compiler. But the Kotlin/Native compiler (aka Konan) knows about some platform dependencies (e.g. native stdlib, platform libraries: posix, iconv, gles...) , but Dokka does not.
They are a part of the Native compiler distribution, see this readme and ~/.konan/klib, and KotlinTool.libraries does not contain them. By the way, e.g. a platform library of Apple SDK is unavaible on non-apple computers.

In order to get it, Dokka uses platformDependencies in Gradle Runner. (TBH, I haven't researched what else in platformDependencies)

For KGP 1.9.0 platformDependencies starts leading to issues (e.g., implicit dependencies).

The hack comes from the setupKotlinNativePlatformDependencies function.

Here it adds these dependencies only into Dokka's platformDependencies (aka implementationMetadataConfigurationName configuration) and metadata compilation.

@vmishenev vmishenev changed the title Add platform dependencies from K/N distribution Add platform libraries from K/N distribution Aug 27, 2023
@vmishenev vmishenev added the runner: Gradle plugin An issue/PR related to Dokka's Gradle plugin label Aug 27, 2023
@vmishenev vmishenev changed the title Add platform libraries from K/N distribution Add the native stdlib and platform libraries from K/N distribution Aug 28, 2023
@IgnatBeresnev
Copy link
Member

This solution somewhat duplicates #3147. We had a suspicion that it might work differently (for better or for worse), so we shipped both this fix and #3147 in Dokka 1.9.0 under different flags.

So far we've heard no reports of any differences, so we're closing this PR in favor of #3147.

@IgnatBeresnev IgnatBeresnev deleted the hack-platform-dependencies branch October 5, 2023 14:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
runner: Gradle plugin An issue/PR related to Dokka's Gradle plugin
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants