diff --git a/.github/workflows/build-linux-arm64.yml b/.github/workflows/build-linux-arm64.yml index c1ff066..7e0fafd 100644 --- a/.github/workflows/build-linux-arm64.yml +++ b/.github/workflows/build-linux-arm64.yml @@ -80,8 +80,8 @@ jobs: working-directory: zeromq-4.3.5 run: make -j$(nproc) && make install - - name: Copy libzmq into src/nativeInterop - run: mkdir src/nativeInterop && cp -r libzmq/* src/nativeInterop + - name: Copy libzmq into src/nativeInterop/linux-arm64 + run: mkdir -p src/nativeInterop/linux-arm64 && cp -r libzmq/* src/nativeInterop/linux-arm64 - name: Add arm64 architecture to dpkg run: dpkg --add-architecture arm64 @@ -124,20 +124,20 @@ jobs: - name: Grant execute permission for gradlew run: chmod +x gradle - - name: Build native binaries - run: SPMS_ARCH="aarch64" ./gradlew nativeBinariesStatic + - name: Build linux-arm64 binaries + run: ./gradlew linux-arm64BinariesStatic - name: Strip release binary - run: $TOOLCHAIN/bin/aarch64-unknown-linux-gnu-strip build/bin/native/releaseExecutable/*.kexe + run: $TOOLCHAIN/bin/aarch64-unknown-linux-gnu-strip build/bin/linux-arm64/releaseExecutable/*.kexe - name: Upload debug binary uses: actions/upload-artifact@v3 with: name: spms-linux-arm64-debug - path: build/bin/native/debugExecutable/*.kexe + path: build/bin/linux-arm64/debugExecutable/*.kexe - name: Upload release binary uses: actions/upload-artifact@v3 with: name: spms-linux-arm64-release - path: build/bin/native/releaseExecutable/*.kexe + path: build/bin/linux-arm64/releaseExecutable/*.kexe diff --git a/.github/workflows/build-linux-x86_64.yml b/.github/workflows/build-linux-x86_64.yml index 5a33eda..d1f9b59 100644 --- a/.github/workflows/build-linux-x86_64.yml +++ b/.github/workflows/build-linux-x86_64.yml @@ -2,7 +2,7 @@ name: Build [Linux x86_64] on: push: - branches: [ "main", "test" ] + branches: [ "main" ] pull_request: branches: [ "main" ] workflow_dispatch: @@ -78,8 +78,8 @@ jobs: working-directory: zeromq-4.3.5 run: make -j$(nproc) && make install - - name: Copy libzmq into src/nativeInterop - run: mkdir src/nativeInterop && cp -r libzmq/* src/nativeInterop + - name: Copy libzmq into src/nativeInterop/linux-x86_64 + run: mkdir -p src/nativeInterop/linux-x86_64 && cp -r libzmq/* src/nativeInterop/linux-x86_64 - name: Set up Gradle uses: gradle/gradle-build-action@v3 @@ -87,20 +87,20 @@ jobs: - name: Grant execute permission for gradlew run: chmod +x gradle - - name: Build native binaries - run: ./gradlew nativeBinariesStatic + - name: Build linux-x86_64 binaries + run: ./gradlew linux-x86_64BinariesStatic - name: Strip release binary - run: $TOOLCHAIN/bin/x86_64-unknown-linux-gnu-strip build/bin/native/releaseExecutable/*.kexe + run: $TOOLCHAIN/bin/x86_64-unknown-linux-gnu-strip build/bin/linux-x86_64/releaseExecutable/*.kexe - name: Upload debug binary uses: actions/upload-artifact@v3 with: name: spms-linux-x86_64-debug - path: build/bin/native/debugExecutable/*.kexe + path: build/bin/linux-x86_64/debugExecutable/*.kexe - name: Upload release binary uses: actions/upload-artifact@v3 with: name: spms-linux-x86_64-release - path: build/bin/native/releaseExecutable/*.kexe + path: build/bin/linux-x86_64/releaseExecutable/*.kexe diff --git a/.github/workflows/build-windows-x86_64.yml b/.github/workflows/build-windows-x86_64.yml index d9f0213..efe179f 100644 --- a/.github/workflows/build-windows-x86_64.yml +++ b/.github/workflows/build-windows-x86_64.yml @@ -30,11 +30,8 @@ jobs: token: ${{ github.token }} github-binarycache: true - - name: Copy libzmq files - run: xcopy /s /i /y "${{ github.workspace }}\vcpkg\packages\zeromq_x64-windows\*" "${{ github.workspace }}\src\nativeInterop" - - - name: Copy libcurl files - run: xcopy /s /i /y "${{ github.workspace }}\vcpkg\packages\curl_x64-windows\*" "${{ github.workspace }}\src\nativeInterop" + - name: Copy built files + run: xcopy /s /i /y "${{ github.workspace }}\vcpkg\installed\x64-windows\*" "${{ github.workspace }}\src\nativeInterop\windows-x86_64" - name: Download 7-Zip run: curl https://www.7-zip.org/a/7z2301-x64.exe --output 7z-installer.exe @@ -46,25 +43,34 @@ jobs: run: curl https://kumisystems.dl.sourceforge.net/project/mpv-player-windows/libmpv/mpv-dev-x86_64-20240114-git-bd35dc8.7z --output mpv.7z - name: Extract mpv - run: 7zip\7z.exe x mpv.7z -osrc\nativeInterop + run: 7zip\7z.exe x mpv.7z -osrc\nativeInterop\windows-x86_64 - name: Move libmpv.dll.a - run: move src\nativeInterop\libmpv.dll.a src\nativeInterop\lib\libmpv.dll.a + run: move src\nativeInterop\windows-x86_64\libmpv.dll.a src\nativeInterop\windows-x86_64\lib\libmpv.dll.a + + - name: Move libmpv-2.dll + run: move src\nativeInterop\windows-x86_64\libmpv-2.dll src\nativeInterop\windows-x86_64\bin\libmpv-2.dll - name: Set up Gradle uses: gradle/gradle-build-action@v3 - - name: Build native binaries - run: .\gradlew.bat nativeBinariesStatic + - name: Build windows-x86_64 binaries + run: .\gradlew.bat windows-x86_64BinariesStatic - name: Upload debug binary uses: actions/upload-artifact@v3 with: name: spms-windows-x86_64-debug - path: build\bin\native\debugExecutable\*.exe + path: build\bin\windows-x86_64\debugExecutable\*.exe - name: Upload release binary uses: actions/upload-artifact@v3 with: name: spms-windows-x86_64-release - path: build\bin\native\releaseExecutable\*.exe + path: build\bin\windows-x86_64\releaseExecutable\*.exe + + # - name: Upload DLL dependencies + # uses: actions/upload-artifact@v3 + # with: + # name: dependencies + # path: build\bin\windows-x86_64\releaseExecutable\*.dll diff --git a/build.gradle.kts b/build.gradle.kts index afd00e6..9720521 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -1,5 +1,6 @@ @file:Suppress("UNUSED_VARIABLE") +import org.jetbrains.kotlin.gradle.dsl.KotlinMultiplatformExtension import org.jetbrains.kotlin.gradle.internal.ensureParentDirsCreated import org.jetbrains.kotlin.gradle.plugin.mpp.KotlinNativeTarget import java.io.PrintWriter @@ -20,6 +21,8 @@ repositories { maven("https://jitpack.io") } +fun String.capitalised() = this.first().uppercase() + this.drop(1) + enum class Arch { X86_64, ARM64; @@ -31,18 +34,22 @@ enum class Arch { val PKG_CONFIG_PATH: String get() = "/usr/lib/$libdir_name/pkgconfig" companion object { - val target: Arch get() { - val target_arch: String = System.getenv("SPMS_ARCH") ?: System.getProperty("os.arch") + fun getTarget(project: Project): Arch { + val target_arch: String = + project.findProperty("SPMS_ARCH")?.toString() + ?: System.getenv("SPMS_ARCH") + ?: System.getProperty("os.arch") + return when (target_arch.lowercase()) { "x86_64", "amd64" -> X86_64 - "aarch64" -> ARM64 + "aarch64", "arm64" -> ARM64 else -> throw GradleException("Unsupported CPU architecture '$target_arch'") } } } } -enum class OS { +enum class Platform { LINUX_X86, LINUX_ARM64, WINDOWS, OSX_X86, OSX_ARM; val identifier: String @@ -61,10 +68,26 @@ enum class OS { OSX_X86, OSX_ARM -> "osx" } + val arch: Arch + get() = when (this) { + LINUX_X86, WINDOWS, OSX_X86 -> Arch.X86_64 + LINUX_ARM64, OSX_ARM -> Arch.ARM64 + } + + fun getNativeDependenciesDir(project: Project) = + project.file("src/nativeInterop/$identifier") + companion object { - val target: OS get() { - val target_os: String = System.getenv("SPMS_OS") ?: System.getProperty("os.name") - val target_arch: Arch = Arch.target + val supported: List = listOf( + LINUX_X86, LINUX_ARM64, WINDOWS + ) + + fun getTarget(project: Project): Platform { + val target_os: String = + project.findProperty("SPMS_OS")?.toString() + ?: System.getenv("SPMS_OS") + ?: System.getProperty("os.name") + val target_arch: Arch = Arch.getTarget(project) val os: String = target_os.lowercase() @@ -88,100 +111,122 @@ val platform_specific_files: List = listOf( "spms/Platform.kt" ) -val cinterop_definitions: List = listOf( - CInteropDefinition( - "libmpv", - when (OS.target) { - OS.WINDOWS -> "libmpv.dll.a" - else -> "mpv" - }, - listOf("mpv/client.h"), - bin_dependencies = when (OS.target) { - OS.WINDOWS -> listOf("libmpv-2.dll") - else -> emptyList() - } - ), - CInteropDefinition( - "libzmq", - when (OS.target) { - OS.WINDOWS -> "libzmq-mt-4_3_5.lib" - else -> "libzmq" - }, - listOf("zmq.h", "zmq_utils.h"), - compiler_opts = listOf("-DZMQ_BUILD_DRAFT_API=1") - ).apply { - when (OS.target) { - OS.LINUX_X86, OS.LINUX_ARM64 -> static_lib = "libzmq.a" - OS.WINDOWS -> { - linker_opts = listOf("-lssp") - bin_dependencies = listOf("libzmq-mt-4_3_5.dll") +enum class CinteropLibraries { + LIBMPV, LIBZMQ, LIBCURL, LIBAPPINDICATOR; + + val identifier: String get() = name.lowercase() + + private fun Platform.createDefinition(lib: String, headers: List, action: CInteropDefinition.() -> Unit = {}): CInteropDefinition = + CInteropDefinition(this, this@CinteropLibraries.identifier, lib, headers).apply(action) + + private fun String.capitalised() = this.first().uppercase() + this.drop(1) + + fun getDefinition(platform: Platform): CInteropDefinition = when (this) { + LIBMPV -> + platform.createDefinition( + when (platform) { + Platform.WINDOWS -> "libmpv.dll.a" + else -> "mpv" + }, + listOf("mpv/client.h") + ) { + if (platform == Platform.WINDOWS) { + bin_dependencies = listOf("libmpv-2.dll") + } } - else -> {} - } - }, - CInteropDefinition( - "libcurl", - when (OS.target) { - OS.WINDOWS -> "libcurl.lib" - else -> "libcurl" - }, - listOf("curl/curl.h"), - bin_dependencies = when (OS.target) { - OS.WINDOWS -> listOf("libcurl.dll") - else -> emptyList() - } - ), - CInteropDefinition( - "libappindicator", - "appindicator3-0.1", - listOf("libappindicator3-0.1/libappindicator/app-indicator.h"), - platforms = listOf(OS.LINUX_X86, OS.LINUX_ARM64) - ) -) + LIBZMQ -> + platform.createDefinition( + when (platform) { + Platform.WINDOWS -> "libzmq-mt-4_3_5.lib" + else -> "libzmq" + }, + listOf("zmq.h", "zmq_utils.h") + ) { + compiler_opts = listOf("-DZMQ_BUILD_DRAFT_API=1") + when (platform) { + Platform.LINUX_X86, Platform.LINUX_ARM64 -> { + static_lib = "libzmq.a" + } + Platform.WINDOWS -> { + linker_opts = listOf("-lssp", "-static", "-static-libgcc", "-static-libstdc++", "-lgcc", "-lstdc++") + bin_dependencies = listOf("libzmq-mt-4_3_5.dll") + } + else -> {} + } + } + LIBCURL -> + platform.createDefinition( + when (platform) { + Platform.WINDOWS -> "libcurl.lib" + else -> "libcurl" + }, + listOf("curl/curl.h") + ) { + if (platform == Platform.WINDOWS) { + bin_dependencies = listOf("libcurl.dll", "zlib1.dll") + } + } + LIBAPPINDICATOR -> + platform.createDefinition( + "appindicator3-0.1", + listOf("libappindicator3-0.1/libappindicator/app-indicator.h") + ) { + platforms = listOf(Platform.LINUX_X86, Platform.LINUX_ARM64) + } + } +} kotlin { - val native_target: KotlinNativeTarget = - when (OS.target) { - OS.LINUX_X86 -> linuxX64("native") - OS.LINUX_ARM64 -> linuxArm64("native") - OS.WINDOWS -> mingwX64("native") - OS.OSX_X86 -> macosX64("native") - OS.OSX_ARM -> macosArm64("native") - } + for (os in Platform.supported) { + configureKotlinTarget(os) + } +} + +fun KotlinMultiplatformExtension.configureKotlinTarget(platform: Platform) { + val native_target: KotlinNativeTarget = when (platform) { + Platform.LINUX_X86 -> linuxX64(platform.identifier) + Platform.LINUX_ARM64 -> linuxArm64(platform.identifier) + Platform.WINDOWS -> mingwX64(platform.identifier) + Platform.OSX_X86 -> macosX64(platform.identifier) + Platform.OSX_ARM -> macosArm64(platform.identifier) + } native_target.apply { compilations.getByName("main") { cinterops { - for (lib in cinterop_definitions) { - if (!lib.platforms.contains(OS.target)) { + for (library in CinteropLibraries.values()) { + val definition: CInteropDefinition = library.getDefinition(platform) + if (!definition.platforms.contains(platform)) { continue } - create(lib.name) + create(definition.name) } } } binaries { executable { - baseName = "spms-${OS.target.identifier}" + baseName = "spms-${platform.identifier}" entryPoint = "main" } } } - sourceSets { - val nativeMain by getting { - languageSettings.optIn("kotlin.experimental.ExperimentalNativeApi") - languageSettings.optIn("kotlinx.cinterop.ExperimentalForeignApi") + sourceSets.getByName(platform.identifier + "Main") { + languageSettings.optIn("kotlin.experimental.ExperimentalNativeApi") + languageSettings.optIn("kotlinx.cinterop.ExperimentalForeignApi") - dependencies { - implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.7.3") - implementation("org.jetbrains.kotlinx:kotlinx-serialization-json:1.5.1") - implementation("com.squareup.okio:okio:3.6.0") + dependencies { + implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.7.3") + implementation("org.jetbrains.kotlinx:kotlinx-serialization-json:1.5.1") + implementation("com.squareup.okio:okio:3.6.0") - when (Arch.target) { - Arch.X86_64 -> implementation("com.github.ajalt.clikt:clikt:4.2.2") - Arch.ARM64 -> implementation("com.github.toasterofbread:clikt:65ebc8a4bb0eeecfcfeeec7cd1d05099a4e33df1") + when (platform.arch) { + Arch.X86_64 -> { + implementation("com.github.ajalt.clikt:clikt:4.2.2") + } + Arch.ARM64 -> { + implementation("com.github.toasterofbread:clikt:65ebc8a4bb0eeecfcfeeec7cd1d05099a4e33df1") } } } @@ -197,7 +242,7 @@ tasks.register("bundleIcon") { val in_file: File = project.file("icon.png") inputs.file(in_file) - val out_file: File = project.file("src/nativeMain/kotlin/Icon.gen.kt") + val out_file: File = project.file("src/commonMain/kotlin/Icon.gen.kt") outputs.file(out_file) doLast { @@ -226,27 +271,17 @@ tasks.register("bundleIcon") { } } -tasks.register("nativeBinariesStatic") { - val native_binaries = tasks.getByName("nativeBinaries") - finalizedBy(native_binaries) - group = native_binaries.group - - doFirst { - project.ext.set(FLAG_LINK_STATIC, 1) - } -} - tasks.register("configurePlatformSpecificFiles") { outputs.upToDateWhen { false } fun String.getFile(suffix: String? = null): File = - project.file("src/nativeMain/kotlin/" + if (suffix == null) this.replace(".kt", ".gen.kt") else (this + suffix)) + project.file("src/commonMain/kotlin/" + if (suffix == null) this.replace(".kt", ".gen.kt") else (this + suffix)) for (path in platform_specific_files) { outputs.file(path.getFile()) val input_files: List = - OS.values().map { path.getFile('.' + it.name.toLowerCase()) } + listOf(path.getFile(".other")) + Platform.supported.map { path.getFile('.' + it.name.toLowerCase()) } + listOf(path.getFile(".other")) for (file in input_files) { if (file.isFile) { inputs.file(file) @@ -258,7 +293,7 @@ tasks.register("configurePlatformSpecificFiles") { for (path in platform_specific_files) { val out_file: File = path.getFile() - var platform_file: File = path.getFile('.' + OS.target.gen_file_extension.toLowerCase()) + var platform_file: File = path.getFile('.' + Platform.getTarget(project).gen_file_extension.toLowerCase()) if (!platform_file.isFile) { platform_file = path.getFile(".other") } @@ -277,36 +312,37 @@ tasks.register("configurePlatformSpecificFiles") { } tasks.register("printBuildTarget") { - println("Building spmp-server for target ${OS.target}") -} - -tasks.getByName("compileKotlinNative") { - dependsOn("printBuildTarget") - dependsOn("bundleIcon") - dependsOn("configurePlatformSpecificFiles") + doLast { + println("Building spmp-server for target ${Platform.getTarget(project)}") + } } tasks.register("generateCInteropDefinitions") { outputs.upToDateWhen { false } doLast { + println("Generating CInterop definitions for platform ${Platform.getTarget(project)}") + + val platform: Platform = Platform.getTarget(project) val static: Boolean = project.hasProperty(FLAG_LINK_STATIC) val cinterop_directory: File = project.file("src/nativeInterop/cinterop") - val bin_directory: File = project.file("src/nativeInterop/bin") + val bin_directory: File = platform.getNativeDependenciesDir(project).resolve("bin") - for (lib in cinterop_definitions) { - val file: File = cinterop_directory.resolve(lib.name + ".def") + for (library in CinteropLibraries.values()) { + val definition: CInteropDefinition = library.getDefinition(platform) - if (!lib.platforms.contains(OS.target)) { + val file: File = cinterop_directory.resolve(definition.name + ".def") + + if (!definition.platforms.contains(platform)) { file.delete() continue } - for (bin in lib.bin_dependencies) { + for (bin in definition.bin_dependencies) { val bin_file: File = bin_directory.resolve(bin) if (!bin_file.isFile) { - println("WARNING: File ${bin_file.path} is required by library ${lib.name}, but was not found. Compiled executable may not work correctly.") + println("WARNING: File ${bin_file.path} is required by library ${definition.name}, but was not found. Compiled executable may not work correctly.") } } @@ -315,20 +351,65 @@ tasks.register("generateCInteropDefinitions") { file.printWriter().use { writer -> writer.print(GENERATED_FILE_PREFIX.replace("//", "#")) - lib.writeTo(writer, static) + definition.writeTo(writer, static, project) } } } } -for (lib in cinterop_definitions) { - if (!lib.platforms.contains(OS.target)) { - continue +for (platform in Platform.supported) { + tasks.getByName("compileKotlin" + platform.identifier.capitalised()) { + dependsOn("printBuildTarget") + dependsOn("bundleIcon") + dependsOn("configurePlatformSpecificFiles") + } + + val register_task = tasks.register("setEnv${platform.identifier.capitalised()}") { + doFirst { + project.ext.set("SPMS_OS", when (platform) { + Platform.LINUX_X86, Platform.LINUX_ARM64 -> "linux" + Platform.WINDOWS -> "windows" + else -> throw NotImplementedError(platform.name) + }) + project.ext.set("SPMS_ARCH", platform.arch.name) + } } - val libname: String = lib.name.first().toUpperCase() + lib.name.drop(1) - tasks.getByName("cinterop${libname}Native") { - dependsOn("generateCInteropDefinitions") + for (library in CinteropLibraries.values()) { + val definition: CInteropDefinition = library.getDefinition(platform) + if (!definition.platforms.contains(platform)) { + continue + } + + tasks.getByName("cinterop${definition.name.capitalised()}${platform.identifier.capitalised()}") { + dependsOn(register_task) + + val generate_task = tasks.getByName("generateCInteropDefinitions") + dependsOn(generate_task) + generate_task.mustRunAfter(register_task) + } + } + + val debug_link_task: Task = tasks.getByName("linkDebugExecutable" + platform.identifier.capitalised()) + val debug_finalise_task = tasks.register("finaliseBuildDebug" + platform.identifier.capitalised(), FinaliseBuild::class.java) { + binary_output_directory.set(debug_link_task.outputs.files.single()) + } + debug_link_task.finalizedBy(debug_finalise_task) + + val release_link_task: Task = tasks.getByName("linkReleaseExecutable" + platform.identifier.capitalised()) + val release_finalise_task = tasks.register("finaliseBuildRelease" + platform.identifier.capitalised(), FinaliseBuild::class.java) { + binary_output_directory.set(release_link_task.outputs.files.single()) + } + release_link_task.finalizedBy(release_finalise_task) + + tasks.register(platform.identifier + "BinariesStatic") { + val native_binaries = tasks.getByName(platform.identifier + "Binaries") + finalizedBy(native_binaries) + group = native_binaries.group + + doFirst { + project.ext.set(FLAG_LINK_STATIC, 1) + } } } @@ -336,50 +417,33 @@ open class FinaliseBuild: DefaultTask() { @get:InputDirectory val binary_output_directory: DirectoryProperty = project.objects.directoryProperty() - @get:Input - val _cinterop_definitions: ListProperty = project.objects.listProperty() + init { + outputs.upToDateWhen { false } + } @TaskAction fun execute() { - val bin_directory: File = project.file("src/nativeInterop/bin") + val platform: Platform = Platform.getTarget(project) + + val bin_directory: File = platform.getNativeDependenciesDir(project).resolve("bin") val target_directory: File = binary_output_directory.get().asFile - for (lib in _cinterop_definitions.get()) { - for (bin in lib.bin_dependencies) { + for (library in CinteropLibraries.values()) { + val definition: CInteropDefinition = library.getDefinition(platform) + for (bin in definition.bin_dependencies) { val file: File = bin_directory.resolve(bin) if (!file.isFile) { continue } - Files.copy(file.toPath(), target_directory.resolve(bin).toPath(), StandardCopyOption.REPLACE_EXISTING) + file.copyTo(target_directory.resolve(bin), overwrite = true) } } } } -tasks.register("finaliseBuildDebug", FinaliseBuild::class.java) { - val task = tasks.getByName("linkDebugExecutableNative") - binary_output_directory.set(task.outputs.getFiles().single()) - - _cinterop_definitions.set(cinterop_definitions) -} - -tasks.register("finaliseBuildRelease", FinaliseBuild::class.java) { - val task = tasks.getByName("linkReleaseExecutableNative") - binary_output_directory.set(task.outputs.getFiles().single()) - - _cinterop_definitions.set(cinterop_definitions) -} - -tasks.getByName("linkDebugExecutableNative") { - finalizedBy("finaliseBuildDebug") -} - -tasks.getByName("linkReleaseExecutableNative") { - finalizedBy("finaliseBuildRelease") -} - data class CInteropDefinition( + val platform: Platform, val name: String, val lib: String, val headers: List, @@ -387,21 +451,27 @@ data class CInteropDefinition( var compiler_opts: List = emptyList(), var linker_opts: List = emptyList(), var bin_dependencies: List = emptyList(), - var platforms: List = OS.values().toList() + var platforms: List = Platform.supported.toList() ) { - fun writeTo(writer: PrintWriter, static: Boolean) { + fun writeTo(writer: PrintWriter, static: Boolean, project: Project) { writer.writeList("headers", headers.map { formatPlatformInclude(it) }) - var copts: List = getBaseCompilerOpts() + compiler_opts - var lopts: List = getBaseLinkerOpts() + linker_opts + var copts: List = getBaseCompilerOpts(project) + compiler_opts + var lopts: List = getBaseLinkerOpts(project) + linker_opts if (static && static_lib != null) { - writer.writeList("libraryPaths", listOf("src/nativeInterop/lib")) + writer.writeList( + "libraryPaths", + listOfNotNull( + platform.getNativeDependenciesDir(project).resolve("lib").absolutePath, + System.getenv("SPMS_LIB") + ) + ) writer.writeList("staticLibraries", listOf(static_lib!!)) } else { - copts += pkgConfig(formatPlatformLib(lib), cflags = true) - lopts += pkgConfig(formatPlatformLib(lib), libs = true) + copts += pkgConfig(formatPlatformLib(project, lib), cflags = true) + lopts += pkgConfig(formatPlatformLib(project, lib), libs = true) } writer.writeList("compilerOpts", copts) @@ -409,25 +479,27 @@ data class CInteropDefinition( } private fun formatPlatformInclude(path: String): String = - when (OS.target) { + when (platform) { else -> path } - private fun formatPlatformLib(path: String): String = - when (OS.target) { - OS.WINDOWS -> project.file("src/nativeInterop/lib").absolutePath.replace('\\', '/') + '/' + path + private fun formatPlatformLib(project: Project, path: String): String = + when (platform) { + Platform.WINDOWS -> platform.getNativeDependenciesDir(project).resolve("lib").absolutePath.replace('\\', '/') + '/' + path else -> path } - private fun getBaseCompilerOpts(): List = - when (OS.target) { - OS.LINUX_X86, OS.LINUX_ARM64 -> listOf("-I/usr/include", "-I/usr/include/${Arch.target.libdir_name}") + private fun getBaseCompilerOpts(project: Project): List = + when (platform) { + Platform.LINUX_X86, Platform.LINUX_ARM64 -> listOf("-I/usr/include", "-I/usr/include/${platform.arch.libdir_name}") else -> emptyList() - } + listOf("-I" + project.file("src/nativeInterop/include").absolutePath.replace('\\', '/')) + } + listOfNotNull(platform.getNativeDependenciesDir(project).resolve("include"), System.getenv("SPMS_INCLUDE")).map { path -> + "-I" + project.file(path).absolutePath.replace('\\', '/') + } - private fun getBaseLinkerOpts(): List = - when (OS.target) { - OS.LINUX_X86, OS.LINUX_ARM64 -> listOf("-L/usr/lib", "-L/usr/lib/${Arch.target.libdir_name}") + private fun getBaseLinkerOpts(project: Project): List = + when (platform) { + Platform.LINUX_X86, Platform.LINUX_ARM64 -> listOf("-L/usr/lib", "-L/usr/lib/${platform.arch.libdir_name}") else -> emptyList() } @@ -441,45 +513,46 @@ data class CInteropDefinition( print('\n') } } -} -// https://gist.github.com/micolous/c00b14b2dc321fdb0eab8ad796d71b80 -fun pkgConfig( - vararg package_names: String, - cflags: Boolean = false, - libs: Boolean = false -): List { - if (OS.target != OS.LINUX_X86 && OS.target != OS.LINUX_ARM64) { - if (libs) { - return package_names.map { - if (it.startsWith("lib")) "-l" + it.drop(3) - else it + // https://gist.github.com/micolous/c00b14b2dc321fdb0eab8ad796d71b80 + private fun pkgConfig( + vararg package_names: String, + cflags: Boolean = false, + libs: Boolean = false + ): List { + if (platform != Platform.LINUX_X86 && platform != Platform.LINUX_ARM64) { + if (libs) { + // return package_names.map { "-l$it" } + return package_names.map { + if (it.startsWith("lib")) "-l" + it.drop(3) + else it + } } + return emptyList() } - return emptyList() - } - require(cflags || libs) + require(cflags || libs) - val process_builder: ProcessBuilder = ProcessBuilder( - listOfNotNull( - "pkg-config", - if (cflags) "--cflags" else null, - if (libs) "--libs" else null - ) + package_names - ) - process_builder.environment()["PKG_CONFIG_PATH"] = Arch.target.PKG_CONFIG_PATH - process_builder.environment()["PKG_CONFIG_ALLOW_SYSTEM_LIBS"] = "1" + val process_builder: ProcessBuilder = ProcessBuilder( + listOfNotNull( + "pkg-config", + if (cflags) "--cflags" else null, + if (libs) "--libs" else null + ) + package_names + ) + process_builder.environment()["PKG_CONFIG_PATH"] = listOfNotNull(platform.arch.PKG_CONFIG_PATH, System.getenv("SPMS_LIB")?.plus("/pkgconfig")).joinToString(":") + process_builder.environment()["PKG_CONFIG_ALLOW_SYSTEM_LIBS"] = "1" - val process: Process = process_builder.start() - process.waitFor(10, TimeUnit.SECONDS) + val process: Process = process_builder.start() + process.waitFor(10, TimeUnit.SECONDS) - check(process.exitValue() == 0) { - process.errorStream - "pkg-config failed with package_names: ${package_names.toList()}\n" + process.errorStream.bufferedReader().use { it.readText() } - } + check(process.exitValue() == 0) { + process.errorStream + "pkg-config failed with package_names: ${package_names.toList()}\n" + process.errorStream.bufferedReader().use { it.readText() } + } - return process.inputStream.bufferedReader().use { reader -> - reader.readText().split(" ").mapNotNull { it.trim().takeIf { it.isNotBlank() } } + return process.inputStream.bufferedReader().use { reader -> + reader.readText().split(" ").mapNotNull { it.trim().takeIf { it.isNotBlank() } } + } } } diff --git a/src/nativeMain/kotlin/cinterop/indicator/TrayIndicator.kt b/src/commonMain/kotlin/cinterop/indicator/TrayIndicator.kt similarity index 100% rename from src/nativeMain/kotlin/cinterop/indicator/TrayIndicator.kt rename to src/commonMain/kotlin/cinterop/indicator/TrayIndicator.kt diff --git a/src/nativeMain/kotlin/cinterop/indicator/TrayIndicatorImpl.kt.linux b/src/commonMain/kotlin/cinterop/indicator/TrayIndicatorImpl.kt.linux similarity index 100% rename from src/nativeMain/kotlin/cinterop/indicator/TrayIndicatorImpl.kt.linux rename to src/commonMain/kotlin/cinterop/indicator/TrayIndicatorImpl.kt.linux diff --git a/src/nativeMain/kotlin/cinterop/indicator/TrayIndicatorImpl.kt.other b/src/commonMain/kotlin/cinterop/indicator/TrayIndicatorImpl.kt.other similarity index 100% rename from src/nativeMain/kotlin/cinterop/indicator/TrayIndicatorImpl.kt.other rename to src/commonMain/kotlin/cinterop/indicator/TrayIndicatorImpl.kt.other diff --git a/src/nativeMain/kotlin/cinterop/mpv/LibMpvClient.kt b/src/commonMain/kotlin/cinterop/mpv/LibMpvClient.kt similarity index 100% rename from src/nativeMain/kotlin/cinterop/mpv/LibMpvClient.kt rename to src/commonMain/kotlin/cinterop/mpv/LibMpvClient.kt diff --git a/src/nativeMain/kotlin/cinterop/mpv/MpvClientImpl.kt b/src/commonMain/kotlin/cinterop/mpv/MpvClientImpl.kt similarity index 100% rename from src/nativeMain/kotlin/cinterop/mpv/MpvClientImpl.kt rename to src/commonMain/kotlin/cinterop/mpv/MpvClientImpl.kt diff --git a/src/nativeMain/kotlin/cinterop/mpv/MpvCommandInterface.kt b/src/commonMain/kotlin/cinterop/mpv/MpvCommandInterface.kt similarity index 100% rename from src/nativeMain/kotlin/cinterop/mpv/MpvCommandInterface.kt rename to src/commonMain/kotlin/cinterop/mpv/MpvCommandInterface.kt diff --git a/src/nativeMain/kotlin/cinterop/zmq/ZmqRouter.kt b/src/commonMain/kotlin/cinterop/zmq/ZmqRouter.kt similarity index 100% rename from src/nativeMain/kotlin/cinterop/zmq/ZmqRouter.kt rename to src/commonMain/kotlin/cinterop/zmq/ZmqRouter.kt diff --git a/src/nativeMain/kotlin/cinterop/zmq/ZmqSocket.kt b/src/commonMain/kotlin/cinterop/zmq/ZmqSocket.kt similarity index 100% rename from src/nativeMain/kotlin/cinterop/zmq/ZmqSocket.kt rename to src/commonMain/kotlin/cinterop/zmq/ZmqSocket.kt diff --git a/src/nativeMain/kotlin/main.kt b/src/commonMain/kotlin/main.kt similarity index 100% rename from src/nativeMain/kotlin/main.kt rename to src/commonMain/kotlin/main.kt diff --git a/src/nativeMain/kotlin/spms/Command.kt b/src/commonMain/kotlin/spms/Command.kt similarity index 100% rename from src/nativeMain/kotlin/spms/Command.kt rename to src/commonMain/kotlin/spms/Command.kt diff --git a/src/nativeMain/kotlin/spms/Platform.kt.linux b/src/commonMain/kotlin/spms/Platform.kt.linux similarity index 100% rename from src/nativeMain/kotlin/spms/Platform.kt.linux rename to src/commonMain/kotlin/spms/Platform.kt.linux diff --git a/src/nativeMain/kotlin/spms/Platform.kt.other b/src/commonMain/kotlin/spms/Platform.kt.other similarity index 100% rename from src/nativeMain/kotlin/spms/Platform.kt.other rename to src/commonMain/kotlin/spms/Platform.kt.other diff --git a/src/nativeMain/kotlin/spms/client/ClientOptions.kt b/src/commonMain/kotlin/spms/client/ClientOptions.kt similarity index 100% rename from src/nativeMain/kotlin/spms/client/ClientOptions.kt rename to src/commonMain/kotlin/spms/client/ClientOptions.kt diff --git a/src/nativeMain/kotlin/spms/client/cli/CommandLineClient.kt b/src/commonMain/kotlin/spms/client/cli/CommandLineClient.kt similarity index 100% rename from src/nativeMain/kotlin/spms/client/cli/CommandLineClient.kt rename to src/commonMain/kotlin/spms/client/cli/CommandLineClient.kt diff --git a/src/nativeMain/kotlin/spms/client/cli/CommandLineClientMode.kt b/src/commonMain/kotlin/spms/client/cli/CommandLineClientMode.kt similarity index 100% rename from src/nativeMain/kotlin/spms/client/cli/CommandLineClientMode.kt rename to src/commonMain/kotlin/spms/client/cli/CommandLineClientMode.kt diff --git a/src/nativeMain/kotlin/spms/client/cli/CommandLineModeContext.kt b/src/commonMain/kotlin/spms/client/cli/CommandLineModeContext.kt similarity index 100% rename from src/nativeMain/kotlin/spms/client/cli/CommandLineModeContext.kt rename to src/commonMain/kotlin/spms/client/cli/CommandLineModeContext.kt diff --git a/src/nativeMain/kotlin/spms/client/cli/modes/Interactive.kt b/src/commonMain/kotlin/spms/client/cli/modes/Interactive.kt similarity index 100% rename from src/nativeMain/kotlin/spms/client/cli/modes/Interactive.kt rename to src/commonMain/kotlin/spms/client/cli/modes/Interactive.kt diff --git a/src/nativeMain/kotlin/spms/client/cli/modes/Poll.kt b/src/commonMain/kotlin/spms/client/cli/modes/Poll.kt similarity index 100% rename from src/nativeMain/kotlin/spms/client/cli/modes/Poll.kt rename to src/commonMain/kotlin/spms/client/cli/modes/Poll.kt diff --git a/src/nativeMain/kotlin/spms/client/cli/modes/Run.kt b/src/commonMain/kotlin/spms/client/cli/modes/Run.kt similarity index 100% rename from src/nativeMain/kotlin/spms/client/cli/modes/Run.kt rename to src/commonMain/kotlin/spms/client/cli/modes/Run.kt diff --git a/src/nativeMain/kotlin/spms/client/player/PlayerClient.kt b/src/commonMain/kotlin/spms/client/player/PlayerClient.kt similarity index 100% rename from src/nativeMain/kotlin/spms/client/player/PlayerClient.kt rename to src/commonMain/kotlin/spms/client/player/PlayerClient.kt diff --git a/src/nativeMain/kotlin/spms/localisation/Language.kt b/src/commonMain/kotlin/spms/localisation/Language.kt similarity index 100% rename from src/nativeMain/kotlin/spms/localisation/Language.kt rename to src/commonMain/kotlin/spms/localisation/Language.kt diff --git a/src/nativeMain/kotlin/spms/localisation/SpMsLocalisation.kt b/src/commonMain/kotlin/spms/localisation/SpMsLocalisation.kt similarity index 100% rename from src/nativeMain/kotlin/spms/localisation/SpMsLocalisation.kt rename to src/commonMain/kotlin/spms/localisation/SpMsLocalisation.kt diff --git a/src/nativeMain/kotlin/spms/localisation/strings/CliLocalisation.kt b/src/commonMain/kotlin/spms/localisation/strings/CliLocalisation.kt similarity index 100% rename from src/nativeMain/kotlin/spms/localisation/strings/CliLocalisation.kt rename to src/commonMain/kotlin/spms/localisation/strings/CliLocalisation.kt diff --git a/src/nativeMain/kotlin/spms/localisation/strings/CliLocalisationEn.kt b/src/commonMain/kotlin/spms/localisation/strings/CliLocalisationEn.kt similarity index 100% rename from src/nativeMain/kotlin/spms/localisation/strings/CliLocalisationEn.kt rename to src/commonMain/kotlin/spms/localisation/strings/CliLocalisationEn.kt diff --git a/src/nativeMain/kotlin/spms/localisation/strings/CliLocalisationJa.kt b/src/commonMain/kotlin/spms/localisation/strings/CliLocalisationJa.kt similarity index 100% rename from src/nativeMain/kotlin/spms/localisation/strings/CliLocalisationJa.kt rename to src/commonMain/kotlin/spms/localisation/strings/CliLocalisationJa.kt diff --git a/src/nativeMain/kotlin/spms/localisation/strings/LocalisationEn.kt b/src/commonMain/kotlin/spms/localisation/strings/LocalisationEn.kt similarity index 100% rename from src/nativeMain/kotlin/spms/localisation/strings/LocalisationEn.kt rename to src/commonMain/kotlin/spms/localisation/strings/LocalisationEn.kt diff --git a/src/nativeMain/kotlin/spms/localisation/strings/LocalisationJa.kt b/src/commonMain/kotlin/spms/localisation/strings/LocalisationJa.kt similarity index 100% rename from src/nativeMain/kotlin/spms/localisation/strings/LocalisationJa.kt rename to src/commonMain/kotlin/spms/localisation/strings/LocalisationJa.kt diff --git a/src/nativeMain/kotlin/spms/localisation/strings/PlayerActionLocalisation.kt b/src/commonMain/kotlin/spms/localisation/strings/PlayerActionLocalisation.kt similarity index 100% rename from src/nativeMain/kotlin/spms/localisation/strings/PlayerActionLocalisation.kt rename to src/commonMain/kotlin/spms/localisation/strings/PlayerActionLocalisation.kt diff --git a/src/nativeMain/kotlin/spms/localisation/strings/PlayerActionLocalisationEn.kt b/src/commonMain/kotlin/spms/localisation/strings/PlayerActionLocalisationEn.kt similarity index 100% rename from src/nativeMain/kotlin/spms/localisation/strings/PlayerActionLocalisationEn.kt rename to src/commonMain/kotlin/spms/localisation/strings/PlayerActionLocalisationEn.kt diff --git a/src/nativeMain/kotlin/spms/localisation/strings/PlayerActionLocalisationJa.kt b/src/commonMain/kotlin/spms/localisation/strings/PlayerActionLocalisationJa.kt similarity index 100% rename from src/nativeMain/kotlin/spms/localisation/strings/PlayerActionLocalisationJa.kt rename to src/commonMain/kotlin/spms/localisation/strings/PlayerActionLocalisationJa.kt diff --git a/src/nativeMain/kotlin/spms/localisation/strings/ServerActionLocalisation.kt b/src/commonMain/kotlin/spms/localisation/strings/ServerActionLocalisation.kt similarity index 100% rename from src/nativeMain/kotlin/spms/localisation/strings/ServerActionLocalisation.kt rename to src/commonMain/kotlin/spms/localisation/strings/ServerActionLocalisation.kt diff --git a/src/nativeMain/kotlin/spms/localisation/strings/ServerActionLocalisationEn.kt b/src/commonMain/kotlin/spms/localisation/strings/ServerActionLocalisationEn.kt similarity index 100% rename from src/nativeMain/kotlin/spms/localisation/strings/ServerActionLocalisationEn.kt rename to src/commonMain/kotlin/spms/localisation/strings/ServerActionLocalisationEn.kt diff --git a/src/nativeMain/kotlin/spms/localisation/strings/ServerActionLocalisationJa.kt b/src/commonMain/kotlin/spms/localisation/strings/ServerActionLocalisationJa.kt similarity index 100% rename from src/nativeMain/kotlin/spms/localisation/strings/ServerActionLocalisationJa.kt rename to src/commonMain/kotlin/spms/localisation/strings/ServerActionLocalisationJa.kt diff --git a/src/nativeMain/kotlin/spms/localisation/strings/ServerLocalisation.kt b/src/commonMain/kotlin/spms/localisation/strings/ServerLocalisation.kt similarity index 100% rename from src/nativeMain/kotlin/spms/localisation/strings/ServerLocalisation.kt rename to src/commonMain/kotlin/spms/localisation/strings/ServerLocalisation.kt diff --git a/src/nativeMain/kotlin/spms/localisation/strings/ServerLocalisationEn.kt b/src/commonMain/kotlin/spms/localisation/strings/ServerLocalisationEn.kt similarity index 100% rename from src/nativeMain/kotlin/spms/localisation/strings/ServerLocalisationEn.kt rename to src/commonMain/kotlin/spms/localisation/strings/ServerLocalisationEn.kt diff --git a/src/nativeMain/kotlin/spms/localisation/strings/ServerLocalisationJa.kt b/src/commonMain/kotlin/spms/localisation/strings/ServerLocalisationJa.kt similarity index 100% rename from src/nativeMain/kotlin/spms/localisation/strings/ServerLocalisationJa.kt rename to src/commonMain/kotlin/spms/localisation/strings/ServerLocalisationJa.kt diff --git a/src/nativeMain/kotlin/spms/player/HeadlessPlayer.kt b/src/commonMain/kotlin/spms/player/HeadlessPlayer.kt similarity index 100% rename from src/nativeMain/kotlin/spms/player/HeadlessPlayer.kt rename to src/commonMain/kotlin/spms/player/HeadlessPlayer.kt diff --git a/src/nativeMain/kotlin/spms/player/Player.kt b/src/commonMain/kotlin/spms/player/Player.kt similarity index 100% rename from src/nativeMain/kotlin/spms/player/Player.kt rename to src/commonMain/kotlin/spms/player/Player.kt diff --git a/src/nativeMain/kotlin/spms/player/VideoInfoProvider.kt b/src/commonMain/kotlin/spms/player/VideoInfoProvider.kt similarity index 95% rename from src/nativeMain/kotlin/spms/player/VideoInfoProvider.kt rename to src/commonMain/kotlin/spms/player/VideoInfoProvider.kt index 5b2b11c..745a42a 100644 --- a/src/nativeMain/kotlin/spms/player/VideoInfoProvider.kt +++ b/src/commonMain/kotlin/spms/player/VideoInfoProvider.kt @@ -31,12 +31,12 @@ private data class YoutubeFormatsResponse( data class PlayabilityStatus(val status: String) } -fun writeCallback(ptr: CPointer, size: ULong, nmemb: ULong, data: COpaquePointer): Int { +private fun writeCallback(ptr: CPointer, size: ULong, nmemb: ULong, data: COpaquePointer): Int { val writer: ByteArrayWriter = data.asStableRef().get() return writer.fromPtr(ptr, nmemb.toInt()) } -fun readCallback(buffer: CPointer, size: ULong, n_items: ULong, data: COpaquePointer): Int { +private fun readCallback(buffer: CPointer, size: ULong, n_items: ULong, data: COpaquePointer): Int { val reader: ByteArrayReader = data.asStableRef().get() return reader.toBuffer(buffer, n_items.toInt()) } @@ -150,7 +150,7 @@ object VideoInfoProvider { writer_ref.dispose() } if (result != CURLE_OK) { - throw RuntimeException("getVideoStreamUrl for $video_id with ${account_headers?.size ?: 0} account headers failed ($result)") + throw RuntimeException("getVideoStreamUrl for $video_id with ${account_headers?.size ?: 0} account headers failed (${curl_easy_strerror(result)?.toKString() ?: result})") } val body: String = writer.decodeToString() diff --git a/src/nativeMain/kotlin/spms/server/SpMs.kt b/src/commonMain/kotlin/spms/server/SpMs.kt similarity index 100% rename from src/nativeMain/kotlin/spms/server/SpMs.kt rename to src/commonMain/kotlin/spms/server/SpMs.kt diff --git a/src/nativeMain/kotlin/spms/server/SpMsClient.kt b/src/commonMain/kotlin/spms/server/SpMsClient.kt similarity index 100% rename from src/nativeMain/kotlin/spms/server/SpMsClient.kt rename to src/commonMain/kotlin/spms/server/SpMsClient.kt diff --git a/src/nativeMain/kotlin/spms/server/SpMsCommand.kt b/src/commonMain/kotlin/spms/server/SpMsCommand.kt similarity index 100% rename from src/nativeMain/kotlin/spms/server/SpMsCommand.kt rename to src/commonMain/kotlin/spms/server/SpMsCommand.kt diff --git a/src/nativeMain/kotlin/spms/socketapi/Action.kt b/src/commonMain/kotlin/spms/socketapi/Action.kt similarity index 100% rename from src/nativeMain/kotlin/spms/socketapi/Action.kt rename to src/commonMain/kotlin/spms/socketapi/Action.kt diff --git a/src/nativeMain/kotlin/spms/socketapi/ParseMessage.kt b/src/commonMain/kotlin/spms/socketapi/ParseMessage.kt similarity index 100% rename from src/nativeMain/kotlin/spms/socketapi/ParseMessage.kt rename to src/commonMain/kotlin/spms/socketapi/ParseMessage.kt diff --git a/src/nativeMain/kotlin/spms/socketapi/player/PlayerAction.kt b/src/commonMain/kotlin/spms/socketapi/player/PlayerAction.kt similarity index 100% rename from src/nativeMain/kotlin/spms/socketapi/player/PlayerAction.kt rename to src/commonMain/kotlin/spms/socketapi/player/PlayerAction.kt diff --git a/src/nativeMain/kotlin/spms/socketapi/player/PlayerActionAddLocalFiles.kt b/src/commonMain/kotlin/spms/socketapi/player/PlayerActionAddLocalFiles.kt similarity index 100% rename from src/nativeMain/kotlin/spms/socketapi/player/PlayerActionAddLocalFiles.kt rename to src/commonMain/kotlin/spms/socketapi/player/PlayerActionAddLocalFiles.kt diff --git a/src/nativeMain/kotlin/spms/socketapi/player/PlayerActionRemoveLocalFiles.kt b/src/commonMain/kotlin/spms/socketapi/player/PlayerActionRemoveLocalFiles.kt similarity index 100% rename from src/nativeMain/kotlin/spms/socketapi/player/PlayerActionRemoveLocalFiles.kt rename to src/commonMain/kotlin/spms/socketapi/player/PlayerActionRemoveLocalFiles.kt diff --git a/src/nativeMain/kotlin/spms/socketapi/player/PlayerActionSetAuthInfo.kt b/src/commonMain/kotlin/spms/socketapi/player/PlayerActionSetAuthInfo.kt similarity index 100% rename from src/nativeMain/kotlin/spms/socketapi/player/PlayerActionSetAuthInfo.kt rename to src/commonMain/kotlin/spms/socketapi/player/PlayerActionSetAuthInfo.kt diff --git a/src/nativeMain/kotlin/spms/socketapi/player/PlayerActionSetLocalFiles.kt b/src/commonMain/kotlin/spms/socketapi/player/PlayerActionSetLocalFiles.kt similarity index 100% rename from src/nativeMain/kotlin/spms/socketapi/player/PlayerActionSetLocalFiles.kt rename to src/commonMain/kotlin/spms/socketapi/player/PlayerActionSetLocalFiles.kt diff --git a/src/nativeMain/kotlin/spms/socketapi/server/ServerAction.kt b/src/commonMain/kotlin/spms/socketapi/server/ServerAction.kt similarity index 100% rename from src/nativeMain/kotlin/spms/socketapi/server/ServerAction.kt rename to src/commonMain/kotlin/spms/socketapi/server/ServerAction.kt diff --git a/src/nativeMain/kotlin/spms/socketapi/server/ServerActionAddItem.kt b/src/commonMain/kotlin/spms/socketapi/server/ServerActionAddItem.kt similarity index 100% rename from src/nativeMain/kotlin/spms/socketapi/server/ServerActionAddItem.kt rename to src/commonMain/kotlin/spms/socketapi/server/ServerActionAddItem.kt diff --git a/src/nativeMain/kotlin/spms/socketapi/server/ServerActionClearQueue.kt b/src/commonMain/kotlin/spms/socketapi/server/ServerActionClearQueue.kt similarity index 100% rename from src/nativeMain/kotlin/spms/socketapi/server/ServerActionClearQueue.kt rename to src/commonMain/kotlin/spms/socketapi/server/ServerActionClearQueue.kt diff --git a/src/nativeMain/kotlin/spms/socketapi/server/ServerActionGetClients.kt b/src/commonMain/kotlin/spms/socketapi/server/ServerActionGetClients.kt similarity index 100% rename from src/nativeMain/kotlin/spms/socketapi/server/ServerActionGetClients.kt rename to src/commonMain/kotlin/spms/socketapi/server/ServerActionGetClients.kt diff --git a/src/nativeMain/kotlin/spms/socketapi/server/ServerActionGetProperty.kt b/src/commonMain/kotlin/spms/socketapi/server/ServerActionGetProperty.kt similarity index 100% rename from src/nativeMain/kotlin/spms/socketapi/server/ServerActionGetProperty.kt rename to src/commonMain/kotlin/spms/socketapi/server/ServerActionGetProperty.kt diff --git a/src/nativeMain/kotlin/spms/socketapi/server/ServerActionGetStatus.kt b/src/commonMain/kotlin/spms/socketapi/server/ServerActionGetStatus.kt similarity index 100% rename from src/nativeMain/kotlin/spms/socketapi/server/ServerActionGetStatus.kt rename to src/commonMain/kotlin/spms/socketapi/server/ServerActionGetStatus.kt diff --git a/src/nativeMain/kotlin/spms/socketapi/server/ServerActionMoveItem.kt b/src/commonMain/kotlin/spms/socketapi/server/ServerActionMoveItem.kt similarity index 100% rename from src/nativeMain/kotlin/spms/socketapi/server/ServerActionMoveItem.kt rename to src/commonMain/kotlin/spms/socketapi/server/ServerActionMoveItem.kt diff --git a/src/nativeMain/kotlin/spms/socketapi/server/ServerActionPause.kt b/src/commonMain/kotlin/spms/socketapi/server/ServerActionPause.kt similarity index 100% rename from src/nativeMain/kotlin/spms/socketapi/server/ServerActionPause.kt rename to src/commonMain/kotlin/spms/socketapi/server/ServerActionPause.kt diff --git a/src/nativeMain/kotlin/spms/socketapi/server/ServerActionPlay.kt b/src/commonMain/kotlin/spms/socketapi/server/ServerActionPlay.kt similarity index 100% rename from src/nativeMain/kotlin/spms/socketapi/server/ServerActionPlay.kt rename to src/commonMain/kotlin/spms/socketapi/server/ServerActionPlay.kt diff --git a/src/nativeMain/kotlin/spms/socketapi/server/ServerActionPlayPause.kt b/src/commonMain/kotlin/spms/socketapi/server/ServerActionPlayPause.kt similarity index 100% rename from src/nativeMain/kotlin/spms/socketapi/server/ServerActionPlayPause.kt rename to src/commonMain/kotlin/spms/socketapi/server/ServerActionPlayPause.kt diff --git a/src/nativeMain/kotlin/spms/socketapi/server/ServerActionReadyToPlay.kt b/src/commonMain/kotlin/spms/socketapi/server/ServerActionReadyToPlay.kt similarity index 100% rename from src/nativeMain/kotlin/spms/socketapi/server/ServerActionReadyToPlay.kt rename to src/commonMain/kotlin/spms/socketapi/server/ServerActionReadyToPlay.kt diff --git a/src/nativeMain/kotlin/spms/socketapi/server/ServerActionRemoveItem.kt b/src/commonMain/kotlin/spms/socketapi/server/ServerActionRemoveItem.kt similarity index 100% rename from src/nativeMain/kotlin/spms/socketapi/server/ServerActionRemoveItem.kt rename to src/commonMain/kotlin/spms/socketapi/server/ServerActionRemoveItem.kt diff --git a/src/nativeMain/kotlin/spms/socketapi/server/ServerActionSeekToItem.kt b/src/commonMain/kotlin/spms/socketapi/server/ServerActionSeekToItem.kt similarity index 100% rename from src/nativeMain/kotlin/spms/socketapi/server/ServerActionSeekToItem.kt rename to src/commonMain/kotlin/spms/socketapi/server/ServerActionSeekToItem.kt diff --git a/src/nativeMain/kotlin/spms/socketapi/server/ServerActionSeekToNext.kt b/src/commonMain/kotlin/spms/socketapi/server/ServerActionSeekToNext.kt similarity index 100% rename from src/nativeMain/kotlin/spms/socketapi/server/ServerActionSeekToNext.kt rename to src/commonMain/kotlin/spms/socketapi/server/ServerActionSeekToNext.kt diff --git a/src/nativeMain/kotlin/spms/socketapi/server/ServerActionSeekToPrevious.kt b/src/commonMain/kotlin/spms/socketapi/server/ServerActionSeekToPrevious.kt similarity index 100% rename from src/nativeMain/kotlin/spms/socketapi/server/ServerActionSeekToPrevious.kt rename to src/commonMain/kotlin/spms/socketapi/server/ServerActionSeekToPrevious.kt diff --git a/src/nativeMain/kotlin/spms/socketapi/server/ServerActionSeekToTime.kt b/src/commonMain/kotlin/spms/socketapi/server/ServerActionSeekToTime.kt similarity index 100% rename from src/nativeMain/kotlin/spms/socketapi/server/ServerActionSeekToTime.kt rename to src/commonMain/kotlin/spms/socketapi/server/ServerActionSeekToTime.kt diff --git a/src/nativeMain/kotlin/spms/socketapi/server/ServerActionSetVolume.kt b/src/commonMain/kotlin/spms/socketapi/server/ServerActionSetVolume.kt similarity index 100% rename from src/nativeMain/kotlin/spms/socketapi/server/ServerActionSetVolume.kt rename to src/commonMain/kotlin/spms/socketapi/server/ServerActionSetVolume.kt diff --git a/src/nativeMain/kotlin/spms/socketapi/shared/SpMsActionReply.kt b/src/commonMain/kotlin/spms/socketapi/shared/SpMsActionReply.kt similarity index 100% rename from src/nativeMain/kotlin/spms/socketapi/shared/SpMsActionReply.kt rename to src/commonMain/kotlin/spms/socketapi/shared/SpMsActionReply.kt diff --git a/src/nativeMain/kotlin/spms/socketapi/shared/SpMsClientData.kt b/src/commonMain/kotlin/spms/socketapi/shared/SpMsClientData.kt similarity index 100% rename from src/nativeMain/kotlin/spms/socketapi/shared/SpMsClientData.kt rename to src/commonMain/kotlin/spms/socketapi/shared/SpMsClientData.kt diff --git a/src/nativeMain/kotlin/spms/socketapi/shared/SpMsPlayerEvent.kt b/src/commonMain/kotlin/spms/socketapi/shared/SpMsPlayerEvent.kt similarity index 100% rename from src/nativeMain/kotlin/spms/socketapi/shared/SpMsPlayerEvent.kt rename to src/commonMain/kotlin/spms/socketapi/shared/SpMsPlayerEvent.kt diff --git a/src/nativeMain/kotlin/spms/socketapi/shared/SpMsSocketApi.kt b/src/commonMain/kotlin/spms/socketapi/shared/SpMsSocketApi.kt similarity index 100% rename from src/nativeMain/kotlin/spms/socketapi/shared/SpMsSocketApi.kt rename to src/commonMain/kotlin/spms/socketapi/shared/SpMsSocketApi.kt