Compile for android. Probably needs a bunch of work to run, but it's a step in a direction.

git-svn-id: https://www.unprompted.com/svn/projects/tildefriends/trunk@4087 ed5197a5-7fde-0310-b194-c3ffbd925b24
This commit is contained in:
Cory McWilliams 2022-12-29 21:58:54 +00:00
parent 94d7d2e3e0
commit d9aee6d05f
2 changed files with 30 additions and 5 deletions

View File

@ -5,7 +5,7 @@ MAKEFLAGS += --no-builtin-rules
PROJECT = tildefriends
BUILD_DIR ?= out
BUILD_TYPES := debug release windebug winrelease
BUILD_TYPES := debug release windebug winrelease androiddebug androidrelease
UNAME_M := $(shell uname -m)
CFLAGS += \
@ -20,13 +20,27 @@ CFLAGS += \
-g
LDFLAGS += -Wl,-gc-sections
debug windebug: CFLAGS += -Og
debug release: LDFLAGS += -rdynamic
NDK_PATH := /usr/lib/android-sdk/ndk-bundle
NDK_SSL_PATH := deps/openssl_android
NDK_API_VERSION := 30
NDK_TARGET_TRIPLE := aarch64-linux-android
debug windebug androiddebug: CFLAGS += -Og
debug release androidrelease: LDFLAGS += -rdynamic
release winrelease: CFLAGS += -DNDEBUG -O3
windebug winrelease: CC = i686-w64-mingw32-gcc-win32
windebug winrelease: AS = $(CC)
windebug winrelease: CFLAGS += -D_WIN32_WINNT=0x0A00 -DWINVER=0x0A00 -DNTDDI_VERSION=NTDDI_WIN10
windebug winrelease: LDFLAGS += -static
androiddebug androidrelease: CC = $(NDK_PATH)/toolchains/llvm/prebuilt/linux-x86_64/bin/clang
androiddebug androidrelease: AS = $(CC)
androiddebug androidrelease: CFLAGS += \
-target $(NDK_TARGET_TRIPLE)$(NDK_API_VERSION) \
-I$(NDK_SSL_PATH)/arm64-v8a/usr/local/include \
-Wno-unknown-warning-option
androiddebug androidrelease: LDFLAGS += \
-target $(NDK_TARGET_TRIPLE)$(NDK_API_VERSION) \
-L$(NDK_SSL_PATH)/arm64-v8a/usr/local/lib
ifeq ($(UNAME_M),x86_64)
debug: CFLAGS += -fsanitize=address -fsanitize=undefined -fno-common
@ -36,7 +50,9 @@ endif
get_objs = \
$(foreach build_type,$(BUILD_TYPES),$(addprefix $(BUILD_DIR)/$(build_type)/,$(addsuffix .o,$(basename $(value $(1)))))) \
$(foreach build_type,debug release,$(addprefix $(BUILD_DIR)/$(build_type)/,$(addsuffix .o,$(basename $(value $(1)_unix))))) \
$(foreach build_type,windebug winrelease,$(addprefix $(BUILD_DIR)/$(build_type)/,$(addsuffix .o,$(basename $(value $(1)_win)))))
$(foreach build_type,windebug winrelease,$(addprefix $(BUILD_DIR)/$(build_type)/,$(addsuffix .o,$(basename $(value $(1)_win))))) \
$(foreach build_type,androiddebug androidrelease,$(addprefix $(BUILD_DIR)/$(build_type)/,$(addsuffix .o,$(basename $(value $(1)_android))))) \
$(foreach build_type,androiddebug androidrelease,$(addprefix $(BUILD_DIR)/$(build_type)/,$(addsuffix .o,$(basename $(value $(1)_unix)))))
APP_SOURCES := $(wildcard src/*.c)
APP_OBJS := $(call get_objs,APP_SOURCES)
@ -105,6 +121,9 @@ UV_SOURCES_unix := \
deps/libuv/src/unix/thread.c \
deps/libuv/src/unix/tty.c \
deps/libuv/src/unix/udp.c
UV_SOURCES_android := \
deps/libuv/src/unix/pthread-fixes.c \
deps/libuv/src/unix/random-getentropy.c
UV_SOURCES_win := \
deps/libuv/src/win/async.c \
deps/libuv/src/win/core.c \
@ -282,6 +301,10 @@ windebug winrelease: LDFLAGS += \
-lkernel32 \
-liphlpapi \
-luserenv
androiddebug androidrelease: LDFLAGS += \
-ldl \
-lssl \
-lcrypto
unix: debug release
win: windebug winrelease

View File

@ -29,7 +29,9 @@
#include <backtrace.h>
#ifndef _WIN32
#ifndef __ANDROID__
#include <execinfo.h>
#endif
#include <unistd.h>
#endif
@ -1147,7 +1149,7 @@ JSValue tf_task_allocate_promise(tf_task_t* task, promiseid_t* out_promise)
#ifdef _WIN32
count = CaptureStackBackTrace(0, sizeof(buffer) / sizeof(*buffer), buffer, NULL);
stack_hash = fnv32a((const void*)buffer, sizeof(void*) * count, stack_hash);
#else
#elif !defined(__ANDROID__)
count = backtrace(buffer, sizeof(buffer) / sizeof(*buffer));
stack_hash = fnv32a((const void*)buffer, sizeof(void*) * count, stack_hash);
#endif