Skip to content

Commit

Permalink
Merge pull request #56 from Stremio/chore/move-stremio-core-kotlin-to…
Browse files Browse the repository at this point in the history
…-own-crate

Chore/move stremio core kotlin to own crate
  • Loading branch information
elpiel authored Nov 5, 2024
2 parents 7ca0ae9 + 568dcd5 commit 591f600
Show file tree
Hide file tree
Showing 35 changed files with 127 additions and 112 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Build
name: Build (stremio-core-kotlin)

on:
push:
Expand Down Expand Up @@ -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
Expand Down
7 changes: 5 additions & 2 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Release stremio-core-android
name: Release stremio-core-kotlin

on:
release:
Expand Down Expand Up @@ -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
10 changes: 5 additions & 5 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
/build
/target
/.gradle
/src/debug
/src/release
**/build
**/target
**/.gradle
**/src/debug
**/src/release
/.idea/
/local.properties

Expand Down
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

89 changes: 1 addition & 88 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -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 = [
Expand Down Expand Up @@ -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" }
7 changes: 0 additions & 7 deletions src/commonMain/rust/model.rs

This file was deleted.

9 changes: 9 additions & 0 deletions stremio-core-kotlin/.cargo/config copy.toml
Original file line number Diff line number Diff line change
@@ -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"
File renamed without changes.
88 changes: 88 additions & 0 deletions stremio-core-kotlin/Cargo.toml
Original file line number Diff line number Diff line change
@@ -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" }
File renamed without changes.
File renamed without changes.
5 changes: 3 additions & 2 deletions build.gradle.kts → stremio-core-kotlin/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -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")
}
Expand Down Expand Up @@ -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
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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 {
Expand All @@ -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;
File renamed without changes.
File renamed without changes.

0 comments on commit 591f600

Please sign in to comment.