Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
danielweck committed May 3, 2017
2 parents 7fe6413 + 7ec3ca6 commit 84761cc
Show file tree
Hide file tree
Showing 84 changed files with 3,107 additions and 1,951 deletions.
27 changes: 24 additions & 3 deletions Platform/Android/epub3/Application.mk
Original file line number Diff line number Diff line change
@@ -1,4 +1,25 @@
APP_ABI := armeabi-v7a x86
APP_PLATFORM := android-22
APP_PLATFORM := android-25

ifneq ($(READIUM_SKIPARM),true)

APP_ABI := armeabi-v7a

ifneq ($(READIUM_SKIPX86),true)
APP_ABI += x86
endif

else

APP_ABI := x86

endif

ifeq ($(READIUM_CLANG),true)
#NDK_TOOLCHAIN := clang
NDK_TOOLCHAIN_VERSION := clang
APP_STL := c++_shared
else
#NDK_TOOLCHAIN := gcc
NDK_TOOLCHAIN_VERSION := 4.9
APP_STL := gnustl_static
APP_STL := gnustl_shared
endif
438 changes: 233 additions & 205 deletions Platform/Android/epub3/Experimental.mk

Large diffs are not rendered by default.

82 changes: 53 additions & 29 deletions Platform/Android/epub3/Stable.mk
Original file line number Diff line number Diff line change
Expand Up @@ -21,46 +21,63 @@ THIRD_PARTY_PATH := $(EPUB3_PATH)/ThirdParty
###########################################################
# Prebuilt libraries for ICU

ICU_LIB_PATH := $(THIRD_PARTY_PATH)/icu4c/lib/$(TARGET_ARCH_ABI)
ICU_INCLUDE_PATH := $(THIRD_PARTY_PATH)/icu4c/include
#ICU_LIB_PATH := $(THIRD_PARTY_PATH)/icu4c/lib/$(TARGET_ARCH_ABI)
#ICU_INCLUDE_PATH := $(THIRD_PARTY_PATH)/icu4c/include

# Unicode

include $(CLEAR_VARS)
LOCAL_MODULE := icuuc
LOCAL_SRC_FILES := $(ICU_LIB_PATH)/libicuuc.a
LOCAL_EXPORT_C_INCLUDES := $(ICU_INCLUDE_PATH)
include $(PREBUILT_STATIC_LIBRARY)
#include $(CLEAR_VARS)
#LOCAL_MODULE := icuuc
#LOCAL_SRC_FILES := $(ICU_LIB_PATH)/libicuuc.a
#LOCAL_EXPORT_C_INCLUDES := $(ICU_INCLUDE_PATH)
#include $(PREBUILT_STATIC_LIBRARY)

# Internationalization

include $(CLEAR_VARS)
LOCAL_MODULE := icui18n
LOCAL_SRC_FILES := $(ICU_LIB_PATH)/libicui18n.a
LOCAL_EXPORT_C_INCLUDES := $(ICU_INCLUDE_PATH)
include $(PREBUILT_STATIC_LIBRARY)
#include $(CLEAR_VARS)
#LOCAL_MODULE := icui18n
#LOCAL_SRC_FILES := $(ICU_LIB_PATH)/libicui18n.a
#LOCAL_EXPORT_C_INCLUDES := $(ICU_INCLUDE_PATH)
#include $(PREBUILT_STATIC_LIBRARY)

# Input/Output

include $(CLEAR_VARS)
LOCAL_MODULE := icuio
LOCAL_SRC_FILES := $(ICU_LIB_PATH)/libicuio.a
LOCAL_EXPORT_C_INCLUDES := $(ICU_INCLUDE_PATH)
include $(PREBUILT_STATIC_LIBRARY)
#include $(CLEAR_VARS)
#LOCAL_MODULE := icuio
#LOCAL_SRC_FILES := $(ICU_LIB_PATH)/libicuio.a
#LOCAL_EXPORT_C_INCLUDES := $(ICU_INCLUDE_PATH)
#include $(PREBUILT_STATIC_LIBRARY)

# Data

include $(CLEAR_VARS)
LOCAL_MODULE := icudata
LOCAL_SRC_FILES := $(ICU_LIB_PATH)/libicudata.a
LOCAL_EXPORT_C_INCLUDES := $(ICU_INCLUDE_PATH)
include $(PREBUILT_STATIC_LIBRARY)
#include $(CLEAR_VARS)
#LOCAL_MODULE := icudata
#LOCAL_SRC_FILES := $(ICU_LIB_PATH)/libicudata.a
#LOCAL_EXPORT_C_INCLUDES := $(ICU_INCLUDE_PATH)
#include $(PREBUILT_STATIC_LIBRARY)

###########################################################
# libxml2

include $(CLEAR_VARS)
LOCAL_MODULE := xml2

