Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

simplify sample usage #623

Open
wants to merge 8 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 7 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ jobs:
./gradlew --stacktrace --info -Pskiko.native.enabled=true -Pskiko.test.onci=true :skiko:awtTest
./gradlew --stacktrace --info -Pskiko.native.enabled=true -Pskiko.test.onci=true :skiko:macosX64Test
./gradlew --stacktrace --info -Pskiko.native.enabled=true :skiko:publishToMavenLocal
./gradlew --stacktrace --info :SkiaAwtSample:installDist # check AWT sample works
./gradlew --stacktrace --info :SkiaAwtSample:installDist -Pskiko.version=0.0.0-SNAPSHOT # check AWT sample works
- uses: actions/upload-artifact@v2
with:
name: test-reports-macos
Expand Down Expand Up @@ -96,8 +96,8 @@ jobs:
sudo Xvfb :0 -screen 0 1280x720x24 &
export DISPLAY=:0
./gradlew --stacktrace --info -Pskiko.native.enabled=true -Pkotlin.native.cacheKind.linuxX64=none -Pskiko.test.onci=true :skiko:linuxX64Test :skiko:awtTest
./gradlew --stacktrace --info -Pkotlin.native.cacheKind.linuxX64=none :skiko:publishToMavenLocal
./gradlew --stacktrace --info :SkiaAwtSample:installDist # check jvm sample works
./gradlew --stacktrace --info -Pkotlin.native.cacheKind.linuxX64=none :skiko:publishToMavenLocal -Pdeploy.version=0.0.0
./gradlew --stacktrace --info :SkiaAwtSample:installDist -Pskiko.version=0.0.0-SNAPSHOT # check jvm sample works
./gradlew -Pskiko.android.enabled=true :skiko:publishSkikoJvmRuntimeAndroidX64PublicationToMavenLocal :skiko:publishSkikoJvmRuntimeAndroidArm64PublicationToMavenLocal :skiko:publishAndroidPublicationToMavenLocal
- uses: actions/upload-artifact@v2
with:
Expand Down Expand Up @@ -156,7 +156,7 @@ jobs:
run: |
./gradlew --stacktrace --info -Pskiko.test.onci=true :skiko:awtTest
./gradlew --stacktrace --info :skiko:publishToMavenLocal
./gradlew --stacktrace --info :SkiaAwtSample:installDist # check jvm sample works
./gradlew --stacktrace --info :SkiaAwtSample:installDist -Pskiko.version=0.0.0-SNAPSHOT # check jvm sample works
- uses: actions/upload-artifact@v2
with:
name: test-reports-windows
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<component name="ProjectRunConfigurationManager">
<configuration default="false" name="SkijaInjectSample (show long frames) " type="GradleRunConfiguration" factoryName="Gradle">
<configuration default="false" name="SkiaAwtSample (show long frames)" type="GradleRunConfiguration" factoryName="Gradle">
<ExternalSystemSettings>
<option name="executionName" />
<option name="externalProjectPath" value="$PROJECT_DIR$/samples/SkijaInjectSample" />
<option name="externalProjectPath" value="$PROJECT_DIR$/samples/SkiaAwtSample" />
<option name="externalSystemIdString" value="GRADLE" />
<option name="scriptParameters" value="-Dskiko.fps.longFrames.show=true" />
<option name="taskDescriptions">
Expand All @@ -19,7 +19,7 @@
<ExternalSystemReattachDebugProcess>true</ExternalSystemReattachDebugProcess>
<DebugAllEnabled>false</DebugAllEnabled>
<method v="2">
<option name="Gradle.BeforeRunTask" enabled="false" tasks="publishToMavenLocal" externalProjectPath="$PROJECT_DIR$/skiko" vmOptions="" scriptParameters="" />
<option name="Gradle.BeforeRunTask" enabled="true" tasks=":skiko:publishAllSkikoJvmRuntimeToMavenLocal" externalProjectPath="$PROJECT_DIR$" vmOptions="" scriptParameters="" />
</method>
</configuration>
</component>
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<component name="ProjectRunConfigurationManager">
<configuration default="false" name="SkijaInjectSample (software)" type="GradleRunConfiguration" factoryName="Gradle">
<configuration default="false" name="SkiaAwtSample (software)" type="GradleRunConfiguration" factoryName="Gradle">
<ExternalSystemSettings>
<option name="executionName" />
<option name="externalProjectPath" value="$PROJECT_DIR$/samples/SkijaInjectSample" />
<option name="externalProjectPath" value="$PROJECT_DIR$/samples/SkiaAwtSample" />
<option name="externalSystemIdString" value="GRADLE" />
<option name="scriptParameters" value="-Dskiko.renderApi=SOFTWARE" />
<option name="taskDescriptions">
Expand All @@ -19,7 +19,7 @@
<ExternalSystemReattachDebugProcess>true</ExternalSystemReattachDebugProcess>
<DebugAllEnabled>false</DebugAllEnabled>
<method v="2">
<option name="Gradle.BeforeRunTask" enabled="false" tasks="publishToMavenLocal" externalProjectPath="$PROJECT_DIR$/skiko" vmOptions="" scriptParameters="" />
<option name="Gradle.BeforeRunTask" enabled="true" tasks=":skiko:publishAllSkikoJvmRuntimeToMavenLocal" externalProjectPath="$PROJECT_DIR$" vmOptions="" scriptParameters="" />
</method>
</configuration>
</component>
25 changes: 25 additions & 0 deletions .run/SkiaAwtSample (without vsync).run.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<component name="ProjectRunConfigurationManager">
<configuration default="false" name="SkiaAwtSample (without vsync)" type="GradleRunConfiguration" factoryName="Gradle">
<ExternalSystemSettings>
<option name="executionName" />
<option name="externalProjectPath" value="$PROJECT_DIR$/samples/SkiaAwtSample" />
<option name="externalSystemIdString" value="GRADLE" />
<option name="scriptParameters" value="-Dskiko.vsync.enabled=false" />
<option name="taskDescriptions">
<list />
</option>
<option name="taskNames">
<list>
<option value="run" />
</list>
</option>
<option name="vmOptions" value="" />
</ExternalSystemSettings>
<ExternalSystemDebugServerProcess>true</ExternalSystemDebugServerProcess>
<ExternalSystemReattachDebugProcess>true</ExternalSystemReattachDebugProcess>
<DebugAllEnabled>false</DebugAllEnabled>
<method v="2">
<option name="Gradle.BeforeRunTask" enabled="true" tasks=":skiko:publishAllSkikoJvmRuntimeToMavenLocal" externalProjectPath="$PROJECT_DIR$" vmOptions="" scriptParameters="" />
</method>
</configuration>
</component>
6 changes: 3 additions & 3 deletions .run/SkijaInjectSample.run.xml → .run/SkiaAwtSample.run.xml
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<component name="ProjectRunConfigurationManager">
<configuration default="false" name="SkijaInjectSample" type="GradleRunConfiguration" factoryName="Gradle">
<configuration default="false" name="SkiaAwtSample" type="GradleRunConfiguration" factoryName="Gradle">
<ExternalSystemSettings>
<option name="executionName" />
<option name="externalProjectPath" value="$PROJECT_DIR$/samples/SkijaInjectSample" />
<option name="externalProjectPath" value="$PROJECT_DIR$/samples/SkiaAwtSample" />
<option name="externalSystemIdString" value="GRADLE" />
<option name="scriptParameters" value="" />
<option name="taskDescriptions">
Expand All @@ -19,7 +19,7 @@
<ExternalSystemReattachDebugProcess>true</ExternalSystemReattachDebugProcess>
<DebugAllEnabled>false</DebugAllEnabled>
<method v="2">
<option name="Gradle.BeforeRunTask" enabled="true" tasks="publishToMavenLocal" externalProjectPath="$PROJECT_DIR$/skiko" vmOptions="" scriptParameters="" />
<option name="Gradle.BeforeRunTask" enabled="true" tasks=":skiko:publishAllSkikoJvmRuntimeToMavenLocal" externalProjectPath="$PROJECT_DIR$" vmOptions="" scriptParameters="" />
</method>
</configuration>
</component>
46 changes: 0 additions & 46 deletions .run/SkijaInjectSample (without vsync).run.xml

