Page MenuHomePhabricator

[native] introduce RustCallback
ClosedPublic

Authored by varun on Mar 27 2023, 8:54 PM.
Tags
None
Referenced Files
Unknown Object (File)
Thu, Nov 7, 4:31 AM
Unknown Object (File)
Mon, Nov 4, 12:06 PM
Unknown Object (File)
Mon, Nov 4, 8:31 AM
Unknown Object (File)
Mon, Nov 4, 8:30 AM
Unknown Object (File)
Mon, Nov 4, 5:30 AM
Unknown Object (File)
Sun, Oct 27, 5:11 PM
Unknown Object (File)
Fri, Oct 18, 7:11 AM
Unknown Object (File)
Fri, Oct 18, 7:11 AM
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
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

varun requested review of this revision.Mar 27 2023, 9:09 PM
native/android/app/build.gradle
382–401 ↗(On Diff #24257)

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 ↗(On Diff #24257)

i'll remove this random extra line

3–5 ↗(On Diff #24257)

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 ↗(On Diff #24257)

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 ↗(On Diff #24257)

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 ↗(On Diff #24257)

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.