Sorted out native sourcesets, using intialization and sodium srng in js and native
This commit is contained in:
parent
ccbb8ebe5b
commit
63c5db199e
@ -17,30 +17,28 @@
|
|||||||
|
|
||||||
@file:Suppress("UnstableApiUsage")
|
@file:Suppress("UnstableApiUsage")
|
||||||
|
|
||||||
import com.moowork.gradle.node.task.NodeTask
|
|
||||||
import org.gradle.api.tasks.testing.logging.TestLogging
|
|
||||||
import org.jetbrains.kotlin.gradle.targets.native.tasks.KotlinNativeTest
|
|
||||||
import org.jetbrains.kotlin.gradle.targets.js.testing.KotlinJsTest
|
import org.jetbrains.kotlin.gradle.targets.js.testing.KotlinJsTest
|
||||||
|
import org.jetbrains.kotlin.gradle.targets.native.tasks.KotlinNativeTest
|
||||||
|
import org.jetbrains.kotlin.gradle.plugin.mpp.KotlinNativeTarget
|
||||||
import org.jetbrains.kotlin.gradle.tasks.Kotlin2JsCompile
|
import org.jetbrains.kotlin.gradle.tasks.Kotlin2JsCompile
|
||||||
import org.jetbrains.kotlin.konan.library.konanCommonLibraryPath
|
|
||||||
|
|
||||||
plugins {
|
plugins {
|
||||||
kotlin(PluginsDeps.multiplatform)
|
kotlin(PluginsDeps.multiplatform)
|
||||||
id (PluginsDeps.mavenPublish)
|
id(PluginsDeps.mavenPublish)
|
||||||
id (PluginsDeps.signing)
|
id(PluginsDeps.signing)
|
||||||
id (PluginsDeps.node) version Versions.nodePlugin
|
id(PluginsDeps.node) version Versions.nodePlugin
|
||||||
id (PluginsDeps.dokka) version Versions.dokkaPlugin
|
id(PluginsDeps.dokka) version Versions.dokkaPlugin
|
||||||
}
|
}
|
||||||
|
|
||||||
val sonatypeStaging = "https://oss.sonatype.org/service/local/staging/deploy/maven2/"
|
val sonatypeStaging = "https://oss.sonatype.org/service/local/staging/deploy/maven2/"
|
||||||
val sonatypeSnapshots = "https://oss.sonatype.org/content/repositories/snapshots/"
|
val sonatypeSnapshots = "https://oss.sonatype.org/content/repositories/snapshots/"
|
||||||
|
|
||||||
val sonatypePassword : String? by project
|
val sonatypePassword: String? by project
|
||||||
|
|
||||||
val sonatypeUsername : String? by project
|
val sonatypeUsername: String? by project
|
||||||
|
|
||||||
val sonatypePasswordEnv : String? = System.getenv()["SONATYPE_PASSWORD"]
|
val sonatypePasswordEnv: String? = System.getenv()["SONATYPE_PASSWORD"]
|
||||||
val sonatypeUsernameEnv : String? = System.getenv()["SONATYPE_USERNAME"]
|
val sonatypeUsernameEnv: String? = System.getenv()["SONATYPE_USERNAME"]
|
||||||
|
|
||||||
repositories {
|
repositories {
|
||||||
mavenCentral()
|
mavenCentral()
|
||||||
@ -61,34 +59,18 @@ fun getHostOsName(): String {
|
|||||||
}
|
}
|
||||||
|
|
||||||
kotlin {
|
kotlin {
|
||||||
|
|
||||||
val libsodiumCompilation : org.jetbrains.kotlin.gradle.plugin.mpp.KotlinNativeTargetWithHostTests.() -> Unit = {
|
|
||||||
compilations.getByName("main") {
|
|
||||||
val libsodiumCinterop by cinterops.creating {
|
|
||||||
defFile(project.file("src/nativeInterop/cinterop/libsodium.def"))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
val hostOsName = getHostOsName()
|
val hostOsName = getHostOsName()
|
||||||
if (ideaActive) {
|
|
||||||
when(hostOsName) {
|
|
||||||
"linux" -> linuxX64("native", libsodiumCompilation)
|
|
||||||
"macos" -> macosX64("native", libsodiumCompilation)
|
|
||||||
"windows" -> mingwX64("native", libsodiumCompilation)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (hostOsName == "linux") {
|
if (hostOsName == "linux") {
|
||||||
jvm()
|
jvm()
|
||||||
js {
|
js {
|
||||||
browser {
|
browser {
|
||||||
testTask {
|
testTask {
|
||||||
enabled = true //Until I sort out testing on travis
|
enabled = true //Until I sort out testing on travis
|
||||||
useKarma {
|
useKarma {
|
||||||
useChrome()
|
useChrome()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
nodejs {
|
nodejs {
|
||||||
testTask {
|
testTask {
|
||||||
useMocha() {
|
useMocha() {
|
||||||
@ -99,7 +81,6 @@ kotlin {
|
|||||||
|
|
||||||
}
|
}
|
||||||
linuxX64("linux") {
|
linuxX64("linux") {
|
||||||
libsodiumCompilation(this)
|
|
||||||
binaries {
|
binaries {
|
||||||
staticLib {
|
staticLib {
|
||||||
}
|
}
|
||||||
@ -192,41 +173,43 @@ kotlin {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
val nativeMain = if (ideaActive) {
|
val nativeMain by creating {
|
||||||
val nativeMain by getting {
|
dependsOn(commonMain)
|
||||||
dependsOn(commonMain)
|
dependencies {
|
||||||
dependencies {
|
implementation(Deps.Native.coroutines)
|
||||||
implementation(Deps.Native.coroutines)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
nativeMain
|
|
||||||
} else {
|
|
||||||
val nativeMain by creating {
|
|
||||||
dependsOn(commonMain)
|
|
||||||
dependencies {
|
|
||||||
implementation(Deps.Native.coroutines)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
nativeMain
|
|
||||||
}
|
}
|
||||||
val nativeTest = if (ideaActive) {
|
|
||||||
val nativeTest by getting {
|
|
||||||
dependsOn(commonTest)
|
val nativeTest by creating {
|
||||||
dependencies {
|
dependsOn(commonTest)
|
||||||
implementation(Deps.Native.coroutines)
|
dependencies {
|
||||||
}
|
implementation(Deps.Native.coroutines)
|
||||||
}
|
}
|
||||||
nativeTest
|
|
||||||
} else {
|
|
||||||
val nativeTest by creating {
|
|
||||||
dependsOn(commonTest)
|
|
||||||
dependencies {
|
|
||||||
implementation(Deps.Native.coroutines)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
nativeTest
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
targets.withType<KotlinNativeTarget> {
|
||||||
|
println("Target $name")
|
||||||
|
compilations.getByName("main") {
|
||||||
|
println("Setting cinterop for $name")
|
||||||
|
defaultSourceSet.dependsOn(nativeMain)
|
||||||
|
if (!name.contains("ios")) {
|
||||||
|
val libsodiumCinterop by cinterops.creating {
|
||||||
|
defFile(project.file("src/nativeInterop/cinterop/libsodium.def"))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
compilations.getByName("test") {
|
||||||
|
println("Setting cinterop for $name")
|
||||||
|
if (!name.contains("ios")) {
|
||||||
|
defaultSourceSet.dependsOn(nativeTest)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if (hostOsName == "linux") {
|
if (hostOsName == "linux") {
|
||||||
val jvmMain by getting {
|
val jvmMain by getting {
|
||||||
dependencies {
|
dependencies {
|
||||||
@ -261,10 +244,22 @@ kotlin {
|
|||||||
}
|
}
|
||||||
val linuxMain by getting {
|
val linuxMain by getting {
|
||||||
dependsOn(nativeMain)
|
dependsOn(nativeMain)
|
||||||
|
//Force idea to consider native sourceset
|
||||||
|
if (ideaActive) {
|
||||||
|
kotlin.srcDir("src/nativeMain/kotlin")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
val linuxTest by getting {
|
val linuxTest by getting {
|
||||||
dependsOn(nativeTest)
|
dependsOn(nativeTest)
|
||||||
|
//Force idea to consider native sourceset
|
||||||
|
if (ideaActive) {
|
||||||
|
kotlin.srcDir("src/nativeTest/kotlin")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//Not supported in coroutines at the moment
|
//Not supported in coroutines at the moment
|
||||||
// val linuxArm32HfpMain by getting {
|
// val linuxArm32HfpMain by getting {
|
||||||
// dependsOn(nativeMain)
|
// dependsOn(nativeMain)
|
||||||
@ -354,9 +349,9 @@ kotlin {
|
|||||||
task<Copy>("copyPackageJson") {
|
task<Copy>("copyPackageJson") {
|
||||||
dependsOn("compileKotlinJs")
|
dependsOn("compileKotlinJs")
|
||||||
println("Copying package.json from $projectDir/core/src/jsMain/npm")
|
println("Copying package.json from $projectDir/core/src/jsMain/npm")
|
||||||
from ("$projectDir/src/jsMain/npm")
|
from("$projectDir/src/jsMain/npm")
|
||||||
println("Node modules dir ${node.nodeModulesDir}")
|
println("Node modules dir ${node.nodeModulesDir}")
|
||||||
into ("${node.nodeModulesDir}")
|
into("${node.nodeModulesDir}")
|
||||||
}
|
}
|
||||||
|
|
||||||
tasks {
|
tasks {
|
||||||
@ -369,14 +364,15 @@ tasks {
|
|||||||
}
|
}
|
||||||
|
|
||||||
dokka {
|
dokka {
|
||||||
println ("Dokka !")
|
println("Dokka !")
|
||||||
impliedPlatforms = mutableListOf("Common")
|
impliedPlatforms = mutableListOf("Common")
|
||||||
kotlinTasks {
|
kotlinTasks {
|
||||||
listOf()
|
listOf()
|
||||||
}
|
}
|
||||||
sourceRoot {
|
sourceRoot {
|
||||||
println ("Common !")
|
println("Common !")
|
||||||
path = "/home/ionspin/Projects/Future/kotlin-multiplatform-crypto/crypto/src/commonMain" //TODO remove static path!
|
path =
|
||||||
|
"/home/ionspin/Projects/Future/kotlin-multiplatform-crypto/crypto/src/commonMain" //TODO remove static path!
|
||||||
platforms = listOf("Common")
|
platforms = listOf("Common")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,39 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2019 Ugljesa Jovanovic
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package com.ionspin.kotlin.crypto
|
||||||
|
|
||||||
|
import com.ionspin.kotlin.crypto.util.testBlocking
|
||||||
|
import kotlin.test.Test
|
||||||
|
import kotlin.test.assertTrue
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Created by Ugljesa Jovanovic
|
||||||
|
* ugljesa.jovanovic@ionspin.com
|
||||||
|
* on 21-Sep-2019
|
||||||
|
*/
|
||||||
|
class SRNGTest {
|
||||||
|
@Test
|
||||||
|
fun testSrng() = testBlocking {
|
||||||
|
Crypto.initialize()
|
||||||
|
//Just a sanity test, need to add better srng tests.
|
||||||
|
val randomBytes1 = SRNG.getRandomBytes(10)
|
||||||
|
val randomBytes2 = SRNG.getRandomBytes(10)
|
||||||
|
randomBytes1.forEach { println("RB1: $it")}
|
||||||
|
randomBytes2.forEach { println("RB2: $it")}
|
||||||
|
assertTrue { !randomBytes1.contentEquals(randomBytes2) }
|
||||||
|
}
|
||||||
|
}
|
@ -1,10 +0,0 @@
|
|||||||
package com.ionspin.kotlin.crypto
|
|
||||||
|
|
||||||
actual object Initializer {
|
|
||||||
actual suspend fun initialize() {
|
|
||||||
// sodi
|
|
||||||
}
|
|
||||||
|
|
||||||
actual fun initializeWithCallback(done: () -> Unit) {
|
|
||||||
}
|
|
||||||
}
|
|
@ -0,0 +1,19 @@
|
|||||||
|
package com.ionspin.kotlin.crypto
|
||||||
|
|
||||||
|
import kotlinx.coroutines.GlobalScope
|
||||||
|
import kotlinx.coroutines.launch
|
||||||
|
import libsodium.sodium_init
|
||||||
|
|
||||||
|
actual object Initializer {
|
||||||
|
actual suspend fun initialize() {
|
||||||
|
GlobalScope.launch {
|
||||||
|
sodium_init()
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
actual fun initializeWithCallback(done: () -> Unit) {
|
||||||
|
sodium_init()
|
||||||
|
done()
|
||||||
|
}
|
||||||
|
}
|
@ -17,6 +17,7 @@
|
|||||||
package com.ionspin.kotlin.crypto
|
package com.ionspin.kotlin.crypto
|
||||||
|
|
||||||
import kotlinx.cinterop.*
|
import kotlinx.cinterop.*
|
||||||
|
import libsodium.randombytes_buf
|
||||||
import platform.posix.*
|
import platform.posix.*
|
||||||
//import libsod
|
//import libsod
|
||||||
|
|
||||||
@ -30,7 +31,7 @@ actual object SRNG {
|
|||||||
actual fun getRandomBytes(amount: Int): UByteArray {
|
actual fun getRandomBytes(amount: Int): UByteArray {
|
||||||
memScoped {
|
memScoped {
|
||||||
val array = allocArray<UByteVar>(amount)
|
val array = allocArray<UByteVar>(amount)
|
||||||
// randombytes_buf()
|
randombytes_buf(array, amount.toULong())
|
||||||
return UByteArray(amount) {
|
return UByteArray(amount) {
|
||||||
array[it]
|
array[it]
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
package com.ionspin.kotlin.crypto.hash.blake2b
|
package com.ionspin.kotlin.crypto.hash.blake2b
|
||||||
import com.ionspin.kotlin.crypto.util.toHexString
|
import com.ionspin.kotlin.crypto.util.toHexString
|
||||||
import interop.*
|
|
||||||
import kotlinx.cinterop.*
|
import kotlinx.cinterop.*
|
||||||
import libsodium.*
|
import libsodium.*
|
||||||
/**
|
/**
|
@ -6,6 +6,7 @@ package com.ionspin.kotlin.crypto.hash.blake2b
|
|||||||
* on 24-May-2020
|
* on 24-May-2020
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
import com.ionspin.kotlin.crypto.hash.blake2b.Blake2bStateless
|
||||||
import com.ionspin.kotlin.crypto.util.testBlocking
|
import com.ionspin.kotlin.crypto.util.testBlocking
|
||||||
import interop.*
|
import interop.*
|
||||||
import kotlinx.cinterop.*
|
import kotlinx.cinterop.*
|
@ -16,30 +16,26 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
@file:Suppress("UnstableApiUsage")
|
@file:Suppress("UnstableApiUsage")
|
||||||
|
|
||||||
import com.moowork.gradle.node.task.NodeTask
|
|
||||||
import org.gradle.api.tasks.testing.logging.TestLogging
|
|
||||||
import org.jetbrains.kotlin.gradle.targets.native.tasks.KotlinNativeTest
|
import org.jetbrains.kotlin.gradle.targets.native.tasks.KotlinNativeTest
|
||||||
import org.jetbrains.kotlin.gradle.targets.js.testing.KotlinJsTest
|
import org.jetbrains.kotlin.gradle.targets.js.testing.KotlinJsTest
|
||||||
import org.jetbrains.kotlin.gradle.tasks.Kotlin2JsCompile
|
|
||||||
|
|
||||||
plugins {
|
plugins {
|
||||||
kotlin(PluginsDeps.multiplatform)
|
kotlin(PluginsDeps.multiplatform)
|
||||||
id (PluginsDeps.mavenPublish)
|
id(PluginsDeps.mavenPublish)
|
||||||
id (PluginsDeps.signing)
|
id(PluginsDeps.signing)
|
||||||
id (PluginsDeps.node) version Versions.nodePlugin
|
id(PluginsDeps.node) version Versions.nodePlugin
|
||||||
id (PluginsDeps.dokka) version Versions.dokkaPlugin
|
id(PluginsDeps.dokka) version Versions.dokkaPlugin
|
||||||
}
|
}
|
||||||
|
|
||||||
val sonatypeStaging = "https://oss.sonatype.org/service/local/staging/deploy/maven2/"
|
val sonatypeStaging = "https://oss.sonatype.org/service/local/staging/deploy/maven2/"
|
||||||
val sonatypeSnapshots = "https://oss.sonatype.org/content/repositories/snapshots/"
|
val sonatypeSnapshots = "https://oss.sonatype.org/content/repositories/snapshots/"
|
||||||
|
|
||||||
val sonatypePassword : String? by project
|
val sonatypePassword: String? by project
|
||||||
|
|
||||||
val sonatypeUsername : String? by project
|
val sonatypeUsername: String? by project
|
||||||
|
|
||||||
val sonatypePasswordEnv : String? = System.getenv()["SONATYPE_PASSWORD"]
|
val sonatypePasswordEnv: String? = System.getenv()["SONATYPE_PASSWORD"]
|
||||||
val sonatypeUsernameEnv : String? = System.getenv()["SONATYPE_USERNAME"]
|
val sonatypeUsernameEnv: String? = System.getenv()["SONATYPE_USERNAME"]
|
||||||
|
|
||||||
repositories {
|
repositories {
|
||||||
mavenCentral()
|
mavenCentral()
|
||||||
@ -61,13 +57,6 @@ fun getHostOsName(): String {
|
|||||||
|
|
||||||
kotlin {
|
kotlin {
|
||||||
val hostOsName = getHostOsName()
|
val hostOsName = getHostOsName()
|
||||||
if (ideaActive) {
|
|
||||||
when(hostOsName) {
|
|
||||||
"linux" -> linuxX64("native")
|
|
||||||
"macos" -> macosX64("native")
|
|
||||||
"windows" -> mingwX64("native")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (hostOsName == "linux") {
|
if (hostOsName == "linux") {
|
||||||
jvm()
|
jvm()
|
||||||
js {
|
js {
|
||||||
@ -196,41 +185,39 @@ kotlin {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
val nativeMain = if (ideaActive) {
|
|
||||||
val nativeMain by getting {
|
val nativeMain by creating {
|
||||||
dependsOn(commonMain)
|
dependsOn(commonMain)
|
||||||
dependencies {
|
dependencies {
|
||||||
implementation(Deps.Native.coroutines)
|
implementation(Deps.Native.coroutines)
|
||||||
}
|
|
||||||
}
|
}
|
||||||
nativeMain
|
|
||||||
} else {
|
|
||||||
val nativeMain by creating {
|
|
||||||
dependsOn(commonMain)
|
|
||||||
dependencies {
|
|
||||||
implementation(Deps.Native.coroutines)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
nativeMain
|
|
||||||
}
|
}
|
||||||
val nativeTest = if (ideaActive) {
|
|
||||||
val nativeTest by getting {
|
|
||||||
dependsOn(commonTest)
|
val nativeTest by creating {
|
||||||
dependencies {
|
dependsOn(commonTest)
|
||||||
implementation(Deps.Native.coroutines)
|
dependencies {
|
||||||
}
|
implementation(Deps.Native.coroutines)
|
||||||
}
|
}
|
||||||
nativeTest
|
|
||||||
} else {
|
|
||||||
val nativeTest by creating {
|
|
||||||
dependsOn(commonTest)
|
|
||||||
dependencies {
|
|
||||||
implementation(Deps.Native.coroutines)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
nativeTest
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
targets.withType<org.jetbrains.kotlin.gradle.plugin.mpp.KotlinNativeTarget> {
|
||||||
|
compilations.getByName("main") {
|
||||||
|
println("Setting native sourceset dependancy for $name")
|
||||||
|
if (!name.contains("ios")) {
|
||||||
|
defaultSourceSet.dependsOn(nativeMain)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
compilations.getByName("test") {
|
||||||
|
println("Setting native sourceset dependancy for $name")
|
||||||
|
if (!name.contains("ios")) {
|
||||||
|
defaultSourceSet.dependsOn(nativeTest)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if (hostOsName == "linux") {
|
if (hostOsName == "linux") {
|
||||||
val jvmMain by getting {
|
val jvmMain by getting {
|
||||||
dependencies {
|
dependencies {
|
||||||
@ -262,9 +249,17 @@ kotlin {
|
|||||||
}
|
}
|
||||||
val linuxMain by getting {
|
val linuxMain by getting {
|
||||||
dependsOn(nativeMain)
|
dependsOn(nativeMain)
|
||||||
|
//Force idea to consider native sourceset
|
||||||
|
if (ideaActive) {
|
||||||
|
kotlin.srcDir("src/nativeMain/kotlin")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
val linuxTest by getting {
|
val linuxTest by getting {
|
||||||
dependsOn(nativeTest)
|
dependsOn(nativeTest)
|
||||||
|
//Force idea to consider native sourceset
|
||||||
|
if (ideaActive) {
|
||||||
|
kotlin.srcDir("src/nativeTest/kotlin")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
//Not supported in coroutines at the moment
|
//Not supported in coroutines at the moment
|
||||||
// val linuxArm32HfpMain by getting {
|
// val linuxArm32HfpMain by getting {
|
||||||
@ -355,9 +350,9 @@ kotlin {
|
|||||||
task<Copy>("copyPackageJson") {
|
task<Copy>("copyPackageJson") {
|
||||||
dependsOn("compileKotlinJs")
|
dependsOn("compileKotlinJs")
|
||||||
println("Copying package.json from $projectDir/core/src/jsMain/npm")
|
println("Copying package.json from $projectDir/core/src/jsMain/npm")
|
||||||
from ("$projectDir/src/jsMain/npm")
|
from("$projectDir/src/jsMain/npm")
|
||||||
println("Node modules dir ${node.nodeModulesDir}")
|
println("Node modules dir ${node.nodeModulesDir}")
|
||||||
into ("${node.nodeModulesDir}")
|
into("${node.nodeModulesDir}")
|
||||||
}
|
}
|
||||||
|
|
||||||
tasks {
|
tasks {
|
||||||
@ -370,23 +365,20 @@ tasks {
|
|||||||
}
|
}
|
||||||
|
|
||||||
dokka {
|
dokka {
|
||||||
println ("Dokka !")
|
println("Dokka !")
|
||||||
impliedPlatforms = mutableListOf("Common")
|
impliedPlatforms = mutableListOf("Common")
|
||||||
kotlinTasks {
|
kotlinTasks {
|
||||||
listOf()
|
listOf()
|
||||||
}
|
}
|
||||||
sourceRoot {
|
sourceRoot {
|
||||||
println ("Common !")
|
println("Common !")
|
||||||
path = "/home/ionspin/Projects/Future/kotlin-multiplatform-crypto/crypto/src/commonMain" //TODO remove static path!
|
path =
|
||||||
|
"/home/ionspin/Projects/Future/kotlin-multiplatform-crypto/crypto/src/commonMain" //TODO remove static path!
|
||||||
platforms = listOf("Common")
|
platforms = listOf("Common")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (getHostOsName() == "linux") {
|
if (getHostOsName() == "linux") {
|
||||||
|
|
||||||
val npmInstall by getting
|
|
||||||
val compileKotlinJs by getting(AbstractCompile::class)
|
|
||||||
val compileTestKotlinJs by getting(Kotlin2JsCompile::class)
|
|
||||||
|
|
||||||
val jvmTest by getting(Test::class) {
|
val jvmTest by getting(Test::class) {
|
||||||
testLogging {
|
testLogging {
|
||||||
events("PASSED", "FAILED", "SKIPPED")
|
events("PASSED", "FAILED", "SKIPPED")
|
||||||
@ -397,7 +389,7 @@ tasks {
|
|||||||
|
|
||||||
testLogging {
|
testLogging {
|
||||||
events("PASSED", "FAILED", "SKIPPED")
|
events("PASSED", "FAILED", "SKIPPED")
|
||||||
// showStandardStreams = true
|
// showStandardStreams = true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -61,13 +61,6 @@ fun getHostOsName(): String {
|
|||||||
|
|
||||||
kotlin {
|
kotlin {
|
||||||
val hostOsName = getHostOsName()
|
val hostOsName = getHostOsName()
|
||||||
if (ideaActive) {
|
|
||||||
when(hostOsName) {
|
|
||||||
"linux" -> linuxX64("native")
|
|
||||||
"macos" -> macosX64("native")
|
|
||||||
"windows" -> mingwX64("native")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (hostOsName == "linux") {
|
if (hostOsName == "linux") {
|
||||||
jvm()
|
jvm()
|
||||||
js {
|
js {
|
||||||
@ -197,39 +190,34 @@ kotlin {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
val nativeMain = if (ideaActive) {
|
|
||||||
val nativeMain by getting {
|
val nativeMain by creating {
|
||||||
dependsOn(commonMain)
|
dependsOn(commonMain)
|
||||||
dependencies {
|
dependencies {
|
||||||
implementation(Deps.Native.coroutines)
|
implementation(Deps.Native.coroutines)
|
||||||
}
|
|
||||||
}
|
}
|
||||||
nativeMain
|
|
||||||
} else {
|
|
||||||
val nativeMain by creating {
|
|
||||||
dependsOn(commonMain)
|
|
||||||
dependencies {
|
|
||||||
implementation(Deps.Native.coroutines)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
nativeMain
|
|
||||||
}
|
}
|
||||||
val nativeTest = if (ideaActive) {
|
|
||||||
val nativeTest by getting {
|
val nativeTest by creating {
|
||||||
dependsOn(commonTest)
|
dependsOn(commonTest)
|
||||||
dependencies {
|
dependencies {
|
||||||
implementation(Deps.Native.coroutines)
|
implementation(Deps.Native.coroutines)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
targets.withType<org.jetbrains.kotlin.gradle.plugin.mpp.KotlinNativeTarget> {
|
||||||
|
compilations.getByName("main") {
|
||||||
|
println("Setting native sourceset dependancy for $name")
|
||||||
|
if (!name.contains("ios")) {
|
||||||
|
defaultSourceSet.dependsOn(nativeMain)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
nativeTest
|
compilations.getByName("test") {
|
||||||
} else {
|
println("Setting native sourceset dependancy for $name")
|
||||||
val nativeTest by creating {
|
if (!name.contains("ios")) {
|
||||||
dependsOn(commonTest)
|
defaultSourceSet.dependsOn(nativeTest)
|
||||||
dependencies {
|
|
||||||
implementation(Deps.Native.coroutines)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
nativeTest
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (hostOsName == "linux") {
|
if (hostOsName == "linux") {
|
||||||
@ -263,9 +251,17 @@ kotlin {
|
|||||||
}
|
}
|
||||||
val linuxMain by getting {
|
val linuxMain by getting {
|
||||||
dependsOn(nativeMain)
|
dependsOn(nativeMain)
|
||||||
|
//Force idea to consider native sourceset
|
||||||
|
if (ideaActive) {
|
||||||
|
kotlin.srcDir("src/nativeMain/kotlin")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
val linuxTest by getting {
|
val linuxTest by getting {
|
||||||
dependsOn(nativeTest)
|
dependsOn(nativeTest)
|
||||||
|
//Force idea to consider native sourceset
|
||||||
|
if (ideaActive) {
|
||||||
|
kotlin.srcDir("src/nativeTest/kotlin")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
//Not supported in coroutines at the moment
|
//Not supported in coroutines at the moment
|
||||||
// val linuxArm32HfpMain by getting {
|
// val linuxArm32HfpMain by getting {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user