Skip to content

Commit

Permalink
upgrade to gradle 8 and agp 8
Browse files Browse the repository at this point in the history
Signed-off-by: Mukilan Thiyagarajan <[email protected]>
  • Loading branch information
mukilan committed Nov 26, 2023
1 parent 0e780a5 commit 7bbcfee
Show file tree
Hide file tree
Showing 10 changed files with 137 additions and 175 deletions.
6 changes: 5 additions & 1 deletion etc/shell.nix
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@ let
pinnedNixpkgs = import (builtins.fetchTarball {
url = "https://github.com/NixOS/nixpkgs/archive/${pinnedSha}.tar.gz";
}) {};
buildToolsVersion = "33.0.2";
androidComposition = androidenv.composeAndroidPackages {
buildToolsVersions = [ buildToolsVersion ];
includeEmulator = true;
platformVersions = [ "30" ];
includeSources = false;
Expand Down Expand Up @@ -57,7 +59,7 @@ clangStdenv.mkDerivation rec {
pinnedNixpkgs.gnumake

# android build
openjdk8_headless
openjdk17_headless

# android, make this conditional?
androidSdk
Expand All @@ -80,6 +82,8 @@ clangStdenv.mkDerivation rec {
# Enable colored cargo and rustc output
TERMINFO = "${ncurses.out}/share/terminfo";

GRADLE_OPTS = "-Dorg.gradle.project.android.aapt2FromMavenOverride=${ANDROID_SDK_ROOT}/build-tools/${buildToolsVersion}/aapt2";

# Provide libraries that aren’t linked against but somehow required
LD_LIBRARY_PATH = lib.makeLibraryPath [
# Fixes missing library errors
Expand Down
2 changes: 1 addition & 1 deletion python/servo/package_commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ def package(self, build_type: BuildType, android=None, target=None, flavor=None,
else:
raise Exception("TODO what should this be?")

flavor_name = "Main"
flavor_name = "Basic"
if flavor is not None:
flavor_name = flavor.title()

Expand Down
61 changes: 19 additions & 42 deletions support/android/apk/build.gradle
Original file line number Diff line number Diff line change
@@ -1,74 +1,52 @@
import org.apache.tools.ant.taskdefs.condition.Os

buildscript {
repositories {
jcenter()
google()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.1.3'
}
}

allprojects {
repositories {
jcenter()
flatDir {
dirs rootDir.absolutePath + "/../../../target/android/aar"
}
google()
}
// Top-level build file where you can add configuration options common to all sub-projects/modules.
plugins {
id 'com.android.application' version '8.0.1' apply false
id 'com.android.library' version '8.0.1' apply false
}

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

String getRealTargetDir(boolean debug, String arch) {
ext.getNativeTargetDir = { boolean debug, String arch ->
def basePath = project.rootDir.getParentFile().getParentFile().getParentFile().absolutePath
return basePath + '/target/' + getSubTargetDir(debug, arch)
}

String getSubTargetDir(boolean debug, String arch) {
ext.getSubTargetDir = { boolean debug, String arch ->
return getRustTarget(arch) + '/' + (debug ? 'debug' : 'release')
}

String getJniLibsPath(boolean debug, String arch) {
ext.getJniLibsPath = { boolean debug, String arch ->
return getTargetDir(debug, arch) + '/apk/jniLibs'
}

static String getRustTarget(String arch) {
ext.getRustTarget = { String arch ->
switch (arch.toLowerCase()) {
case 'arm' : return 'arm-linux-androideabi'
//XXX 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)
}
}

static String getNDKAbi(String arch) {
ext.getNDKAbi = { String arch ->
switch (arch.toLowerCase()) {
case 'arm' : return 'armeabi'
//XXX 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() {
ext.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) {
String ndkRoot = System.getenv('ANDROID_NDK_ROOT')
if (ndkRoot == null) {
// Fallback to ndkDir in local.properties
def rootDir = project.rootDir
def localProperties = new File(rootDir, "local.properties")
Expand All @@ -77,14 +55,13 @@ String getNdkDir() {
properties.load(instr)
}

ndkDir = properties.getProperty('ndk.dir')
ndkRoot = 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()) {
def ndkDir = new File(ndkRoot)
if (!ndkDir.exists()) {
throw new GradleException("Please set a valid NDK_HOME environment variable" +
"or ndk.dir path in local.properties file");
}
return ndkbuild.absolutePath
return ndkDir.absolutePath
}
22 changes: 21 additions & 1 deletion support/android/apk/gradle.properties
Original file line number Diff line number Diff line change
@@ -1 +1,21 @@
org.gradle.jvmargs=-Xmx1024M
# Project-wide Gradle settings.
# IDE (e.g. Android Studio) users:
# Gradle settings configured through the IDE *will override*
# any settings specified in this file.
# For more details on how to configure your build environment visit
# http://www.gradle.org/docs/current/userguide/build_environment.html
# Specifies the JVM arguments used for the daemon process.
# The setting is particularly useful for tweaking memory settings.
org.gradle.jvmargs=-Xmx2048m -Dfile.encoding=UTF-8
# When configured, Gradle will run in incubating parallel mode.
# This option should only be used with decoupled projects. More details, visit
# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
# org.gradle.parallel=true
# AndroidX package structure to make it clearer which packages are bundled with the
# Android operating system, and which are packaged with your app's APK
# https://developer.android.com/topic/libraries/support-library/androidx-rn
android.useAndroidX=true
# Enables namespacing of each library's R class so that its R class includes only the
# resources declared in the library itself and none from the library's dependencies,
# thereby reducing the size of the R class for that library
android.nonTransitiveRClass=true
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-5.1.1-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.0-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
27 changes: 8 additions & 19 deletions support/android/apk/servoapp/build.gradle
Original file line number Diff line number Diff line change
@@ -1,18 +1,21 @@
apply plugin: 'com.android.application'
plugins {
id 'com.android.application'
}

import java.util.regex.Matcher
import java.util.regex.Pattern

android {
compileSdkVersion 30
buildToolsVersion '33.0.2'
compileSdk 33

namespace 'org.mozilla.servo'

buildDir = rootDir.absolutePath + "/../../../target/android/gradle/servoapp"

defaultConfig {
applicationId "org.mozilla.servo"
minSdkVersion 21
targetSdkVersion 30
targetSdkVersion 30
versionCode 1
versionName "1.0.0"
}
Expand All @@ -26,7 +29,7 @@ android {
flavorDimensions "default"

productFlavors {
main {
basic {
}
googlevr {
}
Expand Down Expand Up @@ -61,19 +64,6 @@ android {
}

// Custom build types
armDebug {
initWith(debug)
ndk {
abiFilters getNDKAbi('arm')
}
}

armRelease {
initWith(release)
ndk {
abiFilters getNDKAbi('arm')
}
}
armv7Debug {
initWith(debug)
ndk {
Expand Down Expand Up @@ -144,7 +134,6 @@ android {
}

dependencies {
implementation 'com.android.support.constraint:constraint-layout:1.1.2'
if (findProject(':servoview-local')) {
implementation project(':servoview-local')
} else {
Expand Down
3 changes: 1 addition & 2 deletions support/android/apk/servoapp/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- BEGIN_INCLUDE(manifest) -->
<manifest xmlns:android="http://schemas.android.com/apk/res/android" android:installLocation="auto"
package="org.mozilla.servo">
<manifest xmlns:android="http://schemas.android.com/apk/res/android" android:installLocation="auto">

<uses-feature android:glEsVersion="0x00030000" android:required="true" />
<uses-feature android:name="android.hardware.bluetooth_le" android:required="true"/>
Expand Down
Loading

0 comments on commit 7bbcfee

Please sign in to comment.