在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
开源软件名称(OpenSource Name):koreader/android-luajit-launcher开源软件地址(OpenSource Url):https://github.com/koreader/android-luajit-launcher开源编程语言(OpenSource Language):Kotlin 44.6%开源软件介绍(OpenSource Introduction):android-luajit-launcherAndroid NativeActivity based launcher for LuaJIT, implementing the main loop within Lua land via FFI. NativeActivity is available starting with platform android-9. Have a look at the Android NDK's "native-plasma" sample activity to get an idea what it does - or rather, is theoretically able to do. While the sample from NDK implements everything in C, in our case, we create a LuaJIT instance and hand off control to it instead. LuaJIT then handles the main loop. In this programming model, we have a thread which presents us with a "main" entry point and allow us to follow our own program flow as long as we poll for and react to events. A good number of Android native API headers are readily presented via FFI already. I'll probably add more along the way. For now - and probably ever, since Mike Pall recommends strongly to do so - the compilation of LuaJIT is not integrated into the Android build framework and has to be run separately. A wrapper script for building LuaJIT is provided. It relies on NDK r15c Have a look at KOReader's llapp_main.lua file. You can use it as a starting point for your own app. The real starting point, called from JNI/C, is the run() function in android.lua. It sets up a few things, namely FFI definitions for the Android native API (since it uses that itself for a few things) and some wrapper functions for logging. Also, it registers the "android" module in package.loaded, so you can access it in your own code via require("android"). It also registers a new package loader which can load Lua code from the activity's asset store, so you can use require() for Lua code stored there. StartingInit and update the submodulesmake update Compile LuaJIT for all target architecture(s)make prepare Compile native code and package APK with gradleYou can see available tasks with ./gradlew tasks For example, you can build the debug variant for all supported ABIs with ./gradlew assembleDebug For more examples please look at the Makefile. To-do
|
2023-10-27
2022-08-15
2022-08-17
2022-09-23
2022-08-13
请发表评论