Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
75 commits
Select commit Hold shift + click to select a range
1eed578
Add pure kotlin runtime implementation
Mar 5, 2020
5fd8e94
Add kotlin native protoc gen
Mar 5, 2020
734280b
Add conformance-native
Mar 5, 2020
2f13e3d
Move Util to new folder tree
Apr 1, 2020
b03b1e4
Add iOS target
Apr 1, 2020
c87db29
Add use experimental to ByteArr deserialize function
Apr 1, 2020
7cd01e4
Fix rebase errors
Apr 2, 2020
fa05b3e
Update Kotlin and serialization version to latest
Apr 3, 2020
53d5022
Refactor sourcetsets and create native
Apr 4, 2020
567cf35
Move iOSMain to nativeMain
Apr 4, 2020
cf81d7f
Merge branch 'streem/master' into kotlin-native
Apr 4, 2020
ef0a1e8
Fix strict mode being spread into multiple values
Apr 4, 2020
08de644
Change StringDescription to Primitive of kind String
Apr 4, 2020
ae5a691
Temp fix for Kotlin DCE
Apr 6, 2020
4f7ee52
Refactor build.gradle.kts to use by getting
Apr 6, 2020
ed55104
Remove un-necessary import
Apr 6, 2020
7a50d6c
Add ios and macos source sets witn dependance on native
Apr 6, 2020
80b1567
Move conformance native under macosX64
Apr 6, 2020
c3c7fa3
Add native conformance exe with list of failing tests from JVM
Apr 6, 2020
68fae4f
Add native conformance tests to script
Apr 7, 2020
814a092
Add protoc-gen-kotlin macos implementation and gradle file update
Apr 8, 2020
2a94125
Add protoc-gen-kotlin macos (not fully working)
Apr 8, 2020
ac0ca1a
Change CI config to execute conformance tests
Apr 8, 2020
c51c011
Try to fix circleci config
Apr 8, 2020
5992dec
Update README file with native support
Apr 8, 2020
d061e1b
Create native executor
Apr 28, 2020
610c490
Disable gradle daemon for all builds (faster build time)
Apr 28, 2020
6befbec
Fix alignment in config.yml
Apr 28, 2020
36564b5
Use simple ubuntu base image for native tests
Apr 29, 2020
684dd2f
Remove protoc-gen-kotlin macos
Apr 29, 2020
fa70c5e
Create both arm and x64 ios source sets
Apr 29, 2020
e70a5ea
Use by creating in build.gradle
Apr 29, 2020
26997c1
Enable linux sourceset on runtime
May 4, 2020
104ae1b
Enable native conformance tests
May 4, 2020
0a295d4
Build native to generate executables
May 5, 2020
57b8337
Execute linux conformance and keep the right executable
May 5, 2020
bd32a42
Merge branch 'streem/master' into kotlin-native
Jun 10, 2020
e1cbee4
Fix post-merge changes
Jun 10, 2020
adbd2ee
Fix README
Jun 10, 2020
f94dde5
Use variable to make sure both targets outputs have the same name
Jun 10, 2020
ebf362b
Point Linux conformance test to right executable
Jun 10, 2020
b89c049
Fix pbandk version
Jun 10, 2020
6cf47db
Move dependency to common
Jun 10, 2020
7fd6b4d
Remove macos target in protoc-gen-kotlin
Jun 10, 2020
430cb25
Add space
Jun 10, 2020
2bb582e
Remove this with dependencies
Jun 10, 2020
79e107c
Fix readme with right task to execute
Jun 10, 2020
1d02a71
Move zigzagencode functions to extension file
Jun 10, 2020
ee5223f
Use rawBits for float and double values as per protobuf-java implemen…
Jun 10, 2020
348ff2e
Make Wireformat internal
Jun 10, 2020
8e77bb5
Move comment
Jun 10, 2020
07c6f10
Rename Util to UtilImpl
Jun 10, 2020
e12d0b0
Rename UtilInteface to Util
Jun 10, 2020
c069df6
Rename Sizer to SizerImpl
Jun 10, 2020
4afa11e
Rename SizerInterface to Sizer
Jun 10, 2020
540837b
Refactor fun getTotalBytesRead to property totalBytesRead
Jun 10, 2020
3f2e4b6
Remove try/catch because we rethrow the exception
Jun 11, 2020
353a164
Revert code
Jun 11, 2020
b854389
Use high/low surrogate functions on chars
Jun 11, 2020
9f3aaeb
Throw NoSuchElementException when element doesn't exists
Jun 11, 2020
3b7e94c
Remove interface used only in impl code
Jun 11, 2020
70eabd4
Remove full implementation of string to bytearray conversion with stdlib
Jun 12, 2020
5b1e446
Remove unnecessary function
Jun 12, 2020
a8e7979
Correctly handle errors while not reading/writing bytes
Jun 15, 2020
bfe2f8a
Correctly encode/decode strings in base64
Jun 15, 2020
089b660
More PR feedback
garyp Jul 26, 2020
0505ba9
Update well-known types and other protos
garyp Jul 27, 2020
c2aaa81
Rename UtilImpl and SizerImpl back to Util and Sizer
garyp Jul 27, 2020
7eab015
Add native dependencies to CI cache
garyp Jul 27, 2020
384fb87
Get native conformance binaries building correctly
garyp Jul 27, 2020
c5ad010
update examples
garyp Jul 27, 2020
e092ec8
Fix K/N compiler error in CI
garyp Jul 27, 2020
148a1ba
Timestamp formatting/parsing on native
garyp Jul 31, 2020
74c0a3a
More PR feedback
garyp Aug 2, 2020
945347b
Merge pull request #3 from streem/garyp/kotlin-native
Aug 5, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
76 changes: 48 additions & 28 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
#
version: 2.1


executors:
jvm:
docker:
Expand All @@ -17,6 +16,32 @@ executors:
docker:
- image: circleci/node:lts

native:
docker:
- image: cimg/base:2020.01

commands:

conformance_test:
parameters:
target:
description: Target platform for which to run conformance tests
type: string

steps:
- attach_workspace:
at: ~/project

- restore_cache:
name: Restore protobuf cache
keys:
- v3-protobuf-3.10.1

- run:
name: Run << parameters.target >> conformance tests
command: |
export CONF_TEST_PATH=~/protobuf/conformance/conformance-test-runner
./conformance/test-conformance.sh << parameters.target >>

jobs:

Expand All @@ -27,6 +52,10 @@ jobs:
steps:
- checkout

- run:
name: Install Kotlin/Native compiler dependencies
command: sudo apt update && sudo apt install libncurses5

- run:
name: Collect files for dependencies cache key
command: |
Expand Down Expand Up @@ -105,7 +134,7 @@ jobs:

- run:
name: Build conformance test suite
command: ./gradlew :conformance:lib:assemble :conformance:jvm:installDist
command: ./gradlew :conformance:lib:assemble :conformance:jvm:installDist :conformance:native:build

# persist files necessary to run conformance tests
- persist_to_workspace:
Expand All @@ -119,11 +148,15 @@ jobs:
- build/js
- conformance/js/failing_tests.txt
- conformance/js/run.sh
# native
- conformance/native/build/bin/linux/conformanceReleaseExecutable/conformance.kexe
- conformance/native/failing_tests.txt

- save_cache:
name: Save dependencies cache
paths:
- ~/.gradle
- ~/.konan
key: v2-dependencies-{{ checksum "/tmp/circleci_cache_key" }}
when: always

Expand All @@ -133,40 +166,24 @@ jobs:
name: jvm

steps:
- attach_workspace:
at: ~/project

- restore_cache:
name: Restore protobuf cache
keys:
- v3-protobuf-3.10.1

- run:
name: Run JVM conformance tests
command: |
export CONF_TEST_PATH=~/protobuf/conformance/conformance-test-runner
./conformance/test-conformance.sh jvm

- conformance_test:
target: jvm

conformance_js:
executor:
name: nodejs

steps:
- attach_workspace:
at: ~/project

- restore_cache:
name: Restore protobuf cache
keys:
- v3-protobuf-3.10.1
- conformance_test:
target: js

- run:
name: Run JS conformance tests
command: |
export CONF_TEST_PATH=~/protobuf/conformance/conformance-test-runner
./conformance/test-conformance.sh js
conformance_native:
executor:
name: native

steps:
- conformance_test:
target: linux

build_examples:
executor:
Expand Down Expand Up @@ -228,6 +245,9 @@ workflows:
- conformance_js:
requires:
- build
- conformance_native:
requires:
- build
- build_examples:
requires:
- build
22 changes: 13 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ It is built to work across multiple Kotlin platforms.
**Features**

* Clean data class generation
* Works for JVM and JS
* Works for JVM, JS and Native
* Support for proto2 and proto3 syntaxes
* Oneof's are properly handled as sealed classes
* Specialized support to handle wrappers from the well-known types (e.g. `StringValue`, `BoolValue`) as nullable primitives (`String?`, `Boolean?`, etc.)
Expand All @@ -21,8 +21,6 @@ It is built to work across multiple Kotlin platforms.

**Not Yet Implemented**

* Kotlin Native runtime support
* Protobuf code generator in Kotlin Native for easier importing
* Specialized support for more of the well known types (e.g. `Any`)
* Support for protobuf annotations
* Access to the protobuf descriptor from generated code
Expand Down Expand Up @@ -234,7 +232,15 @@ Then the dependency can be added for JVM libraries:

```
dependencies {
implementation 'com.github.streem.pbandk:pbandk-runtime-jvm:0.8.1'
implementation 'com.github.streem.pbandk:pbandk-runtime-jvm:0.9.0-SNAPSHOT'
}
```

or for the Native libraries:

```
dependencies {
implementation "com.github.streem.pbandk:pbandk-runtime-native:0.9.0-SNAPSHOT
}
```

Expand All @@ -253,7 +259,7 @@ runtime:

```
dependencies {
compileOnly 'com.github.streem.pbandk:protoc-gen-kotlin-lib-jvm:0.8.1'
compileOnly 'com.github.streem.pbandk:protoc-gen-kotlin-jvm:0.9.0-SNAPSHOT'
}
```

