Unverified Commit 3451c14e authored by Ivan Matkov's avatar Ivan Matkov Committed by GitHub

Refactor local Skia build to Gradle/Kotlin (#1163)

Previously:
- The bash script required specifying `SKIA_VERSION` separately from
`gradle.properties`, leading to version mismatches
- Script hardcoded `SKIA_TARGET` default to `iosSim`, requiring manual
override on non-macOS systems

This change:
- Added `skiaVersionFromEnvOrProperties` property and `printSkiaVersion`
task. The bash script now queries Gradle for the version instead of
maintaining its own default.
- Target platform now defaults to current OS (`hostOs.id`) instead of
hardcoded `iosSim`.
- Introduced `BuildLocalSkiaTask` that handles Python build script
invocation, architecture detection, and validation.
- Added `SkiaTarget` enum centralizing platform-specific Gradle flags
and architecture mappings.
- Simplified bash script: Now focuses solely on git operations
(clone/checkout skia-pack), delegating all build logic to Gradle.

### Usage
```sh
# Version from gradle.properties, target auto-detected from OS
./build-with-local-skia.sh

# Override either via environment variables
SKIA_VERSION=m138-80d088a-2 SKIA_TARGET=iosSim ./build-with-local-skia.sh

# Or use Gradle tasks directly
./gradlew prepareLocalSkiaBuild -Pskia.target=linux
```
parent 1b3f124b
#!/usr/bin/env bash #!/usr/bin/env bash
####### Variables you can edit to change build config, or set same environment variables before script execution ####### # Build Skia locally and publish to Maven Local
SKIA_VERSION="${SKIA_VERSION:="m138-80d088a-2"}" # Version of Skia m###-commit-sha-#. This commit sha will be cloned from repository https://github.com/JetBrains/skia #
SKIA_DEBUG_MODE="${SKIA_DEBUG_MODE:="false"}" # in debug mode Skiko will be published with postix "+debug", for example "0.0.0-SNAPSHOT+debug" # This script handles git operations and delegates configuration to Gradle.
SKIA_TARGET="${SKIA_TARGET:="iosSim"}" # possible values: "ios", "iosSim", "macos", "windows", "linux", "wasm", "android", "tvos", "tvosSim" # For more control, use Gradle tasks directly:
# For M1 Mac use "iosSim" to build for simulator, and ios to build for device. # ./gradlew prepareLocalSkiaBuild -Pskia.pack.dir=/path/to/skia-pack
# For Intel Mac - use "ios" target to build for iOS x64 simulator. # ./gradlew publishToMavenLocal -Pskia.dir=/path/to/skia
# For Desktop JVM use "macos", "windows", "linux" #
######################################################################################################################## # Environment variables:
# SKIA_VERSION - Skia version to build (default: from gradle.properties)
# SKIA_TARGET - Target platform: ios, iosSim, macos, windows, linux, wasm (default: current OS)
# SKIA_PACK_DIR - Skia-pack repository directory with tools/skia_release/ (default: ./skia-pack)
# SKIA_DIR - Skia source directory for publishing (default: $SKIA_PACK_DIR/skia)
if [[ $SKIA_DEBUG_MODE == "true" ]]; then set -e # Exit on error
skikoBuildType=Debug cd "$(dirname "$0")"
else SCRIPT_DIR="$(pwd)"
skikoBuildType=Release
# Use provided skia-pack directory or default
SKIA_PACK_DIR="${SKIA_PACK_DIR:-$SCRIPT_DIR/skia-pack}"
# Clone if needed
if [ ! -d "$SKIA_PACK_DIR" ]; then
echo "Cloning skia-pack repository to $SKIA_PACK_DIR..."
git clone https://github.com/JetBrains/skia-pack.git "$SKIA_PACK_DIR"
fi fi
case $SKIA_TARGET in # Convert to absolute path if relative
"ios") if [[ "$SKIA_PACK_DIR" != /* ]]; then
if [[ $(uname -m) == 'arm64' ]]; then SKIA_PACK_DIR="$(cd "$SKIA_PACK_DIR" && pwd)"
SKIKO_TARGET_FLAGS="-Pskiko.native.ios.arm64.enabled=true -Pskiko.awt.enabled=false" fi
skikoMachines=("arm64")
else
SKIKO_TARGET_FLAGS="-Pskiko.native.ios.x64.enabled=true -Pskiko.awt.enabled=false"
skikoMachines=("x64")
fi
;;
"iosSim")
if [[ $(uname -m) == 'arm64' ]]; then
SKIKO_TARGET_FLAGS="-Pskiko.native.ios.simulatorArm64.enabled=true -Pskiko.awt.enabled=false"
skikoMachines=("arm64")
else
SKIKO_TARGET_FLAGS="-Pskiko.native.ios.x64.enabled=true -Pskiko.awt.enabled=false"
skikoMachines=("x64")
fi
;;
"macos")
SKIKO_TARGET_FLAGS="-Pskiko.awt.enabled=true"
if [[ $(uname -m) == 'arm64' ]]; then
skikoMachines=("arm64" "x64") # bash arrays split elements by spaces
else
skikoMachines=("x64")
fi
;;
"windows")
SKIKO_TARGET_FLAGS="-Pskiko.awt.enabled=true"
if [[ $(uname -m) == 'arm64' ]]; then
skikoMachines=("arm64")
else
skikoMachines=("x64")
fi
;;
"linux")
SKIKO_TARGET_FLAGS="-Pskiko.awt.enabled=true"
if [[ $(uname -m) == 'arm64' ]]; then
skikoMachines=("arm64")
else
skikoMachines=("x64")
fi
;;
"wasm")
SKIKO_TARGET_FLAGS="-Pskiko.wasm.enabled=true -Pskiko.awt.enabled=false"
if [[ $(uname -m) == 'arm64' ]]; then
skikoMachines=("arm64")
else
skikoMachines=("x64")
fi
;;
*)
echo "can't determine skia target"; exit 1
;;
esac
set -e # fail fast echo "Using skia-pack directory: $SKIA_PACK_DIR"
set -x # print all commands cd "$SKIA_PACK_DIR"
cd "$(dirname "$0")"
SCRIPT_DIR="$(pwd)" # Get version from Gradle (respects SKIA_VERSION env var)
SKIA_VERSION=$(cd "$SCRIPT_DIR" && ./gradlew -q printSkiaVersion)
echo "Using Skia version: $SKIA_VERSION"
# Checkout the Skia sources corresponding to the selected version
echo "Checking out Skia sources for version: $SKIA_VERSION"
python3 script/checkout.py --version "$SKIA_VERSION"
git clone https://github.com/JetBrains/skia-pack.git || echo "skia-pack exists. You can remove it or update by hands with git pull" # Build Skia binaries
cd skia-pack
[ -d "skia" ] && echo "skip cript/checkout.py, because directory skia-pack/skia already exists"
[ ! -d "skia" ] && python3 script/checkout.py --version "$SKIA_VERSION"
for skikoMachine in ${skikoMachines[@]}; do
python3 script/build.py --target "$SKIA_TARGET" --machine "$skikoMachine" --build-type "$skikoBuildType"
python3 script/archive.py --version "$SKIA_VERSION" --target "$SKIA_TARGET" --machine "$skikoMachine" --build-type "$skikoBuildType"
done
cd "$SCRIPT_DIR" cd "$SCRIPT_DIR"
echo "Building Skia binaries with Gradle..."
./gradlew prepareLocalSkiaBuild -Pskia.pack.dir="$SKIA_PACK_DIR"
# Publish Skiko to Maven Local with the built Skia binaries
# If SKIA_DIR not explicitly set, use the default location where Python scripts output built Skia
if [ -z "$SKIA_DIR" ]; then
SKIA_DIR="$SKIA_PACK_DIR/skia"
fi
rm -rf build/classes/kotlin/* # We need to drop old cache. We can do it with ./gradlew clean as well, but it tooks longer time to redownload dependencies dir. echo "Publishing Skiko to Maven Local..."
echo "Using Skia source directory: $SKIA_DIR"
./gradlew publishToMavenLocal -Pskia.dir="$SKIA_DIR"
./gradlew publishToMavenLocal $SKIKO_TARGET_FLAGS -Pskia.dir="$(pwd)/skia-pack/skia" -Pskiko.debug=$SKIA_DEBUG_MODE echo "Successfully published Skia build to Maven Local"
...@@ -359,6 +359,37 @@ skikoProjectContext.additionalRuntimeLibraries.forEach { ...@@ -359,6 +359,37 @@ skikoProjectContext.additionalRuntimeLibraries.forEach {
it.registerRuntimePublishTaskDependency(listOf("MavenLocal", "ComposeRepoRepository")) it.registerRuntimePublishTaskDependency(listOf("MavenLocal", "ComposeRepoRepository"))
} }
// Local Skia build tasks
tasks.register<BuildLocalSkiaTask>("prepareLocalSkiaBuild") {
group = "skia"
description = "Build Skia binaries locally (without publishing Skiko)"
skiaVersion.set(provider { skiko.skiaVersionFromEnvOrProperties })
skiaTarget.set(provider { skiko.skiaTarget })
buildType.set(skiko.buildType)
// Set skiaPackDir - either from property or default location
val skiaPackDir = skiko.skiaPackDir
if (skiaPackDir != null) {
this.skiaPackDir.set(skiaPackDir)
} else {
// Will be set by bash script via -Pskia.pack.dir, or use default skia-pack
this.skiaPackDir.set(project.file("skia-pack"))
}
skikoTargetFlags.set(provider {
skiko.skiaTarget.getGradleFlags(skiko.targetArch)
})
}
tasks.register("printSkiaVersion") {
group = "skia"
description = "Print resolved Skia version"
doLast {
println(skiko.skiaVersionFromEnvOrProperties)
}
}
tasks.withType<KotlinNativeCompile>().configureEach { tasks.withType<KotlinNativeCompile>().configureEach {
// https://youtrack.jetbrains.com/issue/KT-56583 // https://youtrack.jetbrains.com/issue/KT-56583
compilerOptions.freeCompilerArgs.add("-XXLanguage:+ImplicitSignedToUnsignedIntegerConversion") compilerOptions.freeCompilerArgs.add("-XXLanguage:+ImplicitSignedToUnsignedIntegerConversion")
......
import org.gradle.api.DefaultTask
import org.gradle.api.GradleException
import org.gradle.api.file.DirectoryProperty
import org.gradle.api.provider.ListProperty
import org.gradle.api.provider.Property
import org.gradle.api.tasks.*
import java.io.ByteArrayOutputStream
import java.io.File
abstract class BuildLocalSkiaTask : DefaultTask() {
@get:Input
abstract val skiaVersion: Property<String>
@get:Input
abstract val skiaTarget: Property<SkiaTarget>
@get:Input
abstract val buildType: Property<SkiaBuildType>
@get:InputDirectory
abstract val skiaPackDir: DirectoryProperty
@get:Internal
abstract val skikoTargetFlags: ListProperty<String>
@TaskAction
fun buildSkia() {
val version = skiaVersion.get()
val target = skiaTarget.get()
val type = buildType.get()
val skiaPackRoot = skiaPackDir.get().asFile
// Validate that skiaPackDir points to skia-pack repository root
val scriptsDir = File(skiaPackRoot, "script")
if (!scriptsDir.isDirectory) {
throw GradleException(
"Directory script not found in ${skiaPackRoot.absolutePath}\n" +
"Expected: skia-pack repository root containing script/\n" +
"Ensure skia.pack.dir points to the correct skia-pack directory"
)
}
// Validate version format
if (!version.matches(Regex("^m[0-9]+-[0-9a-f]+(-.+)?$"))) {
throw GradleException(
"Invalid SKIA_VERSION format: '$version'\n" +
"Expected format: m###-commit_sha[-increment]\n" +
"Example: m138-80d088a-2"
)
}
logger.lifecycle("Building Skia $version for target ${target.id} in ${type.id} mode")
logger.lifecycle("Using skia-pack directory: ${skiaPackRoot.absolutePath}")
logger.lifecycle("Using scripts directory: script")
// Determine host architecture
val hostArch = when (System.getProperty("os.arch")) {
"aarch64", "arm64" -> Arch.Arm64
else -> Arch.X64
}
// Run Python scripts for each machine architecture
val machines = target.machines(hostArch)
logger.lifecycle("Building for architectures: ${machines.joinToString { it.id }}")
// Checkout Skia dependencies
runPythonScript(skiaPackRoot, "checkout.py", "--version", version)
// Build and archive for each machine
machines.forEach { machine ->
logger.lifecycle("Building for ${machine.id}...")
runPythonScript(
skiaPackRoot, "build.py",
"--target", target.id,
"--machine", machine.id,
"--build-type", type.id
)
logger.lifecycle("Archiving ${machine.id}...")
runPythonScript(
skiaPackRoot, "archive.py",
"--version", version,
"--target", target.id,
"--machine", machine.id,
"--build-type", type.id
)
}
// Clean selective cache
logger.lifecycle("Cleaning selective cache...")
project.file("build/classes/kotlin").deleteRecursively()
logger.lifecycle("Skia binaries built successfully")
logger.lifecycle("Next: Run './gradlew publishToMavenLocal -Pskia.dir=<skia-source-dir>' to publish")
}
private fun runPythonScript(skiaPackRoot: File, script: String, vararg args: String) {
val scriptPath = "script/$script"
val scriptFile = File(skiaPackRoot, scriptPath)
// Validate script file exists
if (!scriptFile.exists()) {
throw GradleException(
"Python script not found: ${scriptFile.absolutePath}\n" +
"Expected: skia-pack directory with script/$script\n" +
"Ensure skia.pack.dir points to correct skia-pack directory"
)
}
val fullCommand = listOf("python3", scriptPath) + args
logger.lifecycle("Running: ${fullCommand.joinToString(" ")}")
val output = ByteArrayOutputStream()
val result = project.exec {
workingDir = skiaPackRoot
commandLine = fullCommand
standardOutput = output
errorOutput = output
isIgnoreExitValue = true
}
val outputStr = output.toString()
if (outputStr.isNotEmpty()) {
logger.lifecycle(outputStr)
}
if (result.exitValue != 0) {
throw GradleException(
"Python script $script failed with exit code ${result.exitValue}"
)
}
}
}
enum class SkiaTarget(
val id: String,
val gradleProperties: List<String>
) {
IOS("ios", listOf("-P${SkikoGradleProperties.AWT_ENABLED}=false")),
IOS_SIM("iosSim", listOf("-P${SkikoGradleProperties.AWT_ENABLED}=false")),
MACOS("macos", listOf("-P${SkikoGradleProperties.AWT_ENABLED}=true")),
WINDOWS("windows", listOf("-P${SkikoGradleProperties.AWT_ENABLED}=true")),
LINUX("linux", listOf("-P${SkikoGradleProperties.AWT_ENABLED}=true")),
WASM("wasm", listOf("-P${SkikoGradleProperties.WASM_ENABLED}=true", "-P${SkikoGradleProperties.AWT_ENABLED}=false"));
private val Arch.gradleProperty: String
get() = when (this) {
Arch.X64 -> "x64"
Arch.Arm64 -> "arm64"
Arch.Wasm -> "wasm"
}
private val Arch.titleCase: String
get() = when (this) {
Arch.X64 -> "X64"
Arch.Arm64 -> "Arm64"
Arch.Wasm -> "Wasm"
}
fun machines(hostArch: Arch): List<Arch> = when (this) {
IOS -> listOf(if (hostArch == Arch.Arm64) Arch.Arm64 else Arch.X64)
IOS_SIM -> listOf(if (hostArch == Arch.Arm64) Arch.Arm64 else Arch.X64)
MACOS -> if (hostArch == Arch.Arm64) listOf(Arch.Arm64, Arch.X64) else listOf(Arch.X64)
WINDOWS -> listOf(hostArch)
LINUX -> listOf(hostArch)
WASM -> listOf(hostArch)
}
fun getGradleFlags(hostArch: Arch): List<String> {
val archProperties = when (this) {
IOS -> listOf("-P${SkikoGradleProperties.NATIVE_IOS}.${hostArch.gradleProperty}.enabled=true")
IOS_SIM -> listOf("-P${SkikoGradleProperties.NATIVE_IOS}.simulator${hostArch.titleCase}.enabled=true")
else -> emptyList()
}
return gradleProperties + archProperties
}
companion object {
fun fromString(target: String): SkiaTarget = when (target) {
"ios" -> IOS
"iosSim" -> IOS_SIM
"macos" -> MACOS
"windows" -> WINDOWS
"linux" -> LINUX
"wasm" -> WASM
else -> throw IllegalArgumentException(
"Unknown SKIA_TARGET: $target. Valid targets: ios, iosSim, macos, windows, linux, wasm"
)
}
}
}
...@@ -102,55 +102,55 @@ internal val Project.isInIdea: Boolean ...@@ -102,55 +102,55 @@ internal val Project.isInIdea: Boolean
} }
val Project.supportAndroid: Boolean val Project.supportAndroid: Boolean
get() = findProperty("skiko.android.enabled") == "true" // || isInIdea get() = findProperty(SkikoGradleProperties.ANDROID_ENABLED) == "true" // || isInIdea
val Project.supportAwt: Boolean val Project.supportAwt: Boolean
get() = findProperty("skiko.awt.enabled") == "true" || isInIdea get() = findProperty(SkikoGradleProperties.AWT_ENABLED) == "true" || isInIdea
val Project.supportAllNative: Boolean val Project.supportAllNative: Boolean
get() = findProperty("skiko.native.enabled") == "true" || isInIdea get() = findProperty(SkikoGradleProperties.NATIVE_ENABLED) == "true" || isInIdea
val Project.supportAllNativeIos: Boolean val Project.supportAllNativeIos: Boolean
get() = supportAllNative || findProperty("skiko.native.ios.enabled") == "true" || isInIdea get() = supportAllNative || findProperty("${SkikoGradleProperties.NATIVE_IOS}.enabled") == "true" || isInIdea
val Project.supportNativeIosArm64: Boolean val Project.supportNativeIosArm64: Boolean
get() = supportAllNativeIos || findProperty("skiko.native.ios.arm64.enabled") == "true" || isInIdea get() = supportAllNativeIos || findProperty(SkikoGradleProperties.NATIVE_IOS_ARM64) == "true" || isInIdea
val Project.supportNativeIosSimulatorArm64: Boolean val Project.supportNativeIosSimulatorArm64: Boolean
get() = supportAllNativeIos || findProperty("skiko.native.ios.simulatorArm64.enabled") == "true" || isInIdea get() = supportAllNativeIos || findProperty(SkikoGradleProperties.NATIVE_IOS_SIMULATOR_ARM64) == "true" || isInIdea
val Project.supportNativeIosX64: Boolean val Project.supportNativeIosX64: Boolean
get() = supportAllNativeIos || findProperty("skiko.native.ios.x64.enabled") == "true" || isInIdea get() = supportAllNativeIos || findProperty(SkikoGradleProperties.NATIVE_IOS_X64) == "true" || isInIdea
val Project.supportAnyNativeIos: Boolean val Project.supportAnyNativeIos: Boolean
get() = supportAllNativeIos || supportNativeIosArm64 || supportNativeIosSimulatorArm64 || supportNativeIosX64 get() = supportAllNativeIos || supportNativeIosArm64 || supportNativeIosSimulatorArm64 || supportNativeIosX64
val Project.supportAllNativeTvos: Boolean val Project.supportAllNativeTvos: Boolean
get() = supportAllNative || findProperty("skiko.native.tvos.enabled") == "true" || isInIdea get() = supportAllNative || findProperty("${SkikoGradleProperties.NATIVE_TVOS}.enabled") == "true" || isInIdea
val Project.supportNativeTvosArm64: Boolean val Project.supportNativeTvosArm64: Boolean
get() = supportAllNativeTvos || findProperty("skiko.native.tvos.arm64.enabled") == "true" || isInIdea get() = supportAllNativeTvos || findProperty(SkikoGradleProperties.NATIVE_TVOS_ARM64) == "true" || isInIdea
val Project.supportNativeTvosSimulatorArm64: Boolean val Project.supportNativeTvosSimulatorArm64: Boolean
get() = supportAllNativeTvos || findProperty("skiko.native.tvos.simulatorArm64.enabled") == "true" || isInIdea get() = supportAllNativeTvos || findProperty(SkikoGradleProperties.NATIVE_TVOS_SIMULATOR_ARM64) == "true" || isInIdea
val Project.supportNativeTvosX64: Boolean val Project.supportNativeTvosX64: Boolean
get() = supportAllNativeTvos || findProperty("skiko.native.tvos.x64.enabled") == "true" || isInIdea get() = supportAllNativeTvos || findProperty(SkikoGradleProperties.NATIVE_TVOS_X64) == "true" || isInIdea
val Project.supportAnyNativeTvos: Boolean val Project.supportAnyNativeTvos: Boolean
get() = supportAllNativeTvos || supportNativeTvosArm64 || supportNativeTvosSimulatorArm64 || supportNativeTvosX64 get() = supportAllNativeTvos || supportNativeTvosArm64 || supportNativeTvosSimulatorArm64 || supportNativeTvosX64
val Project.supportNativeMac: Boolean val Project.supportNativeMac: Boolean
get() = supportAllNative || findProperty("skiko.native.mac.enabled") == "true" || isInIdea get() = supportAllNative || findProperty(SkikoGradleProperties.NATIVE_MAC) == "true" || isInIdea
val Project.supportNativeLinux: Boolean val Project.supportNativeLinux: Boolean
get() = supportAllNative || findProperty("skiko.native.linux.enabled") == "true" || isInIdea get() = supportAllNative || findProperty(SkikoGradleProperties.NATIVE_LINUX) == "true" || isInIdea
val Project.supportAnyNative: Boolean val Project.supportAnyNative: Boolean
get() = supportAllNative || supportAnyNativeIos || supportNativeMac || supportNativeLinux get() = supportAllNative || supportAnyNativeIos || supportNativeMac || supportNativeLinux
val Project.supportWeb: Boolean val Project.supportWeb: Boolean
get() = findProperty("skiko.wasm.enabled") == "true" || isInIdea get() = findProperty(SkikoGradleProperties.WASM_ENABLED) == "true" || isInIdea
fun Project.skiaVersion(target: String): String { fun Project.skiaVersion(target: String): String {
val platformSpecificVersion = "dependencies.skia.$target" val platformSpecificVersion = "dependencies.skia.$target"
......
...@@ -157,12 +157,45 @@ class SkikoProperties(private val myProject: Project) { ...@@ -157,12 +157,45 @@ 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 }
/**
* Skia-pack repository root directory for building Skia from source.
*
* Property naming conventions:
* - Gradle property: `-Pskia.pack.dir=...` (kebab-case, Gradle convention)
* - Kotlin accessor: `skiaPackDir` (camelCase, Kotlin convention)
* - Environment variable: `SKIA_PACK_DIR`
*
* Usage: `-Pskia.pack.dir=/path/to/skia-pack`
*
* Note: Must point to skia-pack repository root containing script/ with Python build scripts.
*/
// todo: make compatible with the configuration cache
val skiaPackDir: File?
get() = (System.getenv()["SKIA_PACK_DIR"] ?: System.getProperty("skia.pack.dir") ?: myProject.findProperty("skia.pack.dir")
?.toString())?.let { skiaPackDirProp ->
val file = File(skiaPackDirProp)
if (!file.isDirectory) throw (GradleException("\"skia.pack.dir\" property was explicitly set to ${skiaPackDirProp} which is not resolved as a directory"))
file
}
/**
* Skia source directory for publishing.
*
* Property naming conventions:
* - Gradle property: `-Pskia.dir=...` (kebab-case, Gradle convention)
* - Kotlin accessor: `skiaDir` (camelCase, Kotlin convention)
* - Environment variable: `SKIA_DIR`
*
* Usage: `-Pskia.dir=/path/to/skia`
*
* Note: Must point to directory containing built Skia source code and headers.
*/
// todo: make compatible with the configuration cache // todo: make compatible with the configuration cache
val skiaDir: File? val skiaDir: File?
get() = (System.getenv()["SKIA_DIR"] ?: System.getProperty("skia.dir") ?: myProject.findProperty("skia.dir") get() = (System.getenv()["SKIA_DIR"] ?: System.getProperty("skia.dir") ?: myProject.findProperty("skia.dir")
?.toString())?.let { skiaDirProp -> ?.toString())?.let { skiaDirProp ->
val file = File(skiaDirProp) val file = File(skiaDirProp)
if (!file.isDirectory) throw (GradleException("\"skiko.skiaDir\" property was explicitly set to ${skiaDirProp} which is not resolved as a directory")) if (!file.isDirectory) throw (GradleException("\"skia.dir\" property was explicitly set to ${skiaDirProp} which is not resolved as a directory"))
file file
} }
...@@ -189,6 +222,40 @@ class SkikoProperties(private val myProject: Project) { ...@@ -189,6 +222,40 @@ class SkikoProperties(private val myProject: Project) {
val dependenciesDir: File val dependenciesDir: File
get() = myProject.rootProject.projectDir.resolve("dependencies") get() = myProject.rootProject.projectDir.resolve("dependencies")
val skiaTarget: SkiaTarget
get() {
val targetString = System.getenv("SKIA_TARGET")
?: myProject.findProperty("skia.target")?.toString()
?: hostOs.id // Default to current OS
return SkiaTarget.fromString(targetString)
}
val skiaVersionFromEnvOrProperties: String
get() {
// Environment variable takes precedence
System.getenv("SKIA_VERSION")?.let { return it }
// Fall back to gradle.properties
return myProject.property("dependencies.skia").toString()
}
}
object SkikoGradleProperties {
const val AWT_ENABLED = "skiko.awt.enabled"
const val WASM_ENABLED = "skiko.wasm.enabled"
const val ANDROID_ENABLED = "skiko.android.enabled"
const val NATIVE_ENABLED = "skiko.native.enabled"
const val NATIVE_IOS = "skiko.native.ios"
const val NATIVE_IOS_ARM64 = "skiko.native.ios.arm64.enabled"
const val NATIVE_IOS_SIMULATOR_ARM64 = "skiko.native.ios.simulatorArm64.enabled"
const val NATIVE_IOS_X64 = "skiko.native.ios.x64.enabled"
const val NATIVE_TVOS = "skiko.native.tvos"
const val NATIVE_TVOS_ARM64 = "skiko.native.tvos.arm64.enabled"
const val NATIVE_TVOS_SIMULATOR_ARM64 = "skiko.native.tvos.simulatorArm64.enabled"
const val NATIVE_TVOS_X64 = "skiko.native.tvos.x64.enabled"
const val NATIVE_MAC = "skiko.native.mac.enabled"
const val NATIVE_LINUX = "skiko.native.linux.enabled"
} }
object SkikoArtifacts { object SkikoArtifacts {
......
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