Skip to content

Commit a42e37c

Browse files
committed
bootstrap JVM bindings
1 parent 6c16129 commit a42e37c

File tree

93 files changed

+4790
-5
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

93 files changed

+4790
-5
lines changed

.editorconfig

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
[*.{kt,kts}]
2+
# ktlint rules to disable
3+
disabled_rules=no-wildcard-imports,filename

.github/workflows/ci.yaml

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches:
6+
- '*'
7+
- '!main'
8+
9+
env:
10+
BUILDER_VERSION: v0.7.7
11+
BUILDER_SOURCE: releases
12+
BUILDER_HOST: https://d19elf31gohf1l.cloudfront.net
13+
PACKAGE_NAME: aws-crt-kotlin
14+
LINUX_BASE_IMAGE: ubuntu-16-x64
15+
RUN: ${{ github.run_id }}-${{ github.run_number }}
16+
17+
jobs:
18+
linux-compat:
19+
runs-on: ubuntu-latest
20+
strategy:
21+
matrix:
22+
image:
23+
- manylinux2014-x64
24+
#- manylinux2014-x86 until we find 32-bit linux binaries we can use
25+
steps:
26+
# We can't use the `uses: docker://image` version yet, GitHub lacks authentication for actions -> packages
27+
- name: Checkout Sources
28+
uses: actions/checkout@v2
29+
with:
30+
submodules: true
31+
- name: Build ${{ env.PACKAGE_NAME }}
32+
run: |
33+
echo "${{ secrets.GITHUB_TOKEN }}" | docker login docker.pkg.github.com -u awslabs --password-stdin
34+
export DOCKER_IMAGE=docker.pkg.github.com/awslabs/aws-crt-builder/aws-crt-${{ matrix.image }}:${{ env.BUILDER_VERSION }}
35+
docker pull $DOCKER_IMAGE
36+
docker run --mount type=bind,source=$(pwd),target=/root/${{ env.PACKAGE_NAME }} \
37+
--env GITHUB_REF $DOCKER_IMAGE build -p ${{ env.PACKAGE_NAME }} --build-dir=/root/${{ env.PACKAGE_NAME }} --spec=downstream
38+

.gitignore

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
.DS_Store
2+
/dist
3+
/ideaSDK
4+
/android-studio/sdk
5+
out/
6+
/tmp
7+
workspace.xml
8+
*.versionsBackup
9+
.gradle/
10+
build/
11+
*.iml
12+
.idea/
13+
local.properties

README.md

Lines changed: 58 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,66 @@
1-
## My Project
1+
## AWS CRT Kotlin
22

3-
TODO: Fill this README out!
3+
Kotlin bindings to the AWS Common Runtime
44

5-
Be sure to:
5+
[![License][apache-badge]][apache-url]
66

7-
* Change the title in this README
8-
* Edit your repository description on GitHub
7+
[apache-badge]: https://img.shields.io/badge/License-Apache%202.0-blue.svg
8+
[apache-url]: LICENSE
99

1010
## License
1111

1212
This project is licensed under the Apache-2.0 License.
1313

