Compare commits

...

14 Commits

Author SHA1 Message Date
Nolan Darilek 1df00952e4 Update repositories and remove Gitlab CI configuration.
continuous-integration/drone/push Build is passing Details
2022-11-22 14:07:10 -06:00
Nolan Darilek db43d95cf7 Fix indentation.
continuous-integration/drone/push Build is passing Details
continuous-integration/drone/tag Build is passing Details
2022-11-22 13:59:51 -06:00
Nolan Darilek 89fcced31e Update CI build configuration. 2022-11-22 13:55:55 -06:00
Nolan Darilek 1c11f279ec Bump version and use correct features in docs.rs builds. 2022-11-22 13:52:19 -06:00
Nolan Darilek f854e386a6 Re-add support for speech-dispatcher 0.9. 2022-11-22 13:49:54 -06:00
Nolan Darilek 1ba40e898b Merge branch 'master' into 'master'
Fix missing size_t on latest stable

See merge request ndarilek/speech-dispatcher-rs!7
2022-10-19 14:40:39 +00:00
Tait Hoyem bcf7025f14 Fix missing size_t on latest stable 2022-10-16 15:10:24 -06:00
Nolan Darilek 2239c2539a Publish with features compatible for Rust CI image. 2022-09-07 12:13:55 -05:00
Nolan Darilek 2ea85bc1bd Bump version and drop support for 0.9. 2022-09-07 11:43:22 -05:00
Nolan Darilek 0efdccc9aa Merge branch '32bit' into 'master'
Fix msg_id and client_id being size_t in C

Closes #5

See merge request ndarilek/speech-dispatcher-rs!5
2022-09-07 14:53:43 +00:00
Nolan Darilek e770c73e67 Merge branch 'voice_type' into 'master'
Fix voice_type signedness change

Closes #4

See merge request ndarilek/speech-dispatcher-rs!6
2022-09-07 14:48:56 +00:00
Samuel Thibault 8ff6902148 Fix voice_type signedness change
The signedness changed happened in speech-dispatcher 0.11, not in
speech-dispatcher 0.10.2.

Closes #4
2022-09-07 15:54:53 +02:00
Samuel Thibault 29f990e19b Fix msg_id and client_id being size_t in C
instead of u64 which is only valid on 64bit architectures.

Fixes #5
2022-09-07 15:31:10 +02:00
Nolan Darilek 6a6bc3f805 Add Drone/cargo-release/git-cliff configuration. 2022-09-04 09:15:13 -05:00
6 changed files with 136 additions and 57 deletions

27
.drone.yml Normal file
View File

@ -0,0 +1,27 @@
kind: pipeline
type: docker
name: default
steps:
- name: test
image: rust
commands:
- rustup component add clippy rustfmt
- apt-get update -qq
- apt-get install -qqy llvm-dev libclang-dev clang libspeechd-dev
- cargo fmt --all --check
- cargo test --no-default-features --features 0_10
- cargo clippy --no-default-features --features 0_10
- name: release
image: rust
commands:
- apt-get update -qq
- apt-get install -qqy llvm-dev libclang-dev clang libspeechd-dev
- cargo publish --no-default-features --features 0_10 --manifest-path speech-dispatcher-sys/Cargo.toml || true
- cargo publish --no-default-features --features 0_10 --manifest-path speech-dispatcher/Cargo.toml
when:
ref:
- refs/tags/v*
environment:
CARGO_REGISTRY_TOKEN:
from_secret: cargo_registry_token

View File

@ -1,23 +0,0 @@
image: rust
stages:
- test
- publish
before_script:
- apt-get update
- apt-get install -y libspeechd-dev llvm-dev libclang-dev clang
test:
stage: test
script:
- cargo test
publish:
stage: publish
script:
- cargo login $CARGO_TOKEN
- cargo publish --manifest-path speech-dispatcher-sys/Cargo.toml || true
- cargo publish --manifest-path speech-dispatcher/Cargo.toml
only:
- tags

60
cliff.toml Normal file
View File