This file was deleted.

4 changes: 2 additions & 2 deletions .run/test.run.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<configuration default="false" name="test" type="GradleRunConfiguration" factoryName="Gradle">
<ExternalSystemSettings>
<option name="executionName" />
<option name="externalProjectPath" value="$PROJECT_DIR$/samples/SkijaInjectSample" />
<option name="externalProjectPath" value="$PROJECT_DIR$/samples/SkiaAwtSample" />
<option name="externalSystemIdString" value="GRADLE" />
<option name="scriptParameters" value="" />
<option name="taskDescriptions">
Expand All @@ -19,7 +19,7 @@
<ExternalSystemReattachDebugProcess>true</ExternalSystemReattachDebugProcess>
<DebugAllEnabled>false</DebugAllEnabled>
<method v="2">
<option name="Gradle.BeforeRunTask" enabled="false" tasks="publishToMavenLocal" externalProjectPath="$PROJECT_DIR$/skiko" vmOptions="" scriptParameters="" />
<option name="Gradle.BeforeRunTask" enabled="true" tasks=":skiko:publishAllSkikoJvmRuntimeToMavenLocal" externalProjectPath="$PROJECT_DIR$" vmOptions="" scriptParameters="" />
</method>
</configuration>
</component>
82 changes: 79 additions & 3 deletions DEVELOPMENT.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
## Building JVM bindings

