diff --git a/.github/workflows/build.yml b/.github/workflows/build-kotlin.yml similarity index 92% rename from .github/workflows/build.yml rename to .github/workflows/build-kotlin.yml index cb526f2..02fe0e8 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build-kotlin.yml @@ -1,4 +1,4 @@ -name: Build +name: Build (stremio-core-kotlin) on: push: @@ -41,7 +41,7 @@ jobs: uses: Swatinem/rust-cache@v2 - name: Build code - run: cargo build -p stremio-core-android + run: cargo build -p stremio-core-kotlin - name: Lint code format run: cargo fmt --all -- --check diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 9667bb1..8c889e3 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -1,4 +1,4 @@ -name: Release stremio-core-android +name: Release stremio-core-kotlin on: release: @@ -43,16 +43,19 @@ jobs: - uses: Swatinem/rust-cache@v2 - name: Build aar + working-directory: stremio-core-kotlin run: ./gradlew -Pversion=${GITHUB_REF##*/} publishToMavenLocal - name: Archive artifacts + working-directory: stremio-core-kotlin run: tar -C ~/.m2/repository/com/github/Stremio -cvzf stremio-core-kotlin.tar.gz . - name: Archive build + working-directory: stremio-core-kotlin run: tar -C build -cvzf build.tar.gz publications - name: Upload build artifacts uses: svenstaro/upload-release-action@v2 with: repo_token: ${{ secrets.GITHUB_TOKEN }} - file: "*.tar.gz" + file: "stremio-core-kotlin/*.tar.gz" tag: ${{ github.ref }} overwrite: true file_glob: true diff --git a/.gitignore b/.gitignore index c4e793f..9f4fce0 100644 --- a/.gitignore +++ b/.gitignore @@ -1,8 +1,8 @@ -/build -/target -/.gradle -/src/debug -/src/release +**/build +**/target +**/.gradle +**/src/debug +**/src/release /.idea/ /local.properties diff --git a/Cargo.lock b/Cargo.lock index 40aeefb..a95c827 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2438,7 +2438,7 @@ dependencies = [ ] [[package]] -name = "stremio-core-android" +name = "stremio-core-kotlin" version = "1.2.6" dependencies = [ "Inflector", diff --git a/Cargo.toml b/Cargo.toml index 8273e51..5170230 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,33 +1,6 @@ -[package] -name = "stremio-core-android" -version = "1.2.6" -authors = ["Smart Code OOD"] -edition = "2021" - -rust-version = "1.70.0" - -[features] -default = ["kotlin"] -kotlin = [ - # for fetch (making requests): - "dep:http", - "dep:reqwest", - "dep:openssl", - "dep:http-cache-reqwest", - "dep:reqwest-middleware", - # executors - "dep:tokio", - # java bindings - "dep:jni", - "dep:getrandom", -] - -[lib] -path = "src/commonMain/rust/lib.rs" - [workspace] resolver = "2" -members = ["stremio-core-protobuf"] +members = ["stremio-core-kotlin", "stremio-core-protobuf"] [workspace.dependencies] stremio-core = { version = "0.1", git = "https://github.com/Stremio/stremio-core", branch = "development", features = [ @@ -73,63 +46,3 @@ futures = "0.3" [profile.release] lto = true opt-level = 3 - -[dependencies] -stremio-core.workspace = true -# stremio-core-web.workspace = true -stremio-core-protobuf.workspace = true - -serde.workspace = true -serde_json.workspace = true -serde_path_to_error.workspace = true - -strum = { version = "0.22.*", features = ["derive"] } - -# Utils -once_cell.workspace = true -semver = { version = "1", features = ["serde"] } -enclose = "1.1.*" -itertools.workspace = true -chrono.workspace = true -boolinator = "2.4.*" -Inflector = "0.11.*" -cfg-if = "0.1.*" -auto_impl = "0.5.*" - -base64 = "0.13.*" -hex.workspace = true -flate2 = "1.0.*" -url = { version = "2.4", features = ["serde"] } -percent-encoding = "2.1" - -# kotlin specific + Env impl -getrandom = { workspace = true, optional = true } - -jni = { version = "0.19.*", optional = true } - -# Async executor -tokio = { version = "1", features = ["rt", "rt-multi-thread"], optional = true } -# Futures -futures.workspace = true - -# Http Request handling -http = { workspace = true, optional = true } -reqwest = { workspace = true, features = ["json", "rustls-tls"], optional = true } -openssl = { workspace = true, features = ["vendored"], optional = true } -http-cache-reqwest = { workspace = true, optional = true } -reqwest-middleware = { workspace = true, optional = true } - -# Bytes / Protobuf -bytes = "1.1.0" -prost.workspace = true -prost-types.workspace = true - -[build-dependencies] -prost-build.workspace = true -protox.workspace = true -glob.workspace = true - -# A way to quickly test with local version of `core` crates -# [patch.'https://github.com/Stremio/stremio-core'] -# stremio-core = { path = "../core" } -# stremio-core-web = { path = "../core/stremio-core-web" } diff --git a/src/commonMain/rust/model.rs b/src/commonMain/rust/model.rs deleted file mode 100644 index 95bd5f6..0000000 --- a/src/commonMain/rust/model.rs +++ /dev/null @@ -1,7 +0,0 @@ -#[cfg(feature = "kotlin")] -pub use model::*; - -#[cfg(feature = "kotlin")] -// model is only available when the feature is enabled -// because of the `AndroidEnv` impl -mod model; diff --git a/stremio-core-kotlin/.cargo/config copy.toml b/stremio-core-kotlin/.cargo/config copy.toml new file mode 100644 index 0000000..2a0f2e7 --- /dev/null +++ b/stremio-core-kotlin/.cargo/config copy.toml @@ -0,0 +1,9 @@ +[env] +NDK_VERSION = "27.2.12479018" + +# Set the same RANLIB binary location for all the 4 targets: +# armv7-linux-androideabi, aarch64-linux-android, i686-linux-android, x86_64-linux-android +RANLIB_armv7_linux_androideabi = "$$ANDROID_HOME/ndk/$$NDK_VERSION/toolchains/llvm/prebuilt/linux-x86_64/bin/llvm-ranlib" +RANLIB_aarch64_linux_android = "$$ANDROID_HOME/ndk/$$NDK_VERSION/toolchains/llvm/prebuilt/linux-x86_64/bin/llvm-ranlib" +RANLIB_i686_linux_android = "$$ANDROID_HOME/ndk/$$NDK_VERSION/toolchains/llvm/prebuilt/linux-x86_64/bin/llvm-ranlib" +RANLIB_x86_64_linux_android = "$$ANDROID_HOME/ndk/$$NDK_VERSION/toolchains/llvm/prebuilt/linux-x86_64/bin/llvm-ranlib" \ No newline at end of file diff --git a/.cargo/config.toml b/stremio-core-kotlin/.cargo/config.toml similarity index 100% rename from .cargo/config.toml rename to stremio-core-kotlin/.cargo/config.toml diff --git a/stremio-core-kotlin/Cargo.toml b/stremio-core-kotlin/Cargo.toml new file mode 100644 index 0000000..6a17fae --- /dev/null +++ b/stremio-core-kotlin/Cargo.toml @@ -0,0 +1,88 @@ +[package] +name = "stremio-core-kotlin" +version = "1.2.6" +authors = ["Smart Code OOD"] +edition = "2021" + +rust-version = "1.70.0" + +[features] +default = ["kotlin"] +kotlin = [ + # for fetch (making requests): + "dep:http", + "dep:reqwest", + "dep:openssl", + "dep:http-cache-reqwest", + "dep:reqwest-middleware", + # executors + "dep:tokio", + # java bindings + "dep:jni", + "dep:getrandom", +] + +[lib] +name = "stremio_core_kotlin" +path = "src/commonMain/rust/lib.rs" +crate-type = ["staticlib", "dylib"] + +[dependencies] +stremio-core.workspace = true +# stremio-core-web.workspace = true +stremio-core-protobuf.workspace = true + +serde.workspace = true +serde_json.workspace = true +serde_path_to_error.workspace = true + +strum = { version = "0.22.*", features = ["derive"] } + +# Utils +once_cell.workspace = true +semver = { version = "1", features = ["serde"] } +enclose = "1.1.*" +itertools.workspace = true +chrono.workspace = true +boolinator = "2.4.*" +Inflector = "0.11.*" +cfg-if = "0.1.*" +auto_impl = "0.5.*" + +base64 = "0.13.*" +hex.workspace = true +flate2 = "1.0.*" +url = { version = "2.4", features = ["serde"] } +percent-encoding = "2.1" + +# kotlin specific + Env impl +getrandom = { workspace = true, optional = true } + +jni = { version = "0.19.*", optional = true } + +# Async executor +tokio = { version = "1", features = ["rt", "rt-multi-thread"], optional = true } +# Futures +futures.workspace = true + +# Http Request handling +http = { workspace = true, optional = true } +reqwest = { workspace = true, features = ["json", "rustls-tls"], optional = true } +openssl = { workspace = true, features = ["vendored"], optional = true } +http-cache-reqwest = { workspace = true, optional = true } +reqwest-middleware = { workspace = true, optional = true } + +# Bytes / Protobuf +bytes = "1.1.0" +prost.workspace = true +prost-types.workspace = true + +[build-dependencies] +prost-build.workspace = true +protox.workspace = true +glob.workspace = true + +# A way to quickly test with local version of `core` crates +# [patch.'https://github.com/Stremio/stremio-core'] +# stremio-core = { path = "../core" } +# stremio-core-web = { path = "../core/stremio-core-web" } diff --git a/LICENSE.md b/stremio-core-kotlin/LICENSE.md similarity index 100% rename from LICENSE.md rename to stremio-core-kotlin/LICENSE.md diff --git a/README.md b/stremio-core-kotlin/README.md similarity index 100% rename from README.md rename to stremio-core-kotlin/README.md diff --git a/build.gradle.kts b/stremio-core-kotlin/build.gradle.kts similarity index 96% rename from build.gradle.kts rename to stremio-core-kotlin/build.gradle.kts index 14f67d6..40ac46f 100644 --- a/build.gradle.kts +++ b/stremio-core-kotlin/build.gradle.kts @@ -88,7 +88,7 @@ android { sourceSets { getByName("main") { proto { - srcDirs("stremio-core-protobuf/proto") + srcDirs("../stremio-core-protobuf/proto") } manifest.srcFile("src/androidMain/AndroidManifest.xml") } @@ -125,7 +125,8 @@ protobuf { cargo { module = "./" - libname = "stremio_core_android" + libname = "stremio_core_kotlin" + targetDirectory = "../target" targets = listOf("arm", "arm64", "x86", "x86_64") verbose = true profile = stremioCoreAndroidProfile diff --git a/gradle.properties b/stremio-core-kotlin/gradle.properties similarity index 100% rename from gradle.properties rename to stremio-core-kotlin/gradle.properties diff --git a/gradle/wrapper/gradle-wrapper.jar b/stremio-core-kotlin/gradle/wrapper/gradle-wrapper.jar similarity index 100% rename from gradle/wrapper/gradle-wrapper.jar rename to stremio-core-kotlin/gradle/wrapper/gradle-wrapper.jar diff --git a/gradle/wrapper/gradle-wrapper.properties b/stremio-core-kotlin/gradle/wrapper/gradle-wrapper.properties similarity index 100% rename from gradle/wrapper/gradle-wrapper.properties rename to stremio-core-kotlin/gradle/wrapper/gradle-wrapper.properties diff --git a/gradlew b/stremio-core-kotlin/gradlew similarity index 100% rename from gradlew rename to stremio-core-kotlin/gradlew diff --git a/gradlew.bat b/stremio-core-kotlin/gradlew.bat similarity index 100% rename from gradlew.bat rename to stremio-core-kotlin/gradlew.bat diff --git a/settings.gradle.kts b/stremio-core-kotlin/settings.gradle.kts similarity index 100% rename from settings.gradle.kts rename to stremio-core-kotlin/settings.gradle.kts diff --git a/src/androidMain/AndroidManifest.xml b/stremio-core-kotlin/src/androidMain/AndroidManifest.xml similarity index 100% rename from src/androidMain/AndroidManifest.xml rename to stremio-core-kotlin/src/androidMain/AndroidManifest.xml diff --git a/src/androidMain/kotlin/com/stremio/core/Core.kt b/stremio-core-kotlin/src/androidMain/kotlin/com/stremio/core/Core.kt similarity index 97% rename from src/androidMain/kotlin/com/stremio/core/Core.kt rename to stremio-core-kotlin/src/androidMain/kotlin/com/stremio/core/Core.kt index 2a514c8..91863c8 100644 --- a/src/androidMain/kotlin/com/stremio/core/Core.kt +++ b/stremio-core-kotlin/src/androidMain/kotlin/com/stremio/core/Core.kt @@ -15,7 +15,7 @@ import kotlin.reflect.full.companionObjectInstance actual object Core { init { - System.loadLibrary("stremio_core_android") + System.loadLibrary("stremio_core_kotlin") } actual fun interface EventListener { diff --git a/src/androidMain/kotlin/com/stremio/core/DeepLinks.kt b/stremio-core-kotlin/src/androidMain/kotlin/com/stremio/core/DeepLinks.kt similarity index 100% rename from src/androidMain/kotlin/com/stremio/core/DeepLinks.kt rename to stremio-core-kotlin/src/androidMain/kotlin/com/stremio/core/DeepLinks.kt diff --git a/src/commonMain/kotlin/com/stremio/core/Core.kt b/stremio-core-kotlin/src/commonMain/kotlin/com/stremio/core/Core.kt similarity index 100% rename from src/commonMain/kotlin/com/stremio/core/Core.kt rename to stremio-core-kotlin/src/commonMain/kotlin/com/stremio/core/Core.kt diff --git a/src/commonMain/kotlin/com/stremio/core/Storage.kt b/stremio-core-kotlin/src/commonMain/kotlin/com/stremio/core/Storage.kt similarity index 100% rename from src/commonMain/kotlin/com/stremio/core/Storage.kt rename to stremio-core-kotlin/src/commonMain/kotlin/com/stremio/core/Storage.kt diff --git a/src/commonMain/rust/bridge.rs b/stremio-core-kotlin/src/commonMain/rust/bridge.rs similarity index 100% rename from src/commonMain/rust/bridge.rs rename to stremio-core-kotlin/src/commonMain/rust/bridge.rs diff --git a/src/commonMain/rust/bridge/android_model_field.rs b/stremio-core-kotlin/src/commonMain/rust/bridge/android_model_field.rs similarity index 100% rename from src/commonMain/rust/bridge/android_model_field.rs rename to stremio-core-kotlin/src/commonMain/rust/bridge/android_model_field.rs diff --git a/src/commonMain/rust/bridge/to_jni_byte_array.rs b/stremio-core-kotlin/src/commonMain/rust/bridge/to_jni_byte_array.rs similarity index 100% rename from src/commonMain/rust/bridge/to_jni_byte_array.rs rename to stremio-core-kotlin/src/commonMain/rust/bridge/to_jni_byte_array.rs diff --git a/src/commonMain/rust/env/env.rs b/stremio-core-kotlin/src/commonMain/rust/env/env.rs similarity index 100% rename from src/commonMain/rust/env/env.rs rename to stremio-core-kotlin/src/commonMain/rust/env/env.rs diff --git a/src/commonMain/rust/env/event.rs b/stremio-core-kotlin/src/commonMain/rust/env/event.rs similarity index 100% rename from src/commonMain/rust/env/event.rs rename to stremio-core-kotlin/src/commonMain/rust/env/event.rs diff --git a/src/commonMain/rust/env/fetch.rs b/stremio-core-kotlin/src/commonMain/rust/env/fetch.rs similarity index 100% rename from src/commonMain/rust/env/fetch.rs rename to stremio-core-kotlin/src/commonMain/rust/env/fetch.rs diff --git a/src/commonMain/rust/env/kotlin_class_name.rs b/stremio-core-kotlin/src/commonMain/rust/env/kotlin_class_name.rs similarity index 100% rename from src/commonMain/rust/env/kotlin_class_name.rs rename to stremio-core-kotlin/src/commonMain/rust/env/kotlin_class_name.rs diff --git a/src/commonMain/rust/env/storage.rs b/stremio-core-kotlin/src/commonMain/rust/env/storage.rs similarity index 100% rename from src/commonMain/rust/env/storage.rs rename to stremio-core-kotlin/src/commonMain/rust/env/storage.rs diff --git a/src/commonMain/rust/jni_ext.rs b/stremio-core-kotlin/src/commonMain/rust/jni_ext.rs similarity index 100% rename from src/commonMain/rust/jni_ext.rs rename to stremio-core-kotlin/src/commonMain/rust/jni_ext.rs diff --git a/src/commonMain/rust/lib.rs b/stremio-core-kotlin/src/commonMain/rust/lib.rs similarity index 68% rename from src/commonMain/rust/lib.rs rename to stremio-core-kotlin/src/commonMain/rust/lib.rs index 2b1a116..cba989a 100644 --- a/src/commonMain/rust/lib.rs +++ b/stremio-core-kotlin/src/commonMain/rust/lib.rs @@ -2,13 +2,13 @@ #[cfg(feature = "kotlin")] // Re-export the kotlin-specific impls -pub use stremio_core_android::*; +pub use stremio_core_kotlin::*; #[cfg(feature = "kotlin")] pub mod bridge; #[cfg(feature = "kotlin")] -/// Contains all android (kotlin) related implementations for the bridge between +/// Contains all kotlin (for android) related implementations for the bridge between /// Rust and Kotlin. /// /// - [AndroidEnv](crate::env::AndroidEnv) @@ -32,7 +32,15 @@ pub mod env { pub use storage::*; } -pub mod model; +pub mod model { + #[cfg(feature = "kotlin")] + pub use model::*; + + #[cfg(feature = "kotlin")] + // model is only available when the feature is enabled + // because of the `AndroidEnv` impl + mod model; +} #[allow(clippy::all)] /// Protobuf generated module pub mod protobuf { @@ -42,4 +50,4 @@ pub mod protobuf { #[cfg(feature = "kotlin")] pub mod jni_ext; #[cfg(feature = "kotlin")] -mod stremio_core_android; +mod stremio_core_kotlin; diff --git a/src/commonMain/rust/model/model.rs b/stremio-core-kotlin/src/commonMain/rust/model/model.rs similarity index 100% rename from src/commonMain/rust/model/model.rs rename to stremio-core-kotlin/src/commonMain/rust/model/model.rs diff --git a/src/commonMain/rust/stremio_core_android.rs b/stremio-core-kotlin/src/commonMain/rust/stremio_core_kotlin.rs similarity index 100% rename from src/commonMain/rust/stremio_core_android.rs rename to stremio-core-kotlin/src/commonMain/rust/stremio_core_kotlin.rs