desktop: change libs path (#2776)
Co-authored-by: Evgeny Poberezkin <2769109+epoberezkin@users.noreply.github.com>
This commit is contained in:
parent
6be8476f90
commit
92d13591f3
@ -25,7 +25,7 @@ val defaultLocale: Locale = Locale.getDefault()
|
|||||||
lateinit var androidAppContext: Context
|
lateinit var androidAppContext: Context
|
||||||
lateinit var mainActivity: WeakReference<FragmentActivity>
|
lateinit var mainActivity: WeakReference<FragmentActivity>
|
||||||
|
|
||||||
actual fun initHaskell() {
|
fun initHaskell() {
|
||||||
val socketName = "chat.simplex.app.local.socket.address.listen.native.cmd2" + Random.nextLong(100000)
|
val socketName = "chat.simplex.app.local.socket.address.listen.native.cmd2" + Random.nextLong(100000)
|
||||||
val s = Semaphore(0)
|
val s = Semaphore(0)
|
||||||
thread(name="stdout/stderr pipe") {
|
thread(name="stdout/stderr pipe") {
|
||||||
|
@ -22,8 +22,6 @@ val appVersionInfo: Pair<String, Int?> = if (appPlatform == AppPlatform.ANDROID)
|
|||||||
else
|
else
|
||||||
BuildConfigCommon.DESKTOP_VERSION_NAME to null
|
BuildConfigCommon.DESKTOP_VERSION_NAME to null
|
||||||
|
|
||||||
expect fun initHaskell()
|
|
||||||
|
|
||||||
class FifoQueue<E>(private var capacity: Int) : LinkedList<E>() {
|
class FifoQueue<E>(private var capacity: Int) : LinkedList<E>() {
|
||||||
override fun add(element: E): Boolean {
|
override fun add(element: E): Boolean {
|
||||||
if(size > capacity) removeFirst()
|
if(size > capacity) removeFirst()
|
||||||
|
@ -146,6 +146,3 @@ fun AppPreview() {
|
|||||||
AppScreen()
|
AppScreen()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Needed for [chat.simplex.common.platform.Files] to get path to jar file */
|
|
||||||
class DesktopApp()
|
|
||||||
|
@ -1,12 +1,8 @@
|
|||||||
package chat.simplex.common.platform
|
package chat.simplex.common.platform
|
||||||
|
|
||||||
import chat.simplex.common.DesktopApp
|
|
||||||
import chat.simplex.common.model.*
|
import chat.simplex.common.model.*
|
||||||
import chat.simplex.common.views.call.RcvCallInvitation
|
import chat.simplex.common.views.call.RcvCallInvitation
|
||||||
import chat.simplex.common.views.helpers.withBGApi
|
import chat.simplex.common.views.helpers.withBGApi
|
||||||
import java.io.*
|
|
||||||
import java.nio.file.*
|
|
||||||
import java.nio.file.attribute.BasicFileAttributes
|
|
||||||
import java.util.*
|
import java.util.*
|
||||||
|
|
||||||
actual val appPlatform = AppPlatform.DESKTOP
|
actual val appPlatform = AppPlatform.DESKTOP
|
||||||
@ -39,29 +35,3 @@ private fun applyAppLocale() {
|
|||||||
if (lang == null || lang == Locale.getDefault().language) return
|
if (lang == null || lang == Locale.getDefault().language) return
|
||||||
Locale.setDefault(Locale.forLanguageTag(lang))
|
Locale.setDefault(Locale.forLanguageTag(lang))
|
||||||
}
|
}
|
||||||
|
|
||||||
@Suppress("UnsafeDynamicallyLoadedCode")
|
|
||||||
actual fun initHaskell() {
|
|
||||||
val libApp = "libapp-lib.${desktopPlatform.libExtension}"
|
|
||||||
val libsTmpDir = File(tmpDir.absolutePath + File.separator + "libs")
|
|
||||||
copyResources(desktopPlatform.libPath, libsTmpDir.toPath())
|
|
||||||
System.load(File(libsTmpDir, libApp).absolutePath)
|
|
||||||
libsTmpDir.deleteRecursively()
|
|
||||||
initHS()
|
|
||||||
}
|
|
||||||
|
|
||||||
private fun copyResources(from: String, to: Path) {
|
|
||||||
val resource = DesktopApp::class.java.getResource("")!!.toURI()
|
|
||||||
val fileSystem = FileSystems.newFileSystem(resource, emptyMap<String, String>())
|
|
||||||
val resPath = fileSystem.getPath(from)
|
|
||||||
Files.walkFileTree(resPath, object: SimpleFileVisitor<Path>() {
|
|
||||||
override fun preVisitDirectory(dir: Path, attrs: BasicFileAttributes): FileVisitResult {
|
|
||||||
Files.createDirectories(to.resolve(resPath.relativize(dir).toString()))
|
|
||||||
return FileVisitResult.CONTINUE
|
|
||||||
}
|
|
||||||
override fun visitFile(file: Path, attrs: BasicFileAttributes): FileVisitResult {
|
|
||||||
Files.copy(file, to.resolve(resPath.relativize(file).toString()), StandardCopyOption.REPLACE_EXISTING)
|
|
||||||
return FileVisitResult.CONTINUE
|
|
||||||
}
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
@ -7,15 +7,6 @@ import chat.simplex.res.MR
|
|||||||
import java.io.*
|
import java.io.*
|
||||||
import java.net.URI
|
import java.net.URI
|
||||||
|
|
||||||
private fun applicationParentPath(): String = try {
|
|
||||||
DesktopApp::class.java.protectionDomain!!.codeSource.location.toURI().path
|
|
||||||
.replaceAfterLast("/", "")
|
|
||||||
.replaceAfterLast(File.separator, "")
|
|
||||||
.replace("/", File.separator)
|
|
||||||
} catch (e: Exception) {
|
|
||||||
"./"
|
|
||||||
}
|
|
||||||
|
|
||||||
actual val dataDir: File = File(desktopPlatform.dataPath)
|
actual val dataDir: File = File(desktopPlatform.dataPath)
|
||||||
actual val tmpDir: File = File(System.getProperty("java.io.tmpdir") + File.separator + "simplex").also { it.deleteOnExit() }
|
actual val tmpDir: File = File(System.getProperty("java.io.tmpdir") + File.separator + "simplex").also { it.deleteOnExit() }
|
||||||
actual val filesDir: File = File(dataDir.absolutePath + File.separator + "simplex_v1_files")
|
actual val filesDir: File = File(dataDir.absolutePath + File.separator + "simplex_v1_files")
|
||||||
|
@ -30,7 +30,7 @@ kotlin {
|
|||||||
compose {
|
compose {
|
||||||
desktop {
|
desktop {
|
||||||
application {
|
application {
|
||||||
mainClass = "MainKt"
|
mainClass = "chat.simplex.desktop.MainKt"
|
||||||
nativeDistributions {
|
nativeDistributions {
|
||||||
modules("jdk.zipfs")
|
modules("jdk.zipfs")
|
||||||
//includeAllModules = true
|
//includeAllModules = true
|
||||||
@ -40,19 +40,19 @@ compose {
|
|||||||
//, TargetFormat.AppImage // Gradle doesn't sync on Mac with it
|
//, TargetFormat.AppImage // Gradle doesn't sync on Mac with it
|
||||||
)
|
)
|
||||||
linux {
|
linux {
|
||||||
iconFile.set(project.file("../common/src/commonMain/resources/distribute/simplex.png"))
|
iconFile.set(project.file("src/jvmMain/resources/distribute/simplex.png"))
|
||||||
appCategory = "Messenger"
|
appCategory = "Messenger"
|
||||||
}
|
}
|
||||||
windows {
|
windows {
|
||||||
// LALAL
|
// LALAL
|
||||||
iconFile.set(project.file("../common/src/commonMain/resources/distribute/simplex.ico"))
|
iconFile.set(project.file("src/jvmMain/resources/distribute/simplex.ico"))
|
||||||
console = true
|
console = true
|
||||||
perUserInstall = true
|
perUserInstall = true
|
||||||
dirChooser = true
|
dirChooser = true
|
||||||
}
|
}
|
||||||
macOS {
|
macOS {
|
||||||
// LALAL
|
// LALAL
|
||||||
//iconFile.set(project.file("../common/src/commonMain/resources/distribute/simplex.icns"))
|
//iconFile.set(project.file("../desktop/src/jvmMain/resources/distribute/simplex.icns"))
|
||||||
appCategory = "public.app-category.social-networking"
|
appCategory = "public.app-category.social-networking"
|
||||||
bundleID = "chat.simplex.app"
|
bundleID = "chat.simplex.app"
|
||||||
}
|
}
|
||||||
@ -116,7 +116,7 @@ afterEvaluate {
|
|||||||
doLast {
|
doLast {
|
||||||
copy {
|
copy {
|
||||||
from("${project(":desktop").buildDir}/cmake/main/linux-amd64", "$cppPath/desktop/libs/linux-x86_64", "$cppPath/desktop/libs/linux-x86_64/deps")
|
from("${project(":desktop").buildDir}/cmake/main/linux-amd64", "$cppPath/desktop/libs/linux-x86_64", "$cppPath/desktop/libs/linux-x86_64/deps")
|
||||||
into("../common/src/commonMain/resources/libs/linux-x86_64")
|
into("src/jvmMain/resources/libs/linux-x86_64")
|
||||||
include("*.so")
|
include("*.so")
|
||||||
eachFile {
|
eachFile {
|
||||||
path = name
|
path = name
|
||||||
@ -126,7 +126,7 @@ afterEvaluate {
|
|||||||
}
|
}
|
||||||
copy {
|
copy {
|
||||||
from("${project(":desktop").buildDir}/cmake/main/linux-aarch64", "$cppPath/desktop/libs/linux-aarch64", "$cppPath/desktop/libs/linux-aarch64/deps")
|
from("${project(":desktop").buildDir}/cmake/main/linux-aarch64", "$cppPath/desktop/libs/linux-aarch64", "$cppPath/desktop/libs/linux-aarch64/deps")
|
||||||
into("../common/src/commonMain/resources/libs/linux-aarch64")
|
into("src/jvmMain/resources/libs/linux-aarch64")
|
||||||
include("*.so")
|
include("*.so")
|
||||||
eachFile {
|
eachFile {
|
||||||
path = name
|
path = name
|
||||||
@ -136,7 +136,7 @@ afterEvaluate {
|
|||||||
}
|
}
|
||||||
copy {
|
copy {
|
||||||
from("${project(":desktop").buildDir}/cmake/main/win-amd64", "$cppPath/desktop/libs/windows-x86_64", "$cppPath/desktop/libs/windows-x86_64/deps")
|
from("${project(":desktop").buildDir}/cmake/main/win-amd64", "$cppPath/desktop/libs/windows-x86_64", "$cppPath/desktop/libs/windows-x86_64/deps")
|
||||||
into("../common/src/commonMain/resources/libs/windows-x86_64")
|
into("src/jvmMain/resources/libs/windows-x86_64")
|
||||||
include("*.dll")
|
include("*.dll")
|
||||||
eachFile {
|
eachFile {
|
||||||
path = name
|
path = name
|
||||||
@ -146,7 +146,7 @@ afterEvaluate {
|
|||||||
}
|
}
|
||||||
copy {
|
copy {
|
||||||
from("${project(":desktop").buildDir}/cmake/main/mac-x86_64", "$cppPath/desktop/libs/mac-x86_64", "$cppPath/desktop/libs/mac-x86_64/deps")
|
from("${project(":desktop").buildDir}/cmake/main/mac-x86_64", "$cppPath/desktop/libs/mac-x86_64", "$cppPath/desktop/libs/mac-x86_64/deps")
|
||||||
into("../common/src/commonMain/resources/libs/mac-x86_64")
|
into("src/jvmMain/resources/libs/mac-x86_64")
|
||||||
include("*.dylib")
|
include("*.dylib")
|
||||||
eachFile {
|
eachFile {
|
||||||
path = name
|
path = name
|
||||||
@ -156,7 +156,7 @@ afterEvaluate {
|
|||||||
}
|
}
|
||||||
copy {
|
copy {
|
||||||
from("${project(":desktop").buildDir}/cmake/main/mac-aarch64", "$cppPath/desktop/libs/mac-aarch64", "$cppPath/desktop/libs/mac-aarch64/deps")
|
from("${project(":desktop").buildDir}/cmake/main/mac-aarch64", "$cppPath/desktop/libs/mac-aarch64", "$cppPath/desktop/libs/mac-aarch64/deps")
|
||||||
into("../common/src/commonMain/resources/libs/mac-aarch64")
|
into("src/jvmMain/resources/libs/mac-aarch64")
|
||||||
include("*.dylib")
|
include("*.dylib")
|
||||||
eachFile {
|
eachFile {
|
||||||
path = name
|
path = name
|
||||||
|
@ -1,9 +0,0 @@
|
|||||||
import chat.simplex.common.platform.*
|
|
||||||
import chat.simplex.common.showApp
|
|
||||||
|
|
||||||
fun main() {
|
|
||||||
initHaskell()
|
|
||||||
initApp()
|
|
||||||
tmpDir.deleteRecursively()
|
|
||||||
return showApp()
|
|
||||||
}
|
|
@ -0,0 +1,40 @@
|
|||||||
|
package chat.simplex.desktop
|
||||||
|
|
||||||
|
import chat.simplex.common.platform.*
|
||||||
|
import chat.simplex.common.showApp
|
||||||
|
import java.io.File
|
||||||
|
import java.nio.file.*
|
||||||
|
import java.nio.file.attribute.BasicFileAttributes
|
||||||
|
|
||||||
|
fun main() {
|
||||||
|
initHaskell()
|
||||||
|
initApp()
|
||||||
|
tmpDir.deleteRecursively()
|
||||||
|
return showApp()
|
||||||
|
}
|
||||||
|
|
||||||
|
@Suppress("UnsafeDynamicallyLoadedCode")
|
||||||
|
private fun initHaskell() {
|
||||||
|
val libApp = "libapp-lib.${desktopPlatform.libExtension}"
|
||||||
|
val libsTmpDir = File(tmpDir.absolutePath + File.separator + "libs")
|
||||||
|
copyResources(desktopPlatform.libPath, libsTmpDir.toPath())
|
||||||
|
System.load(File(libsTmpDir, libApp).absolutePath)
|
||||||
|
libsTmpDir.deleteRecursively()
|
||||||
|
initHS()
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun copyResources(from: String, to: Path) {
|
||||||
|
val resource = Class.forName("chat.simplex.desktop.MainKt").getResource("")!!.toURI()
|
||||||
|
val fileSystem = FileSystems.newFileSystem(resource, emptyMap<String, String>())
|
||||||
|
val resPath = fileSystem.getPath(from)
|
||||||
|
Files.walkFileTree(resPath, object: SimpleFileVisitor<Path>() {
|
||||||
|
override fun preVisitDirectory(dir: Path, attrs: BasicFileAttributes): FileVisitResult {
|
||||||
|
Files.createDirectories(to.resolve(resPath.relativize(dir).toString()))
|
||||||
|
return FileVisitResult.CONTINUE
|
||||||
|
}
|
||||||
|
override fun visitFile(file: Path, attrs: BasicFileAttributes): FileVisitResult {
|
||||||
|
Files.copy(file, to.resolve(resPath.relativize(file).toString()), StandardCopyOption.REPLACE_EXISTING)
|
||||||
|
return FileVisitResult.CONTINUE
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
@ -2,6 +2,6 @@
|
|||||||
Type=Application
|
Type=Application
|
||||||
Name=SimpleX Chat
|
Name=SimpleX Chat
|
||||||
Comment=Private and secure open-source messenger - no user IDs (not even random numbers).
|
Comment=Private and secure open-source messenger - no user IDs (not even random numbers).
|
||||||
Exec=simplex
|
Exec=/opt/simplex/bin/simplex
|
||||||
Icon=simplex.png
|
Icon=/opt/simplex/lib/simplex
|
||||||
Categories=Messenger;
|
Categories=Network;Chat;
|
Before Width: | Height: | Size: 25 KiB After Width: | Height: | Size: 25 KiB |
@ -17,7 +17,7 @@ ldd libHSsimplex-chat-*-inplace-ghc${GHC_VERSION}.so | grep "ghc" | cut -d' ' -f
|
|||||||
cd -
|
cd -
|
||||||
|
|
||||||
rm -rf apps/multiplatform/common/src/commonMain/cpp/desktop/libs/$OS-$ARCH/
|
rm -rf apps/multiplatform/common/src/commonMain/cpp/desktop/libs/$OS-$ARCH/
|
||||||
rm -rf apps/multiplatform/common/src/commonMain/resources/libs/$OS-$ARCH/
|
rm -rf apps/multiplatform/desktop/src/jvmMain/resources/libs/$OS-$ARCH/
|
||||||
rm -rf apps/multiplatform/desktop/build/cmake
|
rm -rf apps/multiplatform/desktop/build/cmake
|
||||||
|
|
||||||
mkdir -p apps/multiplatform/common/src/commonMain/cpp/desktop/libs/$OS-$ARCH/
|
mkdir -p apps/multiplatform/common/src/commonMain/cpp/desktop/libs/$OS-$ARCH/
|
||||||
|
@ -64,7 +64,7 @@ rm deps/`basename $LIB`
|
|||||||
cd -
|
cd -
|
||||||
|
|
||||||
rm -rf apps/multiplatform/common/src/commonMain/cpp/desktop/libs/$OS-$ARCH/
|
rm -rf apps/multiplatform/common/src/commonMain/cpp/desktop/libs/$OS-$ARCH/
|
||||||
rm -rf apps/multiplatform/common/src/commonMain/resources/libs/$OS-$ARCH/
|
rm -rf apps/multiplatform/desktop/src/jvmMain/resources/libs/$OS-$ARCH/
|
||||||
rm -rf apps/multiplatform/desktop/build/cmake
|
rm -rf apps/multiplatform/desktop/build/cmake
|
||||||
|
|
||||||
mkdir -p apps/multiplatform/common/src/commonMain/cpp/desktop/libs/$OS-$ARCH/
|
mkdir -p apps/multiplatform/common/src/commonMain/cpp/desktop/libs/$OS-$ARCH/
|
||||||
|
Loading…
Reference in New Issue
Block a user