Skip to content
This repository has been archived by the owner on Dec 12, 2024. It is now read-only.

Add builds & dynamic loading for four targets #67

Merged
merged 33 commits into from
Jul 8, 2024

Conversation

KendallWeihe
Copy link
Contributor

@KendallWeihe KendallWeihe commented Jul 5, 2024

  • Add bindings/tbdex_uniffi/libtargets for building the 4 targets we support
  • Add test for loading shared library based on system architecture
  • Add GitHub CI workflow for testing the loading of the shared library across our targets
  • Add the shared lib binaries for each of the four
  • Add SystemArchitecture.set() in bound/kt and add calls in all relevant places (this ensures the proper system architecture is detected prior to UniFFI's codegen'd Native.load()
  • Add assumption for all local dev right now to be aarch64-apple-darwin 🚧 we'll make this dynamic later, but right now all major developers are running Apple silicon
  • Add print statements to example PFI

@KendallWeihe
Copy link
Contributor Author

I'm moving this to a Draft, I want to reconsider a few things

@KendallWeihe KendallWeihe marked this pull request as draft July 6, 2024 14:57
@KendallWeihe KendallWeihe marked this pull request as ready for review July 6, 2024 19:14
@KendallWeihe
Copy link
Contributor Author

@nitro-neal heads up on this PR because I went a slightly different direction then when we last spoke. I decided to use the GitHub Workflow specifically for testing the loading of the shared library across the four targets, and building has been moved to bindings/tbdex_uniffi/libtargets. We'll probably still build the shared libs in the pipeline in due time, but for now this enables us to move quicker -- we can debug builds locally, and use the pipeline for a quick <60 seconds test to ensure the build is still compatible. The alternative is 10+ minute process times when using the pipeline. I think we can get the best of both worlds in due time but for now this is ideal.

Another thing, I couldn't quite get the RustCore abstraction to work around the UniFFI code gen. For now, I went with SystemArchitecture.set() and am calling it in all the relevant places. There may be a more eloquent way to do this, but this works.

COPY crates/tbdex ./crates/tbdex

# Build the static lib (override the lib type)
RUN sed -i 's/crate-type = \["cdylib"\]/crate-type = \["staticlib"\]/' bindings/tbdex_uniffi/Cargo.toml
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe in the future this can be an env variable instead of sed ing

import tbdex.sdk.web5.BearerDid
import tbdex.sdk.rust.getBalances as rustCoreGetBalances

fun getBalances(pfiDidUri: String, bearerDid: BearerDid): List<Balance> {
SystemArchitecture.set() // ensure the sys arch is set for first-time loading
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There must be a way to call this when someone does an import on tbdex-kt..

like maybe a wrapper around the entire sdk thats like this:

class TbdexWrapper {
    companion object {
        init {
           SystemArchitecture.set()
        }
    }
}

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably other ways too, we can experiment with it

Copy link
Contributor

@nitro-neal nitro-neal left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Its pretty ugly with the SystemArchitecture.set() I think first priority would be to figure out how to do it in just one place on init somewhere

KendallWeihe and others added 2 commits July 8, 2024 11:28
* Add latest web5, make RfqPrivateData optional

* Add SubmitOrderRequestBody, add dev print statements to httpclient

* Add latest bindings for 2 macOS targets

* Add serde skip for null

* Add latest bindings

* Fix Rfq binding

* Add fat jar build support

* Build linux shared libs

* Undo temporary integration changes

* Add latest bindings

* Rename directories to use underscores to be consistent
@nitro-neal nitro-neal merged commit efe07e3 into main Jul 8, 2024
10 checks passed
@nitro-neal nitro-neal deleted the kendall/build-both-macs branch July 8, 2024 17:58
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants