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 mainActivity: WeakReference<FragmentActivity>
|
||||
|
||||
actual fun initHaskell() {
|
||||
fun initHaskell() {
|
||||
val socketName = "chat.simplex.app.local.socket.address.listen.native.cmd2" + Random.nextLong(100000)
|
||||
val s = Semaphore(0)
|
||||
thread(name="stdout/stderr pipe") {
|
||||
|
@ -22,8 +22,6 @@ val appVersionInfo: Pair<String, Int?> = if (appPlatform == AppPlatform.ANDROID)
|
||||
else
|
||||
BuildConfigCommon.DESKTOP_VERSION_NAME to null
|
||||
|
||||
expect fun initHaskell()
|
||||
|
||||
class FifoQueue<E>(private var capacity: Int) : LinkedList<E>() {
|
||||
override fun add(element: E): Boolean {
|
||||
if(size > capacity) removeFirst()
|
||||
|
@ -146,6 +146,3 @@ fun AppPreview() {
|
||||
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
|
||||
|
||||
import chat.simplex.common.DesktopApp
|
||||
import chat.simplex.common.model.*
|
||||
import chat.simplex.common.views.call.RcvCallInvitation
|
||||
import chat.simplex.common.views.helpers.withBGApi
|
||||
import java.io.*
|
||||
import java.nio.file.*
|
||||
import java.nio.file.attribute.BasicFileAttributes
|
||||
import java.util.*
|
||||
|
||||
actual val appPlatform = AppPlatform.DESKTOP
|
||||
@ -39,29 +35,3 @@ private fun applyAppLocale() {
|
||||
if (lang == null || lang == Locale.getDefault().language) return
|
||||
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.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 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")
|
||||
|
@ -30,7 +30,7 @@ kotlin {
|
||||
compose {
|
||||
desktop {
|
||||
application {
|
||||
mainClass = "MainKt"
|
||||
mainClass = "chat.simplex.desktop.MainKt"
|
||||
nativeDistributions {
|
||||
modules("jdk.zipfs")
|
||||
//includeAllModules = true
|
||||
@ -40,19 +40,19 @@ compose {
|
||||
//, TargetFormat.AppImage // Gradle doesn't sync on Mac with it
|
||||
)
|
||||
linux {
|
||||
iconFile.set(project.file("../common/src/commonMain/resources/distribute/simplex.png"))
|
||||
iconFile.set(project.file("src/jvmMain/resources/distribute/simplex.png"))
|
||||
appCategory = "Messenger"
|
||||
}
|
||||
windows {
|
||||
// LALAL
|
||||
iconFile.set(project.file("../common/src/commonMain/resources/distribute/simplex.ico"))
|
||||
iconFile.set(project.file("src/jvmMain/resources/distribute/simplex.ico"))
|
||||
console = true
|
||||
perUserInstall = true
|
||||
dirChooser = true
|
||||
}
|
||||
macOS {
|
||||
// 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"
|
||||
bundleID = "chat.simplex.app"
|
||||
}
|
||||
@ -116,7 +116,7 @@ afterEvaluate {
|
||||
doLast {
|
||||
copy {
|
||||
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")
|
||||
eachFile {
|
||||
path = name
|
||||
@ -126,7 +126,7 @@ afterEvaluate {
|
||||
}
|
||||
copy {
|
||||
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")
|
||||
eachFile {
|
||||
path = name
|
||||
@ -136,7 +136,7 @@ afterEvaluate {
|
||||
}
|
||||
copy {
|
||||
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")
|
||||
eachFile {
|
||||
path = name
|
||||
@ -146,7 +146,7 @@ afterEvaluate {
|
||||
}
|
||||
copy {
|
||||
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")
|
||||
eachFile {
|
||||
path = name
|
||||
@ -156,7 +156,7 @@ afterEvaluate {
|
||||
}
|
||||
copy {
|
||||
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")
|
||||
eachFile {
|
||||
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
|
||||
Name=SimpleX Chat
|
||||
Comment=Private and secure open-source messenger - no user IDs (not even random numbers).
|
||||
Exec=simplex
|
||||
Icon=simplex.png
|
||||
Categories=Messenger;
|
||||
Exec=/opt/simplex/bin/simplex
|
||||
Icon=/opt/simplex/lib/simplex
|
||||
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 -
|
||||
|
||||
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
|
||||
|
||||
mkdir -p apps/multiplatform/common/src/commonMain/cpp/desktop/libs/$OS-$ARCH/
|
||||
|
@ -64,7 +64,7 @@ rm deps/`basename $LIB`
|
||||
cd -
|
||||
|
||||
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
|
||||
|
||||
mkdir -p apps/multiplatform/common/src/commonMain/cpp/desktop/libs/$OS-$ARCH/
|
||||
|
Loading…
Reference in New Issue
Block a user