From fb15992546c908f299573326f300505e7d6d854f Mon Sep 17 00:00:00 2001 From: Ilya Matveev Date: Fri, 18 Aug 2017 13:04:40 +0700 Subject: [PATCH] build: Distribute 'shared' as a separate jar --- backend.native/build.gradle | 82 ++++++++++++++++++------------------ build.gradle | 5 +++ buildSrc/shared/build.gradle | 6 +-- cmd/run_konan | 3 +- 4 files changed, 50 insertions(+), 46 deletions(-) diff --git a/backend.native/build.gradle b/backend.native/build.gradle index d9d62faf92c..cc83fd27225 100644 --- a/backend.native/build.gradle +++ b/backend.native/build.gradle @@ -52,25 +52,24 @@ allprojects { sourceSets { compiler { - proto.srcDir 'compiler/ir/backend.native/src/' - java { - srcDir 'compiler/ir/backend.native/src/' - srcDir 'build/renamed/source/proto/compiler/java' - } - kotlin { - srcDir 'compiler/ir/backend.native/src/' - srcDir "${rootProject.projectDir}/shared/src/main/kotlin" - } - resources.srcDir 'compiler/ir/backend.native/resources/' + proto.srcDir 'compiler/ir/backend.native/src/' + java { + srcDir 'compiler/ir/backend.native/src/' + srcDir 'build/renamed/source/proto/compiler/java' + } + kotlin { + srcDir 'compiler/ir/backend.native/src/' + } + resources.srcDir 'compiler/ir/backend.native/resources/' } cli_bc { - java.srcDir 'cli.bc/src' - kotlin.srcDir 'cli.bc/src' + java.srcDir 'cli.bc/src' + kotlin.srcDir 'cli.bc/src' } bc_frontend { - java.srcDir 'bc.frontend/src' - kotlin.srcDir 'bc.frontend/src' - } + java.srcDir 'bc.frontend/src' + kotlin.srcDir 'bc.frontend/src' + } } compileCompilerKotlin { @@ -96,26 +95,26 @@ task renamePackage(type: Copy) { } kotlinNativeInterop { - llvm { - dependsOn ":llvmDebugInfoC:debugInfoStaticLibrary" - defFile 'llvm.def' - compilerOpts "-fPIC", "-I$llvmDir/include", "-I${project(':llvmDebugInfoC').projectDir}/src/main/include" - linkerOpts "-L$llvmDir/lib", "-L${project(':llvmDebugInfoC').buildDir}/libs/debugInfo/static" - } + llvm { + dependsOn ":llvmDebugInfoC:debugInfoStaticLibrary" + defFile 'llvm.def' + compilerOpts "-fPIC", "-I$llvmDir/include", "-I${project(':llvmDebugInfoC').projectDir}/src/main/include" + linkerOpts "-L$llvmDir/lib", "-L${project(':llvmDebugInfoC').buildDir}/libs/debugInfo/static" + } - hash { // TODO: copy-pasted from ':common:compileHash' - compilerOpts '-fPIC' - linkerOpts '-fPIC' - linker 'clang++' - linkOutputs ":common:${hostName}Hash" + hash { // TODO: copy-pasted from ':common:compileHash' + compilerOpts '-fPIC' + linkerOpts '-fPIC' + linker 'clang++' + linkOutputs ":common:${hostName}Hash" - headers fileTree('../common/src/hash/headers') { - include '**/*.h' - include '**/*.hpp' - } + headers fileTree('../common/src/hash/headers') { + include '**/*.h' + include '**/*.hpp' + } - pkg 'org.jetbrains.kotlin.backend.konan.hash' - } + pkg 'org.jetbrains.kotlin.backend.konan.hash' + } } @@ -129,19 +128,20 @@ configurations { dependencies { - compilerCompile "com.google.protobuf:protobuf-java:${protobufVersion}" + compilerCompile "com.google.protobuf:protobuf-java:${protobufVersion}" - compilerCompile kotlinCompilerModule - compilerCompile kotlinNativeInterop['llvm'].configuration - compilerCompile kotlinNativeInterop['hash'].configuration - compilerCompile project(':shared') + compilerCompile kotlinCompilerModule + compilerCompile kotlinNativeInterop['llvm'].configuration + compilerCompile kotlinNativeInterop['hash'].configuration + compilerCompile project(':shared') - cli_bcCompile "org.jetbrains.kotlin:kotlin-runtime:$kotlin_version" - cli_bcCompile sourceSets.compiler.output + cli_bcCompile "org.jetbrains.kotlin:kotlin-runtime:$kotlin_version" + cli_bcCompile project(':shared') + cli_bcCompile sourceSets.compiler.output - bc_frontendCompile kotlinCompilerModule + bc_frontendCompile kotlinCompilerModule - cli_bc sourceSets.cli_bc.output + cli_bc sourceSets.cli_bc.output } diff --git a/build.gradle b/build.gradle index 426f4e73fd6..b98809a2001 100644 --- a/build.gradle +++ b/build.gradle @@ -146,6 +146,7 @@ task distCompiler(type: Copy) { dependsOn ':tools:helpers:jar' dependsOn ':utilities:jar' dependsOn ':klib:jar' + dependsOn ':shared:jar' destinationDir file('dist') @@ -197,6 +198,10 @@ task distCompiler(type: Copy) { into('konan/lib') } + from(project(':shared').file('build/libs')) { + into('konan/lib') + } + from(file('cmd')) { fileMode(0755) into('bin') diff --git a/buildSrc/shared/build.gradle b/buildSrc/shared/build.gradle index d248644d0ba..931fd8b96f2 100644 --- a/buildSrc/shared/build.gradle +++ b/buildSrc/shared/build.gradle @@ -26,10 +26,8 @@ buildscript { apply plugin: 'kotlin' -compileKotlin { - // We reuse the source code from the Project in buildSrc. - source "$projectDir/../../shared" -} +// We reuse the source code from the Project in buildSrc. +sourceSets.main.kotlin.srcDirs = ["$projectDir/../../shared"] dependencies { compile "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version" diff --git a/cmd/run_konan b/cmd/run_konan index 830a34001cb..fb9a776b348 100755 --- a/cmd/run_konan +++ b/cmd/run_konan @@ -80,9 +80,10 @@ STUB_GENERATOR_JAR="${KONAN_HOME}/konan/lib/StubGenerator.jar" INTEROP_INDEXER_JAR="${KONAN_HOME}/konan/lib/Indexer.jar" INTEROP_JAR="${KONAN_HOME}/konan/lib/Runtime.jar" HELPERS_JAR="${KONAN_HOME}/konan/lib/helpers.jar" +SHARED_JAR="${KONAN_HOME}/konan/lib/shared.jar" KLIB_JAR="${KONAN_HOME}/konan/lib/klib.jar" UTILITIES_JAR="${KONAN_HOME}/konan/lib/utilities.jar" -KONAN_CLASSPATH="$KOTLIN_JAR:$INTEROP_JAR:$STUB_GENERATOR_JAR:$INTEROP_INDEXER_JAR:$KONAN_JAR:$HELPERS_JAR:$KLIB_JAR:$UTILITIES_JAR" +KONAN_CLASSPATH="$KOTLIN_JAR:$INTEROP_JAR:$STUB_GENERATOR_JAR:$INTEROP_INDEXER_JAR:$KONAN_JAR:$HELPERS_JAR:$KLIB_JAR:$UTILITIES_JAR:$SHARED_JAR" TOOL_CLASS=org.jetbrains.kotlin.cli.utilities.MainKt LIBCLANG_DISABLE_CRASH_RECOVERY=1 \