Page MenuHomePhabricator

[native] introduce RustCallback
ClosedPublic

Authored by varun on Mar 27 2023, 8:54 PM.
Tags
None
Referenced Files
Unknown Object (File)
Wed, Jun 26, 4:17 PM
Unknown Object (File)
Wed, Jun 26, 3:29 PM
Unknown Object (File)
Tue, Jun 25, 12:37 PM
Unknown Object (File)
Tue, Jun 25, 12:37 PM
Unknown Object (File)
Tue, Jun 25, 12:36 PM
Unknown Object (File)
Tue, Jun 25, 12:32 PM
Unknown Object (File)
Wed, Jun 19, 11:35 PM
Unknown Object (File)
Wed, Jun 12, 5:43 PM
Subscribers

Details

Summary

we introduce a generic C++ callback function to be called from Rust

note that this function is only used when the js return type is Promise<string>

we'll have to add similar functions to RustCallback for other return types
luckily we really only ever return strings from rust...

Test Plan

this gets tested in the next diff in stack

Diff Detail

Repository
rCOMM Comm
Lint
No Lint Coverage
Unit
No Test Coverage

Event Timeline

varun requested review of this revision.Mar 27 2023, 9:09 PM
native/android/app/build.gradle
382–401

we build the native_rust_library in a gradle preBuild step because RustCallback includes generated files that need to exist before CMake attempts to build the binary

native/native_rust_library/RustCallback.cpp
1

i'll remove this random extra line

3–5

couldn't figure out how to make these absolute paths without xcode complaining..

ashoat added 1 blocking reviewer(s): jon.
ashoat added inline comments.
native/android/app/build.gradle
382–401

Does this mean we build it "twice"? Is it cached the second time? Do we build it for every architecture here?

I'm not able to comment on gradle code, but I couldn't find a better way to do this using just cmake + corrosion + cxxbridge

native/native_rust_library/RustCallback.cpp
3–5

I'll do it some time later https://linear.app/comm/issue/ENG-3419

This revision is now accepted and ready to land.Mar 28 2023, 8:25 AM
native/android/app/build.gradle
382–401

yeah we build it twice, but it is cached the second time. we only build for a single arch here since we just need the generated C++ files

This revision was automatically updated to reflect the committed changes.