Whoa. Apps are running on android. Switched to a static build of OpenSSL 1.1.1t for simplicity.

git-svn-id: https://www.unprompted.com/svn/projects/tildefriends/trunk@4211 ed5197a5-7fde-0310-b194-c3ffbd925b24
This commit is contained in:
2023-03-10 02:02:24 +00:00
parent d532795b7f
commit 400f07660f
7649 changed files with 9904 additions and 2321 deletions

View File

@ -309,7 +309,7 @@ bool tf_task_send_error_to_parent(tf_task_t* task, JSValue error)
return false;
}
static const char* _task_loadFile(tf_task_t* task, const char* fileName)
static const char* _task_loadFile(tf_task_t* task, const char* fileName, size_t* out_size)
{
char* result = NULL;
if (task->_zip)
@ -326,6 +326,10 @@ static const char* _task_loadFile(tf_task_t* task, const char* fileName)
{
buffer[info.uncompressed_size] = '\0';
result = buffer;
if (out_size)
{
*out_size = info.uncompressed_size;
}
buffer = NULL;
}
unzCloseCurrentFile(task->_zip);
@ -367,7 +371,7 @@ int tf_task_execute(tf_task_t* task, const char* fileName)
bool executed = false;
tf_trace_begin(task->_trace, "tf_task_execute");
const char* source = _task_loadFile(task, fileName);
const char* source = _task_loadFile(task, fileName, NULL);
tf_printf("Running script %s\n", fileName);
if (!*task->_scriptName)
{
@ -1500,7 +1504,7 @@ JSModuleDef* _tf_task_module_loader(JSContext* context, const char* module_name,
if (!source && task->_trusted)
{
source = (char*)_task_loadFile(task, module_name);
source = (char*)_task_loadFile(task, module_name, NULL);
length = source ? strlen(source) : 0;
}
@ -1580,11 +1584,42 @@ static void _tf_task_trace_to_parent(tf_trace_t* trace, const char* buffer, size
tf_packetstream_send(tf_taskstub_get_stream(task->_parent), kTaskTrace, buffer, size);
}
static void _tf_task_extract_file(tf_task_t* task, const char* name, int mode)
{
size_t size = 0;
char path_in_zip[256];
snprintf(path_in_zip, sizeof(path_in_zip), "lib/arm64-v8a/%s", name);
const char* exe_source = _task_loadFile(task, path_in_zip, &size);
if (exe_source)
{
FILE* exe_target = fopen(name, "wb");
if (exe_target)
{
fwrite(exe_source, size, 1, exe_target);
fchmod(fileno(exe_target), mode);
fclose(exe_target);
}
else
{
tf_printf("failed to open %s for write", name);
}
tf_free((void*)exe_source);
}
else
{
tf_printf("failed to read %s source", path_in_zip);
}
}
void tf_task_activate(tf_task_t* task)
{
assert(!task->_activated);
task->_activated = true;
#if defined(__ANDROID__)
_tf_task_extract_file(task, "tildefriends", 0755);
#endif
JSContext* context = task->_context;
JSValue global = JS_GetGlobalObject(context);
JSValue e = JS_NewObject(context);