[K/N] Move files, env interop generation to kotlin-native/common/
This commit is contained in:
committed by
Space Team
parent
9f0a6537bb
commit
ab62632a85
@@ -5,9 +5,6 @@
|
||||
|
||||
import org.jetbrains.kotlin.gradle.tasks.KotlinCompilationTask
|
||||
import org.jetbrains.kotlin.PlatformInfo
|
||||
import org.jetbrains.kotlin.cpp.CppConsumerPlugin
|
||||
import org.jetbrains.kotlin.cpp.CppUsage
|
||||
import org.jetbrains.kotlin.cpp.DependencyHandlerExKt
|
||||
import org.jetbrains.kotlin.gradle.dsl.JvmTarget
|
||||
import org.jetbrains.kotlin.tools.NativePluginKt
|
||||
|
||||
@@ -20,7 +17,6 @@ apply plugin: 'java'
|
||||
apply plugin: 'kotlin'
|
||||
apply plugin: "native-interop-plugin"
|
||||
apply plugin: "maven-publish"
|
||||
apply plugin: CppConsumerPlugin
|
||||
|
||||
sourceSets {
|
||||
compiler {
|
||||
@@ -46,8 +42,6 @@ compileCompilerKotlin {
|
||||
}
|
||||
|
||||
def tasksWithoutOptInUsage = [
|
||||
"compileEnvInteropStubsKotlin",
|
||||
"compileFilesInteropStubsKotlin",
|
||||
"compileLlvmInteropStubsKotlin"
|
||||
]
|
||||
tasks.withType(KotlinCompilationTask.class).configureEach {
|
||||
@@ -60,30 +54,6 @@ compileCli_bcKotlin {
|
||||
compilerOptions.freeCompilerArgs.add('-Xskip-prerelease-check')
|
||||
}
|
||||
|
||||
configurations {
|
||||
commonFilesBitcode {
|
||||
canBeConsumed = false
|
||||
canBeResolved = true
|
||||
attributes {
|
||||
attribute(Usage.USAGE_ATTRIBUTE, objects.named(Usage, CppUsage.LLVM_BITCODE))
|
||||
}
|
||||
}
|
||||
commonEnvBitcode {
|
||||
canBeConsumed = false
|
||||
canBeResolved = true
|
||||
attributes {
|
||||
attribute(Usage.USAGE_ATTRIBUTE, objects.named(Usage, CppUsage.LLVM_BITCODE))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
dependencies {
|
||||
use(DependencyHandlerExKt) {
|
||||
commonFilesBitcode module(project(":kotlin-native:common"), "files")
|
||||
commonEnvBitcode module(project(":kotlin-native:common"), "env")
|
||||
}
|
||||
}
|
||||
|
||||
kotlinNativeInterop {
|
||||
llvm {
|
||||
|
||||
@@ -104,40 +74,11 @@ kotlinNativeInterop {
|
||||
}
|
||||
linkerOpts "-L$llvmDir/lib", "-L${rootProject.project(':kotlin-native:llvmDebugInfoC').layout.buildDirectory.get().asFile}", "-L${rootProject.project(':kotlin-native:libllvmext').layout.buildDirectory.get().asFile}"
|
||||
}
|
||||
|
||||
files {
|
||||
linker 'clang++'
|
||||
link configurations.commonFilesBitcode
|
||||
|
||||
// TODO: These should come from some sort of commonFilesApi configuration
|
||||
headers fileTree('../common/src/files/headers') {
|
||||
include '**/*.h'
|
||||
include '**/*.hpp'
|
||||
}
|
||||
|
||||
pkg 'org.jetbrains.kotlin.backend.konan.files'
|
||||
}
|
||||
|
||||
|
||||
env {
|
||||
linker 'clang++'
|
||||
link configurations.commonEnvBitcode
|
||||
|
||||
// TODO: These should come from some sort of commonEnvApi configuration
|
||||
headers fileTree('../common/src/env/headers') {
|
||||
include '**/*.h'
|
||||
include '**/*.hpp'
|
||||
}
|
||||
|
||||
pkg 'org.jetbrains.kotlin.backend.konan.env'
|
||||
}
|
||||
}
|
||||
|
||||
configurations {
|
||||
compilerApi {
|
||||
extendsFrom kotlinNativeInterop['llvm'].configuration
|
||||
extendsFrom kotlinNativeInterop['files'].configuration
|
||||
extendsFrom kotlinNativeInterop['env'].configuration
|
||||
}
|
||||
kotlin_compiler_jar
|
||||
kotlin_stdlib_jar
|
||||
@@ -204,8 +145,6 @@ classes.dependsOn 'compilerClasses', 'cli_bcClasses'
|
||||
tasks.named("jar") {
|
||||
from sourceSets.cli_bc.output,
|
||||
sourceSets.compiler.output,
|
||||
sourceSets.filesInteropStubs.output,
|
||||
sourceSets.envInteropStubs.output,
|
||||
sourceSets.llvmInteropStubs.output
|
||||
|
||||
dependsOn 'external_jars'
|
||||
|
||||
@@ -163,6 +163,11 @@ configurations {
|
||||
canBeConsumed = false
|
||||
canBeResolved = true
|
||||
}
|
||||
|
||||
nativeLibs {
|
||||
canBeConsumed = false
|
||||
canBeResolved = true
|
||||
}
|
||||
}
|
||||
|
||||
apply plugin: CompilationDatabasePlugin
|
||||
@@ -188,6 +193,7 @@ dependencies {
|
||||
runtimeBitcode project(":kotlin-native:runtime")
|
||||
objcExportApi project(":kotlin-native:runtime")
|
||||
embeddableJar project(path: ':kotlin-native:prepare:kotlin-native-compiler-embeddable', configuration: 'runtimeElements')
|
||||
nativeLibs project(path: ':kotlin-native:common', configuration: 'nativeLibs')
|
||||
}
|
||||
|
||||
apply plugin: GitClangFormatPlugin
|
||||
@@ -277,6 +283,10 @@ tasks.register("distCompiler", Copy) {
|
||||
into('konan/nativelib')
|
||||
}
|
||||
|
||||
from(configurations.nativeLibs) {
|
||||
into('konan/nativelib')
|
||||
}
|
||||
|
||||
from(project(':kotlin-native:backend.native').file('build/external_jars/trove4j.jar')) {
|
||||
into('konan/lib')
|
||||
}
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
import org.jetbrains.kotlin.konan.target.TargetWithSanitizer
|
||||
|
||||
/*
|
||||
* Copyright 2010-2020 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license
|
||||
* that can be found in the LICENSE file.
|
||||
@@ -6,6 +8,8 @@
|
||||
plugins {
|
||||
id("kotlin.native.build-tools-conventions")
|
||||
id("compile-to-bitcode")
|
||||
kotlin("jvm")
|
||||
id("native-interop-plugin")
|
||||
}
|
||||
|
||||
bitcode {
|
||||
@@ -26,12 +30,33 @@ bitcode {
|
||||
}
|
||||
}
|
||||
|
||||
val hostName: String by project
|
||||
|
||||
tasks.register("build") {
|
||||
dependsOn("${hostName}Common")
|
||||
kotlinNativeInterop {
|
||||
create("files") {
|
||||
pkg("org.jetbrains.kotlin.backend.konan.files")
|
||||
linker("clang++")
|
||||
linkOutputs(bitcode.hostTarget.module("files").get().sourceSets.main.get().task.get())
|
||||
headers(layout.projectDirectory.files("src/files/headers/Files.h"))
|
||||
}
|
||||
|
||||
tasks.register<Delete>("clean") {
|
||||
delete(layout.buildDirectory)
|
||||
create("env") {
|
||||
pkg("org.jetbrains.kotlin.backend.konan.env")
|
||||
linker("clang++")
|
||||
linkOutputs(bitcode.hostTarget.module("env").get().sourceSets.main.get().task.get())
|
||||
headers(layout.projectDirectory.files("src/env/headers/Env.h"))
|
||||
}
|
||||
}
|
||||
|
||||
val nativeLibs by configurations.creating {
|
||||
isCanBeConsumed = true
|
||||
isCanBeResolved = false
|
||||
attributes {
|
||||
attribute(ArtifactTypeDefinition.ARTIFACT_TYPE_ATTRIBUTE, ArtifactTypeDefinition.DIRECTORY_TYPE)
|
||||
attribute(TargetWithSanitizer.TARGET_ATTRIBUTE, TargetWithSanitizer.host)
|
||||
}
|
||||
}
|
||||
|
||||
artifacts {
|
||||
add(nativeLibs.name, layout.buildDirectory.dir("nativelibs/${TargetWithSanitizer.host}")) {
|
||||
builtBy(kotlinNativeInterop["files"].genTask, kotlinNativeInterop["env"].genTask)
|
||||
}
|
||||
}
|
||||
@@ -1,3 +1,5 @@
|
||||
import org.jetbrains.kotlin.gradle.tasks.KotlinJvmCompile
|
||||
|
||||
plugins {
|
||||
kotlin("jvm")
|
||||
}
|
||||
@@ -10,6 +12,16 @@ dependencies {
|
||||
implementation(project(":kotlin-native:klib"))
|
||||
implementation(project(":kotlin-native:endorsedLibraries:kotlinx.cli", configuration = "jvmRuntimeElements"))
|
||||
implementation(project(":native:kotlin-native-utils"))
|
||||
implementation(project(":kotlin-native:common", configuration = "filesInteropStubs"))
|
||||
implementation(project(":kotlin-native:common", configuration = "envInteropStubs"))
|
||||
}
|
||||
|
||||
tasks.withType<KotlinJvmCompile>().configureEach {
|
||||
compilerOptions.optIn.addAll(
|
||||
listOf(
|
||||
"kotlinx.cinterop.ExperimentalForeignApi",
|
||||
)
|
||||
)
|
||||
}
|
||||
|
||||
sourceSets {
|
||||
|
||||
Reference in New Issue
Block a user