Add the native stdlib and platform libraries from K/N distribution #3145
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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
Compilation
s in KGP plugin.KGP's pipeline:
Compilation
-->KotlinTool
(Compile task) --> run a compiler process with CLI arguments.For classpath, KGP transforms
KotlinTool.libraries
(orcompilation.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
, andKotlinTool.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 inplatformDependencies
)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
(akaimplementationMetadataConfigurationName
configuration) and metadata compilation.