* Set JAVA_HOME to location of JDK, at least version 11
* If you have **Apple silicon CPU (M1)**, better to use **X86** JDK architecture to compile JS target.
eymar marked this conversation as resolved.
Show resolved Hide resolved
* `./gradlew :skiko:publishToMavenLocal` will build the artifact and publish it to local Maven repo

To build with debug symbols and debug Skia build use `-Pskiko.debug=true` Gradle argument.
Expand Down Expand Up @@ -43,6 +44,81 @@ For example, if we want to include UI tests when we test JVM target, call this:
```
Don't run any background tasks, click mouse, or press keys during the tests. Otherwise, they probably fail.

#### Run samples
- First follow the instruction here: [Building JVM bindings](#building-jvm-bindings)
- `./gradlew :SkiaAwtSample:run`
## Run samples
* First follow the instruction here: [Building JVM bindings](#building-jvm-bindings)
### samples/SkiaAwtSample
```bash
./gradlew :skiko:publishAllSkikoJvmRuntimeToMavenLocal &&\
./gradlew :SkiaAwtSample:run -Pskiko.version=0.0.0-SNAPSHOT
```
- skiko.fps.longFrames.show=true
```bash
./gradlew :skiko:publishAllSkikoJvmRuntimeToMavenLocal &&\
./gradlew :SkiaAwtSample:run -Dskiko.fps.longFrames.show=true -Pskiko.version=0.0.0-SNAPSHOT
```
- skiko.renderApi=SOFTWARE
```bash
./gradlew :skiko:publishAllSkikoJvmRuntimeToMavenLocal &&\
./gradlew :SkiaAwtSample:run -Dskiko.renderApi=SOFTWARE -Pskiko.version=0.0.0-SNAPSHOT
```
- skiko.vsync.enabled=false
```bash
./gradlew :skiko:publishAllSkikoJvmRuntimeToMavenLocal &&\
./gradlew :SkiaAwtSample:run -Dskiko.vsync.enabled=false -Pskiko.version=0.0.0-SNAPSHOT
```
- skiko.transparency=true
```bash
./gradlew :skiko:publishAllSkikoJvmRuntimeToMavenLocal &&\
./gradlew :SkiaAwtSample:run -Dskiko.transparency=true -Pskiko.version=0.0.0-SNAPSHOT
```
- skiko.swing.interop=true
```bash
./gradlew :skiko:publishAllSkikoJvmRuntimeToMavenLocal &&\
./gradlew :SkiaAwtSample:run -Dskiko.swing.interop=true -Pskiko.version=0.0.0-SNAPSHOT
```

### samples/SkiaJsSample with mavenLocal
```bash
./gradlew publishToMavenLocal -p skiko -Pskiko.native.enabled=true -Pskiko.wasm.enabled=true &&\
./gradlew jsBrowserDevelopmentRun -p samples/SkiaJsSample -Pskiko.version=0.0.0-SNAPSHOT
```

### samples/SkiaJsSample with skikoCompositeBuild=true
When you add `-DskikoCompositeBuild=true`, Skiko from [sources](https://github.com/JetBrains/skiko/tree/master/skiko) is
used (without this property the maven artifact is used).
Every time you change sources, they are automatically applied when you run `jsBrowserDevelopmentRun`.

```bash
./gradlew publishSkikoWasmRuntimePublicationToMavenLocal -p skiko -Pskiko.native.enabled=true -Pskiko.wasm.enabled=true &&\
./gradlew jsBrowserDevelopmentRun -p samples/SkiaJsSample -Pskiko.wasm.enabled=true -DskikoCompositeBuild=true -Pskiko.version=0.0.0-SNAPSHOT
```

### samples/SkiaMultiplatformSample JVM, Native and JS
```bash
./gradlew publishToMavenLocal -p skiko -Pskiko.native.enabled=true -Pskiko.wasm.enabled=true &&\
./gradlew runAwt runNative jsBrowserDevelopmentRun -p samples/SkiaMultiplatformSample -Pskiko.version=0.0.0-SNAPSHOT
```
#### Run iOS
- Open SkiaMultiplatformSample project in AppCode with KMM plugin.
- Run iOS on simulator

### samples/SkiaMultiplatformSample JVM, Native and JS with skikoCompositeBuild=true
When you add `-DskikoCompositeBuild=true`, Skiko from [sources](https://github.com/JetBrains/skiko/tree/master/skiko) is
used (without this property the maven artifact is used).
Every time you change sources, they are automatically applied when you run `runAwt runNative jsBrowserDevelopmentRun`.

```bash
./gradlew publishAllSkikoJvmRuntimeToMavenLocal publishSkikoWasmRuntimePublicationToMavenLocal -p skiko -Pskiko.native.enabled=true -Pskiko.wasm.enabled=true &&\
./gradlew runAwt runNative jsBrowserDevelopmentRun -p samples/SkiaMultiplatformSample -Pskiko.native.enabled=true -Pskiko.wasm.enabled=true -DskikoCompositeBuild=true -Pskiko.version=0.0.0-SNAPSHOT
```

### samples/SkiaAndroidSample
- Download Android NDK (Side by side)
![install-android-ndk.png](install-android-ndk.png)
- Add local.properties with key `sdk.dir=...`
- Connect Android device or emulator
```bash
./gradlew publishToMavenLocal -p skiko -Pskiko.android.enabled=true &&\
./gradlew installDebug -p samples/SkiaAndroidSample -Pskiko.android.enabled=true -Pskiko.version=0.0.0-SNAPSHOT ||\
./gradlew assembleDebug -p samples/SkiaAndroidSample -Pskiko.android.enabled=true -Pskiko.version=0.0.0-SNAPSHOT
```
5 changes: 1 addition & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ i.e. something like this
else -> error("Unsupported arch: $osArch")
}

val version = "0.5.3"
val version = "0.7.41"
val target = "${targetOs}-${targetArch}"
dependencies {
implementation("org.jetbrains.skiko:skiko-awt-runtime-$target:$version")
Expand Down Expand Up @@ -126,6 +126,3 @@ class SkikoAppDelegate : UIResponder, UIApplicationDelegateProtocol {
}
```
See this [sample](/samples/SkiaMultiplatformSample) for complete example.

To use latest development snapshot use version `0.0.0-SNAPSHOT`.

Binary file added install-android-ndk.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
8 changes: 8 additions & 0 deletions samples/SkiaAndroidSample/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# Skiko Android sample

## Simple run
- Open project in Android Studio or in Intellij IDEA
- Run Android configuration

## Advanced run for contributors
Described here: [DEVELOPMENT.md](../../DEVELOPMENT.md)
3 changes: 2 additions & 1 deletion samples/SkiaAndroidSample/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -27,15 +27,16 @@ val skikoNativeArm64 by configurations.creating

val jniDir = "${projectDir.absolutePath}/src/main/jniLibs"

// TODO: filter .so files only.
val unzipTaskX64 = tasks.register("unzipNativeX64", Copy::class) {
destinationDir = file("$jniDir/x86_64")
from(skikoNativeX64.map { zipTree(it) })
include("*.so")
}

val unzipTaskArm64 = tasks.register("unzipNativeArm64", Copy::class) {
destinationDir = file("$jniDir/arm64-v8a")
from(skikoNativeArm64.map { zipTree(it) })
include("*.so")
}

android {
Expand Down
3 changes: 3 additions & 0 deletions samples/SkiaAndroidSample/gradle.properties
Original file line number Diff line number Diff line change
@@ -1 +1,4 @@
# android.useAndroidX=true
kotlin.code.style=official
skiko.version=0.7.41
#skiko.version=0.0.0-SNAPSHOT
7 changes: 7 additions & 0 deletions samples/SkiaAwtSample/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# Skiko Jvm Awt sample

## Simple run
`./gradlew run`

## Advanced run for contributors
Described here: [DEVELOPMENT.md](../../DEVELOPMENT.md)
3 changes: 3 additions & 0 deletions samples/SkiaAwtSample/gradle.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
kotlin.code.style=official
skiko.version=0.7.41
#skiko.version=0.0.0-SNAPSHOT
9 changes: 9 additions & 0 deletions samples/SkiaJsSample/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# Skiko JS sample

## Simple run

`./gradlew jsBrowserRun`

## Advanced run for contributors

Described here: [DEVELOPMENT.md](../../DEVELOPMENT.md)
2 changes: 1 addition & 1 deletion samples/SkiaJsSample/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
plugins {
kotlin("multiplatform") version "1.6.10"
kotlin("multiplatform") version "1.7.21"
}

repositories {
Expand Down
3 changes: 3 additions & 0 deletions samples/SkiaJsSample/gradle.properties
Original file line number Diff line number Diff line change
@@ -1 +1,4 @@
kotlin.code.style=official
skiko.version=0.7.41
#skiko.version=0.0.0-SNAPSHOT
#systemProp.skikoCompositeBuild=true
7 changes: 7 additions & 0 deletions samples/SkiaJsSample/settings.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,10 @@ pluginManagement {
}
rootProject.name = "SkiaJsSample"

if (System.getenv("SKIKO_COMPOSITE_BUILD") == "1" || System.getProperty("skikoCompositeBuild") == "true") {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if (System.getenv("SKIKO_COMPOSITE_BUILD") == "1" || System.getProperty("skikoCompositeBuild") == "true") {
// This section is needed to use Skiko from sources instead as a maven artifact. If you use Skiko in your own project outside of this repository, you don't this section.
if (File("../../skiko").exists()) {

I assume, when we develop Skiko - there is no point to use Skiko from maven repo. And if users just copy the example, it will work too.

This change will simplify the whole process:

  • we can just run the example with a simple Gradle command without additional properties (./gradlew run). It will work as in our use case, and in user's use case (when they copy the example)
  • we can open the example in IDEA without adding a global SKIKO_COMPOSITE_BUILD (I just checked the AWT sample, highlighting and debugging work)

If we do this change, we can (and should) simplify the Readme and the CI file - there will be no need to call publishAllSkikoJvmRuntimeToMavenLocal and define skiko.version.

Also, because of this, we can remove skiko.version property completely, and just use 0.7.41 constant instead of it.

(we can discuss this online, to sync on the final decision)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's a good suggestion. But we have problems with this case.

includeBuild("skiko") provides only org.jetbrains.skiko:skiko:1.2.3 artifact.

When we run task publishAllSkikoJvmRuntimeToMavenLocal, under the hood this task downloads and packs skia inside jar and saves to mavenLocal several additional dependencies org.jetbrains.skiko:skiko-awt-runtime-macos-arm64:1.2.3, org.jetbrains.skiko:skiko-awt-runtime-macos-x64:0.0.0, org.jetbrains.skiko:skiko-android-runtime-arm64:1.2.3 and others.

Also, we have task publishSkikoWasmRuntimePublicationToMavenLocal to save org.jetbrains.skiko:skiko-js-wasm-runtime:1.2.3

I think we also can solve this problem, but I don't know how...
For this case, we need to rewrite publishing tasks and also provide modules instead of jars:

allJvmRuntimeJars.forEach { entry ->

includeBuild("../../skiko") {
dependencySubstitution {
substitute(module("org.jetbrains.skiko:skiko")).using(project(":"))
}
}
}
Loading