ifeq ($(READIUM_CLANG),true)
LOCAL_CPPFLAGS := -std=c++11 -fpermissive -DBUILDING_EPUB3 -D_LIBCPP_INLINE_VISIBILITY_EXCEPT_GCC49=_LIBCPP_INLINE_VISIBILITY
LOCAL_CXXFLAGS := -std=c++11 -fpermissive -DBUILDING_EPUB3 -D_LIBCPP_INLINE_VISIBILITY_EXCEPT_GCC49=_LIBCPP_INLINE_VISIBILITY
LOCAL_CFLAGS := -std=c11 -DBUILDING_EPUB3 -D_LIBCPP_INLINE_VISIBILITY_EXCEPT_GCC49=_LIBCPP_INLINE_VISIBILITY
else
LOCAL_CPPFLAGS := -std=gnu++11 -fpermissive -DBUILDING_EPUB3
LOCAL_CXXFLAGS := -std=gnu++11 -fpermissive -DBUILDING_EPUB3
LOCAL_CFLAGS := -std=gnu11 -DBUILDING_EPUB3
endif

LOCAL_CPP_FEATURES += exceptions rtti

ifeq ($(TARGET_ARCH_ABI),x86)
LOCAL_CFLAGS += -mtune=atom -mssse3 -mfpmath=sse
endif

LOCAL_SRC_FILES := \
$(THIRD_PARTY_PATH)/libxml2-android/SAX.c \
$(THIRD_PARTY_PATH)/libxml2-android/entities.c \
Expand Down Expand Up @@ -116,16 +133,24 @@ include $(BUILD_STATIC_LIBRARY)
include $(CLEAR_VARS)
LOCAL_DISABLE_FATAL_LINKER_WARNINGS := true
LOCAL_MODULE := epub3

ifeq ($(READIUM_CLANG),true)
LOCAL_CPPFLAGS := -std=c++11 -fpermissive -DBUILDING_EPUB3 -D_LIBCPP_INLINE_VISIBILITY_EXCEPT_GCC49=_LIBCPP_INLINE_VISIBILITY
LOCAL_CXXFLAGS := -std=c++11 -fpermissive -DBUILDING_EPUB3 -D_LIBCPP_INLINE_VISIBILITY_EXCEPT_GCC49=_LIBCPP_INLINE_VISIBILITY
LOCAL_CFLAGS := -std=c11 -DBUILDING_EPUB3 -D_LIBCPP_INLINE_VISIBILITY_EXCEPT_GCC49=_LIBCPP_INLINE_VISIBILITY
else
LOCAL_CPPFLAGS := -std=gnu++11 -fpermissive -DBUILDING_EPUB3
LOCAL_CFLAGS := -DBUILDING_EPUB3
LOCAL_CXXFLAGS := -std=gnu++11 -fpermissive -DBUILDING_EPUB3
LOCAL_CFLAGS := -std=gnu11 -DBUILDING_EPUB3
endif

LOCAL_CPP_FEATURES += exceptions rtti

ifeq ($(TARGET_ARCH_ABI),x86)
LOCAL_CFLAGS += -mtune=atom -mssse3 -mfpmath=sse
endif

LOCAL_CXXFLAGS := -std=gnu++11 -fpermissive -DBUILDING_EPUB3
LOCAL_CPP_FEATURES += exceptions rtti
LOCAL_STATIC_LIBRARIES := xml2 crypto
LOCAL_STATIC_LIBRARIES := xml2
LOCAL_LDLIBS := -lz -landroid -llog
LOCAL_C_INCLUDES += \
$(LOCAL_PATH)/include \
Expand Down Expand Up @@ -230,8 +255,7 @@ LOCAL_SRC_FILES := \
$(EPUB3_PATH)/utilities/utfstring.cpp \
$(wildcard $(EPUB3_PATH)/ePub/*.cpp) \
$(wildcard $(LOCAL_PATH)/src/main/jni/*.cpp) \
$(wildcard $(LOCAL_PATH)/src/main/jni/jni/*.cpp) \
$(wildcard $(LOCAL_PATH)/src/main/jni/android/*.cpp)
$(wildcard $(LOCAL_PATH)/src/main/jni/jni/*.cpp)
# $(wildcard $(LOCAL_PATH)/src/main/jni/android/*.cpp)

include $(BUILD_SHARED_LIBRARY)

75 changes: 61 additions & 14 deletions Platform/Android/epub3/build.gradle
Original file line number Diff line number Diff line change
@@ -1,9 +1,17 @@
import org.apache.tools.ant.taskdefs.condition.Os
//import org.gradle.internal.os.OperatingSystem;

if (rootProject.hasProperty("readium_ndk_debug") && rootProject.readium_ndk_debug) {
// Use gradle experimental receipt to debug C/C++ code
println "${project.name}: Use gradle experimental to build application"

def ndk_skipX86 = (rootProject.hasProperty("readium_ndk_skipX86") && rootProject.readium_ndk_skipX86)
def ndk_skipARM = (rootProject.hasProperty("readium_ndk_skipARM") && rootProject.readium_ndk_skipARM)
def ndk_clang = (rootProject.hasProperty("readium_ndk_clang") && rootProject.readium_ndk_clang)
def ndk_experimental = (rootProject.hasProperty("readium_ndk_experimental") && rootProject.readium_ndk_experimental)

if (ndk_experimental) {
println "${project.name}: Using Gradle EXPERIMENTAL to build EPUB3 lib"
apply from: 'build_experimental.gradle'
} else {
println "${project.name}: Using Gradle STABLE to build EPUB3 lib"
}

/**
Expand All @@ -18,6 +26,12 @@ task copyLibxmlIncludes(type: Copy) {
task copySha1Includes(type: Copy) {
from '../../../ePub3/ThirdParty/sha1'
into './include/sha1'
include '*.h'
}

task copyICUIncludes(type: Copy) {
from '../../../ePub3/ThirdParty/icu4c/include'
into './include/icu4c'
include '**/*.h'
}

