• Stars
    star
    118
  • Rank 289,843 (Top 6 %)
  • Language
    Kotlin
  • License
    MIT License
  • Created over 10 years ago
  • Updated about 2 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Android NativeActivity based launcher for LuaJIT, implementing the main loop within Lua land via FFI

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

More Repositories

1

koreader

An ebook reader application supporting PDF, DjVu, EPUB, FB2 and many more formats, running on Cervantes, Kindle, Kobo, PocketBook and Android devices
Lua
14,890
star
2

kindlepdfviewer

(DEPRECATED, please use KOReader instead) A PDF (plus DJVU, ePub, TXT, CHM, FB2, HTML...) viewer made for e-ink framebuffer devices, using muPDF, djvulibre, crengine
Lua
494
star
3

kpvbooklet

KPVBooklet is a Kindle booklet for starting koreader/kindlepdfviewer and updating last access and percentage finished information in Kindle content catalog entry of the opened document.
Java
205
star
4

koreader-sync-server

self hostable synchronization service for koreader devices
Lua
135
star
5

koreader-base

Base framework offering a Lua scriptable environment for creating document readers
Lua
120
star
6

libk2pdfopt

k2pdfopt library for koreader, based on http://willus.com/k2pdfopt
C
83
star
7

crengine

This is the KOReader CREngine fork. It cross-pollinates with the official CoolReader repository at https://github.com/buggins/coolreader, in case you were looking for that one.
C++
65
star
8

koxtoolchain

Build script for various toolchains used by KOReader
Shell
49
star
9

contrib

Collection of non-official plugins designed for KOReader
Lua
26
star
10

virdevenv

virtual dev environment for koreader
Shell
14
star
11

KoboUSBMS

Small helper to handle USBMS on Kobo in KOReader
C
14
star
12

ffi-cdecl

Automated C declaration extraction for FFI interfaces
Lua
11
star
13

sdcv

console version of StarDict formerly used by koreader; fork of https://github.com/Dushistov/sdcv
Makefile
10
star
14

koreader-misc

helper scripts and tools used/created by the dev team.
Python
8
star
15

lj-wpaclient

wpa_supplicant client library for LuaJIT
Lua
8
star
16

koreader-fonts

Fonts for use in KOReader
6
star
17

evernote-sdk-lua

Unofficial Evernote SDK for Lua
Lua
6
star
18

koreader-translations

KOReader localization.
5
star
19

android-send2ebook

**deprecated** send2ebook lets you send articles found on your android device to your ereader
Java
5
star
20

stardict-dictionaries

Script to quickly convert zip files to .tar.lz
Shell
2
star
21

doc

github page repo for hosting KOReader's documentation (write only)
HTML
1
star
22

test-data

Test suit for various document formats
1
star
23

koreader.github.io

Landing page for KOReader project
HTML
1
star