Skip to content

Commit

Permalink
Update Gradle and SDK
Browse files Browse the repository at this point in the history
  • Loading branch information
paulrouget committed Jul 31, 2018
1 parent bef2fe8 commit 6a31864
Show file tree
Hide file tree
Showing 20 changed files with 49 additions and 53 deletions.
2 changes: 1 addition & 1 deletion python/servo/bootstrap_commands.py
Expand Up @@ -63,7 +63,7 @@ def bootstrap_android(self):
ndk = "android-ndk-r12b-{system}-{arch}"
tools = "sdk-tools-{system}-4333796"

sdk_build_tools = "25.0.2"
sdk_build_tools = "27.0.3"
emulator_images = [
("servo-arm", "25", "google_apis;armeabi-v7a"),
("servo-x86", "28", "google_apis;x86"),
Expand Down
2 changes: 1 addition & 1 deletion python/servo/command_base.py
Expand Up @@ -333,7 +333,7 @@ def get_target_dir(self):
def get_apk_path(self, release):
base_path = self.get_target_dir()
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"
return path.join(base_path, build_type, apk_name)

Expand Down
2 changes: 1 addition & 1 deletion python/servo/package_commands.py
Expand Up @@ -42,7 +42,7 @@

PACKAGES = {
'android': [
'target/armv7-linux-androideabi/release/servo.apk',
'target/armv7-linux-androideabi/release/servoapp.apk',
],
'linux': [
'target/release/servo-tech-demo.tar.gz',
Expand Down
3 changes: 1 addition & 2 deletions python/servo/testing_commands.py
Expand Up @@ -607,8 +607,7 @@ def in_android_emulator(self, release, dev):
env = self.build_env(target=target)
os.environ["PATH"] = env["PATH"]
assert self.handle_android_target(target)
binary_path = self.get_binary_path(release, dev, android=True)
apk = binary_path + ".apk"
apk = self.get_apk_path(release)

py = path.join(self.context.topdir, "etc", "run_in_headless_android_emulator.py")
return [py, avd, apk]
Expand Down
4 changes: 3 additions & 1 deletion support/android/apk/build.gradle
Expand Up @@ -2,9 +2,10 @@
buildscript {
repositories {
jcenter()
google()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.2.3'
classpath 'com.android.tools.build:gradle:3.1.3'
}
}

Expand All @@ -14,6 +15,7 @@ allprojects {
flatDir {
dirs rootDir.absolutePath + "/../../../target/android_aar"
}
google()
}

buildDir = rootDir.absolutePath + "/../../../target/gradle"
Expand Down
3 changes: 2 additions & 1 deletion support/android/apk/gradle/wrapper/gradle-wrapper.properties
@@ -1,5 +1,6 @@
#Wed Jul 11 13:23:08 CEST 2018
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
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
Expand Up @@ -6,18 +6,15 @@ import java.util.regex.Matcher
import java.util.regex.Pattern

android {
compileSdkVersion 25
buildToolsVersion "25.0.2"
compileSdkVersion 27
buildToolsVersion '27.0.3'

defaultConfig {
applicationId "com.mozilla.servo"
minSdkVersion 18
targetSdkVersion 25
targetSdkVersion 27
versionCode 1
versionName "1.0.0"
jackOptions {
enabled true
}
}

compileOptions {
Expand All @@ -33,6 +30,13 @@ android {
}
}

compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}

flavorDimensions "default"

productFlavors {
main {
}
Expand Down Expand Up @@ -144,25 +148,27 @@ android {
variant.setIgnore(true);
}
}

// Define apk output directory
applicationVariants.all { variant ->
variant.outputs.each { output ->
def name = variant.buildType.name
output.outputFile = new File(getApkPath(isDebug(name), getArch(name)))
variant.outputs.all { output ->
Pattern pattern = Pattern.compile(/^[\w\d]+([A-Z][\w\d]+)(Debug|Release)/)
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
tasks.all {
compileTask ->
// Parse architecture name from gradle task name:
// Examples: transformJackWithJackForMainArmv7Release, transformJackWithJackForOculusvrArmv7Release
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);
Pattern pattern = Pattern.compile(/^compile[A-Z][\w\d]+([A-Z][\w\d]+)(Debug|Release)/)
Matcher matcher = pattern.matcher(compileTask.name)
if (!matcher.find()) {
return
}
Expand All @@ -188,57 +194,45 @@ android {
dependencies {
//Dependency list
def deps = [
new ServoDependency("blurdroid.jar", "blurdroid")
new ServoDependency("blurdroid.jar", "blurdroid")
]

// 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']
for (arch in list) {
for (debug in [true, false]) {
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)
if (path) {
"${cmd}" files(path)
}
}
}
}

googlevrCompile 'com.google.vr:sdk-base:1.70.0'
googlevrCompile(name:'GVRService', ext:'aar')
oculusvrCompile(name:'OVRService', ext:'aar')

// compile is deprecated. Will become "implementation" once we upgrade graddle.
compile 'com.android.support.constraint:constraint-layout:1.0.0'
googlevrImplementation 'com.google.vr:sdk-base:1.140.0'
googlevrImplementation(name: 'GVRService', ext: 'aar')
oculusvrImplementation(name: 'OVRService', ext: 'aar')
implementation 'com.android.support.constraint:constraint-layout:1.1.2'
}

// Utility methods
String getTargetDir(boolean debug, String arch) {
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) {
return getTargetDir(debug, arch) + '/servo.apk'
String getSubTargetDir(boolean debug, String arch) {
return getRustTarget(arch) + '/' + (debug ? 'debug' : 'release')
}

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

String getArch(String buildType) {
return buildType.replaceAll(/(Debug|Release)/, '')
}

boolean isDebug(String buildType) {
return buildType.contains("Debug")
}

String getRustTarget(String arch) {
static String getRustTarget(String arch) {
switch (arch.toLowerCase()) {
case 'arm' : return 'arm-linux-androideabi'
case 'armv7' : return 'armv7-linux-androideabi'
Expand All @@ -248,7 +242,7 @@ String getRustTarget(String arch) {
}
}

String getNDKAbi(String arch) {
static String getNDKAbi(String arch) {
switch (arch.toLowerCase()) {
case 'arm' : return 'armeabi'
case 'armv7' : return 'armeabi-v7a'
Expand Down Expand Up @@ -286,7 +280,7 @@ String getNdkDir() {
}

// 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);
if (!path.exists()) {
return ''
Expand All @@ -310,10 +304,10 @@ String findDependencyPath(String basePath, String filename, String folderFilter)
}

class ServoDependency {
public ServoDependency(String fileName, String folderFilter = null) {
ServoDependency(String fileName, String folderFilter = null) {
this.fileName = fileName;
this.folderFilter = folderFilter;
}
public String fileName;
public String folderFilter;
}
}
2 changes: 1 addition & 1 deletion support/android/apk/settings.gradle
@@ -1 +1 @@
include ':app'
include ':servoapp'

0 comments on commit 6a31864

Please sign in to comment.