Expand Down Expand Up @@ -433,12 +439,10 @@ Set the `CONF_TEST_PATH` environment variable (used to run the tests below) with
export CONF_TEST_PATH="$(pwd)/conformance-test-runner"
```

Now, back in `pbandk`, build both the JS and JVM projects via:
Now, back in `pbandk`, build all JS. JVM and native projects via:

```
./gradlew \
:conformance:lib:assemble
:conformance:jvm:installDist
./gradlew :conformance:lib:assemble :conformance:jvm:installDist :conformance:native:build
```

You are now ready to run the conformance tests. Make sure `CONF_TEST_PATH` environment variable is set to `path/to/protobuf/conformance/conformance-test-runner` (see above).
Expand Down
2 changes: 1 addition & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ plugins {

allprojects {
group = "com.github.streem.pbandk"
version = "0.8.2-SNAPSHOT"
version = "0.9.0-SNAPSHOT"

repositories {
jcenter()
Expand Down
28 changes: 18 additions & 10 deletions conformance/lib/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import org.jetbrains.kotlin.gradle.plugin.mpp.KotlinNativeTarget

plugins {
kotlin("multiplatform")
kotlin("plugin.serialization")
Expand All @@ -18,11 +20,22 @@ kotlin {
nodejs {}
}

// For ARM, should be changed to iosArm32 or iosArm64
// For Linux, should be changed to e.g. linuxX64
// For MacOS, should be changed to e.g. macosX64
// For Windows, should be changed to e.g. mingwX64
// macosX64("macos")
macosX64("macos")
linuxX64("linux")
// Uncomment to enable Windows
// mingwX64("windows")

targets.withType<KotlinNativeTarget> {
val main by compilations.getting {
defaultSourceSet {
kotlin.srcDir("src/nativeMain/kotlin")
}
dependencies {
implementation("org.jetbrains.kotlinx:kotlinx-serialization-runtime-native:${Versions.kotlinSerialization}")
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core-native:${Versions.kotlinCoroutines}")
}
}
}

sourceSets {
val commonMain by getting {
Expand Down Expand Up @@ -70,11 +83,6 @@ kotlin {
implementation(kotlin("test-js"))
}
}

// sourceSets["macosMain"].dependencies {
// }
// sourceSets["macosTest"].dependencies {
// }
}
}

Expand Down
11 changes: 8 additions & 3 deletions conformance/lib/src/commonMain/kotlin/pbandk/conformance/Main.kt
Original file line number Diff line number Diff line change
@@ -1,15 +1,20 @@
package pbandk.conformance

import pbandk.ByteArr
import pbandk.conformance.Platform.runBlockingMain
import pbandk.conformance.pb.*

var logDebug = false
inline fun debug(fn: () -> String) { if (logDebug) Platform.stderrPrintln(fn()) }

suspend fun main(args: Array<String>) {
inline fun debug(fn: () -> String) {
if (logDebug) Platform.stderrPrintln(fn())
}

fun main(args: Array<String>) = runBlockingMain {
debug { "Starting conformance test" }
while (true) {
val res = doTestIo().also { debug { "Result: $it" } } ?: return
val res = doTestIo().also { debug { "Result: $it" } } ?: return@runBlockingMain

ConformanceResponse(res).protoMarshal().also { bytes ->
Platform.stdoutWriteIntLE(bytes.size)
Platform.stdoutWriteFull(bytes)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package pbandk.conformance

import kotlinx.coroutines.CoroutineScope

expect object Platform {
fun stderrPrintln(str: String)

Expand All @@ -10,4 +12,6 @@ expect object Platform {
fun stdoutWriteFull(arr: ByteArray)

inline fun <T> doTry(fn: () -> T, errFn: (Any) -> T): T

fun runBlockingMain(block: suspend CoroutineScope.() -> Unit)
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import pbandk.asByteArray
import pbandk.asUint8Array
import kotlin.coroutines.resume
import kotlin.coroutines.suspendCoroutine
import kotlinx.coroutines.*

internal external interface StdStream {
val fd: Int
Expand Down Expand Up @@ -104,4 +105,8 @@ actual object Platform {
} catch (e: dynamic) {
errFn(e as Any)
}

actual fun runBlockingMain(block: suspend CoroutineScope.() -> Unit) {
GlobalScope.launch(block = block)
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package pbandk.conformance

import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.withContext
import java.nio.ByteBuffer
Expand Down Expand Up @@ -27,5 +28,13 @@ actual object Platform {

actual fun stdoutWriteFull(arr: ByteArray) = System.out.write(arr)

actual inline fun <T> doTry(fn: () -> T, errFn: (Any) -> T) = try { fn() } catch (e: Exception) { errFn(e) }
actual inline fun <T> doTry(fn: () -> T, errFn: (Any) -> T) = try {
fn()
} catch (e: Exception) {
errFn(e)
}

actual fun runBlockingMain(block: suspend CoroutineScope.() -> Unit) {
kotlinx.coroutines.runBlocking(block = block)
}
}
Loading