diff --git a/Cargo.lock b/Cargo.lock index 302dfd1d8..69d76dafd 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1485,9 +1485,9 @@ dependencies = [ [[package]] name = "fsrs" -version = "1.2.2" +version = "1.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1bbd56ab9e6c5d40802c7f73701b9cc4bccf9fa29037799a94ac9f1a94f1a5f7" +checksum = "2434366942bf285f3c0691e68d731e56f4e1fc1d8ec7b6a0e9411e94eda6ffbd" dependencies = [ "burn", "itertools 0.12.1", diff --git a/build_rust/src/main.rs b/build_rust/src/main.rs index 3fca0498e..0d3c0fe56 100644 --- a/build_rust/src/main.rs +++ b/build_rust/src/main.rs @@ -143,6 +143,7 @@ fn build_android_jni() -> Result<()> { let (is_release, _release_dir) = check_release(false); Command::run("cargo install cargo-ndk@3.5.4")?; + Command::run("cargo install jaq@1.6.0")?; let mut command = Command::new("cargo"); command diff --git a/rsdroid/build.gradle b/rsdroid/build.gradle index 999de539b..5bccb4bae 100644 --- a/rsdroid/build.gradle +++ b/rsdroid/build.gradle @@ -2,6 +2,7 @@ import com.android.build.gradle.tasks.BundleAar import com.vanniktech.maven.publish.SonatypeHost import org.jetbrains.kotlin.gradle.tasks.KotlinCompile import java.util.zip.ZipFile +import org.gradle.internal.os.OperatingSystem apply plugin: 'com.android.library' // required for aar generation to link to from AnkiDroid apply plugin: "kotlin-android" @@ -22,6 +23,30 @@ def getAnkiCommitHash = { -> return commit } +def getFsrsVersion = { -> + def pkgStdout = new ByteArrayOutputStream() + exec { + commandLine "cargo", "metadata", "--format-version=1", "--manifest-path=" + new File("${project.rootDir}", "anki/Cargo.toml"), + "--frozen" + standardOutput = pkgStdout + } + + def verArgs = OperatingSystem.current() == OperatingSystem.WINDOWS ? + ".packages[] | select(.name==\\\"fsrs\\\") | .version" : + ".packages[] | select(.name==\"fsrs\") | .version" + def verStdout = new ByteArrayOutputStream() + def verStdin = new ByteArrayInputStream(pkgStdout.toByteArray()) + exec { + commandLine "jaq", verArgs + standardInput = verStdin + standardOutput = verStdout + } + + def version = verStdout.toString().trim().replace("\"", "") + println("FSRS version: ${version}") + return version +} + def getAnkiDesktopVersion() { Properties properties = new Properties() properties.load(project.rootProject.file('gradle.properties').newDataInputStream()) @@ -61,6 +86,7 @@ android { buildConfigField "String", "ANKI_COMMIT_HASH", "\"${getAnkiCommitHash()}\"" buildConfigField "String", "ANKI_DESKTOP_VERSION", "\"${getAnkiDesktopVersion()}\"" + buildConfigField "String", "FSRS_VERSION", "\"${getFsrsVersion()}\"" buildConfigField "String", "BACKEND_GIT_COMMIT_HASH", "\"${getBackendGitCommitHash()}\"" buildConfigField "long", "BACKEND_BUILD_TIME", System.currentTimeMillis().toString()