Get a stub iOS library building (#535)

This commit is contained in:
Ben Bader 2023-02-22 10:48:40 -07:00 коммит произвёл GitHub
Родитель dba7318837
Коммит 1c73729b0c
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
6 изменённых файлов: 238 добавлений и 7 удалений

2
gradle/wrapper/gradle-wrapper.properties поставляемый
Просмотреть файл

@ -1,6 +1,6 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.0-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.0.1-bin.zip
networkTimeout=10000
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists

Просмотреть файл

@ -15,6 +15,37 @@ dependencyResolutionManagement {
mavenLocal()
mavenCentral()
gradlePluginPortal()
// workaround for https://youtrack.jetbrains.com/issue/KT-51379
exclusiveContent {
forRepository {
ivy {
url = "https://download.jetbrains.com/kotlin/native/builds"
name = "Kotlin Native"
patternLayout {
// example download URLs:
// https://download.jetbrains.com/kotlin/native/builds/releases/1.7.20/linux-x86_64/kotlin-native-prebuilt-linux-x86_64-1.7.20.tar.gz
// https://download.jetbrains.com/kotlin/native/builds/releases/1.7.20/windows-x86_64/kotlin-native-prebuilt-windows-x86_64-1.7.20.zip
// https://download.jetbrains.com/kotlin/native/builds/releases/1.7.20/macos-x86_64/kotlin-native-prebuilt-macos-x86_64-1.7.20.tar.gz
[
"macos-x86_64",
"macos-aarch64",
"osx-x86_64",
"osx-aarch64",
"linux-x86_64",
"windows-x86_64",
].forEach { os ->
["dev", "releases"].forEach { stage ->
artifact("$stage/[revision]/$os/[artifact]-[revision].[ext]")
}
}
}
metadataSources { artifact() }
}
}
filter { includeModuleByRegex(".*", ".*kotlin-native-prebuilt.*") }
}
}
}

Просмотреть файл

