mirror of https://github.com/bjornbytes/lovr.git
Fix broken android lua module
The LOVR_ENABLE_ANDROID flag wasn't getting passed to C, and the getApplicationId code had bugs
This commit is contained in:
parent
99026af5ca
commit
adabf4c6ef
|
@ -571,7 +571,12 @@ elseif(EMSCRIPTEN)
|
|||
target_sources(lovr PRIVATE src/platform/web.c)
|
||||
elseif(ANDROID)
|
||||
target_link_libraries(lovr log EGL GLESv3)
|
||||
target_sources(lovr PRIVATE src/platform/android.c src/api/android.c)
|
||||
target_sources(lovr PRIVATE src/platform/android.c)
|
||||
|
||||
if (LOVR_ENABLE_ANDROID)
|
||||
add_definitions(-DLOVR_ENABLE_ANDROID)
|
||||
target_sources(lovr PRIVATE src/api/android.c)
|
||||
endif()
|
||||
elseif(UNIX)
|
||||
target_sources(lovr PRIVATE src/platform/linux.c)
|
||||
endif()
|
||||
|
|
|
@ -1,19 +1,21 @@
|
|||
#include "api.h"
|
||||
#include "lib/sds/sds.h"
|
||||
#include <unistd.h>
|
||||
#include "platform.h"
|
||||
|
||||
static int l_lovrGetApplicationId(lua_State *L) {
|
||||
pid_t pid = getpid();
|
||||
sds procPath = sdscatfmt(sdsempty(), "/proc/%d/cmdline", (int)pid);
|
||||
sds procPath = sdscatfmt(sdsempty(), "/proc/%i/cmdline", (int)pid);
|
||||
FILE *procFile = fopen(procPath, "r");
|
||||
sdsfree(procPath);
|
||||
if (procFile) {
|
||||
sds procData = sdsempty();
|
||||
char data[64];
|
||||
int read;
|
||||
while ((read = fread(data, sizeof(data), 1, procFile))) {
|
||||
while ((read = fread(data, 1, sizeof(data), procFile))) {
|
||||
procData = sdscatlen(procData, data, read);
|
||||
}
|
||||
lua_pushstring(L, procData);
|
||||
sdsfree(procData);
|
||||
} else {
|
||||
lua_pushnil(L);
|
||||
|
|
Loading…
Reference in New Issue