diff --git a/DEVELOP.md b/DEVELOP.md new file mode 100644 index 0000000..6e43fd3 --- /dev/null +++ b/DEVELOP.md @@ -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`. diff --git a/README.md b/README.md index a83ab96..d91d7f7 100644 --- a/README.md +++ b/README.md @@ -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") @@ -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). diff --git a/anoncreds/build-kotlin-library.sh b/anoncreds/build-kotlin-library.sh index 46b6a57..4388529 100755 --- a/anoncreds/build-kotlin-library.sh +++ b/anoncreds/build-kotlin-library.sh @@ -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 diff --git a/askar/build-kotlin-library.sh b/askar/build-kotlin-library.sh index 64f9b26..a235c00 100755 --- a/askar/build-kotlin-library.sh +++ b/askar/build-kotlin-library.sh @@ -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 diff --git a/indy-vdr/build-kotlin-library.sh b/indy-vdr/build-kotlin-library.sh index c730ff8..cd280d6 100755 --- a/indy-vdr/build-kotlin-library.sh +++ b/indy-vdr/build-kotlin-library.sh @@ -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 @@ -62,4 +61,4 @@ echo "Generating wrapper..." mkdir -p $OUT_PATH cargo install --bin uniffi-bindgen-kotlin-multiplatform uniffi_bindgen_kotlin_multiplatform@0.1.0 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 \ No newline at end of file +uniffi-bindgen-kotlin-multiplatform --lib-file ./target/$CURRENT_ARCH/release/$LIBRARY_NAME --out-dir $OUT_PATH uniffi/indy_vdr_uniffi.udl