Skip to content

Commit

Permalink
add missing android template, build android for x86 and x86_64
Browse files Browse the repository at this point in the history
  • Loading branch information
ianmaclarty committed Oct 21, 2019
1 parent 4cf6305 commit 156869c
Show file tree
Hide file tree
Showing 5 changed files with 63 additions and 10 deletions.
42 changes: 39 additions & 3 deletions Common.mk
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ SELF_DIR := $(dir $(lastword $(MAKEFILE_LIST)))
SPACE1=
SPACE=$(SPACE1) $(SPACE1)

TARGET_PLATFORMS = linux32 linux64 msvc32 msvc64 osx ios android32 android64 html mingw32 mingw64
TARGET_PLATFORMS = linux32 linux64 msvc32 msvc64 osx ios android_arm32 android_arm64 android_x86 android_x86_64 html mingw32 mingw64

# Directories

Expand Down Expand Up @@ -223,7 +223,7 @@ else ifeq ($(TARGET_PLATFORM),ios)
$(IOS_GRAPHICS_LINK_OPT) -Wl,-framework,GameKit $(GOOGLE_ADS_FRAMEWORK_OPT)
LUA_CFLAGS += -DLUA_USE_POSIX -DIPHONEOS
IOS = 1
else ifeq ($(TARGET_PLATFORM),android32)
else ifeq ($(TARGET_PLATFORM),android_arm32)
# useful documentation: https://android.googlesource.com/platform/ndk/+/ndk-release-r20/docs/BuildSystemMaintainers.md
NDK_ANDROID_VER=23
NDK_VER=$(NDK_HOME)/toolchains/llvm
Expand All @@ -241,7 +241,7 @@ else ifeq ($(TARGET_PLATFORM),android32)
-llog -landroid -lEGL -lGLESv2 -llog -lc -lm
LUA_CFLAGS += -DLUA_USE_POSIX
ANDROID = 1
else ifeq ($(TARGET_PLATFORM),android64)
else ifeq ($(TARGET_PLATFORM),android_arm64)
# useful documentation: https://android.googlesource.com/platform/ndk/+/ndk-release-r20/docs/BuildSystemMaintainers.md
NDK_ANDROID_VER=23
NDK_VER=$(NDK_HOME)/toolchains/llvm
Expand All @@ -259,6 +259,42 @@ else ifeq ($(TARGET_PLATFORM),android64)
-llog -landroid -lEGL -lGLESv2 -llog -lc -lm
LUA_CFLAGS += -DLUA_USE_POSIX
ANDROID = 1
else ifeq ($(TARGET_PLATFORM),android_x86)
# useful documentation: https://android.googlesource.com/platform/ndk/+/ndk-release-r20/docs/BuildSystemMaintainers.md
NDK_ANDROID_VER=23
NDK_VER=$(NDK_HOME)/toolchains/llvm
CC = $(NDK_HOME)/toolchains/llvm/prebuilt/$(NDK_HOST)/bin/clang
CPP = $(NDK_HOME)/toolchains/llvm/prebuilt/$(NDK_HOST)/bin/clang++
LINK = $(CPP)
AR= $(NDK_VER)/prebuilt/$(NDK_HOST)/bin/i686-linux-android-ar
TARGET_CFLAGS += -fPIC \
-target i686-linux-android$(NDK_ANDROID_VER) -fno-exceptions -fno-rtti \
-I$(NDK_HOME)/sources/android/native_app_glue \
-DANDROID
XLDFLAGS = $(TARGET_CFLAGS) -Wl,-soname,libamulet.so -shared \
-static-libstdc++ \
-no-canonical-prefixes \
-llog -landroid -lEGL -lGLESv2 -llog -lc -lm
LUA_CFLAGS += -DLUA_USE_POSIX
ANDROID = 1
else ifeq ($(TARGET_PLATFORM),android_x86_64)
# useful documentation: https://android.googlesource.com/platform/ndk/+/ndk-release-r20/docs/BuildSystemMaintainers.md
NDK_ANDROID_VER=23
NDK_VER=$(NDK_HOME)/toolchains/llvm
CC = $(NDK_HOME)/toolchains/llvm/prebuilt/$(NDK_HOST)/bin/clang
CPP = $(NDK_HOME)/toolchains/llvm/prebuilt/$(NDK_HOST)/bin/clang++
LINK = $(CPP)
AR= $(NDK_VER)/prebuilt/$(NDK_HOST)/bin/x86_64-linux-android-ar
TARGET_CFLAGS += -fPIC \
-target x86_64-linux-android$(NDK_ANDROID_VER) -fno-exceptions -fno-rtti \
-I$(NDK_HOME)/sources/android/native_app_glue \
-DANDROID
XLDFLAGS = $(TARGET_CFLAGS) -Wl,-soname,libamulet.so -shared \
-static-libstdc++ \
-no-canonical-prefixes \
-llog -landroid -lEGL -lGLESv2 -llog -lc -lm
LUA_CFLAGS += -DLUA_USE_POSIX
ANDROID = 1
else ifeq ($(TARGET_PLATFORM),html)
CC = emcc
CPP = em++
Expand Down
12 changes: 8 additions & 4 deletions scripts/travis.sh
Original file line number Diff line number Diff line change
Expand Up @@ -54,10 +54,14 @@ else
unzip android-ndk.zip > /dev/null
export NDK_HOME=`pwd`/$NDK
export NDK_HOST=linux-x86_64
make -j2 TARGET=android32.release LUAVM=lua51
make -j2 TARGET=android32.release LUAVM=lua52
make -j2 TARGET=android64.release LUAVM=lua51
make -j2 TARGET=android64.release LUAVM=lua52
make -j2 TARGET=android_arm32.release LUAVM=lua51
make -j2 TARGET=android_arm32.release LUAVM=lua52
make -j2 TARGET=android_arm64.release LUAVM=lua51
make -j2 TARGET=android_arm64.release LUAVM=lua52
make -j2 TARGET=android_x86.release LUAVM=lua51
make -j2 TARGET=android_x86.release LUAVM=lua52
make -j2 TARGET=android_x86_64.release LUAVM=lua51
make -j2 TARGET=android_x86_64.release LUAVM=lua52
else
# build osx
make -j2 TARGET=osx.release LUAVM=lua51 test
Expand Down
12 changes: 10 additions & 2 deletions src/am_export.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -925,6 +925,8 @@ static bool gen_android_studio_proj(export_config *conf) {
char *jnilibs_dir = am_format("%s/app/src/main/jniLibs", projbase_dir);
char *jnilibs_arm32_dir = am_format("%s/app/src/main/jniLibs/armeabi-v7a", projbase_dir);
char *jnilibs_arm64_dir = am_format("%s/app/src/main/jniLibs/arm64-v8a", projbase_dir);
char *jnilibs_x86_dir = am_format("%s/app/src/main/jniLibs/x86", projbase_dir);
char *jnilibs_x86_64_dir = am_format("%s/app/src/main/jniLibs/x86_64", projbase_dir);

char *proguard_rules_src_path = am_format("%sandroid/app/proguard-rules.pro", templates_dir);
char *proguard_rules_dst_path = am_format("%s/app/proguard-rules.pro", projbase_dir);
Expand Down Expand Up @@ -952,6 +954,8 @@ static bool gen_android_studio_proj(export_config *conf) {
am_make_dir(jnilibs_dir);
am_make_dir(jnilibs_arm32_dir);
am_make_dir(jnilibs_arm64_dir);
am_make_dir(jnilibs_x86_dir);
am_make_dir(jnilibs_x86_64_dir);

bool ok =
copy_android_project_iml(conf, projbase_dir) &&
Expand All @@ -966,8 +970,10 @@ static bool gen_android_studio_proj(export_config *conf) {
copy_text_file(build_gradle_src_path, build_gradle_dst_path, NULL) &&
copy_text_file(gradle_properties_src_path, gradle_properties_dst_path, NULL) &&
copy_text_file(settings_gradle_src_path, settings_gradle_dst_path, NULL) &&
copy_platform_bin_file(jnilibs_arm32_dir, conf, "libamulet.so", "android32") &&
copy_platform_bin_file(jnilibs_arm64_dir, conf, "libamulet.so", "android64") &&
copy_platform_bin_file(jnilibs_arm32_dir, conf, "libamulet.so", "android_arm32") &&
copy_platform_bin_file(jnilibs_arm64_dir, conf, "libamulet.so", "android_arm64") &&
copy_platform_bin_file(jnilibs_x86_dir, conf, "libamulet.so", "android_x86") &&
copy_platform_bin_file(jnilibs_x86_64_dir, conf, "libamulet.so", "android_x86_64") &&
copy_data_files(conf, assets_dir) &&
true;
if (ok) printf("Generated %s\n", projbase_dir);
Expand All @@ -986,6 +992,8 @@ static bool gen_android_studio_proj(export_config *conf) {
free(jnilibs_dir);
free(jnilibs_arm32_dir);
free(jnilibs_arm64_dir);
free(jnilibs_x86_dir);
free(jnilibs_x86_64_dir);

free(proguard_rules_src_path);
free(proguard_rules_dst_path);
Expand Down
2 changes: 1 addition & 1 deletion src/amulet.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
#if defined(AM_IOS32) || defined(AM_IOS64) || defined(AM_IOSSIM)
#define AM_IOS
#endif
#if defined(AM_ANDROID32) || defined(AM_ANDROID64)
#if defined(AM_ANDROID_ARM32) || defined(AM_ANDROID_ARM64) || defined(AM_ANDROID_X86) || defined(AM_ANDROID_X86_64)
#define AM_ANDROID
#endif
#if defined(AM_WINDOWS) || defined(AM_OSX) || defined(AM_LINUX)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
<background android:drawable="@mipmap/ic_launcher_background" />
<foreground android:drawable="@mipmap/ic_launcher_foreground" />
</adaptive-icon>

0 comments on commit 156869c

Please sign in to comment.