Skip to content

Commit 2824898

Browse files
authored
Android build (#11)
* Android build fixes, incomplete. * restore unwanted changes * Android buildfixes. * enable CI
1 parent b0b1e07 commit 2824898

File tree

9 files changed

+53
-10
lines changed

9 files changed

+53
-10
lines changed

Diff for: .gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
/.dir-locals.el
22
/build/
3+
/obj/
34
/etc/b2_tests/[Zz]/
45
/dependencies/ProcessorTests/
56
*.etl

Diff for: .gitlab-ci.yml

+6-6
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,8 @@ include:
4040

4141
################################## CELLULAR ################################
4242
# Android
43-
#- project: 'libretro-infrastructure/ci-templates'
44-
# file: '/android-jni.yml'
43+
- project: 'libretro-infrastructure/ci-templates'
44+
file: '/android-jni.yml'
4545

4646
# iOS
4747
- project: 'libretro-infrastructure/ci-templates'
@@ -148,10 +148,10 @@ libretro-build-osx-arm64:
148148
# - .core-defs
149149

150150
# Android ARMv8a
151-
#android-arm64-v8a:
152-
# extends:
153-
# - .libretro-android-jni-arm64-v8a
154-
# - .core-defs
151+
android-arm64-v8a:
152+
extends:
153+
- .libretro-android-jni-arm64-v8a
154+
- .core-defs
155155

156156
# Android 64-bit x86
157157
#android-x86_64:

Diff for: jni/Android.mk

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
LOCAL_PATH := $(call my-dir)
2+
3+
CORE_DIR := $(LOCAL_PATH)/../src
4+
platform := unix
5+
include $(CORE_DIR)/libretro/Makefile.common
6+
7+
COREFLAGS := -D__LIBRETRO__ -DB2_LIBRETRO_CORE -DHAVE_STRLCPY -DBUILD_TYPE_Final -DBBCMICRO_TRACE $(INCFLAGS)
8+
9+
GIT_VERSION ?= " $(shell git rev-parse --short HEAD || echo unknown)"
10+
ifneq ($(GIT_VERSION)," unknown")
11+
COREFLAGS += -DGIT_VERSION=\"$(GIT_VERSION)\"
12+
endif
13+
14+
include $(CLEAR_VARS)
15+
LOCAL_MODULE := retro
16+
LOCAL_SRC_FILES := $(SOURCES_C) $(SOURCES_CPP)
17+
LOCAL_CXXFLAGS := $(COREFLAGS) -fexceptions -frtti -std=c++17
18+
LOCAL_CFLAGS := $(COREFLAGS)
19+
LOCAL_LDFLAGS := -Wl,-version-script=$(CORE_DIR)/link.T
20+
LOCAL_LDLIBS := -llog
21+
include $(BUILD_SHARED_LIBRARY)

Diff for: jni/Application.mk

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
APP_STL := c++_static
2+
APP_ABI := all

Diff for: src/libretro/Makefile.common

+2-2
Original file line numberDiff line numberDiff line change
@@ -39,22 +39,22 @@ SOURCES_CPP := \
3939
$(CORE_DIR)/beeb/src/TVOutput.cpp \
4040
$(CORE_DIR)/beeb/src/type.cpp \
4141
$(CORE_DIR)/beeb/src/video.cpp \
42+
$(CORE_DIR)/beeb/src/uef.cpp \
4243
$(CORE_DIR)/beeb/src/VideoULA.cpp \
4344
$(CORE_DIR)/shared/c/log.cpp \
4445
$(CORE_DIR)/shared/c/system.cpp \
4546
$(CORE_DIR)/shared/c/mutex.cpp \
4647
$(CORE_DIR)/shared/c/sha1.cpp \
4748
$(CORE_DIR)/shared/c/file_io.cpp \
49+
$(CORE_DIR)/shared/c/path.cpp \
4850
$(CORE_DIR)/beeb/src/DiscGeometry.cpp \
4951
$(CORE_DIR)/beeb/src/DirectDiscImage.cpp \
5052
$(CORE_DIR)/b2/filters.cpp \
5153
$(CORE_DIR)/b2/Remapper.cpp \
5254

5355
SOURCES_C := \
5456
$(CORE_DIR)/6502/c/6502.c \
55-
$(CORE_DIR)/shared/c/path.c \
5657

57-
5858
ifneq (,$(filter osx ios-arm64 tvos-arm64,$(platform)))
5959
SOURCES_CPP += \
6060
$(CORE_DIR)/shared/c/system_osx.cpp \

Diff for: src/link.T

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
global: retro_*;
3+
local: *;
4+
};
5+

Diff for: src/shared/c/log.cpp

+4-1
Original file line numberDiff line numberDiff line change
@@ -671,7 +671,7 @@ void LogStackTrace(Log *log) {
671671
if (!log) {
672672
return;
673673
}
674-
674+
#if !defined(ANDROID)
675675
void *buffer[100];
676676
int n = backtrace(buffer, sizeof buffer / sizeof buffer[0]);
677677

@@ -699,6 +699,9 @@ void LogStackTrace(Log *log) {
699699

700700
free(symbols);
701701
symbols = NULL;
702+
#else
703+
log->f("Stack trace not supported on Android");
704+
#endif
702705
}
703706

704707
//////////////////////////////////////////////////////////////////////////

Diff for: src/shared/c/system_linux.cpp

+10
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,10 @@
66
#include <strings.h>
77
#include <inttypes.h>
88
#include <stdlib.h>
9+
#if !defined(ANDROID)
910
#include <execinfo.h>
1011
#include <uuid/uuid.h>
12+
#endif
1113
#include <shared/debug.h>
1214
#include <fcntl.h>
1315
#include <sys/wait.h>
@@ -212,7 +214,11 @@ char **GetBacktraceSymbols(void *const *addresses, int num_addresses) {
212214

213215
if (num_addresses <= 0) {
214216
/* somebody else's problem... */
217+
#if !defined(ANDROID)
215218
return backtrace_symbols(addresses, num_addresses);
219+
#else
220+
return (char **)NULL;
221+
#endif
216222
}
217223

218224
char *result = NULL;
@@ -340,7 +346,11 @@ char **GetBacktraceSymbols(void *const *addresses, int num_addresses) {
340346

341347
#else
342348

349+
#if !defined(ANDROID)
343350
return backtrace_symbols(addresses, num_addresses);
351+
#else
352+
return (char **)NULL;
353+
#endif
344354

345355
#endif
346356
}

Diff for: src/shared/h/shared/system_posix.h

+2-1
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,9 @@ extern "C" {
1515
* system_windows.h, and it's certainly convenient. */
1616
#include <signal.h>
1717
#include <unistd.h>
18+
#if !defined(ANDROID)
1819
#include <execinfo.h>
19-
20+
#endif
2021
//////////////////////////////////////////////////////////////////////////
2122
//////////////////////////////////////////////////////////////////////////
2223

0 commit comments

Comments
 (0)