@ -20,7 +20,9 @@
*/
import org.gradle.api.attributes.java.TargetJvmVersion
import org.jetbrains.kotlin.gradle.dsl.JvmTarget
import org.jetbrains.kotlin.gradle.plugin.KotlinPlatformType
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
plugins {
id 'thrifty-mpp-module'
@ -29,17 +31,29 @@ plugins {
description = 'Provides a minimal Thrift runtime to support classes generated by Thrifty'
tasks.withType(org.jetbrains.kotlin.gradle.tasks.KotlinCompile).configureEach {
kotlinOptions {
jvmTarget = '1.8'
tasks.withType(KotlinCompile).configureEach {
compilerOptions {
jvmTarget = JvmTarget.JVM_1_8
freeCompilerArgs = ['-Xjvm-default=all']
}
}
kotlin {
jvm {
compilations.main.kotlinOptions {
jvmTarget = "1.8"
jvm()
iosArm64 {
binaries {
framework {
baseName = "Thrifty"
}
}
}
iosX64 {
binaries {
framework {
baseName = "Thrifty"
}
}
}
@ -77,6 +91,30 @@ kotlin {
implementation libs.junit
}
}
iosMain {
dependsOn commonMain
}
iosTest {
dependsOn commonTest
}
iosArm64Main {
dependsOn iosMain
}
iosArm64Test {
dependsOn iosTest
}
iosX64Main {
dependsOn iosMain
}
iosX64Test {
dependsOn iosTest
}
}
}

Просмотреть файл

@ -0,0 +1,47 @@
/*
* Thrifty
*
* Copyright (c) Microsoft Corporation
*
* All rights reserved.
*
* 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
*
* THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR
* CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING
* WITHOUT LIMITATION ANY IMPLIED WARRANTIES OR CONDITIONS OF TITLE,
* FITNESS FOR A PARTICULAR PURPOSE, MERCHANTABLITY OR NON-INFRINGEMENT.
*
* See the Apache Version 2.0 License for specific language governing permissions and limitations under the License.
*/
package com.microsoft.thrifty.internal
actual class AtomicBoolean actual constructor(
initialValue: Boolean
) {
private val actualAtomicBool = kotlin.native.concurrent.AtomicInt(if (initialValue) 1 else 0)
actual fun get(): Boolean {
return actualAtomicBool.value == 1
}
actual fun compareAndSet(expected: Boolean, update: Boolean): Boolean {
val expectedNum = if (expected) 1 else 0
val updateNum = if (update) 1 else 0
return actualAtomicBool.compareAndSet(expectedNum, updateNum)
}
}
actual class AtomicInteger actual constructor(
initialValue: Int
) {
private val actualAtomicInt = kotlin.native.concurrent.AtomicInt(initialValue)
actual fun get(): Int = actualAtomicInt.value
actual fun incrementAndGet(): Int = actualAtomicInt.addAndGet(1)
}

Просмотреть файл

@ -0,0 +1,28 @@
/*
* Thrifty
*
* Copyright (c) Microsoft Corporation
*
* All rights reserved.
*
* 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
*
* THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR
* CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING
* WITHOUT LIMITATION ANY IMPLIED WARRANTIES OR CONDITIONS OF TITLE,
* FITNESS FOR A PARTICULAR PURPOSE, MERCHANTABLITY OR NON-INFRINGEMENT.
*
* See the Apache Version 2.0 License for specific language governing permissions and limitations under the License.
*/
package com.microsoft.thrifty.internal
import kotlinx.coroutines.Dispatchers
import okio.IOException
actual class ProtocolException actual constructor(message: String) : IOException(message)
actual val DefaultDispatcher: kotlinx.coroutines.CoroutineDispatcher = Dispatchers.Default

Просмотреть файл

@ -0,0 +1,87 @@
/*
* Thrifty
*
* Copyright (c) Microsoft Corporation
*
* All rights reserved.
*
* 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
*
* THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR
* CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING
* WITHOUT LIMITATION ANY IMPLIED WARRANTIES OR CONDITIONS OF TITLE,
* FITNESS FOR A PARTICULAR PURPOSE, MERCHANTABLITY OR NON-INFRINGEMENT.
*
* See the Apache Version 2.0 License for specific language governing permissions and limitations under the License.
*/
package com.microsoft.thrifty.service
import com.microsoft.thrifty.Struct
import com.microsoft.thrifty.ThriftException
import com.microsoft.thrifty.protocol.Protocol
import okio.Closeable
/**
* Implements a basic service client that executes methods asynchronously.
*
* Note that, while the client-facing API of this class is callback-based,
* the implementation itself is **blocking**. Unlike the Apache
* implementation, there is no presumption made here about framed encoding
* at the transport level. If your backend requires framing, be sure to
* configure your [Protocol] and [com.microsoft.thrifty.transport.Transport]
* objects appropriately.
*/
@Suppress("UNCHECKED_CAST")
actual open class AsyncClientBase protected actual constructor(
protocol: Protocol,
private val listener: Listener
) : ClientBase(protocol), Closeable {
/**
* Exposes important events in the client's lifecycle.
*/
actual interface Listener {
/**
* Invoked when the client connection has been closed.
*
*
* After invocation, the client is no longer usable. All subsequent
* method call attempts will result in an immediate exception on the
* calling thread.
*/
actual fun onTransportClosed()
/**
* Invoked when a client-level error has occurred.
*
*
* This generally indicates a connectivity or protocol error,
* and is distinct from errors returned as part of normal service
* operation.
*
*
* The client is guaranteed to have been closed and shut down
* by the time this method is invoked.
*
* @param error the throwable instance representing the error.
*/
actual fun onError(error: Throwable)
}
/**
* When invoked by a derived instance, places the given call in a queue to
* be sent to the server.
*
* @param methodCall the remote method call to be invoked
*/
protected actual fun enqueue(methodCall: MethodCall<*>) {
TODO()
}
override fun close() {
TODO()
}
}