More changes to get intellij to reconize cinterop in native sourceset
This commit is contained in:
parent
9c9383d54f
commit
3a81d8e57c
@ -1,11 +1,9 @@
|
||||
import org.apache.tools.ant.taskdefs.condition.Os
|
||||
import org.gradle.api.NamedDomainObjectContainer
|
||||
import org.gradle.nativeplatform.platform.internal.DefaultNativePlatform
|
||||
import org.gradle.nativeplatform.platform.internal.Architectures
|
||||
import org.gradle.nativeplatform.platform.internal.DefaultNativePlatform
|
||||
import org.jetbrains.kotlin.gradle.dsl.KotlinMultiplatformExtension
|
||||
import org.jetbrains.kotlin.gradle.plugin.KotlinDependencyHandler
|
||||
import org.jetbrains.kotlin.gradle.plugin.KotlinSourceSet
|
||||
import java.lang.RuntimeException
|
||||
|
||||
/**
|
||||
* Created by Ugljesa Jovanovic
|
||||
@ -25,7 +23,7 @@ fun getHostOsName(): String {
|
||||
}
|
||||
|
||||
fun getHostArchitecture(): String {
|
||||
val architecture =System.getProperty("os.arch")
|
||||
val architecture = System.getProperty("os.arch")
|
||||
DefaultNativePlatform.getCurrentArchitecture()
|
||||
println("Arch: $architecture")
|
||||
val resolvedArch = Architectures.forInput(architecture).name
|
||||
@ -33,42 +31,49 @@ fun getHostArchitecture(): String {
|
||||
return resolvedArch
|
||||
}
|
||||
|
||||
fun KotlinMultiplatformExtension.isRunningInIdea(block : KotlinMultiplatformExtension.() -> Unit) {
|
||||
fun KotlinMultiplatformExtension.isRunningInIdea(block: KotlinMultiplatformExtension.() -> Unit) {
|
||||
if (isInIdea()) {
|
||||
block(this)
|
||||
}
|
||||
}
|
||||
|
||||
fun KotlinMultiplatformExtension.runningOnLinuxx86_64(block : KotlinMultiplatformExtension.() -> Unit) {
|
||||
fun KotlinMultiplatformExtension.isNotRunningInIdea(block: KotlinMultiplatformExtension.() -> Unit) {
|
||||
if (!isInIdea()) {
|
||||
block(this)
|
||||
}
|
||||
}
|
||||
|
||||
fun KotlinMultiplatformExtension.runningOnLinuxx86_64(block: KotlinMultiplatformExtension.() -> Unit) {
|
||||
if (getHostOsName() == "linux" && getHostArchitecture() == "x86-64") {
|
||||
block(this)
|
||||
}
|
||||
}
|
||||
|
||||
fun KotlinMultiplatformExtension.runningOnLinuxArm64(block : KotlinMultiplatformExtension.() -> Unit) {
|
||||
fun KotlinMultiplatformExtension.runningOnLinuxArm64(block: KotlinMultiplatformExtension.() -> Unit) {
|
||||
if (getHostOsName() == "linux" && getHostArchitecture() == "aarch64") {
|
||||
block(this)
|
||||
}
|
||||
}
|
||||
|
||||
fun KotlinMultiplatformExtension.runningOnLinuxArm32(block : KotlinMultiplatformExtension.() -> Unit) {
|
||||
fun KotlinMultiplatformExtension.runningOnLinuxArm32(block: KotlinMultiplatformExtension.() -> Unit) {
|
||||
if (getHostOsName() == "linux" && getHostArchitecture() == "arm-v7") {
|
||||
block(this)
|
||||
}
|
||||
}
|
||||
|
||||
fun KotlinMultiplatformExtension.runningOnMacos(block : KotlinMultiplatformExtension.() -> Unit) {
|
||||
fun KotlinMultiplatformExtension.runningOnMacos(block: KotlinMultiplatformExtension.() -> Unit) {
|
||||
if (getHostOsName() == "macos") {
|
||||
block(this)
|
||||
}
|
||||
}
|
||||
|
||||
fun KotlinMultiplatformExtension.runningOnWindows(block : KotlinMultiplatformExtension.() -> Unit) {
|
||||
fun KotlinMultiplatformExtension.runningOnWindows(block: KotlinMultiplatformExtension.() -> Unit) {
|
||||
if (getHostOsName() == "windows") {
|
||||
block(this)
|
||||
}
|
||||
}
|
||||
fun independentDependencyBlock(nativeDeps : KotlinDependencyHandler.() -> Unit) : KotlinDependencyHandler.() -> Unit {
|
||||
|
||||
fun independentDependencyBlock(nativeDeps: KotlinDependencyHandler.() -> Unit): KotlinDependencyHandler.() -> Unit {
|
||||
return nativeDeps
|
||||
}
|
||||
|
||||
@ -78,11 +83,17 @@ fun independentDependencyBlock(nativeDeps : KotlinDependencyHandler.() -> Unit)
|
||||
* an intermediary source set with the same set of dependancies
|
||||
*
|
||||
*/
|
||||
fun NamedDomainObjectContainer<KotlinSourceSet>.createWorkaroundNativeMainSourceSet(name : String, nativeDeps : KotlinDependencyHandler.() -> Unit) : KotlinSourceSet {
|
||||
fun NamedDomainObjectContainer<KotlinSourceSet>.createWorkaroundNativeMainSourceSet(
|
||||
name: String,
|
||||
nativeDeps: KotlinDependencyHandler.() -> Unit
|
||||
): KotlinSourceSet {
|
||||
|
||||
return create("${name}Workaround") {
|
||||
kotlin.srcDir("src/nativeMain")
|
||||
dependencies {
|
||||
nativeDeps.invoke(this)
|
||||
if (!isInIdea()) {
|
||||
kotlin.srcDir("src/nativeMain")
|
||||
dependencies {
|
||||
nativeDeps.invoke(this)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
201
multiplatform-crypto-api/package-lock.json
generated
201
multiplatform-crypto-api/package-lock.json
generated
@ -1,201 +0,0 @@
|
||||
{
|
||||
"name": "kotlin-multiplatform-crypto-js",
|
||||
"version": "0.0.1",
|
||||
"lockfileVersion": 1,
|
||||
"requires": true,
|
||||
"dependencies": {
|
||||
"balanced-match": {
|
||||
"version": "1.0.0",
|
||||
"resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.0.tgz",
|
||||
"integrity": "sha1-ibTRmasr7kneFk6gK4nORi1xt2c=",
|
||||
"dev": true
|
||||
},
|
||||
"brace-expansion": {
|
||||
"version": "1.1.11",
|
||||
"resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz",
|
||||
"integrity": "sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"balanced-match": "^1.0.0",
|
||||
"concat-map": "0.0.1"
|
||||
}
|
||||
},
|
||||
"browser-stdout": {
|
||||
"version": "1.3.1",
|
||||
"resolved": "https://registry.npmjs.org/browser-stdout/-/browser-stdout-1.3.1.tgz",
|
||||
"integrity": "sha512-qhAVI1+Av2X7qelOfAIYwXONood6XlZE/fXaBSmW/T5SzLAmCgzi+eiWE7fUvbHaeNBQH13UftjpXxsfLkMpgw==",
|
||||
"dev": true
|
||||
},
|
||||
"commander": {
|
||||
"version": "2.15.1",
|
||||
"resolved": "https://registry.npmjs.org/commander/-/commander-2.15.1.tgz",
|
||||
"integrity": "sha512-VlfT9F3V0v+jr4yxPc5gg9s62/fIVWsd2Bk2iD435um1NlGMYdVCq+MjcXnhYq2icNOizHr1kK+5TI6H0Hy0ag==",
|
||||
"dev": true
|
||||
},
|
||||
"concat-map": {
|
||||
"version": "0.0.1",
|
||||
"resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz",
|
||||
"integrity": "sha1-2Klr13/Wjfd5OnMDajug1UBdR3s=",
|
||||
"dev": true
|
||||
},
|
||||
"debug": {
|
||||
"version": "3.1.0",
|
||||
"resolved": "https://registry.npmjs.org/debug/-/debug-3.1.0.tgz",
|
||||
"integrity": "sha512-OX8XqP7/1a9cqkxYw2yXss15f26NKWBpDXQd0/uK/KPqdQhxbPa994hnzjcE2VqQpDslf55723cKPUOGSmMY3g==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"ms": "2.0.0"
|
||||
}
|
||||
},
|
||||
"diff": {
|
||||
"version": "3.5.0",
|
||||
"resolved": "https://registry.npmjs.org/diff/-/diff-3.5.0.tgz",
|
||||
"integrity": "sha512-A46qtFgd+g7pDZinpnwiRJtxbC1hpgf0uzP3iG89scHk0AUC7A1TGxf5OiiOUv/JMZR8GOt8hL900hV0bOy5xA==",
|
||||
"dev": true
|
||||
},
|
||||
"escape-string-regexp": {
|
||||
"version": "1.0.5",
|
||||
"resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-1.0.5.tgz",
|
||||
"integrity": "sha1-G2HAViGQqN/2rjuyzwIAyhMLhtQ=",
|
||||
"dev": true
|
||||
},
|
||||
"fs.realpath": {
|
||||
"version": "1.0.0",
|
||||
"resolved": "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz",
|
||||
"integrity": "sha1-FQStJSMVjKpA20onh8sBQRmU6k8=",
|
||||
"dev": true
|
||||
},
|
||||
"glob": {
|
||||
"version": "7.1.2",
|
||||
"resolved": "https://registry.npmjs.org/glob/-/glob-7.1.2.tgz",
|
||||
"integrity": "sha512-MJTUg1kjuLeQCJ+ccE4Vpa6kKVXkPYJ2mOCQyUuKLcLQsdrMCpBPUi8qVE6+YuaJkozeA9NusTAw3hLr8Xe5EQ==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"fs.realpath": "^1.0.0",
|
||||
"inflight": "^1.0.4",
|
||||
"inherits": "2",
|
||||
"minimatch": "^3.0.4",
|
||||
"once": "^1.3.0",
|
||||
"path-is-absolute": "^1.0.0"
|
||||
}
|
||||
},
|
||||
"growl": {
|
||||
"version": "1.10.5",
|
||||
"resolved": "https://registry.npmjs.org/growl/-/growl-1.10.5.tgz",
|
||||
"integrity": "sha512-qBr4OuELkhPenW6goKVXiv47US3clb3/IbuWF9KNKEijAy9oeHxU9IgzjvJhHkUzhaj7rOUD7+YGWqUjLp5oSA==",
|
||||
"dev": true
|
||||
},
|
||||
"has-flag": {
|
||||
"version": "3.0.0",
|
||||
"resolved": "https://registry.npmjs.org/has-flag/-/has-flag-3.0.0.tgz",
|
||||
"integrity": "sha1-tdRU3CGZriJWmfNGfloH87lVuv0=",
|
||||
"dev": true
|
||||
},
|
||||
"he": {
|
||||
"version": "1.1.1",
|
||||
"resolved": "https://registry.npmjs.org/he/-/he-1.1.1.tgz",
|
||||
"integrity": "sha1-k0EP0hsAlzUVH4howvJx80J+I/0=",
|
||||
"dev": true
|
||||
},
|
||||
"inflight": {
|
||||
"version": "1.0.6",
|
||||
"resolved": "https://registry.npmjs.org/inflight/-/inflight-1.0.6.tgz",
|
||||
"integrity": "sha1-Sb1jMdfQLQwJvJEKEHW6gWW1bfk=",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"once": "^1.3.0",
|
||||
"wrappy": "1"
|
||||
}
|
||||
},
|
||||
"inherits": {
|
||||
"version": "2.0.4",
|
||||
"resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.4.tgz",
|
||||
"integrity": "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==",
|
||||
"dev": true
|
||||
},
|
||||
"kotlin": {
|
||||
"version": "1.3.40",
|
||||
"resolved": "https://registry.npmjs.org/kotlin/-/kotlin-1.3.40.tgz",
|
||||
"integrity": "sha512-3l718c3QznxsFNUrnsyGworQZrczyzKRhf+Rx/+7XhSS95S/QrCnlUVuEXA1l9iJpfxx4t9Ecc7+jC1JD28aYg=="
|
||||
},
|
||||
"minimatch": {
|
||||
"version": "3.0.4",
|
||||
"resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.0.4.tgz",
|
||||
"integrity": "sha512-yJHVQEhyqPLUTgt9B83PXu6W3rx4MvvHvSUvToogpwoGDOUQ+yDrR0HRot+yOCdCO7u4hX3pWft6kWBBcqh0UA==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"brace-expansion": "^1.1.7"
|
||||
}
|
||||
},
|
||||
"minimist": {
|
||||
"version": "0.0.8",
|
||||
"resolved": "https://registry.npmjs.org/minimist/-/minimist-0.0.8.tgz",
|
||||
"integrity": "sha1-hX/Kv8M5fSYluCKCYuhqp6ARsF0=",
|
||||
"dev": true
|
||||
},
|
||||
"mkdirp": {
|
||||
"version": "0.5.1",
|
||||
"resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-0.5.1.tgz",
|
||||
"integrity": "sha1-MAV0OOrGz3+MR2fzhkjWaX11yQM=",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"minimist": "0.0.8"
|
||||
}
|
||||
},
|
||||
"mocha": {
|
||||
"version": "5.2.0",
|
||||
"resolved": "https://registry.npmjs.org/mocha/-/mocha-5.2.0.tgz",
|
||||
"integrity": "sha512-2IUgKDhc3J7Uug+FxMXuqIyYzH7gJjXECKe/w43IGgQHTSj3InJi+yAA7T24L9bQMRKiUEHxEX37G5JpVUGLcQ==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"browser-stdout": "1.3.1",
|
||||
"commander": "2.15.1",
|
||||
"debug": "3.1.0",
|
||||
"diff": "3.5.0",
|
||||
"escape-string-regexp": "1.0.5",
|
||||
"glob": "7.1.2",
|
||||
"growl": "1.10.5",
|
||||
"he": "1.1.1",
|
||||
"minimatch": "3.0.4",
|
||||
"mkdirp": "0.5.1",
|
||||
"supports-color": "5.4.0"
|
||||
}
|
||||
},
|
||||
"ms": {
|
||||
"version": "2.0.0",
|
||||
"resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz",
|
||||
"integrity": "sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g=",
|
||||
"dev": true
|
||||
},
|
||||
"once": {
|
||||
"version": "1.4.0",
|
||||
"resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz",
|
||||
"integrity": "sha1-WDsap3WWHUsROsF9nFC6753Xa9E=",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"wrappy": "1"
|
||||
}
|
||||
},
|
||||
"path-is-absolute": {
|
||||
"version": "1.0.1",
|
||||
"resolved": "https://registry.npmjs.org/path-is-absolute/-/path-is-absolute-1.0.1.tgz",
|
||||
"integrity": "sha1-F0uSaHNVNP+8es5r9TpanhtcX18=",
|
||||
"dev": true
|
||||
},
|
||||
"supports-color": {
|
||||
"version": "5.4.0",
|
||||
"resolved": "https://registry.npmjs.org/supports-color/-/supports-color-5.4.0.tgz",
|
||||
"integrity": "sha512-zjaXglF5nnWpsq470jSv6P9DwPvgLkuapYmfDm3JWOm0vkNTVF2tI4UrN2r6jH1qM/uc/WtxYY1hYoA2dOKj5w==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"has-flag": "^3.0.0"
|
||||
}
|
||||
},
|
||||
"wrappy": {
|
||||
"version": "1.0.2",
|
||||
"resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz",
|
||||
"integrity": "sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8=",
|
||||
"dev": true
|
||||
}
|
||||
}
|
||||
}
|
@ -1,15 +0,0 @@
|
||||
{
|
||||
"name": "kotlin-multiplatform-crypto-js",
|
||||
"version": "0.0.1",
|
||||
"description": "Kotlin Multiplatform Crypto",
|
||||
"main": "crypto.js",
|
||||
"author": "Ugljesa Jovanovic",
|
||||
"license": "Apache 2.0",
|
||||
"homepage": "",
|
||||
"dependencies": {
|
||||
"kotlin": "1.3.40"
|
||||
},
|
||||
"devDependencies": {
|
||||
"mocha": "5.2.0"
|
||||
}
|
||||
}
|
@ -17,9 +17,9 @@
|
||||
|
||||
@file:Suppress("UnstableApiUsage")
|
||||
|
||||
import org.jetbrains.kotlin.gradle.plugin.mpp.KotlinNativeTarget
|
||||
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
|
||||
|
||||
plugins {
|
||||
kotlin(PluginsDeps.multiplatform)
|
||||
@ -77,6 +77,15 @@ kotlin {
|
||||
|
||||
}
|
||||
linuxX64() {
|
||||
compilations.getByName("main") {
|
||||
val libsodiumCinterop by cinterops.creating {
|
||||
defFile(project.file("src/nativeInterop/cinterop/libsodium.def"))
|
||||
compilerOpts.add("-I${project.rootDir}/sodiumWrapper/static-linux-x86-64/include/")
|
||||
}
|
||||
kotlinOptions.freeCompilerArgs = listOf(
|
||||
"-include-binary", "${project.rootDir}/sodiumWrapper/static-linux-x86-64/lib/libsodium.a"
|
||||
)
|
||||
}
|
||||
binaries {
|
||||
staticLib {
|
||||
}
|
||||
@ -314,18 +323,15 @@ kotlin {
|
||||
compilations.getByName("main") {
|
||||
if (linux64Bit.contains(this@withType.name)) {
|
||||
defaultSourceSet.dependsOn(nativeMain)
|
||||
compilations.getByName("main") {
|
||||
val libsodiumCinterop by cinterops.creating {
|
||||
defFile(project.file("src/nativeInterop/cinterop/libsodium.def"))
|
||||
compilerOpts.add("-I${project.rootDir}/sodiumWrapper/static-linux-x86-64/include/")
|
||||
}
|
||||
kotlinOptions.freeCompilerArgs = listOf(
|
||||
"-include-binary", "${project.rootDir}/sodiumWrapper/static-linux-x86-64/lib/libsodium.a"
|
||||
)
|
||||
}
|
||||
}
|
||||
if (linuxArm64Bit.contains(this@withType.name)) {
|
||||
defaultSourceSet.dependsOn(createWorkaroundNativeMainSourceSet(this@withType.name, nativeDependencies))
|
||||
defaultSourceSet.dependsOn(
|
||||
createWorkaroundNativeMainSourceSet(
|
||||
this@withType.name,
|
||||
nativeDependencies
|
||||
)
|
||||
)
|
||||
|
||||
compilations.getByName("main") {
|
||||
val libsodiumCinterop by cinterops.creating {
|
||||
defFile(project.file("src/nativeInterop/cinterop/libsodium.def"))
|
||||
@ -440,13 +446,13 @@ kotlin {
|
||||
}
|
||||
val linuxX64Main by getting {
|
||||
isRunningInIdea {
|
||||
kotlin.srcDir("src/nativeMain")
|
||||
kotlin.srcDir("src/nativeMain/kotlin")
|
||||
}
|
||||
}
|
||||
val linuxX64Test by getting {
|
||||
dependsOn(nativeTest)
|
||||
isRunningInIdea {
|
||||
kotlin.srcDir("src/nativeTest")
|
||||
kotlin.srcDir("src/nativeTest/kotlin")
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -0,0 +1,9 @@
|
||||
package com.ionspin.kotlin.crypto.hash.sha
|
||||
|
||||
/**
|
||||
* Created by Ugljesa Jovanovic
|
||||
* ugljesa.jovanovic@ionspin.com
|
||||
* on 07-Jun-2020
|
||||
*/
|
||||
import platform.posix.*
|
||||
//import cin
|
@ -33,6 +33,7 @@ actual object Sha256StatelessDelegated : StatelessSha256 {
|
||||
override fun digest(inputMessage: UByteArray): UByteArray {
|
||||
val hashResult = UByteArray(Blake2bDelegatedStateless.MAX_HASH_BYTES)
|
||||
val hashResultPinned = hashResult.pin()
|
||||
// crypto_
|
||||
TODO("not implemented yet")
|
||||
}
|
||||
|
||||
|
@ -178,6 +178,9 @@ kotlin {
|
||||
dependencies {
|
||||
implementation(Deps.Native.coroutines)
|
||||
}
|
||||
isRunningInIdea {
|
||||
kotlin.setSrcDirs(emptySet<String>())
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -249,7 +252,7 @@ kotlin {
|
||||
}
|
||||
val linuxTest by getting {
|
||||
dependsOn(nativeTest)
|
||||
//Force idea to consider native sourceset
|
||||
// Force idea to consider native sourceset
|
||||
if (ideaActive) {
|
||||
kotlin.srcDir("src/nativeTest/kotlin")
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user