Android: make apk (NDK; x86_64 + arm64-v8a) no emulador e no aparelho

O NDK compila o editor, as libraries e o SDL2_ttf/freetype/libpng/openssl
estaticos em libmain.so; o SDL2 vai como libSDL2.so e a activity e a
org.libsdl.app.SDLActivity do proprio SDL2 (sem Java nosso e sem Gradle).
Do SDK so entram aapt2, d8, zipalign, apksigner e o android.jar, porque o
NDK sozinho nao monta nem assina um APK.

- packaging/android: build.sh (deps + libmain + apk), AndroidManifest,
  Java e res do SDL2, README e android.mk (make apk, apk-x86_64,
  apk-arm64, apk-deps, clean-apk).
- android_boot.c: cwd para a pasta de arquivos do app, TINYBLOCKS_APPDIR e
  copia dos assets da DejaVu e do ca-bundle.crt (no Android
  SDL_GetBasePath() e NULL e /proc/self/exe nao e o do app).
- O hint SDL_IOS_ORIENTATIONS (nome historico) mantem o editor em
  paisagem, junto com o sensorLandscape do manifesto.
- gl e vk ficam de fora (como no Windows); a fonte, os certificados e a
  busca por TINYBLOCKS_APPDIR tambem valem para o AppImage.

Testado no emulador Android 35 (x86_64): abre em paisagem, desenha os
blocos e roda o programa de exemplo (x vale = 1..5).
This commit is contained in:
mguinhos committed 2026-10-27 04:09:02 -03:00
1 parent 84513080ab
commit 1d8368036e
24 files changed
+6249 -3

No files matched your search

@@ -293,6 +293,11 @@ const char* tb_opentype_default_font(void) {
};
/* primeiro a que vai junto do programa: <pasta do executavel>/fonts */
static char bundled[1024];
const char* dir = getenv("TINYBLOCKS_APPDIR");
if (dir && dir[0]) { /* Android e AppImage */
snprintf(bundled, sizeof(bundled), "%s/fonts/DejaVuSans.ttf", dir);
if (access(bundled, R_OK) == 0) return bundled;
}
char exe[900];
ssize_t n = readlink("/proc/self/exe", exe, sizeof(exe) - 1);
if (n > 0) {
+7 -1
View File
@@ -70,9 +70,15 @@ static const char* s_font_paths[FONT_SEARCH_COUNT] = {
/* A fonte que vai junto do programa (pacote Windows, AppImage):
<pasta do executavel>/fonts/DejaVuSans.ttf */
static TTF_Font* bundled_font(int size) {
char path[1024];
const char* dir = getenv("TINYBLOCKS_APPDIR");
if (dir && dir[0]) { /* Android e AppImage */
snprintf(path, sizeof(path), "%s/fonts/DejaVuSans.ttf", dir);
TTF_Font* f = TTF_OpenFont(path, size);
if (f) return f;
}
char* base = SDL_GetBasePath();
if (!base) return NULL;
char path[1024];
snprintf(path, sizeof(path), "%sfonts/DejaVuSans.ttf", base);
SDL_free(base);
return TTF_OpenFont(path, size);
+6
View File
@@ -95,6 +95,12 @@ static void eval_version(TinyBlocks_Block* self, TinyBlocks* rt) {
entao o pacote leva o arquivo (ver packaging/windows). */
static void load_bundled_certs(SSL_CTX* ctx) {
char exe[1024];
const char* dir = getenv("TINYBLOCKS_APPDIR");
if (dir && dir[0]) { /* Android e AppImage */
snprintf(exe, sizeof(exe), "%s/certs/ca-bundle.crt", dir);
if (access(exe, R_OK) == 0) SSL_CTX_load_verify_locations(ctx, exe, NULL);
return;
}
ssize_t n = readlink("/proc/self/exe", exe, sizeof(exe) - 1);
if (n <= 0) return;
exe[n] = 0;