@ -0,0 +1,60 @@
# configuration file for git-cliff (0.1.0)
[changelog]
# changelog header
header = """
# Changelog\n
All notable changes to this project will be documented in this file.\n
"""
# template for the changelog body
# https://tera.netlify.app/docs/#introduction
body = """
{% if version %}\
## Version {{ version | trim_start_matches(pat="v") }} - {{ timestamp | date(format="%Y-%m-%d") }}
{% else %}\
## Unreleased
{% endif %}\
{% for group, commits in commits | group_by(attribute="group") %}
### {{ group | upper_first }}
{% for commit in commits %}
- {% if commit.breaking %}[**breaking**] {% endif %}{{ commit.message | upper_first }}\
{% endfor %}
{% endfor %}\n
"""
# remove the leading and trailing whitespace from the template
trim = true
# changelog footer
footer = """
<!-- generated by git-cliff -->
"""
[git]
# parse the commits based on https://www.conventionalcommits.org
conventional_commits = true
# filter out the commits that are not conventional
filter_unconventional = true
# regex for parsing and grouping commits
commit_parsers = [
{ message = "^feat", group = "Features"},
{ message = "^fix", group = "Bug Fixes"},
{ message = "^doc", group = "Documentation"},
{ message = "^perf", group = "Performance"},
{ message = "^refactor", group = "Refactor"},
{ message = "^style", group = "Styling"},
{ message = "^test", group = "Testing"},
{ message = "^chore\\(release\\): prepare for", skip = true},
{ message = "^chore", group = "Miscellaneous Tasks"},
{ body = ".*security", group = "Security"},
]
# filter out the commits that are not matched by commit parsers
filter_commits = false
# glob pattern for matching git tags
tag_pattern = "v[0-9]*"
# regex for skipping tags
skip_tags = ""
# regex for ignoring tags
ignore_tags = ""
# sort the tags chronologically
date_order = false
# sort the commits inside sections by oldest/newest order
sort_commits = "oldest"

View File

@ -2,11 +2,16 @@
name = "speech-dispatcher-sys"
version = "0.7.0"
authors = ["Nolan Darilek <nolan@thewordnerd.info>"]
repository = "https://gitlab.com/ndarilek/speech-dispatcher-rs"
repository = "https://dev.thewordnerd.info/nolan/speech-dispatcher-rs"
description = "speech-dispatcher system bindings"
license = "LGPL-2.1 OR MIT OR Apache-2.0"
edition = "2021"
[build-dependencies]
bindgen = ">= 0.54"
[package.metadata.release]
tag-prefix = ""
publish = false
push = false
pre-release-hook = ["git-cliff", "-o", "CHANGELOG.md", "--tag", "{{version}}"]

View File

@ -1,20 +1,29 @@
[package]
name = "speech-dispatcher"
version = "0.14.0"
version = "0.16.0"
authors = ["Nolan Darilek <nolan@thewordnerd.info>"]
repository = "https://gitlab.com/ndarilek/speech-dispatcher-rs"
repository = "https://dev.thewordnerd.info/nolan/speech-dispatcher-rs"
description = "Rusty interface to the speech-dispatcher speech synthesis library"
license = "LGPL-2.1 OR MIT OR Apache-2.0"
edition = "2021"
[features]
0_10_2 = ["0_10"]
0_11 = ["0_10"]
0_10 = []
default = ["0_10_2"]
0_9 = []
default = ["0_11"]
[dependencies]
lazy_static = "1"
speech-dispatcher-sys = { version = "0.7", path = "../speech-dispatcher-sys" }
libc = "0.2.125"
[package.metadata.docs.rs]
no-default-features = true
no-default-features = true
features = ["0_9"]
[package.metadata.release]
tag-prefix = ""
publish = false
push = false
pre-release-hook = ["git-cliff", "-o", "CHANGELOG.md", "--tag", "{{version}}"]

View File

