Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Various Android / Gradle updates (current working build) #317

Open
wants to merge 11 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
76 changes: 53 additions & 23 deletions Platform/Android/build.gradle
Original file line number Diff line number Diff line change
@@ -1,50 +1,80 @@
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
jcenter()
}
dependencies {

Properties properties = new Properties()
properties.load(rootProject.file('local.properties').newDataInputStream())
Properties properties = new Properties()
properties.load(rootProject.file('local.properties').newDataInputStream())

def ndkClang = properties.getProperty('readium.ndk_clang', "false")
ndkClang = (ndkClang == "true") ? true : false;
rootProject.ext.set('readium_ndk_clang', ndkClang)
def ndkClang = properties.getProperty('readium.ndk_clang', "false")
ndkClang = (ndkClang == "true") ? true : false;
rootProject.ext.set('readium_ndk_clang', ndkClang)
// def ndk_clang = (rootProject.hasProperty("readium_ndk_clang") && rootProject.readium_ndk_clang)
// if (ndk_clang) environment 'READIUM_CLANG', 'true'

def ndkSkipX86 = properties.getProperty('readium.ndk_skipX86', "false")
ndkSkipX86 = (ndkSkipX86 == "true") ? true : false;
rootProject.ext.set('readium_ndk_skipX86', ndkSkipX86)
def ndkSkipX86 = properties.getProperty('readium.ndk_skipX86', "false")
ndkSkipX86 = (ndkSkipX86 == "true") ? true : false;
rootProject.ext.set('readium_ndk_skipX86', ndkSkipX86)
// def ndk_skipX86 = (rootProject.hasProperty("readium_ndk_skipX86") && rootProject.readium_ndk_skipX86)
// if (ndk_skipX86) environment 'READIUM_SKIPX86', 'true'

def ndkSkipARM = properties.getProperty('readium.ndk_skipARM', "false")
ndkSkipARM = (ndkSkipARM == "true") ? true : false;
rootProject.ext.set('readium_ndk_skipARM', ndkSkipARM)
def ndkSkipARM = properties.getProperty('readium.ndk_skipARM', "false")
ndkSkipARM = (ndkSkipARM == "true") ? true : false;
rootProject.ext.set('readium_ndk_skipARM', ndkSkipARM)
// def ndk_skipARM = (rootProject.hasProperty("readium_ndk_skipARM") && rootProject.readium_ndk_skipARM)
// if (ndk_skipARM) environment 'READIUM_SKIPARM', 'true'

def ndkExperimental = properties.getProperty('readium.ndk_experimental', "false")
ndkExperimental = (ndkExperimental == "true") ? true : false;
rootProject.ext.set('readium_ndk_experimental', ndkExperimental)
def ndkExperimental = properties.getProperty('readium.ndk_experimental', "false")
ndkExperimental = (ndkExperimental == "true") ? true : false;
rootProject.ext.set('readium_ndk_experimental', ndkExperimental)
// def ndk_experimental = (rootProject.hasProperty("readium_ndk_experimental") && rootProject.readium_ndk_experimental)
// if (ndk_experimental) environment 'READIUM_EXPERIMENTAL', 'true'

// Use stable gradle or experimental gradle
println "[[${project.name}]] (ROOT) Gradle Experimental: ${ndkExperimental}"
println "[[${project.name}]] (ROOT) Skip ARM: ${ndkSkipARM}"
println "[[${project.name}]] (ROOT) Skip x86: ${ndkSkipX86}"
println "[[${project.name}]] (ROOT) Clang: ${ndkClang}"

buildscript {
repositories {
Properties properties = new Properties()
properties.load(rootProject.file('local.properties').newDataInputStream())
def ndkExperimental = properties.getProperty('readium.ndk_experimental', "false")
ndkExperimental = (ndkExperimental == "true") ? true : false;

if (!ndkExperimental) {
google()
}
maven {
url "https://maven.google.com"
}
jcenter()
}

dependencies {
Properties properties = new Properties()
properties.load(rootProject.file('local.properties').newDataInputStream())
def ndkExperimental = properties.getProperty('readium.ndk_experimental', "false")
ndkExperimental = (ndkExperimental == "true") ? true : false;

if (ndkExperimental) {
//https://bintray.com/android/android-tools/com.android.tools.build.gradle-experimental/view
// https://bintray.com/android/android-tools/com.android.tools.build.gradle-experimental/view
// https://mvnrepository.com/artifact/com.android.tools.build/gradle-experimental?repo=google
// 0.11.1 fails https://stackoverflow.com/questions/47057160/
classpath "com.android.tools.build:gradle-experimental:0.9.3"
} else {
//https://bintray.com/android/android-tools/com.android.tools.build.gradle/view
classpath "com.android.tools.build:gradle:2.3.3"
// https://bintray.com/android/android-tools/com.android.tools.build.gradle/view
// https://mvnrepository.com/artifact/com.android.tools.build/gradle?repo=google
classpath "com.android.tools.build:gradle:3.4.1"
}
}
}

allprojects {
repositories {
if (!ndkExperimental) {
google()
}
maven {
url "https://maven.google.com"
}
jcenter()
flatDir {
dirs 'libs'
Expand Down
3 changes: 3 additions & 0 deletions Platform/Android/clean.sh
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
#!/bin/sh

rm -rf build
rm -rf dist

rm -rf epub3/build
rm -rf epub3/include
rm -rf epub3/libs
rm -rf epub3/jniLibs
rm -rf epub3/obj
#rm -rf epub3/src/main/gen2remove

rm -rf lib/build
rm -rf lib/libs
3 changes: 3 additions & 0 deletions Platform/Android/epub3/Application.mk
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,17 @@ APP_PLATFORM := android-19
ifneq ($(READIUM_SKIPARM),true)

APP_ABI := armeabi-v7a
APP_ABI += arm64-v8a

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

else

APP_ABI := x86
APP_ABI += x86_64

endif

Expand Down
13 changes: 13 additions & 0 deletions Platform/Android/epub3/Stable.mk
Original file line number Diff line number Diff line change
Expand Up @@ -170,9 +170,22 @@ endif

LOCAL_CPP_FEATURES += exceptions rtti

ifneq ($(TARGET_ARCH_ABI),x86)
ifneq ($(TARGET_ARCH_ABI),x86_64)
ifneq ($(TARGET_ARCH_ABI),arm64-v8a)
LOCAL_CPPFLAGS += -J6
LOCAL_CXXFLAGS += -J6
LOCAL_CFLAGS += -J6
endif
endif
endif

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

LOCAL_STATIC_LIBRARIES := xml2
LOCAL_LDLIBS := -lz -landroid -llog
Expand Down
37 changes: 20 additions & 17 deletions Platform/Android/epub3/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,17 @@ def ndk_skipARM = (rootProject.hasProperty("readium_ndk_skipARM") && rootProject
def ndk_clang = (rootProject.hasProperty("readium_ndk_clang") && rootProject.readium_ndk_clang)
def ndk_experimental = (rootProject.hasProperty("readium_ndk_experimental") && rootProject.readium_ndk_experimental)

println "[[${project.name}]] (EPUB3) Gradle Experimental: ${ndk_experimental}"
println "[[${project.name}]] (EPUB3) Skip ARM: ${ndk_skipARM}"
println "[[${project.name}]] (EPUB3) Skip x86: ${ndk_skipX86}"
println "[[${project.name}]] (EPUB3) Clang: ${ndk_clang}"

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"
}
// else {
// defaultTasks 'buildMk'
// }

/**
* Prebuild using ndk
Expand Down Expand Up @@ -77,7 +82,7 @@ task copyEpub3XmlIncludesVALIDATION(type: Copy) {
}

task copyEpub3XmlIncludes() {
println "Copy XML includes"
println "[[${project.name}]] (EPUB3) Task: copyEpub3XmlIncludes"
}

copyEpub3XmlIncludes.dependsOn "copyEpub3XmlIncludesVALIDATION", "copyEpub3XmlIncludesUTILS", "copyEpub3XmlIncludesTREE"
Expand All @@ -101,7 +106,7 @@ task copyEpub3Includes(dependsOn: 'copyEpub3RootIncludes', type: Copy) {
}

task buildIncludes {
println "Build includes"
println "[[${project.name}]] (EPUB3) Task: buildIncludes"
}

buildIncludes.dependsOn "copyEpub3Includes",
Expand All @@ -114,16 +119,14 @@ buildIncludes.dependsOn "copyEpub3Includes",

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

// Retrieve ndk dir
println "[[${project.name}]] (EPUB3) Task: buildMk"

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

def ndkDirIncludes = "${ndkDir}/sysroot/usr/include".toString().replaceAll("\\\\", "/")
println "NDK includes: ${ndkDirIncludes}"
environment "READIUM_NDK_INCLUDE_DIR", "${ndkDirIncludes}"

// Call ndk build
// def ndkDirIncludes = "${ndkDir}/sysroot/usr/include".toString().replaceAll("\\\\", "/")
// environment "READIUM_NDK_INCLUDE_DIR", "${ndkDirIncludes}"

//def isWindows = OperatingSystem.current().isLinux();
def isWindows = Os.isFamily(Os.FAMILY_WINDOWS)
Expand All @@ -138,7 +141,7 @@ task buildMk(dependsOn: "buildIncludes", type: Exec) {
if (ndk_experimental) environment 'READIUM_EXPERIMENTAL', 'true'

commandLine "$ndkDir/ndk-build${ndkBuildExt}",
"-j", "4", //Runtime.runtime.availableProcessors()
"-j", "12", //Runtime.runtime.availableProcessors()
'-C', projectPath,
'NDK_APPLICATION_MK=Application.mk',
"APP_BUILD_SCRIPT=${buildScript}",
Expand All @@ -147,14 +150,14 @@ task buildMk(dependsOn: "buildIncludes", type: Exec) {
}

tasks.whenTaskAdded { task ->
def taskName = task.name
println "[[${project.name}]] (EPUB3) TaskAdded: ${task.name}"

if (taskName.startsWith("compile")) {
if (task.name.startsWith("compile")) {
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"
}
// else {
// task.dependsOn "buildMk"
// }
}
}
Loading