Add API to get version information#2309
Merged
Merged
Conversation
There was a problem hiding this comment.
Pull Request Overview
This PR adds an API to expose the library’s version, Git SHA1, and Git date across all supported language bindings and example projects.
- Introduces
GetVersionStr(),GetGitSha1(), andGetGitDate()in the core C++ code and C/C++ APIs - Updates CMake build scripts to compile and install the new version binary and include
version.cc - Extends language bindings (Python, Swift, Node.js, Java/Kotlin, Go, .NET, Dart, Pascal) with version retrieval functions and example tests
Reviewed Changes
Copilot reviewed 168 out of 169 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| sherpa-onnx/csrc/version.h & version.cc | Declare & implement core version/Git APIs |
| sherpa-onnx/csrc/CMakeLists.txt | Add version.cc to build and sherpa-onnx-version executable |
| sherpa-onnx/c-api/c-api.h & c-api.cc | Export C API functions SherpaOnnxGet* |
| sherpa-onnx/c-api/cxx-api.h & cxx-api.cc | Add C++ wrapper APIs returning std::string |
| swift-api-examples/SherpaOnnx.swift | Add Swift functions and example for version info |
| python/csrc/version.h & version.cc | Bind version APIs into Python module |
| scripts/nodejs/index.js | Add JavaScript functions for version info |
| scripts/go/sherpa_onnx.go | Add Go wrappers for version APIs |
Comments suppressed due to low confidence (1)
sherpa-onnx/c-api/c-api.cc:1378
- The
SHERPA_ONNX_APImacro was removed fromSherpaOnnxWriteWaveToBuffer, which may prevent the function from being exported in the shared library. Please restoreSHERPA_ONNX_APIto ensure correct symbol visibility.
int32_t sample_rate, char *buffer) {
| @@ -0,0 +1 @@ | |||
| ../../../harmony-os/SherpaOnnxHar/sherpa_onnx/src/main/cpp/version.cc No newline at end of file | |||
There was a problem hiding this comment.
This file contains only a path reference instead of actual C++ implementation. It should include or define the version APIs rather than a literal path.
Suggested change
| ../../../harmony-os/SherpaOnnxHar/sherpa_onnx/src/main/cpp/version.cc | |
| // Include the necessary header file for version APIs | |
| #include "version.h" | |
| // Alternatively, define the version APIs directly if not available in a header file | |
| const char* GetVersion() { | |
| return "1.0.0"; // Replace with the actual version string | |
| } |
| // Copyright (c) 2023 Xiaomi Corporation (authors: Fangjun Kuang) | ||
| // | ||
| const sherpa_onnx = require('sherpa-onnx'); | ||
| console.log(`verison : ${sherpa_onnx.version}`); |
There was a problem hiding this comment.
Typo in log message: "verison" should be spelled "version".
Suggested change
| console.log(`verison : ${sherpa_onnx.version}`); | |
| console.log(`version : ${sherpa_onnx.version}`); |
| @@ -1,5 +1,8 @@ | |||
| // Copyright (c) 2024 Xiaomi Corporation | |||
| const sherpa_onnx = require('sherpa-onnx-node'); | |||
| console.log(`verison : ${sherpa_onnx.version}`); | |||
There was a problem hiding this comment.
Typo in log message: "verison" should be spelled "version".
Suggested change
| console.log(`verison : ${sherpa_onnx.version}`); | |
| console.log(`version : ${sherpa_onnx.version}`); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
TODOs