Skip to content

Commit

Permalink
merge assets, add links to official docs
Browse files Browse the repository at this point in the history
  • Loading branch information
pazos committed Oct 8, 2024
1 parent 7c1d6d6 commit f6c01d3
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 28 deletions.
22 changes: 16 additions & 6 deletions assets/android.lua
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
--[[--
Java Native Interface (JNI) wrapper.
FFI bindings for android native APIs and Java Native Interface (JNI).
see https://developer.android.com/ndk/reference/struct/a-native-activity
and https://developer.android.com/reference/games/game-activity/group/android-native-app-glue
@module android
]]
Expand All @@ -26,6 +29,8 @@ for _ = 1, 100 do end
local ffi = require("ffi")

ffi.cdef[[
// posix:
int chdir(const char *path);
// logging:
int __android_log_print(int prio, const char *tag, const char *fmt, ...);
typedef enum android_LogPriority {
Expand Down Expand Up @@ -2738,16 +2743,21 @@ local function run(android_app_state)
-- register the asset loader
table.insert(package.loaders, 2, android.asset_loader)

-- extract assets
local installed = android.extractAssets()
if not installed then
error("error extracting assets")
end
local launch = android.asset_loader("launcher")
if type(launch) == "function" then
return launch()
else
error("error loading launcher.lua")

-- the default current directory is root so we should first of all
-- change current directory to application's data directory
if C.chdir(android.dir) ~= 0 then
local err = "Unable to change working directory to '" .. android.dir .. "'"
android.LOGE(err)
error(err)
end

dofile(android.dir.."/llapp_main.lua")
end

run(...)
22 changes: 0 additions & 22 deletions assets/launcher.lua

This file was deleted.

0 comments on commit f6c01d3

Please sign in to comment.