Skip to content
Discussion options

You must be logged in to vote

Yes — Perry has a first-class FFI mechanism for calling native code (Rust, Swift on Apple, JNI on Android, and via Rust → C anything that compiles to a static library). It's called native extensions and the full docs live at https://docs.perryts.com/plugins/native-extensions.html.

For pure C, the cleanest path is to wrap your C in a tiny Rust staticlib (Cargo's cc crate compiles the .c file for you in build.rs), declare the C functions on the TypeScript side with declare function, and let Perry's --bundle-extensions flag link everything in. Here's a minimal, complete example.

1. Project layout

my-app/
├── package.json
├── src/index.ts
└── extensions/
    └── perry-mathc/
        ├── packa…

Replies: 2 comments

Comment options

You must be logged in to vote
0 replies
Answer selected by proggeramlug
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants