Move K/N dependencies handling logic into gradle plugins:
`NativeDependenciesDownloader` is instantiated in
`:kotlin-native:dependencies` and provides a single configuration that
contains all directories with the dependencies. The configuration has
a variant for each target.
`NativeDependencies` is instantiated by projects that require native
dependencies (i.e. previously used to depend on
`:kotlin-native:dependencies:update`). This plugin creates a configuration
that by default depends on `:kotlin-native:dependencies`. Its extension
provides `llvmDependency`, `libffiDependency`, `hostPlatformDependency`,
`targetDependency()` to depend on the parts needed for the project and
provides accessors `llvmPath`, `libffiPath`, `hostPlatform` that are
safe to use during configuration time, but which do not automatically
resolve those dependencies.
`llvmDir`, `*LibffiDir` properties on `:kotlin-native` are removed
completely, as their use is replaced by `NativeDependencies`. As a
consequence, `evaluationDependsOn(":kotlin-native:dependencies")` is
also gone.
All direct dependencies on `:kotlin-native:dependencies:update` are
replaced with dependencies on specific parts via `NativeDependencies`
Building with macOS gave the linker warning
`ld: warning: ignoring duplicate libraries: '/Users/foo/.konan/dependencies/apple-llvm-20200714-macos-aarch64-1/lib/libclangEdit.a'`
Remove duplication from the build script to get rid of the warning.
Co-authored-by: Dave MacLachlan <dmaclach@gmail.com>
Since Xcode 15 the iconv APIs operate on an opaque type __tag_iconv_t* instead of
void*. This causes a runtime exception in older Ktor versions which
depended on iconv.
^KT-62286
Now (mostly after 3f3f6eb) cinterop adds ExperimentalForeignApi to all
Kotlin declarations it generates from C and Objective-C libraries,
except for the platform libraries.
This commit changes the KDoc for ExperimentalForeignApi to reflect that
change.
^KT-58362
cinterop tool should add ExperimentalForeignApi to all generated
declarations by default. This commit implements adding the annotation.
Nested declarations don't get the annotation, because they inherit the
opt-in requirement from the enclosing classes implicitly.
The annotation is not added to platform libraries, as intended. See
previous commits.
^KT-58362
cinterop tool should add ExperimentalForeignApi to all generated
declarations by default. To make this possible to implement in a
non-intrusive manner, this commit enables adding annotations to some of
the existing Stub IR nodes.
After that, one can add annotations to all generated declarations with
a simple post pass.
^KT-58362
cinterop tool should add ExperimentalForeignApi to all generated
declarations by default. This commit supports this annotation in
cinterop intermediate representation -- Stub IR.
^KT-58362
It disables adding `ExperimentalForeignApi` opt-in to declarations
generated by cinterop.
Main use case is platform libraries, which are not supposed to have this
annotation. Applying the flag to user cinterop libraries is discouraged
and effectively means opting in.
^KT-58362
Include new project as build logic included build. Such change will
allow us to start migration into build convention plugins by splitting
buildSrc logic into subprojects.
Flag, Flag constants, Flags typealias, flagsOf() function, and
Flag accessors in nodes (such as KmClass.flags, KmClass.jvmFlags, KmProperty.setterFlags, etc)
#KT-59440
Introduce extensions for KmNodes to work with various modifiers instead of old Flags.SOMETHING.invoke(flags).
Provide Visibility, Modality, and Kind enums.
Introduce KmPropertyAccessorAttributes to replace KmProperty.getterFlags and KmProperty.setterFlags.
Deprecate nodes constructors which take flags but not flags itself (yet).
Adapt KotlinP to changes.
#KT-59440 Fixed
For a Kotlin wrapper of an Objective-C object, this functions zeroes
and releases the strong reference from the Kotlin wrapper to the
Objective-C object.
Usually, such a release happens only when the Kotlin wrapper is GCed.
So using this function can help that happen sooner.
^KT-59134
Before this change `./gradlew help` (with native enabled)
Created immediately: 1322
Created during configuration: 1541
after this change:
Created immediately: 596
Created during configuration: 1509
To know more about configuration avoidance: https://docs.gradle.org/current/userguide/task_configuration_avoidance.html
`staticCFunction` is used a few times in this module, and it uses
kotlin-reflect to inspect the lambda parameter, which is only possible
for class-generated lambdas.
This is needed to enable indy lambdas in the project.
* @ExperimentalForeignApi for all declarations that operate on
unmanaged memory (i.e. pointers and references)
* @BetaInteropApi for the rest of the interoperability declarations,
namely Swift/CInterop-specific interfaces and convenience-functions
### Implementation details
* Some typealiases are not marked explicitly because it crashes the compiler,
yet their experimentality is properly propagated
* License header is adjusted where it previously had been existing
* Deprecated with ERROR interop declarations that are deprecated for more than
two years are removed
* WASM target interop declarations are deprecated
* Deliberately make Boolean.toByte and Byte.toBoolean foreign-experimental to scare
people away
^KT-57728 fixed
Merge-request: KT-MR-9788
Merged-by: Vsevolod Tolstopyatov <qwwdfsad@gmail.com>
tryRenderStructOrUnion can return null for a struct or union to indicate
that passing it by value to or from C is not supported (e.g. it has
bitfields).
It incorrectly handled the case when passing a nested struct or union by
value was unsupported -- instead of null, it returned incorrect struct
declaration.
As a result, when passing such a complex struct or union by value to or
from C, the backend generated C stubs with syntax errors, which resulted
into obscure compilation error ("unable to compile C bridge").
This commit fixes this case in tryRenderStructOrUnion function, and thus
makes the compilation error message more understandable.
^KT-55030
Adds convention plugin instead of sources inclusion
inside the buildSrc, effectively reducing the amount
of the code to be compiled in buildSrc.
Merge-request: KT-MR-8898
Review: https://jetbrains.team/p/kt/reviews/8401
In scope of: KT-55082
Because this version isn't used for anything. We have KotlinAbiVersion
to version the IR format.
* Replace it with KotlinCompilerVersion
* K/N version should be set now with `deployVersion`.
* Cleanup deprecated functions in older versions
of the Gradle plugin
* Cleanup tests for older versions of compiler downloader
Merge-request: KT-MR-8436
Merged-by: Pavel Punegov <Pavel.Punegov@jetbrains.com>
This allows the compiler to limit imports from "magic" packages like
cnames.structs to forward declarations actually present in dependent
cinterop klibs.
The manifest already had `exportForwardDeclarations` field, but
- it didn't include Objective-C forward declarations (@class, @protocol)
- it has a slightly different meaning (the export list enables importing
the listed declarations through the interop package of the library,
while the include list shouldn't do that), so we better avoid mixing
them.
This way inheritors of such class would be able to override category
members the same way they can in Objective-C. Also, API surface of
interop libraries should become a little more stable.
To avoid adding unnecessary included categories to index, we need
to track their location. Also, we can't just implement TypeDeclaration
interface because category is not a type. Thus, we extract `location`
property from TypeDeclaration to LocatableDeclaration and implement it
in ObjCCategory.
It allows to list Objective-C classes that should include
corresponding categories from the same file.
The current implementation is super-simple and slow, but
it is OK since it is not intended to be a general-purpose
solution for now.