14+
## Building
15+
16+
Kotlin Multiplatform projects are in [Alpha](https://kotlinlang.org/docs/reference/evolution/components-stability.html). The CRT interfaces are subject to change.
17+
18+
### Linux/Unix
19+
Install some version of libcrypto on which s2n depends. See the [s2n](https://github.com/awslabs/s2n) documentation.
20+
21+
```
22+
apt-get install libssl-dev
23+
```
24+
25+
Set the path to `libcrypto.a` either as a command line argument to gradle `-PlibcryptoPath=PATH` or in your `local.properties` file.
26+
27+
28+
### OSX
29+
30+
31+
### Windows
32+
33+
34+
## Elasticurl App
35+
36+
The `elasticurl` project contains an MPP (JVM and Native only) executable that provides a simple testing application for exercising the CRT bindings.
37+
38+
**Native**
39+
40+
```
41+
# replace "PLATFORM" with the target platform you want to run (e.g. macosX64, linuxX64, etc)
42+
43+
./elasticurl/bin/PLATFORM/elasticurl.kexe [OPTIONS] URL
44+
```
45+
46+
47+
**JVM**
48+
```
49+
java -jar ./elasticurl/libs/elasticurl-jvm.jar [OPTIONS] URL
50+
```
51+
52+
NOTE: You can also use the convenience script `./scripts/elasticurlJvm.sh [OPTIONS] URL`
53+
54+
To enable memory tracing specify the environment variable `CRTDEBUG=trace=N` and provide the CLI option `-v trace`
55+
56+
e.g.
57+
```
58+
CRTDEBUG=trace=2 ./elasticurl/bin/macosX64/elasticurl.kexe -v trace https://aws.amazon.com
59+
```
60+
61+
62+
**Integration Test**
63+
64+
Run the simple elasticurl integration test script
65+
66+
`./scripts/elasticurl-test.sh`

build.gradle.kts

Lines changed: 132 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,132 @@
1+
/*
2+
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
3+
* SPDX-License-Identifier: Apache-2.0.
4+
*/
5+
import org.jetbrains.kotlin.konan.target.HostManager
6+
import org.jetbrains.kotlin.gradle.plugin.mpp.KotlinNativeTarget
7+
import java.util.Properties
8+
9+
plugins {
10+
kotlin("multiplatform") version "1.4.21"
11+
`maven`
12+
`maven-publish`
13+
}
14+
15+
group = "software.amazon.awssdk.crt"
16+
version = "0.1.0-SNAPSHOT"
17+
description = "Kotlin Multiplatform bindings for AWS SDK Common Runtime"
18+
19+
allprojects {
20+
repositories {
21+
mavenLocal()
22+
mavenCentral()
23+
jcenter()
24+
maven ("https://dl.bintray.com/kotlin/kotlin-eap")
25+
maven ("https://kotlin.bintray.com/kotlinx")
26+
}
27+
}
28+
29+
// See: https://kotlinlang.org/docs/reference/opt-in-requirements.html#opting-in-to-using-api
30+
val experimentalAnnotations = listOf("kotlin.RequiresOptIn")
31+
32+
33+
kotlin {
34+
explicitApi()
35+
36+
jvm()
37+
38+
val kotlinVersion: String by project
39+
val coroutinesVersion: String by project
40+
41+
sourceSets {
42+
val commonMain by getting {
43+
dependencies {
44+
implementation(kotlin("stdlib-common"))
45+
// native multithreading support for coroutines is not stable...
46+
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:$coroutinesVersion-native-mt")
47+
}
48+
}
49+
val commonTest by getting {
50+
dependencies {
51+
implementation(kotlin("test-common"))
52+
implementation(kotlin("test-annotations-common"))
53+
}
54+
}
55+
56+
val jvmMain by getting {
57+
dependencies {
58+
api("org.jetbrains.kotlin:kotlin-stdlib")
59+
val crtJavaVersion: String by project
60+
implementation("software.amazon.awssdk.crt:aws-crt:$crtJavaVersion")
61+
62+
// FIXME - temporary integration with CompletableFuture while we work out a POC on the jvm target
63+
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-jdk8:$coroutinesVersion")
64+
}
65+
}
66+
67+
val jvmTest by getting {
68+
dependencies {
69+
val junitVersion: String by project
70+
api("org.jetbrains.kotlin:kotlin-test:$kotlinVersion")
71+
api("org.jetbrains.kotlin:kotlin-test-junit5:$kotlinVersion")
72+
implementation("org.junit.jupiter:junit-jupiter:$junitVersion")
73+
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-debug:$coroutinesVersion")
74+
}
75+
}
76+
77+
}
78+
79+
sourceSets.all {
80+
println("configuring source set $name")
81+
val srcDir = if (name.endsWith("Main")) "src" else "test"
82+
val resourcesPrefix = if (name.endsWith("Test")) "test-" else ""
83+
// source set name should always be the platform followed by a suffix of either "Main" or "Test
84+
// e.g. jvmMain, commonTest, etc
85+
val platform = name.substring(0, name.length - 4)
86+
87+
kotlin.srcDir("src/$platform/$srcDir")
88+
resources.srcDir("src/$platform/${resourcesPrefix}resources")
89+
experimentalAnnotations.forEach { languageSettings.useExperimentalAnnotation(it) }
90+
}
91+
}
92+
93+
// have to configure JVM test task to use junit platform when using junit5
94+
val jvmTest: Test by tasks
95+
jvmTest.apply {
96+
testLogging {
97+
events("passed", "skipped", "failed")
98+
showStandardStreams = true
99+
}
100+
101+
useJUnitPlatform()
102+
}
103+
104+
val ktlint by configurations.creating
105+
val ktlintVersion: String by project
106+
107+
dependencies {
108+
ktlint("com.pinterest:ktlint:$ktlintVersion")
109+
}
110+
111+
val lintPaths = listOf(
112+
"src/**/*.kt",
113+
"elasticurl/**/*.kt"
114+
)
115+
116+
tasks.register<JavaExec>("ktlint") {
117+
description = "Check Kotlin code style."
118+
group = "Verification"
119+
classpath = configurations.getByName("ktlint")
120+
main = "com.pinterest.ktlint.Main"
121+
args = lintPaths
122+
}
123+
124+
tasks.register<JavaExec>("ktlintFormat") {
125+
description = "Auto fix Kotlin code style violations"
126+
group = "formatting"
127+
classpath = configurations.getByName("ktlint")
128+
main = "com.pinterest.ktlint.Main"
129+
args = listOf("-F") + lintPaths
130+
}
131+
132+
tasks.check.get().dependsOn(":ktlint")

elasticurl/build.gradle.kts

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
/*
2+
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
3+
* SPDX-License-Identifier: Apache-2.0.
4+
*/
5+
6+
plugins {
7+
kotlin("multiplatform")
8+
application
9+
}
10+
11+
12+
kotlin {
13+
jvm() {
14+
withJava()
15+
val jvmJar by tasks.getting(org.gradle.jvm.tasks.Jar::class) {
16+
doFirst {
17+
manifest {
18+
attributes["Main-Class"] = "ApplicationKt"
19+
}
20+
from(configurations.getByName("runtimeClasspath").map { if (it.isDirectory) it else zipTree(it) })
21+
}
22+
}
23+
}
24+
25+
sourceSets {
26+
commonMain {
27+
dependencies {
28+
val kotlinxCliVersion: String by project
29+
val coroutinesVersion: String by project
30+
31+
implementation(kotlin("stdlib-common"))
32+
implementation("org.jetbrains.kotlinx:kotlinx-cli:$kotlinxCliVersion")
33+
implementation(project(":"))
34+
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:$coroutinesVersion-native-mt")
35+
}
36+
}
37+
38+
val jvmMain by getting {
39+
dependencies {
40+
implementation("org.jetbrains.kotlin:kotlin-stdlib")
41+
}
42+
}
43+
}
44+
}
45+
46+
application {
47+
mainClassName = "ApplicationKt"
48+
}

0 commit comments

Comments
 (0)