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>
This commit is contained in:
parent
531a48ed78
commit
222c9cfd1b
@ -143,7 +143,7 @@ config("default") {
|
||||
libs += [ malloc ]
|
||||
}
|
||||
|
||||
if (is_android) {
|
||||
if (is_android && !is_android_cmake) {
|
||||
asmflags += [ "--target=$ndk_target" ]
|
||||
cflags += [
|
||||
"--sysroot=$ndk/sysroot",
|
||||
|
@ -10,6 +10,7 @@ is_skia_standalone = true
|
||||
declare_args() {
|
||||
is_official_build = false
|
||||
is_component_build = false
|
||||
is_android_cmake = false
|
||||
ndk = ""
|
||||
|
||||
# It's nice to keep ndk_api set to what Clank targets, but probably no big deal if we can't.
|
||||
@ -37,6 +38,7 @@ declare_args() {
|
||||
skia_vulkan_sdk = getenv("VULKAN_SDK")
|
||||
skia_moltenvk_path = ""
|
||||
}
|
||||
|
||||
declare_args() {
|
||||
is_debug = !is_official_build
|
||||
}
|
||||
|
48
platform_tools/android/CMakeLists.txt
Normal file
48
platform_tools/android/CMakeLists.txt
Normal file
@ -0,0 +1,48 @@
|
||||
cmake_minimum_required(VERSION 2.8.8 FATAL_ERROR)
|
||||
cmake_policy(VERSION 2.8.8)
|
||||
|
||||
## Supported ABIs: 'x86', 'x86_64', armeabi-v7a', 'arm64-v8a'
|
||||
message("Build Type: ${CMAKE_BUILD_TYPE}")
|
||||
|
||||
##### ARGS.GN
|
||||
## Set dev in Android-CMake to true
|
||||
set (android_cmake "true")
|
||||
set (arg_android_cmake "is_android_cmake = ${android_cmake}")
|
||||
|
||||
## Set the NDK path
|
||||
set (arg_ndk "ndk = \"${ANDROID_NDK}\"")
|
||||
|
||||
## Set target ABI
|
||||
if(ANDROID_ABI STREQUAL "arm64-v8a")
|
||||
set (arg_abi "target_cpu = \"arm64\"")
|
||||
elseif(ANDROID_ABI STREQUAL "x86")
|
||||
set (arg_abi "target_cpu = \"x86\"")
|
||||
elseif(ANDROID_ABI STREQUAL "x86_64")
|
||||
set (arg_abi "target_cpu = \"x64\"")
|
||||
elseif(ANDROID_ABI STREQUAL "armeabi-v7a")
|
||||
set (arg_abi "target_cpu = \"arm\"")
|
||||
endif()
|
||||
message ("Target ABI: ${ANDROID_ABI}")
|
||||
message ("Target Builds: ${TARGETS}")
|
||||
|
||||
set (android_out "${CMAKE_CURRENT_SOURCE_DIR}/../../out/android_cmake_${ANDROID_ABI}")
|
||||
|
||||
execute_process(COMMAND mkdir -p ${android_out}/)
|
||||
execute_process(COMMAND touch ${android_out}/args.gn)
|
||||
file(WRITE "${android_out}/args.gn" "${arg_ndk}\n${arg_abi}\n${arg_android_cmake}\n")
|
||||
|
||||
message("CMake Target Output Directory: ${CMAKE_LIBRARY_OUTPUT_DIRECTORY}")
|
||||
##### GN to CMAKE
|
||||
set (bin_gn "${CMAKE_CURRENT_SOURCE_DIR}/../../bin/gn")
|
||||
set (gen "gen")
|
||||
message("GN Output Directory: ${android_out}")
|
||||
|
||||
set (ide "--ide=json")
|
||||
set (script_arg "--json-ide-script=")
|
||||
set (script_path "${CMAKE_CURRENT_SOURCE_DIR}/../../gn/gn_to_cmake.py")
|
||||
|
||||
execute_process (COMMAND ${bin_gn} ${gen} ${android_out} ${ide} ${script_arg}${script_path}
|
||||
WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}")
|
||||
|
||||
##### NINJA
|
||||
include(${android_out}/CMakeLists.txt)
|
@ -18,92 +18,3 @@ 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"
|
||||
}
|
||||
|
@ -4,8 +4,12 @@
|
||||
* Use of this source code is governed by a BSD-style license that can be
|
||||
* found in the LICENSE file.
|
||||
*/
|
||||
|
||||
apply plugin: 'com.android.application'
|
||||
|
||||
//Make sure this is directory corresponds to skia/platform_tools/android
|
||||
final String ANDROID_CMAKE_HEADER_PATH = "../../CMakeLists.txt"
|
||||
|
||||
dependencies {
|
||||
compile 'com.android.support:design:26.+'
|
||||
compile 'com.android.support.test:runner:0.5'
|
||||
@ -21,9 +25,48 @@ android {
|
||||
versionCode 1
|
||||
versionName "1.0"
|
||||
signingConfig signingConfigs.debug
|
||||
|
||||
externalNativeBuild {
|
||||
cmake {
|
||||
//Native libraries to build
|
||||
targets "libskqp_app"
|
||||
|
||||
arguments "-DANDROID_STL=c++_static",
|
||||
"-DTARGETS=${android.defaultConfig.externalNativeBuild.cmake.targets}"
|
||||
}
|
||||
}
|
||||
|
||||
buildTypes {
|
||||
debug {
|
||||
applicationIdSuffix ".debug"
|
||||
debuggable true
|
||||
}
|
||||
}
|
||||
|
||||
productFlavors {
|
||||
arm {
|
||||
ndk {
|
||||
abiFilters "armeabi-v7a"
|
||||
}
|
||||
}
|
||||
|
||||
x86 {
|
||||
ndk {
|
||||
abiFilters "x86"
|
||||
}
|
||||
}
|
||||
|
||||
x64 {
|
||||
ndk {
|
||||
abiFilters "x86_64"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
externalNativeBuild {
|
||||
cmake {
|
||||
path ANDROID_CMAKE_HEADER_PATH
|
||||
}
|
||||
}
|
||||
sourceSets.main.jni.srcDirs = []
|
||||
sourceSets.main.jniLibs.srcDir "src/main/libs"
|
||||
productFlavors { universal{}; arm {}; arm64 {}; x86 {}; x64 {}; arm64vulkan{}; }
|
||||
setupSkiaLibraryBuild(project, applicationVariants, "libskqp_app")
|
||||
}
|
||||
|
@ -28,7 +28,7 @@ public class SkQP {
|
||||
protected static final String LOG_PREFIX = "org.skia.skqp";
|
||||
|
||||
static {
|
||||
System.loadLibrary("skqp_app");
|
||||
System.loadLibrary("libskqp_app");
|
||||
}
|
||||
|
||||
protected void runTests(Context context, String outputDirPath) {
|
||||
|
@ -4,8 +4,12 @@
|
||||
* Use of this source code is governed by a BSD-style license that can be
|
||||
* found in the LICENSE file.
|
||||
*/
|
||||
|
||||
apply plugin: 'com.android.application'
|
||||
|
||||
//Make sure this is directory corresponds to skia/platform_tools/android
|
||||
final String ANDROID_CMAKE_HEADER_PATH = "../../CMakeLists.txt"
|
||||
|
||||
dependencies {
|
||||
compile 'com.android.support:support-v13:23.3.0'
|
||||
compile 'com.android.support:appcompat-v7:23.3.0'
|
||||
@ -21,10 +25,54 @@ android {
|
||||
versionCode 1
|
||||
versionName "1.0"
|
||||
signingConfig signingConfigs.debug
|
||||
}
|
||||
sourceSets.main.jni.srcDirs = [] //disable automatic ndk-build call
|
||||
sourceSets.main.jniLibs.srcDir "src/main/libs"
|
||||
productFlavors { universal{}; arm {}; arm64 {}; x86 {}; x64 {}; arm64vulkan{}; }
|
||||
|
||||
setupSkiaLibraryBuild(project, applicationVariants, "libviewer")
|
||||
externalNativeBuild {
|
||||
cmake {
|
||||
//Native libraries to build
|
||||
targets "libviewer"
|
||||
|
||||
arguments "-DANDROID_STL=c++_static",
|
||||
"-DTARGETS=${android.defaultConfig.externalNativeBuild.cmake.targets}"
|
||||
}
|
||||
}
|
||||
|
||||
buildTypes {
|
||||
debug {
|
||||
applicationIdSuffix ".debug"
|
||||
debuggable true
|
||||
}
|
||||
}
|
||||
|
||||
productFlavors {
|
||||
arm64 {
|
||||
ndk {
|
||||
abiFilters "arm64-v8a"
|
||||
}
|
||||
}
|
||||
|
||||
arm {
|
||||
ndk {
|
||||
abiFilters "armeabi-v7a"
|
||||
}
|
||||
}
|
||||
|
||||
x86 {
|
||||
ndk {
|
||||
abiFilters "x86"
|
||||
}
|
||||
}
|
||||
|
||||
x64 {
|
||||
ndk {
|
||||
abiFilters "x86_64"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
externalNativeBuild {
|
||||
cmake {
|
||||
path ANDROID_CMAKE_HEADER_PATH
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -16,7 +16,7 @@ public class ViewerApplication extends Application {
|
||||
private String mStateJsonStr, mTitle;
|
||||
|
||||
static {
|
||||
System.loadLibrary("viewer");
|
||||
System.loadLibrary("libviewer");
|
||||
}
|
||||
|
||||
private native long createNativeApp(AssetManager assetManager);
|
||||
|
Loading…
Reference in New Issue
Block a user