Skip to content

Add API to get version information#2309

Merged
csukuangfj merged 13 commits into
k2-fsa:masterfrom
csukuangfj:add-version
Jun 24, 2025
Merged

Add API to get version information#2309
csukuangfj merged 13 commits into
k2-fsa:masterfrom
csukuangfj:add-version

Conversation

@csukuangfj

@csukuangfj csukuangfj commented Jun 23, 2025

Copy link
Copy Markdown
Collaborator

TODOs

  • Go
  • Dart
  • Pascal
  • ArkTs

@csukuangfj csukuangfj merged commit bda427f into k2-fsa:master Jun 24, 2025
164 of 220 checks passed
@csukuangfj csukuangfj deleted the add-version branch June 24, 2025 16:22
@csukuangfj csukuangfj requested a review from Copilot June 25, 2025 09:45

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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(), and GetGitDate() 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_API macro was removed from SherpaOnnxWriteWaveToBuffer, which may prevent the function from being exported in the shared library. Please restore SHERPA_ONNX_API to 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

Copilot AI Jun 25, 2025

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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
}

Copilot uses AI. Check for mistakes.
// Copyright (c) 2023 Xiaomi Corporation (authors: Fangjun Kuang)
//
const sherpa_onnx = require('sherpa-onnx');
console.log(`verison : ${sherpa_onnx.version}`);

Copilot AI Jun 25, 2025

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Typo in log message: "verison" should be spelled "version".

Suggested change
console.log(`verison : ${sherpa_onnx.version}`);
console.log(`version : ${sherpa_onnx.version}`);

Copilot uses AI. Check for mistakes.
@@ -1,5 +1,8 @@
// Copyright (c) 2024 Xiaomi Corporation
const sherpa_onnx = require('sherpa-onnx-node');
console.log(`verison : ${sherpa_onnx.version}`);

Copilot AI Jun 25, 2025

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Typo in log message: "verison" should be spelled "version".

Suggested change
console.log(`verison : ${sherpa_onnx.version}`);
console.log(`version : ${sherpa_onnx.version}`);

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants