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

Sdk and Gradle update #21160

Closed
wants to merge 8 commits into from
Closed
Prev

Update Gradle and SDK

  • Loading branch information
paulrouget committed Jul 13, 2018
commit 23c4f6fe213d7b92cd1c152046c30ff2da086971
@@ -66,7 +66,7 @@ def bootstrap_android(self, update=False):
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"),
@@ -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)

@@ -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',
@@ -598,8 +598,8 @@ def test_android_startup(self, release, dev):
print("Waiting for the emulator to boot")
time.sleep(1)

binary_path = self.get_binary_path(release, dev, android=True)
result = subprocess.call(adb + ["install", "-r", binary_path + ".apk"])
apk_path = self.get_apk_path(release)
result = subprocess.call(adb + ["install", "-r", apk_path])
if result != 0:
return result

@@ -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'
}
}

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

buildDir = rootDir.absolutePath + "/../../../target/gradle"
@@ -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
@@ -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 {
@@ -33,6 +30,13 @@ android {
}
}

compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}

flavorDimensions "default"

productFlavors {
main {
}
@@ -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
}
@@ -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'
@@ -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'
@@ -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 ''
@@ -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;
}
}
@@ -1 +1 @@
include ':app'
include ':servoapp'
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.