Expand All @@ -41,21 +55,37 @@ task copyGoogleUrlIncludes(dependsOn: 'copyGoogleUrlBaseIncludes', type: Copy) {
task copyLibzipBaseIncludes(type: Copy) {
from '../../../ePub3/ThirdParty/libzip'
into './include/libzip'
include '**/*.h'
include '*.h'
}

task copyEpub3XmlIncludes(type: Copy) {
task copyEpub3XmlIncludesTREE(type: Copy) {
from '../../../ePub3/xml/tree'
into './include/ePub3/xml'
include '*.h'
}

task copyEpub3XmlIncludesUTILS(type: Copy) {
from '../../../ePub3/xml/utilities'
into './include/ePub3/xml'
include '*.h'
}

task copyEpub3XmlIncludesVALIDATION(type: Copy) {
from '../../../ePub3/xml/validation'
into './include/ePub3/xml'
include '**/*.h'
include '*.h'
}

task copyEpub3XmlIncludes() {
println "Copy XML includes"
}

copyEpub3XmlIncludes.dependsOn "copyEpub3XmlIncludesVALIDATION", "copyEpub3XmlIncludesUTILS", "copyEpub3XmlIncludesTREE"

task copyEpub3UtilitiesIncludes(dependsOn: 'copyEpub3XmlIncludes', type: Copy) {
from '../../../ePub3/utilities'
into './include/ePub3/utilities'
include '**/*.h'
include '*.h'
}

task copyEpub3RootIncludes(dependsOn: 'copyEpub3UtilitiesIncludes', type: Copy) {
Expand All @@ -67,7 +97,7 @@ task copyEpub3RootIncludes(dependsOn: 'copyEpub3UtilitiesIncludes', type: Copy)
task copyEpub3Includes(dependsOn: 'copyEpub3RootIncludes', type: Copy) {
from '../../../ePub3/ePub'
into './include/ePub3'
include '**/*.h'
include '*.h'
}

task buildIncludes {
Expand All @@ -79,31 +109,48 @@ buildIncludes.dependsOn "copyEpub3Includes",
"copySha1Includes",
"copyUtf8Includes",
"copyGoogleUrlIncludes",
"copyICUIncludes",
"copyLibzipBaseIncludes"

task buildMk(dependsOn: "buildIncludes", type: Exec) {

// Retrieve ndk dir
Properties properties = new Properties()
properties.load(project.rootProject.file('local.properties').newDataInputStream())
def ndkDir = properties.getProperty('ndk.dir', null)

// Call ndk build
def ndkBuildExt = Os.isFamily(Os.FAMILY_WINDOWS) ? ".cmd" : ""

//def isWindows = OperatingSystem.current().isLinux();
def isWindows = Os.isFamily(Os.FAMILY_WINDOWS)

def ndkBuildExt = isWindows ? ".cmd" : ""
def projectPath = file('.').absolutePath
def buildScript = (rootProject.hasProperty("readium_ndk_debug") &&
rootProject.readium_ndk_debug) ? "Experimental.mk" : "Stable.mk"
def buildScript = (ndk_experimental) ? "Experimental.mk" : "Stable.mk"

if (ndk_skipX86) environment 'READIUM_SKIPX86', 'true'
if (ndk_skipARM) environment 'READIUM_SKIPARM', 'true'
if (ndk_clang) environment 'READIUM_CLANG', 'true'
if (ndk_experimental) environment 'READIUM_EXPERIMENTAL', 'true'

commandLine "$ndkDir/ndk-build${ndkBuildExt}",
"-j", "4", //Runtime.runtime.availableProcessors()
'-C', projectPath,
'NDK_APPLICATION_MK=Application.mk',
"APP_BUILD_SCRIPT=${buildScript}",
"NDK_PROJECT_PATH=${projectPath}"
"NDK_PROJECT_PATH=${projectPath}",
"NDK_DEBUG=1"
}

tasks.whenTaskAdded { task ->
def taskName = task.name

if (taskName.startsWith("compile")) {
task.dependsOn "buildMk"
if (ndk_experimental) {
println "${project.name} - ${taskName}: Using Gradle EXPERIMENTAL, no need to invoke external NDK / Makefile to build EPUB3 lib"
task.dependsOn "buildIncludes"
} else {
task.dependsOn "buildMk"
}
}
}
}
Loading

0 comments on commit 84761cc

Please sign in to comment.