Page MenuHomePhabricator

[native] introduce RustCallback
ClosedPublic

Authored by varun on Mar 27 2023, 8:54 PM.
Tags
None
Referenced Files
F2108382: D7214.id24292.diff
Tue, Jun 25, 12:37 PM
F2108381: D7214.id24257.diff
Tue, Jun 25, 12:37 PM
F2108351: D7214.id.diff
Tue, Jun 25, 12:36 PM
F2108307: D7214.diff
Tue, Jun 25, 12:32 PM
Unknown Object (File)
Wed, Jun 19, 11:35 PM
Unknown Object (File)
Wed, Jun 12, 5:43 PM
Unknown Object (File)
Mon, Jun 3, 12:35 AM
Unknown Object (File)
Wed, May 29, 6:35 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.