@ -1,5 +1,6 @@
#![allow(non_upper_case_globals)]
use libc::size_t;
use std::{
collections::HashMap,
ffi::{CStr, CString},
@ -122,12 +123,12 @@ fn c_int_to_result(r: c_int) -> Result<(), Error> {
#[derive(Default)]
struct Callbacks {
begin: Option<Box<dyn FnMut(u64, u64)>>,
end: Option<Box<dyn FnMut(u64, u64)>>,
index_mark: Option<Box<dyn FnMut(u64, u64, String)>>,
cancel: Option<Box<dyn FnMut(u64, u64)>>,
pause: Option<Box<dyn FnMut(u64, u64)>>,
resume: Option<Box<dyn FnMut(u64, u64)>>,
begin: Option<Box<dyn FnMut(size_t, size_t)>>,
end: Option<Box<dyn FnMut(size_t, size_t)>>,
index_mark: Option<Box<dyn FnMut(size_t, size_t, String)>>,
cancel: Option<Box<dyn FnMut(size_t, size_t)>>,
pause: Option<Box<dyn FnMut(size_t, size_t)>>,
resume: Option<Box<dyn FnMut(size_t, size_t)>>,
}
unsafe impl Send for Callbacks {}
@ -135,13 +136,13 @@ unsafe impl Send for Callbacks {}
unsafe impl Sync for Callbacks {}
lazy_static! {
static ref callbacks: Mutex<HashMap<u64, Callbacks>> = {
static ref callbacks: Mutex<HashMap<size_t, Callbacks>> = {
let m = HashMap::new();
Mutex::new(m)
};
}
unsafe extern "C" fn cb(msg_id: u64, client_id: u64, state: u32) {
unsafe extern "C" fn cb(msg_id: size_t, client_id: size_t, state: u32) {
let state = match state {
SPDNotificationType_SPD_EVENT_BEGIN => Notification::Begin,
SPDNotificationType_SPD_EVENT_END => Notification::End,
@ -165,7 +166,7 @@ unsafe extern "C" fn cb(msg_id: u64, client_id: u64, state: u32) {
}
}
unsafe extern "C" fn cb_im(msg_id: u64, client_id: u64, state: u32, index_mark: *mut c_char) {
unsafe extern "C" fn cb_im(msg_id: size_t, client_id: size_t, state: u32, index_mark: *mut c_char) {
let index_mark = CStr::from_ptr(index_mark);
let index_mark = index_mark.to_string_lossy().to_string();
let state = match state {
@ -205,7 +206,7 @@ impl fmt::Display for Error {
}
#[derive(Clone, Debug)]
pub struct Connection(pub Arc<*mut SPDConnection>, u64);
pub struct Connection(pub Arc<*mut SPDConnection>, size_t);
impl Connection {
pub fn open<S: Into<String>>(
@ -287,7 +288,7 @@ impl Connection {
if let Some(client_id) = client_id {
let client_id: Vec<&str> = client_id.split("-").collect();
if let Some(client_id) = client_id.get(1) {
if let Ok(client_id) = client_id.parse::<u64>() {
if let Ok(client_id) = client_id.parse::<size_t>() {
self.1 = client_id;
}
}
@ -413,26 +414,26 @@ impl Connection {
}
pub fn set_voice_type(&self, voice_type: VoiceType) -> Result<(), Error> {
#[cfg(all(feature = "0_10", not(feature = "0_10_2")))]
let v = unsafe { spd_set_voice_type(*self.0, voice_type as i32) };
#[cfg(any(feature = "0_10_2", not(feature = "0_10")))]
#[cfg(all(any(feature = "0_9", feature = "0_10"), not(feature = "0_11")))]
let v = unsafe { spd_set_voice_type(*self.0, voice_type as u32) };
#[cfg(all(not(feature = "0_9"), any(feature = "0_11", not(feature = "0_10"))))]
let v = unsafe { spd_set_voice_type(*self.0, voice_type as i32) };
c_int_to_result(v)
}
pub fn set_voice_type_all(&self, voice_type: VoiceType) -> Result<(), Error> {
#[cfg(all(feature = "0_10", not(feature = "0_10_2")))]
let v = unsafe { spd_set_voice_type_all(*self.0, voice_type as i32) };
#[cfg(any(feature = "0_10_2", not(feature = "0_10")))]
#[cfg(all(any(feature = "0_9", feature = "0_10"), not(feature = "0_11")))]
let v = unsafe { spd_set_voice_type_all(*self.0, voice_type as u32) };
#[cfg(all(not(feature = "0_9"), any(feature = "0_11", not(feature = "0_10"))))]
let v = unsafe { spd_set_voice_type_all(*self.0, voice_type as i32) };
c_int_to_result(v)
}
pub fn set_voice_type_uid(&self, voice_type: VoiceType, target_uid: u32) -> Result<(), Error> {
#[cfg(all(feature = "0_10", not(feature = "0_10_2")))]
let v = unsafe { spd_set_voice_type_uid(*self.0, voice_type as i32, target_uid) };
#[cfg(any(feature = "0_10_2", not(feature = "0_10")))]
#[cfg(all(any(feature = "0_9", feature = "0_10"), not(feature = "0_11")))]
let v = unsafe { spd_set_voice_type_uid(*self.0, voice_type as u32, target_uid) };
#[cfg(all(not(feature = "0_9"), any(feature = "0_11", not(feature = "0_10"))))]
let v = unsafe { spd_set_voice_type_uid(*self.0, voice_type as i32, target_uid) };
c_int_to_result(v)
}
@ -693,7 +694,7 @@ impl Connection {
}
}
pub fn on_begin(&self, f: Option<Box<dyn FnMut(u64, u64)>>) {
pub fn on_begin(&self, f: Option<Box<dyn FnMut(size_t, size_t)>>) {
if let Ok(mut cbs) = callbacks.lock() {
let cb = cbs.get_mut(&self.1);
if let Some(cb) = cb {
@ -702,7 +703,7 @@ impl Connection {
}
}
pub fn on_end(&self, f: Option<Box<dyn FnMut(u64, u64)>>) {
pub fn on_end(&self, f: Option<Box<dyn FnMut(size_t, size_t)>>) {
if let Ok(mut cbs) = callbacks.lock() {
let cb = cbs.get_mut(&self.1);
if let Some(cb) = cb {
@ -711,7 +712,7 @@ impl Connection {
}
}
pub fn on_cancel(&self, f: Option<Box<dyn FnMut(u64, u64)>>) {
pub fn on_cancel(&self, f: Option<Box<dyn FnMut(size_t, size_t)>>) {
if let Ok(mut cbs) = callbacks.lock() {
let cb = cbs.get_mut(&self.1);
if let Some(cb) = cb {
@ -720,7 +721,7 @@ impl Connection {
}
}
pub fn on_pause(&self, f: Option<Box<dyn FnMut(u64, u64)>>) {
pub fn on_pause(&self, f: Option<Box<dyn FnMut(size_t, size_t)>>) {
if let Ok(mut cbs) = callbacks.lock() {
let cb = cbs.get_mut(&self.1);
if let Some(cb) = cb {
@ -729,7 +730,7 @@ impl Connection {
}
}
pub fn on_resume(&self, f: Option<Box<dyn FnMut(u64, u64)>>) {
pub fn on_resume(&self, f: Option<Box<dyn FnMut(size_t, size_t)>>) {
if let Ok(mut cbs) = callbacks.lock() {
let cb = cbs.get_mut(&self.1);
if let Some(cb) = cb {
@ -738,7 +739,7 @@ impl Connection {
}
}
pub fn on_index_mark(&self, f: Option<Box<dyn FnMut(u64, u64, String)>>) {
pub fn on_index_mark(&self, f: Option<Box<dyn FnMut(size_t, size_t, String)>>) {
if let Ok(mut cbs) = callbacks.lock() {
let cb = cbs.get_mut(&self.1);
if let Some(cb) = cb {
@ -784,7 +785,7 @@ impl Connection {
Ok(modules)
}
pub fn client_id(&self) -> u64 {
pub fn client_id(&self) -> size_t {
self.1
}
}