Skip to content

Commit

Permalink
Update readme (#19)
Browse files Browse the repository at this point in the history
Signed-off-by: conanoc <[email protected]>
  • Loading branch information
conanoc authored Jan 3, 2024
1 parent 0298ab5 commit 6afe289
Show file tree
Hide file tree
Showing 5 changed files with 70 additions and 60 deletions.
58 changes: 58 additions & 0 deletions DEVELOP.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
## Requirements

Rust is required to build the project. Xcode is required to build and test Swift wrappers.
Andriod Stuio and Docker Desktop are required to build and test Android wrappers.

## Swift wrappers

### Build

Create Swift bindings by running `build-swift-framework.sh`. This will create xcframeworks from the
static libraries generated by UniFFI. It also creates Swift bindings and copy them to `swift/Sources` directory.

### Test

Run `USE_LOCAL_XCFRAMEWORK=1 swift test`. This will build the Swift package and run all the tests.

### Publish

Swift xcframeworks are created in `out` directory of each modules.
For example, anoncreds xcframework file is created at `anoncreds/out/anoncreds_uniffiFFI.xcframework`.
Zip the xcframework to a zip file using `zip -rq anoncreds/out/anoncreds_uniffiFFI.xcframework.zip anoncreds/out/anoncreds_uniffiFFI.xcframework` and then upload it as a github release asset. Checksum can be computed using `swift package compute-checksum anoncreds/out/anoncreds_uniffiFFI.xcframework.zip`. Finally, update the `url` and `checksum` properties of binaray targets in the Package.swift file. Note that we need to create a tag after the update of Package.swift.

## Kotlin wrappers

### Build

Create Kotlin bindings by running `build-kotlin-libraries.sh`. This will create libraries and Kotlin bindings in `out/kmpp-uniffi` directory.

### Test

Go to one of the Kotlin projects, e.g., `kotlin/anoncreds` and run tests using `./gradlew jvmTest`.

### Publish

#### Publish to Maven Local

Run `./gradlew publishToMavenLocal` to publish to Maven Local.

To use Maven Local in a seperate project you'll want to make sure to add it inside of your `build.gradle.kts`.
```kotlin
repositories {
mavenLocal()
mavenCentral()
google()
}
```

#### Publish Kotlin libraries to github

Publishing to github will require you to do a couple more steps. First we will want to get a github token with `write:packages` permissions, more details can be [found here](https://docs.github.com/en/packages/learn-github-packages/about-permissions-for-github-packages#about-scopes-and-permissions-for-package-registries).

Once you have a token you will want to add both your token and your github username into `kotlin/${library}/local.properties` like so:
```
githubUsername=ExampleUsername
githubToken=ghp_ajsldk1FakeTokenjkash
```

Now you can publish to github packages using `./gradlew publishAllPublicationsToGithubRepository`.
67 changes: 11 additions & 56 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,65 +31,18 @@ And add the following dependency to your target:
),
```

Take a look at the tests in `Tests` folder for examples on how to use the wrappers.
Take a look at the tests in `swift/Tests` directory for examples on how to use the wrappers.

### Kotlin

The Kotlin wrappers are set up to be distributed as a Maven package. In the future we aim to have releases on github packages. For now you will either have to use Maven Local or fork this repository and publish it yourself.

#### Generate Kotlin bindings

First step before publishing will be to generate the bindings. To generate all bindings for Kotlin just run the `build-kotlin-libraries.sh` file from root. You can also generate bindings for a specific library by running the `build-kotlin-libraries.sh` found inside of target library's directory. (ie: `/askar/build-kotlin-library.sh`)

#### Publish Kotlin libraries with Maven Local

Once bindings have been generated we can now publish to Maven Local. To do so we'll cd into the target kotlin wrapper (ie: `/kotlin/askar/`) and then we will run `./gradlew publishToMavenLocal`.

To use Maven Local in a seperate project you'll want to make sure to add it inside of your `build.gradle.kts`
```kotlin
repositories {
mavenLocal()
mavenCentral()
google()
}
```

#### Publish Kotlin libraries to github

Publishing to github will require you to do a couple more steps. First we will want to get a github token with `write:packages` permissions, more details can be [found here](https://docs.github.com/en/packages/learn-github-packages/about-permissions-for-github-packages#about-scopes-and-permissions-for-package-registries)

Once you have a token we will want to add both your token and your github username into `kotlin/${library}/local.properties` like so:
```
githubUsername=ExampleUsername
githubToken=ghp_ajsldk1FakeTokenjkash
```
Next you'll want to make sure you are targetting the correct URL for publishing. Make sure that the `setUrl` function in `kotlin/${library}/build.gradle.kts` targets your fork's URL instead of the main repository's.

```kotlin
publishing{
repositories{
maven{
name = "github"
setUrl("https://maven.pkg.github.com/${FORK_DIRECTORY}/aries-uniffi-wrappers")
credentials {
username = getExtraString("githubUsername")
password = getExtraString("githubToken")
}
}
}
...
}
```

Now we can publish to github packages. You'll want to call `./gradlew publishAllPublicationsToGithubRepository` inside of the target wrapper root directory.

The Kotlin wrappers are distributed as a Maven package hosted by GitHub Packages.
To add a github packages repository in a seperate project you will have to have a github token with `read:packages` permissions. Then you will add the repository to your `build.gradle.kts` like so:
```kotlin
repositories {
mavenCentral()
google()
maven {
setUrl("https://maven.pkg.github.com/${FORK_DIRECTORY}/aries-uniffi-wrappers")
setUrl("https://maven.pkg.github.com/hyperledger/aries-uniffi-wrappers")
credentials {
username = getExtraString("githubUsername")
password = getExtraString("githubToken")
Expand All @@ -98,21 +51,23 @@ To add a github packages repository in a seperate project you will have to have
}
```

#### Adding as a dependency

Now all we have to do is add the libraries as a dependency in your `build.gradle.kts` like so:
Now you will add the libraries as a dependency in your `build.gradle.kts` like so:
```kotlin
dependencies {
implementation("org.hyperledger:anoncreds_uniffi:0.1.0-wrapper.1")
implementation("org.hyperledger:indy_vdr_uniffi:0.1.0-wrapper.1")
implementation("org.hyperledger:askar_uniffi:0.1.0-wrapper.1")
implementation("org.hyperledger:anoncreds_uniffi:0.1.1-wrapper.1")
implementation("org.hyperledger:indy_vdr_uniffi:0.1.1-wrapper.1")
implementation("org.hyperledger:askar_uniffi:0.1.1-wrapper.1")
}
```

Take a look at the tests in `kotlin/${library}/src/commonTest` for usage examples.

## Contributing

Pull requests are welcome! We enforce [developer certificate of origin](https://developercertificate.org/) (DCO) commit signing. See guidance [here](https://github.com/apps/dco).

Please see our [Developer Guide](DEVELOP.md) for more information.

## License

Aries uniffi wrappers are licensed under the [Apache License 2.0](LICENSE).
1 change: 0 additions & 1 deletion anoncreds/build-kotlin-library.sh
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ cargo install cross --git https://github.com/cross-rs/cross
# Build for android targets
for target in "${android_targets[@]}"; do
echo "Building for $target..."
rustup toolchain install 1.65.0 --target $target
cross build --release --target $target
done

Expand Down
1 change: 0 additions & 1 deletion askar/build-kotlin-library.sh
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ cargo install cross --git https://github.com/cross-rs/cross
# Build for android targets
for target in "${android_targets[@]}"; do
echo "Building for $target..."
rustup toolchain install 1.65.0 --target $target
cross build --release --target $target
done

Expand Down
3 changes: 1 addition & 2 deletions indy-vdr/build-kotlin-library.sh
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ cargo install cross --git https://github.com/cross-rs/cross
# Build for android targets
for target in "${android_targets[@]}"; do
echo "Building for $target..."
rustup toolchain install 1.65.0 --target $target
cross build --release --target $target
done

Expand All @@ -62,4 +61,4 @@ echo "Generating wrapper..."
mkdir -p $OUT_PATH
cargo install --bin uniffi-bindgen-kotlin-multiplatform [email protected]
CURRENT_ARCH=$(rustc --version --verbose | grep host | cut -f2 -d' ')
uniffi-bindgen-kotlin-multiplatform --lib-file ./target/$CURRENT_ARCH/release/$LIBRARY_NAME --out-dir $OUT_PATH uniffi/indy_vdr_uniffi.udl
uniffi-bindgen-kotlin-multiplatform --lib-file ./target/$CURRENT_ARCH/release/$LIBRARY_NAME --out-dir $OUT_PATH uniffi/indy_vdr_uniffi.udl

0 comments on commit 6afe289

Please sign in to comment.