From e2e883ee0894d6a94837ee83c1682e4ca1e5ce83 Mon Sep 17 00:00:00 2001 From: Alexander Gorshenev Date: Thu, 19 Oct 2017 20:24:31 +0300 Subject: [PATCH] Introduced testLibrary and a test utilizing it. --- backend.native/tests/build.gradle | 9 +++++++++ build.gradle | 1 + klib/build.gradle | 28 ++++++++++++++++++++++++++++ 3 files changed, 38 insertions(+) diff --git a/backend.native/tests/build.gradle b/backend.native/tests/build.gradle index afeac5fb27d..7741ecca6ad 100644 --- a/backend.native/tests/build.gradle +++ b/backend.native/tests/build.gradle @@ -1243,6 +1243,15 @@ task link_default_libs(type: RunStandaloneKonanTest) { source = "link/default/default.kt" } +task link_testLib_explicitly(type: RunKonanTest) { + dependsOn ':klib:installTestLibrary' + goldValue = "Hello\n" + source = "link/omit/hello.kt" + // We force library inclusion, so need to see the warning banner. + flags = ['-l', 'testLibrary'] + +} + task no_purge_for_dependencies(type: LinkKonanTest) { disabled = (project.testTarget == 'wasm32') // there will be no posix.klib for wasm goldValue = "linked library\nand symbols from posix available: 17; 1.0\n" diff --git a/build.gradle b/build.gradle index b481dc478db..8b52838847f 100644 --- a/build.gradle +++ b/build.gradle @@ -353,6 +353,7 @@ task bundle(type: (isWindows()) ? Zip : Tar) { from("$project.rootDir/dist") { include '**' exclude 'dependencies' + exclude 'klib/testLibrary' into baseName } from(project.rootDir) { diff --git a/klib/build.gradle b/klib/build.gradle index 9476b1c3492..fd938646d40 100644 --- a/klib/build.gradle +++ b/klib/build.gradle @@ -24,3 +24,31 @@ dependencies { compile "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version" compile project(path: ':backend.native', configuration: 'cli_bc') } + +def dist = rootProject.file('dist').absolutePath + +// TODO: Ideally we want to write just konanArtifacts{} clouse here, +// but we need to make Kotlin Native Gradle Plugin a dependence +// of our buildScripts first. +task compileKonanTestLibrary(type: Exec) { + dependsOn ':dist' + + def compiler = "$dist/bin/konanc" + def source = 'src/testLibrary' + def artifact = 'build/konan/bin/testLibrary' + + executable compiler + args source, '-o', artifact, '-p', 'library' +} + +task installTestLibrary(type: Exec) { + dependsOn 'compileKonanTestLibrary' + + def repo = "$dist/klib/common" + def tool = "$dist/bin/klib" + def library = 'build/konan/bin/testLibrary.klib' + + executable tool + args 'install', library, '-repository', repo +} +