blob: c71ffc3a833853ef2f49ee8ee3fc36f16bb221d0 [file] [log] [blame]
apply plugin: 'sdk-files'
import com.android.tools.internal.emulator.BuildEmulator
// Get SDK revision to define emulator revision
File fprops = new File(rootDir.getParentFile(), 'external/qemu/source.properties')
Properties props = new Properties()
props.load(fprops.newDataInputStream())
// Mac/Win emulator now has dependency on haxm 6.2.1
File fprops_mac = new File(rootDir.getParentFile(), 'external/qemu/mac.source.properties')
File fprops_win = new File(rootDir.getParentFile(), 'external/qemu/win.source.properties')
task buildDefaultEmulator(type: BuildEmulator) {
revision = props."Pkg.Revision"
build_number = System.getenv("BUILD_NUMBER")
output = new File(project.buildDir, "default")
}
task buildEmulatorCodeCoverage(type: BuildEmulator) {
debug = true
revision = props."Pkg.Revision"
build_number = System.getenv("BUILD_NUMBER")
output = new File(project.buildDir, "coverage")
}
task buildWindowsEmulator(type: BuildEmulator) {
revision = props."Pkg.Revision"
build_number = System.getenv("BUILD_NUMBER")
output = new File(project.buildDir, "windows")
windows = true
}
// Package all data to construct a coverage report.
task packageCodeCoverage(type: Zip) {
dependsOn buildEmulatorCodeCoverage
outputs.upToDateWhen { false }
archiveName = "code-coverage.zip"
destinationDir = new File(project.buildDir, "coverage")
from(buildEmulatorCodeCoverage.output) {
include "**/*.csv"
}
from(buildEmulatorCodeCoverage.output) {
include "**/*.gcda"
}
from(buildEmulatorCodeCoverage.output) {
include "**/*.gcno"
}
}
sdk {
common(mac, linux) {
item("$buildDefaultEmulator.output/gradle-release") {
into ''
builtBy buildDefaultEmulator
}
item("$buildDefaultEmulator.output/build/debug_info/gradle-release") {
into ''
builtBy buildDefaultEmulator
debug true
}
item("$project.rootDir/../external/qemu/android-info.txt") {
into ''
}
// This will make it end up in the Debug configuration.
item("$buildEmulatorCodeCoverage.output/code-coverage.zip") {
debug true
into ''
builtBy packageCodeCoverage
}
}
linux {
item(fprops) {
notice null
}
}
mac {
item(fprops_mac) {
name 'source.properties'
notice null
}
}
windows {
item("$buildWindowsEmulator.output/gradle-release") {
into ''
builtBy buildWindowsEmulator
}
item("$buildWindowsEmulator.output/build/debug_info/gradle-release") {
into ''
builtBy buildWindowsEmulator
debug true
}
item("$project.rootDir/../external/qemu/android-info.txt") {
into ''
}
item(fprops_win) {
name 'source.properties'
notice null
}
item("$project.rootDir/../external/qemu/android-info.txt") {
into ''
}
}
}
import com.android.tools.internal.sdk.base.PlatformConfig
import com.android.tools.internal.sdk.base.ToolItem
import com.google.common.collect.Lists
for (PlatformConfig platform : sdk.getPlatforms()) {
def itemlist = Lists.newArrayList()
for (ToolItem toolitem: platform.getItems()) {
if (toolitem.getDebug() || !toolitem.getExecutable()) {
continue
}
def prop = toolitem.properties
def itemPath = prop.itemPath
if (itemPath instanceof String || itemPath instanceof GString) {
def debugItemPath = itemPath
def path = debugItemPath.split("/")
def s = path[path.size()-1]
if (!s.contains("emulator")) {
continue
}
debugItemPath = debugItemPath.replaceFirst("$buildDefaultEmulator.output",
"$buildDefaultEmulator.output/build/debug_info/gradle-release")
if (debugItemPath.equals(itemPath)) {
continue
}
if (platform.getName().equals("mac")) {
debugItemPath += ".dSYM"
if (!prop.destinationPath) {
path = debugItemPath.split("/")
prop.destinationPath = path[path.size()-1]
}
}
prop.debug=true;
prop.remove('itemPath')
prop.remove('class')
def propcopy = {
prop.each { k, v ->
delegate."$k"=v
}
return debugItemPath
}
def debugitem = new ToolItem(propcopy)
propcopy.delegate = debugitem
itemlist.add(debugitem)
}
}
for (ToolItem debugitem: itemlist) {
platform.getItems().add(debugitem)
}
}