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

Android: Introduce ServoSurface #21234

Merged
merged 3 commits into from Aug 1, 2018
Merged
Changes from 1 commit
Commits
File filter...
Filter file types
Jump to…
Jump to file
Failed to load files.

Always

Just for now

Next

Build a AAR archive alongside the APK

  • Loading branch information
paulrouget committed Aug 1, 2018
commit e8af185a3d78ab8a578fa9ced616050c46bf4d14
@@ -214,10 +214,12 @@ def package(self, release=False, dev=False, android=None, debug=False, debugger=
if flavor is not None:
flavor_name = flavor.title()

task_name = "assemble" + flavor_name + build_type + build_mode
variant = ":assemble" + flavor_name + build_type + build_mode
apk_task_name = ":servoapp" + variant
aar_task_name = ":servoview" + variant
try:
with cd(path.join("support", "android", "apk")):
subprocess.check_call(["./gradlew", "--no-daemon", task_name], env=env)
subprocess.check_call(["./gradlew", "--no-daemon", apk_task_name, aar_task_name], env=env)
except subprocess.CalledProcessError as e:
print("Packaging Android exited with return value %d" % e.returncode)
return e.returncode
@@ -1,4 +1,5 @@
// Top-level build file where you can add configuration options common to all sub-projects/modules.
import org.apache.tools.ant.taskdefs.condition.Os

buildscript {
repositories {
jcenter()
@@ -17,6 +18,68 @@ allprojects {
}
google()
}
}

// Utility methods
String getTargetDir(boolean debug, String arch) {
def basePath = project.rootDir.getParentFile().getParentFile().getParentFile().absolutePath
return basePath + '/target/' + getSubTargetDir(debug, arch)
}

String getSubTargetDir(boolean debug, String arch) {
return getRustTarget(arch) + '/' + (debug ? 'debug' : 'release')
}

String getJniLibsPath(boolean debug, String arch) {
return getTargetDir(debug, arch) + '/apk/jniLibs'
}

static String getRustTarget(String arch) {
switch (arch.toLowerCase()) {
case 'arm' : return 'arm-linux-androideabi'
case 'armv7' : return 'armv7-linux-androideabi'
case 'arm64' : return 'aarch64-linux-android'
case 'x86' : return 'i686-linux-android'
default: throw new GradleException("Invalid target architecture " + arch)
}
}

buildDir = rootDir.absolutePath + "/../../../target/gradle"
static String getNDKAbi(String arch) {
switch (arch.toLowerCase()) {
case 'arm' : return 'armeabi'
case 'armv7' : return 'armeabi-v7a'
case 'arm64' : return 'arm64-v8a'
case 'x86' : return 'x86'
default: throw new GradleException("Invalid target architecture " + arch)
}
}

String getNdkDir() {
// Read environment variable used in rust build system
String ndkDir = System.getenv('ANDROID_NDK')
if (ndkDir == null) {
ndkDir = System.getenv('ANDROID_NDK_HOME')
}
if (ndkDir == null) {
ndkDir = System.getenv('ANDROID_NDK_ROOT')
}
if (ndkDir == null) {
// Fallback to ndkDir in local.properties
def rootDir = project.rootDir
def localProperties = new File(rootDir, "local.properties")
Properties properties = new Properties()
localProperties.withInputStream { instr ->
properties.load(instr)
}

ndkDir = properties.getProperty('ndk.dir')
}

def cmd = Os.isFamily(Os.FAMILY_WINDOWS) ? 'ndk-build.cmd' : 'ndk-build'
def ndkbuild = new File(ndkDir + '/' + cmd)
if (!ndkbuild.exists()) {
throw new GradleException("Please set a valid NDK_HOME environment variable" +
"or ndk.dir path in local.properties file");
}
return ndkbuild.absolutePath
}
@@ -17,6 +17,6 @@ MY_LOCAL_PATH := $(call my-dir)

include $(CLEAR_VARS)
LOCAL_PATH:= $(SERVO_TARGET_DIR)
LOCAL_MODULE := servo
LOCAL_MODULE := servojni
LOCAL_SRC_FILES := libsimpleservo.so
include $(PREBUILT_SHARED_LIBRARY)
@@ -1,4 +1,4 @@
NDK_TOOLCHAIN_VERSION := 4.9
APP_MODULES := c++_shared servo
APP_MODULES := c++_shared servojni
APP_PLATFORM := android-18
APP_STL:= c++_shared
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.