Skip to content

Commit

Permalink
Add FSRS version to BuildConfig
Browse files Browse the repository at this point in the history
  • Loading branch information
voczi committed Oct 13, 2024
1 parent d68710b commit 07431c0
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 2 deletions.
4 changes: 2 additions & 2 deletions Cargo.lock

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

1 change: 1 addition & 0 deletions build_rust/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,7 @@ fn build_android_jni() -> Result<()> {
let (is_release, _release_dir) = check_release(false);

Command::run("cargo install [email protected]")?;
Command::run("cargo install [email protected]")?;

let mut command = Command::new("cargo");
command
Expand Down
22 changes: 22 additions & 0 deletions rsdroid/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,27 @@ 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")
standardOutput = pkgStdout
}

def verStdout = new ByteArrayOutputStream()
def verStdin = new ByteArrayInputStream(pkgStdout.toByteArray())
exec {
executable = "jaq"
args = [/.packages[] | select(.name==\"fsrs\") | .version/]
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())
Expand Down Expand Up @@ -61,6 +82,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()
Expand Down

0 comments on commit 07431c0

Please sign in to comment.