• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

koreader/android-luajit-launcher: Android NativeActivity based launcher for LuaJ ...

原作者: [db:作者] 来自: 网络 收藏 邀请

开源软件名称(OpenSource Name):

koreader/android-luajit-launcher

开源软件地址(OpenSource Url):

https://github.com/koreader/android-luajit-launcher

开源编程语言(OpenSource Language):

Kotlin 44.6%

开源软件介绍(OpenSource Introduction):

android-luajit-launcher

License: MIT Codacy Badge

Android 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.

Starting

Init and update the submodules

make update

Compile LuaJIT for all target architecture(s)

make prepare

Compile native code and package APK with gradle

You 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

  • a concept to deal with native Lua modules.
  • a loader for native modules that have been put into the activity's library directory?
  • a loader for obb storage, maybe? We could put native Lua modules there, for example.
  • example code for framebuffer access and more



鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Rerumu/FiOne: Lua 5.1 bytecode interpreter, in Lua发布时间:2022-08-16
下一篇:
nick-nh/qlua: Quik Lua indicators发布时间:2022-08-16
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap