Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
S
skiko
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
liuqiang
skiko
Commits
a30747fe
Unverified
Commit
a30747fe
authored
Mar 23, 2021
by
Nikolay Igotti
Committed by
GitHub
Mar 23, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Support for custom library path. (#82)
parent
a4a1af99
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
22 additions
and
14 deletions
+22
-14
build.gradle.kts
samples/SkijaInjectSample/build.gradle.kts
+1
-0
Library.kt
skiko/src/jvmMain/kotlin/org/jetbrains/skiko/Library.kt
+21
-14
No files found.
samples/SkijaInjectSample/build.gradle.kts
View file @
a30747fe
...
@@ -52,6 +52,7 @@ val additionalArguments = mutableMapOf<String, String>()
...
@@ -52,6 +52,7 @@ val additionalArguments = mutableMapOf<String, String>()
val
casualRun
=
tasks
.
named
<
JavaExec
>(
"run"
)
{
val
casualRun
=
tasks
.
named
<
JavaExec
>(
"run"
)
{
systemProperty
(
"skiko.fps.enabled"
,
"true"
)
systemProperty
(
"skiko.fps.enabled"
,
"true"
)
// Use systemProperty("skiko.library.path", "/tmp") to test loader.
System
.
getProperties
().
entries
System
.
getProperties
().
entries
.
associate
{
.
associate
{
(
it
.
key
as
String
)
to
(
it
.
value
as
String
)
(
it
.
key
as
String
)
to
(
it
.
value
as
String
)
...
...
skiko/src/jvmMain/kotlin/org/jetbrains/skiko/Library.kt
View file @
a30747fe
...
@@ -9,6 +9,7 @@ import java.nio.file.StandardCopyOption
...
@@ -9,6 +9,7 @@ import java.nio.file.StandardCopyOption
object
Library
{
object
Library
{
private
var
loaded
=
false
private
var
loaded
=
false
private
val
skikoLibraryPath
=
System
.
getProperty
(
"skiko.library.path"
)
private
val
cacheRoot
=
"${System.getProperty("
user
.
home
")}/.skiko/"
private
val
cacheRoot
=
"${System.getProperty("
user
.
home
")}/.skiko/"
private
fun
loadOrGet
(
cacheDir
:
File
,
path
:
String
,
resourceName
:
String
,
isLibrary
:
Boolean
)
{
private
fun
loadOrGet
(
cacheDir
:
File
,
path
:
String
,
resourceName
:
String
,
isLibrary
:
Boolean
)
{
...
@@ -33,24 +34,30 @@ object Library {
...
@@ -33,24 +34,30 @@ object Library {
fun
load
()
{
fun
load
()
{
if
(
loaded
)
return
if
(
loaded
)
return
val
resourcePath
=
"/"
val
name
=
"skiko-$hostId"
val
name
=
"skiko-$hostId"
val
platformName
=
System
.
mapLibraryName
(
name
)
val
platformName
=
System
.
mapLibraryName
(
name
)
if
(
skikoLibraryPath
!=
null
)
{
val
library
=
File
(
File
(
skikoLibraryPath
),
platformName
)
System
.
load
(
library
.
absolutePath
)
}
else
{
val
resourcePath
=
"/"
val
hashResourceStream
=
Library
::
class
.
java
.
getResourceAsStream
(
val
hashResourceStream
=
Library
::
class
.
java
.
getResourceAsStream
(
"$resourcePath$platformName.sha256"
)
?:
throw
LibraryLoadException
(
"$resourcePath$platformName.sha256"
)
?:
throw
LibraryLoadException
(
"Cannot find $platformName.sha256, proper native dependency missing."
"Cannot find $platformName.sha256, proper native dependency missing."
)
)
val
hash
=
hashResourceStream
.
use
{
val
hash
=
hashResourceStream
.
use
{
BufferedReader
(
InputStreamReader
(
it
)).
lines
().
toArray
()[
0
]
as
String
BufferedReader
(
InputStreamReader
(
it
)).
lines
().
toArray
()[
0
]
as
String
}
}
val
cacheDir
=
File
(
"$cacheRoot/$hash"
)
val
cacheDir
=
File
(
File
(
cacheRoot
),
hash
)
cacheDir
.
mkdirs
()
cacheDir
.
mkdirs
()
loadOrGet
(
cacheDir
,
resourcePath
,
platformName
,
true
)
loadOrGet
(
cacheDir
,
resourcePath
,
platformName
,
true
)
val
loadIcu
=
hostOs
.
isWindows
val
loadIcu
=
hostOs
.
isWindows
if
(
loadIcu
)
{
if
(
loadIcu
)
{
loadOrGet
(
cacheDir
,
resourcePath
,
"icudtl.dat"
,
false
)
loadOrGet
(
cacheDir
,
resourcePath
,
"icudtl.dat"
,
false
)
}
}
}
// TODO move properties to SkikoProperties
// TODO move properties to SkikoProperties
Setup
.
init
(
Setup
.
init
(
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment