#android #javascript-engine #quickjs #bindings #compatibility #emulator #platform

sys quickjs_android_suitable_sys

QuickJS Javascript Engine FFI bindings, suitable for use on Android

18 releases

0.20220306.3 Aug 8, 2023
0.20220306.2 Jun 22, 2023
0.20220306.0 Jan 21, 2023
0.20201108.12 Jun 6, 2021
0.1.0 Aug 11, 2020

#1721 in Web programming

Download history 61/week @ 2024-07-24 11/week @ 2024-07-31 20/week @ 2024-09-18 23/week @ 2024-09-25

59 downloads per month

MIT license

3MB
84K SLoC

C 73K SLoC // 0.0% comments JavaScript 7.5K SLoC // 0.0% comments Rust 3K SLoC // 0.0% comments Bitbake 483 SLoC // 0.1% comments Shell 108 SLoC // 0.1% comments

quickjs-android-suitable-sys

FFI Bindings for quickjs. One of many, but I created this one as a fork of libquickjs-sys becuse it wasn't working properly on i686 Android.

What?

The i686 toolchain is used when building for the Android emulator and more or less nothing else these days. It turns out that bindgen isn't aware of compilation target by default and for some reason the code generated for 64bit OSes will crash on i686 Android (and maybe others). This crate rebuilds the bindings whenever the library is built, ensuring platform consistency.

Making this change breaks compatibility with the higher level library that uses libquickjs-sys, so I made a fresh fork. There are a bunch of required functions (e.g. JS_NewBool) inlined in the header file rather than in the .c file, so the C compiler doesn't include them. To that end I've created quickjs+extern.c to expose those functions correctly.

Extra features

  • bignum

    Enable this to add bigint support to QuickJS

  • dump_leaks

    Dumps out variables still being held in the JS engine whenever it is released. Useful to debugging memory leaks.

Publishing

Before running cargo publish please run cargo script scripts/generate-bindings.rs. There's a better way to do this, I'm sure.

No runtime deps

~0–2.2MB
~43K SLoC