aboutsummaryrefslogtreecommitdiffhomepage
path: root/platform_tools/android/apps/build.gradle
diff options
context:
space:
mode:
authorGravatar Hal Canary <halcanary@google.com>2018-06-01 20:22:25 +0000
committerGravatar Skia Commit-Bot <skia-commit-bot@chromium.org>2018-06-01 20:22:37 +0000
commita0834048380c51f9e45063e3ae40a142a6f7f2d1 (patch)
tree1e57c75af9d7b3f1e314029c230bce4ebdcbb5de /platform_tools/android/apps/build.gradle
parent804d0f28ba6de89b7e671c0e9192e16b7494944d (diff)
Revert "Added support for visual debugging on Android Studio"
This reverts commit 222c9cfd1b3f50d21d4a1f93b0b52dd4973fe1b5. Reason for revert: Breaks documented workflow. Original change's description: > Added support for visual debugging on Android Studio > > Change-Id: Icaf848c31167db10d6fbb13d74c7287b03628fb6 > Bug: skia: > Reviewed-on: https://skia-review.googlesource.com/130144 > Reviewed-by: Derek Sollenberger <djsollen@google.com> TBR=djsollen@google.com,mtklein@google.com,bsalomon@google.com,halcanary@google.com,bungeman@google.com,ziadb@google.com Change-Id: I6e7ac2d16d9a0f267d75cd202fd4975be36da4f5 No-Presubmit: true No-Tree-Checks: true No-Try: true Bug: skia: Reviewed-on: https://skia-review.googlesource.com/131601 Reviewed-by: Hal Canary <halcanary@google.com> Commit-Queue: Hal Canary <halcanary@google.com>
Diffstat (limited to 'platform_tools/android/apps/build.gradle')
-rw-r--r--platform_tools/android/apps/build.gradle89
1 files changed, 89 insertions, 0 deletions
diff --git a/platform_tools/android/apps/build.gradle b/platform_tools/android/apps/build.gradle
index 7aa9b56af8..9f285e5b06 100644
--- a/platform_tools/android/apps/build.gradle
+++ b/platform_tools/android/apps/build.gradle
@@ -18,3 +18,92 @@ allprojects {
jcenter()
}
}
+
+def setupSkiaLibraryBuild(project, appVariants, appName) {
+ appVariants.all{ variant ->
+ def buildNativeLib = project.task("${variant.name}_BuildSkiaLib", type:Exec) {
+ workingDir '../../../..' // top-level skia directory
+ commandLine constructBuildCommand(project, variant, appName).split()
+ }
+ buildNativeLib.onlyIf { !project.hasProperty("suppressNativeBuild") }
+
+ def copyNativeLib = project.task("${variant.name}_CopySkiaLib", type:Copy) {
+ def fromDir = getVariantOutDir(project, variant).skiaOut
+ def intoDir = getVariantOutDir(project, variant).androidOut
+ from fromDir
+ into intoDir
+ include "${appName}.so"
+ }
+
+ TaskCollection<Task> compileTask = project.tasks.matching {
+ // println(it.name)
+ it.name.toLowerCase().contains("compile" + variant.name.toLowerCase()) &&
+ it.name.toLowerCase().endsWith("ndk")
+ }
+ compileTask.findAll()*.dependsOn copyNativeLib
+ copyNativeLib.dependsOn buildNativeLib
+ }
+}
+
+def getLocalProperties() {
+ Properties properties = new Properties()
+ File propFile = project.rootProject.file('local.properties')
+ if (propFile.canRead()) {
+ properties.load(propFile.newDataInputStream())
+ }
+ propFile = project.rootProject.file('gradle.properties')
+ if (propFile.canRead()) {
+ properties.load(propFile.newDataInputStream())
+ }
+ return properties
+}
+
+def getVariantOutDir(project, variant) {
+ String variantPrefix = null
+ String androidLibDir = null
+ if (variant.name.startsWith("arm64")) {
+ variantPrefix = "arm64"
+ androidLibDir = "arm64-v8a"
+ } else if (variant.name.startsWith("arm")) {
+ variantPrefix = "arm"
+ androidLibDir = "armeabi-v7a"
+ } else if (variant.name.startsWith("x64")) {
+ variantPrefix = "x64"
+ androidLibDir = "x86_64"
+ } else if (variant.name.startsWith("x86")) {
+ variantPrefix = "x86"
+ androidLibDir = "x86"
+ }
+
+ String skiaOutDir = null
+ String propName = "${variantPrefix}.out.dir"
+ if (project.hasProperty(propName)) {
+ skiaOutDir = project.getProperties().getAt(propName)
+ } else {
+ skiaOutDir = getLocalProperties().getProperty(propName, "missing_variant_out")
+ }
+
+ return [skiaOut: skiaOutDir,
+ androidOut: "src/main/libs/${androidLibDir}"]
+}
+
+def constructBuildCommand(project, variant, appName) {
+ String depotToolsDir = null
+ for (String entry : System.getenv("PATH").split(":")) {
+ if (entry.contains("depot_tools")) {
+ depotToolsDir = entry;
+ break;
+ }
+ }
+ if (depotToolsDir == null) {
+ depotToolsDir = getLocalProperties().getProperty('depot_tools.dir', null)
+ }
+
+ if (depotToolsDir == null) {
+ throw GradleScriptException("Depot Tools not found! Please update your path to include" +
+ " depot_tools or define depot_tools.dir in local.properties")
+ }
+
+ String out_dir = getVariantOutDir(project, variant).skiaOut
+ return "${depotToolsDir}/ninja -C $out_dir $appName"
+}