Update Gradle and SDK

This commit is contained in:
Paul Rouget 2018-07-11 15:26:41 +02:00
parent bef2fe83cd
commit 6a31864126
20 changed files with 49 additions and 53 deletions

View file

@ -63,7 +63,7 @@ class MachCommands(CommandBase):
ndk = "android-ndk-r12b-{system}-{arch}" ndk = "android-ndk-r12b-{system}-{arch}"
tools = "sdk-tools-{system}-4333796" tools = "sdk-tools-{system}-4333796"
sdk_build_tools = "25.0.2" sdk_build_tools = "27.0.3"
emulator_images = [ emulator_images = [
("servo-arm", "25", "google_apis;armeabi-v7a"), ("servo-arm", "25", "google_apis;armeabi-v7a"),
("servo-x86", "28", "google_apis;x86"), ("servo-x86", "28", "google_apis;x86"),

View file

@ -333,7 +333,7 @@ class CommandBase(object):
def get_apk_path(self, release): def get_apk_path(self, release):
base_path = self.get_target_dir() base_path = self.get_target_dir()
base_path = path.join(base_path, self.config["android"]["target"]) base_path = path.join(base_path, self.config["android"]["target"])
apk_name = "servo.apk" apk_name = "servoapp.apk"
build_type = "release" if release else "debug" build_type = "release" if release else "debug"
return path.join(base_path, build_type, apk_name) return path.join(base_path, build_type, apk_name)

View file

@ -42,7 +42,7 @@ from servo.util import delete
PACKAGES = { PACKAGES = {
'android': [ 'android': [
'target/armv7-linux-androideabi/release/servo.apk', 'target/armv7-linux-androideabi/release/servoapp.apk',
], ],
'linux': [ 'linux': [
'target/release/servo-tech-demo.tar.gz', 'target/release/servo-tech-demo.tar.gz',

View file

@ -607,8 +607,7 @@ class MachCommands(CommandBase):
env = self.build_env(target=target) env = self.build_env(target=target)
os.environ["PATH"] = env["PATH"] os.environ["PATH"] = env["PATH"]
assert self.handle_android_target(target) assert self.handle_android_target(target)
binary_path = self.get_binary_path(release, dev, android=True) apk = self.get_apk_path(release)
apk = binary_path + ".apk"
py = path.join(self.context.topdir, "etc", "run_in_headless_android_emulator.py") py = path.join(self.context.topdir, "etc", "run_in_headless_android_emulator.py")
return [py, avd, apk] return [py, avd, apk]

View file

@ -2,9 +2,10 @@
buildscript { buildscript {
repositories { repositories {
jcenter() jcenter()
google()
} }
dependencies { dependencies {
classpath 'com.android.tools.build:gradle:2.2.3' classpath 'com.android.tools.build:gradle:3.1.3'
} }
} }
@ -14,6 +15,7 @@ allprojects {
flatDir { flatDir {
dirs rootDir.absolutePath + "/../../../target/android_aar" dirs rootDir.absolutePath + "/../../../target/android_aar"
} }
google()
} }
buildDir = rootDir.absolutePath + "/../../../target/gradle" buildDir = rootDir.absolutePath + "/../../../target/gradle"

View file

@ -1,5 +1,6 @@
#Wed Jul 11 13:23:08 CEST 2018
distributionBase=GRADLE_USER_HOME distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-2.14.1-all.zip distributionUrl=https\://services.gradle.org/distributions/gradle-4.4-all.zip

View file

@ -6,18 +6,15 @@ import java.util.regex.Matcher
import java.util.regex.Pattern import java.util.regex.Pattern
android { android {
compileSdkVersion 25 compileSdkVersion 27
buildToolsVersion "25.0.2" buildToolsVersion '27.0.3'
defaultConfig { defaultConfig {
applicationId "com.mozilla.servo" applicationId "com.mozilla.servo"
minSdkVersion 18 minSdkVersion 18
targetSdkVersion 25 targetSdkVersion 27
versionCode 1 versionCode 1
versionName "1.0.0" versionName "1.0.0"
jackOptions {
enabled true
}
} }
compileOptions { compileOptions {
@ -33,6 +30,13 @@ android {
} }
} }
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
flavorDimensions "default"
productFlavors { productFlavors {
main { main {
} }
@ -144,25 +148,27 @@ android {
variant.setIgnore(true); variant.setIgnore(true);
} }
} }
// Define apk output directory // Define apk output directory
applicationVariants.all { variant -> applicationVariants.all { variant ->
variant.outputs.each { output -> variant.outputs.all { output ->
def name = variant.buildType.name Pattern pattern = Pattern.compile(/^[\w\d]+([A-Z][\w\d]+)(Debug|Release)/)
output.outputFile = new File(getApkPath(isDebug(name), getArch(name))) Matcher matcher = pattern.matcher(variant.name)
if (!matcher.find()) {
throw "Invalid variant name for output"
}
def arch = matcher.group(1)
def debug = variant.name.contains("Debug")
def path = "../../../../../" + getSubTargetDir(debug, arch) + "/servoapp.apk";
outputFileName = new File(path)
} }
} }
// Call our custom NDK Build task using flavor parameters // Call our custom NDK Build task using flavor parameters
tasks.all { tasks.all {
compileTask -> compileTask ->
// Parse architecture name from gradle task name: Pattern pattern = Pattern.compile(/^compile[A-Z][\w\d]+([A-Z][\w\d]+)(Debug|Release)/)
// Examples: transformJackWithJackForMainArmv7Release, transformJackWithJackForOculusvrArmv7Release Matcher matcher = pattern.matcher(compileTask.name)
Pattern pattern = Pattern.compile(/^transformJackWithJackFor[A-Z][\w\d]+([A-Z][\w\d]+)(Debug|Release)/);
Matcher matcher = pattern.matcher(compileTask.name);
// You can use this alternative pattern when jackCompiler is disabled
// Pattern pattern = Pattern.compile(/^compile([\w\d]+)(Debug|Release)/);
// Matcher matcher = pattern.matcher(compileTask.name);
if (!matcher.find()) { if (!matcher.find()) {
return return
} }
@ -188,18 +194,17 @@ android {
dependencies { dependencies {
//Dependency list //Dependency list
def deps = [ def deps = [
new ServoDependency("blurdroid.jar", "blurdroid") new ServoDependency("blurdroid.jar", "blurdroid")
] ]
// Iterate all build types and dependencies // Iterate all build types and dependencies
// For each dependency call the proper compile command and set the correct dependency path // For each dependency call the proper implementation command and set the correct dependency path
def list = ['arm', 'armv7', 'arm64', 'x86'] def list = ['arm', 'armv7', 'arm64', 'x86']
for (arch in list) { for (arch in list) {
for (debug in [true, false]) { for (debug in [true, false]) {
String basePath = getTargetDir(debug, arch) + "/build" String basePath = getTargetDir(debug, arch) + "/build"
String cmd = arch + (debug ? "Debug" : "Release") + "Compile" String cmd = arch + (debug ? "Debug" : "Release") + "Implementation"
for (ServoDependency dep: deps) { for (ServoDependency dep : deps) {
String path = findDependencyPath(basePath, dep.fileName, dep.folderFilter) String path = findDependencyPath(basePath, dep.fileName, dep.folderFilter)
if (path) { if (path) {
"${cmd}" files(path) "${cmd}" files(path)
@ -207,38 +212,27 @@ dependencies {
} }
} }
} }
googlevrImplementation 'com.google.vr:sdk-base:1.140.0'
googlevrCompile 'com.google.vr:sdk-base:1.70.0' googlevrImplementation(name: 'GVRService', ext: 'aar')
googlevrCompile(name:'GVRService', ext:'aar') oculusvrImplementation(name: 'OVRService', ext: 'aar')
oculusvrCompile(name:'OVRService', ext:'aar') implementation 'com.android.support.constraint:constraint-layout:1.1.2'
// compile is deprecated. Will become "implementation" once we upgrade graddle.
compile 'com.android.support.constraint:constraint-layout:1.0.0'
} }
// Utility methods // Utility methods
String getTargetDir(boolean debug, String arch) { String getTargetDir(boolean debug, String arch) {
def basePath = project.rootDir.getParentFile().getParentFile().getParentFile().absolutePath def basePath = project.rootDir.getParentFile().getParentFile().getParentFile().absolutePath
return basePath + '/target/' + getRustTarget(arch) + '/' + (debug ? 'debug' : 'release') return basePath + '/target/' + getSubTargetDir(debug, arch)
} }
String getApkPath(boolean debug, String arch) { String getSubTargetDir(boolean debug, String arch) {
return getTargetDir(debug, arch) + '/servo.apk' return getRustTarget(arch) + '/' + (debug ? 'debug' : 'release')
} }
String getJniLibsPath(boolean debug, String arch) { String getJniLibsPath(boolean debug, String arch) {
return getTargetDir(debug, arch) + '/apk/jniLibs' return getTargetDir(debug, arch) + '/apk/jniLibs'
} }
String getArch(String buildType) { static String getRustTarget(String arch) {
return buildType.replaceAll(/(Debug|Release)/, '')
}
boolean isDebug(String buildType) {
return buildType.contains("Debug")
}
String getRustTarget(String arch) {
switch (arch.toLowerCase()) { switch (arch.toLowerCase()) {
case 'arm' : return 'arm-linux-androideabi' case 'arm' : return 'arm-linux-androideabi'
case 'armv7' : return 'armv7-linux-androideabi' case 'armv7' : return 'armv7-linux-androideabi'
@ -248,7 +242,7 @@ String getRustTarget(String arch) {
} }
} }
String getNDKAbi(String arch) { static String getNDKAbi(String arch) {
switch (arch.toLowerCase()) { switch (arch.toLowerCase()) {
case 'arm' : return 'armeabi' case 'arm' : return 'armeabi'
case 'armv7' : return 'armeabi-v7a' case 'armv7' : return 'armeabi-v7a'
@ -286,7 +280,7 @@ String getNdkDir() {
} }
// folderFilter can be used to improve search performance // folderFilter can be used to improve search performance
String findDependencyPath(String basePath, String filename, String folderFilter) { static String findDependencyPath(String basePath, String filename, String folderFilter) {
File path = new File(basePath); File path = new File(basePath);
if (!path.exists()) { if (!path.exists()) {
return '' return ''
@ -310,10 +304,10 @@ String findDependencyPath(String basePath, String filename, String folderFilter)
} }
class ServoDependency { class ServoDependency {
public ServoDependency(String fileName, String folderFilter = null) { ServoDependency(String fileName, String folderFilter = null) {
this.fileName = fileName; this.fileName = fileName;
this.folderFilter = folderFilter; this.folderFilter = folderFilter;
} }
public String fileName; public String fileName;
public String folderFilter; public String folderFilter;
} }

View file

Before

Width:  |  Height:  |  Size: 509 KiB

After

Width:  |  Height:  |  Size: 509 KiB

Before After
Before After

View file

@ -1 +1 @@
include ':app' include ':servoapp'