Commit 7f5618b2 authored by Alexey Tsvetkov's avatar Alexey Tsvetkov

Add way to modify Skia/Skija sources used in build

parent 0763f5cc
...@@ -7,6 +7,13 @@ ...@@ -7,6 +7,13 @@
* Set JAVA_HOME to location of JDK, at least version 11 * Set JAVA_HOME to location of JDK, at least version 11
* `cd skiko && ./gradlew publishToMavenLocal` will build the artefact and publish it to local Maven repo * `cd skiko && ./gradlew publishToMavenLocal` will build the artefact and publish it to local Maven repo
#### Working with Skia or Skija sources
Gradle build downloads the necessary version of Skia & Skija by default.
However, if downloaded sources are modified, changes are discarded (Gradle
re-evaluates tasks, when outputs are changed).
To use custom version of the dependencies, specify `SKIA_DIR` or `SKIJA_DIR` environment variable
respectively.
#### Building on Windows #### Building on Windows
......
...@@ -18,7 +18,6 @@ version = run { ...@@ -18,7 +18,6 @@ version = run {
properties.deployVersion + suffix properties.deployVersion + suffix
} }
val providedSkiaDir = (System.getenv("SKIA_DIR") ?: System.getProperty("skia.dir"))?.let { File(it) } ?: error("PLEASE_SET_SKIA_DIR")
val hostOs = System.getProperty("os.name") val hostOs = System.getProperty("os.name")
val target = when { val target = when {
hostOs == "Mac OS X" -> "macos" hostOs == "Mac OS X" -> "macos"
...@@ -41,7 +40,7 @@ val skiaZip = run { ...@@ -41,7 +40,7 @@ val skiaZip = run {
val zipFile = properties.dependenciesDir.resolve("skia/$zipName") val zipFile = properties.dependenciesDir.resolve("skia/$zipName")
tasks.register("downloadSkia", Download::class) { tasks.register("downloadSkia", Download::class) {
onlyIf { providedSkiaDir == null && !zipFile.exists() } onlyIf { properties.skiaDir == null && !zipFile.exists() }
inputs.property("skia.release.for.current.os", properties.skiaReleaseForCurrentOS) inputs.property("skia.release.for.current.os", properties.skiaReleaseForCurrentOS)
src("https://bintray.com/api/ui/download/jetbrains/skija/$zipName") src("https://bintray.com/api/ui/download/jetbrains/skija/$zipName")
dest(zipFile) dest(zipFile)
...@@ -49,20 +48,25 @@ val skiaZip = run { ...@@ -49,20 +48,25 @@ val skiaZip = run {
}.map { zipFile } }.map { zipFile }
} }
val unzippedSkia = run { val skiaDir = run {
val targetDir = providedSkiaDir ?: properties.dependenciesDir.resolve("skia/unzipped") if (properties.skiaDir != null) {
tasks.register("unzipSkia", Copy::class) { tasks.register("unzipSkia", Copy::class) {
onlyIf { providedSkiaDir == null } enabled = false
from(skiaZip.map { zipTree(it) }) }.map { properties.skiaDir!! }
into(targetDir) } else {
}.map { targetDir } val targetDir = properties.dependenciesDir.resolve("skia/skia")
tasks.register("unzipSkia", Copy::class) {
from(skiaZip.map { zipTree(it) })
into(targetDir)
}.map { targetDir }
}
} }
val skijaZip = run { val skijaZip = run {
val zipFile = properties.dependenciesDir.resolve("skija/${properties.skijaCommitHash}.zip") val zipFile = properties.dependenciesDir.resolve("skija/${properties.skijaCommitHash}.zip")
tasks.register("downloadSkija", Download::class) { tasks.register("downloadSkija", Download::class) {
onlyIf { !zipFile.exists() } onlyIf { properties.skijaDir == null && !zipFile.exists() }
inputs.property("skija.commit.hash", properties.skijaCommitHash) inputs.property("skija.commit.hash", properties.skijaCommitHash)
src("https://github.com/JetBrains/skija/archive/${properties.skijaCommitHash}.zip") src("https://github.com/JetBrains/skija/archive/${properties.skijaCommitHash}.zip")
dest(zipFile) dest(zipFile)
...@@ -71,18 +75,24 @@ val skijaZip = run { ...@@ -71,18 +75,24 @@ val skijaZip = run {
} }
val skijaDir = run { val skijaDir = run {
val unzipDest = properties.dependenciesDir.resolve("skija/unzipped").apply { mkdirs() } if (properties.skijaDir != null) {
tasks.register("unzipSkija", Copy::class) { tasks.register("unzipSkija", Copy::class) {
from(skijaZip.map { zipTree(it) }) { enabled = false
include("skija-${properties.skijaCommitHash}/**") }.map { properties.skijaDir!! }
eachFile { } else {
// drop skija-<COMMIT> subdir val skijaDest = properties.dependenciesDir.resolve("skija/skija").apply { mkdirs() }
relativePath = RelativePath(true, *relativePath.segments.drop(1).toTypedArray()) tasks.register("unzipSkija", Copy::class) {
from(skijaZip.map { zipTree(it) }) {
include("skija-${properties.skijaCommitHash}/**")
eachFile {
// drop skija-<COMMIT> subdir
relativePath = RelativePath(true, *relativePath.segments.drop(1).toTypedArray())
}
includeEmptyDirs = false
} }
includeEmptyDirs = false into(skijaDest)
} }.map { skijaDest }
into(unzipDest) }
}.map { unzipDest }
} }
val lombok by configurations.creating val lombok by configurations.creating
...@@ -162,8 +172,8 @@ tasks.withType(CppCompile::class.java).configureEach { ...@@ -162,8 +172,8 @@ tasks.withType(CppCompile::class.java).configureEach {
"Check JAVA_HOME (CLI) or Gradle settings (Intellij).") "Check JAVA_HOME (CLI) or Gradle settings (Intellij).")
} }
val jdkHome = System.getProperty("java.home") ?: error("'java.home' is null") val jdkHome = System.getProperty("java.home") ?: error("'java.home' is null")
dependsOn(unzippedSkia) dependsOn(skiaDir)
val skiaDir = unzippedSkia.get().absolutePath val skiaDir = skiaDir.get().absolutePath
compilerArgs.addAll(listOf( compilerArgs.addAll(listOf(
"-I$jdkHome/include", "-I$jdkHome/include",
"-I$skiaDir", "-I$skiaDir",
...@@ -304,7 +314,7 @@ library { ...@@ -304,7 +314,7 @@ library {
dependencies { dependencies {
implementation( implementation(
unzippedSkia.map { skiaDir.map {
fileTree(it.resolve("out/Release-x64")) fileTree(it.resolve("out/Release-x64"))
.matching { include(if (target == "windows") "**.lib" else "**.a") } .matching { include(if (target == "windows") "**.lib" else "**.a") }
} }
...@@ -477,6 +487,12 @@ class SkikoProperties(private val myProject: Project) { ...@@ -477,6 +487,12 @@ class SkikoProperties(private val myProject: Project) {
val visualStudioBuildToolsDir: File? val visualStudioBuildToolsDir: File?
get() = System.getenv()["SKIKO_VSBT_PATH"]?.let { File(it) }?.takeIf { it.isDirectory } get() = System.getenv()["SKIKO_VSBT_PATH"]?.let { File(it) }?.takeIf { it.isDirectory }
val skijaDir: File?
get() = System.getenv()["SKIJA_DIR"]?.let { File(it) }?.takeIf { it.isDirectory }
val skiaDir: File?
get() = (System.getenv()["SKIA_DIR"] ?: System.getProperty("skia.dir"))?.let { File(it) }?.takeIf { it.isDirectory }
val dependenciesDir: File val dependenciesDir: File
get() = myProject.rootProject.projectDir.resolve("dependencies") get() = myProject.rootProject.projectDir.resolve("dependencies")
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment