Skip to content

Commit

Permalink
Make it possible to to develop on devices thar aren't Macs.
Browse files Browse the repository at this point in the history
Also change the test runners to use ubuntu-latest and use this
feature.

Test: Manually tested
Signed-off-by: David Zeuthen <zeuthen@google.com>
  • Loading branch information
davidz25 committed Jun 19, 2024
1 parent fabc6a2 commit 312e2fc
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 32 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/unit-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ permissions:
jobs:
build_and_test:

runs-on: macos-latest
runs-on: ubuntu-latest

steps:
- name: Harden Runner
Expand Down Expand Up @@ -45,7 +45,7 @@ jobs:
- name: Grant execute permission for gradlew
run: chmod +x gradlew
- name: Build with Gradle
run: ./gradlew build -x test
run: ./gradlew -PdisableIosSupport=1 build -x test
- name: Run unit tests
run: ./gradlew test
run: ./gradlew -PdisableIosSupport=1 test

14 changes: 9 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ but the current scope also include other credential formats.
The project includes libraries written in Kotlin:

- `identity` provides the core building blocks and which can also be used
in server-side environments.
in server-side environments. This is a [Kotlin Multiplatform(https://kotlinlang.org/docs/multiplatform.html)
library with support for JVM and iOS.
- `identity-mdoc` provides data structures and routines for working with
mdoc credentials. This library can also be used in server-side-environments
- `identity-sdjwt` provides data structures and routines for working with
Expand Down Expand Up @@ -75,10 +76,13 @@ building blocks
QR engagement, NFC engagement (both static and negotiated), device retrieval
(BLE, Wifi Aware, and NFC)

Currently these libraries require a Java runtime environment but the plan is
to target [Kotlin Multiplatform](https://kotlinlang.org/docs/multiplatform.html)
for the libraries and [Compose Multiplatform](https://www.jetbrains.com/lp/compose-multiplatform/)
for applications and samples.
### Multiplatform support

If not using a Mac for development, the `disableIosSupport` gradle property
can be set to skip targets for iOS:
```
echo "disableIosSupport=1" > ~/.gradle/gradle.properties
```

### Customization

Expand Down
57 changes: 33 additions & 24 deletions identity/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import com.android.builder.core.apiVersionFromString
import org.jetbrains.kotlin.gradle.tasks.KotlinCompilationTask

plugins {
alias(libs.plugins.kotlinMultiplatform)
Expand All @@ -12,21 +10,23 @@ kotlin {

jvm()

listOf(
iosX64(),
iosArm64(),
iosSimulatorArm64()
).forEach {
it.compilations {
val main by getting {
cinterops {
create("SwiftCrypto")
if (!project.hasProperty("disableIosSupport")) {
listOf(
iosX64(),
iosArm64(),
iosSimulatorArm64()
).forEach {
it.compilations {
val main by getting {
cinterops {
create("SwiftCrypto")
}
}
}
}
it.binaries.framework {
baseName = "identity"
isStatic = true
it.binaries.framework {
baseName = "identity"
isStatic = true
}
}
}

Expand Down Expand Up @@ -75,22 +75,31 @@ kotlin {
}

dependencies {
if (project.hasProperty("disableIosSupport")) {
add("kspJvm", project(":processor"))
}
add("kspCommonMainMetadata", project(":processor"))
}

tasks.withType<org.jetbrains.kotlin.gradle.tasks.KotlinCompile>().all {
if (name != "kspCommonMainKotlinMetadata") {
dependsOn("kspCommonMainKotlinMetadata")
if (!project.hasProperty("disableIosSupport")) {
tasks.withType<org.jetbrains.kotlin.gradle.tasks.KotlinCompile>().all {
if (name != "kspCommonMainKotlinMetadata") {
dependsOn("kspCommonMainKotlinMetadata")
}
}
}

tasks["compileKotlinIosX64"].dependsOn("kspCommonMainKotlinMetadata")
tasks["compileKotlinIosArm64"].dependsOn("kspCommonMainKotlinMetadata")
tasks["compileKotlinIosSimulatorArm64"].dependsOn("kspCommonMainKotlinMetadata")
if (!project.hasProperty("disableIosSupport")) {
tasks["compileKotlinIosX64"].dependsOn("kspCommonMainKotlinMetadata")
tasks["compileKotlinIosArm64"].dependsOn("kspCommonMainKotlinMetadata")
tasks["compileKotlinIosSimulatorArm64"].dependsOn("kspCommonMainKotlinMetadata")
}

swiftklib {
create("SwiftCrypto") {
path = file("native/SwiftCrypto")
packageName("com.android.identity.swiftcrypto")
if (!project.hasProperty("disableIosSupport")) {
create("SwiftCrypto") {
path = file("native/SwiftCrypto")
packageName("com.android.identity.swiftcrypto")
}
}
}

0 comments on commit 312e2fc

Please sign in to comment.