Skip to content

Commit b377ec2

Browse files
Simon-Lauxlink2xt
authored andcommitted
build!: remove jsonrpc feature flag
It is enabled everywhere by default since some time now. Breaking, because existing build scripts might need to be adjusted.
1 parent 6e8668e commit b377ec2

File tree

9 files changed

+85
-95
lines changed

9 files changed

+85
-95
lines changed

.github/workflows/ci.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ jobs:
152152
uses: swatinem/rust-cache@v2
153153

154154
- name: Build C library
155-
run: cargo build -p deltachat_ffi --features jsonrpc
155+
run: cargo build -p deltachat_ffi
156156

157157
- name: Upload C library
158158
uses: actions/upload-artifact@v4

CMakeLists.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ add_custom_command(
2727
PREFIX=${CMAKE_INSTALL_PREFIX}
2828
LIBDIR=${CMAKE_INSTALL_FULL_LIBDIR}
2929
INCLUDEDIR=${CMAKE_INSTALL_FULL_INCLUDEDIR}
30-
${CARGO} build --target-dir=${CMAKE_BINARY_DIR}/target --release --features jsonrpc
30+
${CARGO} build --target-dir=${CMAKE_BINARY_DIR}/target --release
3131
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/deltachat-ffi
3232
)
3333

deltachat-ffi/Cargo.toml

+1-2
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ crate-type = ["cdylib", "staticlib"]
1515

1616
[dependencies]
1717
deltachat = { workspace = true, default-features = false }
18-
deltachat-jsonrpc = { workspace = true, optional = true }
18+
deltachat-jsonrpc = { workspace = true }
1919
libc = { workspace = true }
2020
human-panic = { version = "2", default-features = false }
2121
num-traits = { workspace = true }
@@ -30,5 +30,4 @@ yerpc = { workspace = true, features = ["anyhow_expose"] }
3030
[features]
3131
default = ["vendored"]
3232
vendored = ["deltachat/vendored", "deltachat-jsonrpc/vendored"]
33-
jsonrpc = ["dep:deltachat-jsonrpc"]
3433

deltachat-ffi/src/lib.rs

+77-83
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,8 @@ use deltachat::stock_str::StockMessage;
3535
use deltachat::webxdc::StatusUpdateSerial;
3636
use deltachat::*;
3737
use deltachat::{accounts::Accounts, log::LogExt};
38+
use deltachat_jsonrpc::api::CommandApi;
39+
use deltachat_jsonrpc::yerpc::{OutReceiver, RpcClient, RpcSession};
3840
use num_traits::{FromPrimitive, ToPrimitive};
3941
use once_cell::sync::Lazy;
4042
use rand::Rng;
@@ -4930,105 +4932,97 @@ pub unsafe extern "C" fn dc_accounts_get_event_emitter(
49304932
Box::into_raw(Box::new(emitter))
49314933
}
49324934

4933-
#[cfg(feature = "jsonrpc")]
4934-
mod jsonrpc {
4935-
use deltachat_jsonrpc::api::CommandApi;
4936-
use deltachat_jsonrpc::yerpc::{OutReceiver, RpcClient, RpcSession};
4937-
4938-
use super::*;
4935+
pub struct dc_jsonrpc_instance_t {
4936+
receiver: OutReceiver,
4937+
handle: RpcSession<CommandApi>,
4938+
}
49394939

4940-
pub struct dc_jsonrpc_instance_t {
4941-
receiver: OutReceiver,
4942-
handle: RpcSession<CommandApi>,
4940+
#[no_mangle]
4941+
pub unsafe extern "C" fn dc_jsonrpc_init(
4942+
account_manager: *mut dc_accounts_t,
4943+
) -> *mut dc_jsonrpc_instance_t {
4944+
if account_manager.is_null() {
4945+
eprintln!("ignoring careless call to dc_jsonrpc_init()");
4946+
return ptr::null_mut();
49434947
}
49444948

4945-
#[no_mangle]
4946-
pub unsafe extern "C" fn dc_jsonrpc_init(
4947-
account_manager: *mut dc_accounts_t,
4948-
) -> *mut dc_jsonrpc_instance_t {
4949-
if account_manager.is_null() {
4950-
eprintln!("ignoring careless call to dc_jsonrpc_init()");
4951-
return ptr::null_mut();
4952-
}
4949+
let account_manager = &*account_manager;
4950+
let cmd_api = block_on(deltachat_jsonrpc::api::CommandApi::from_arc(
4951+
account_manager.inner.clone(),
4952+
));
49534953

4954-
let account_manager = &*account_manager;
4955-
let cmd_api = block_on(deltachat_jsonrpc::api::CommandApi::from_arc(
4956-
account_manager.inner.clone(),
4957-
));
4954+
let (request_handle, receiver) = RpcClient::new();
4955+
let handle = RpcSession::new(request_handle, cmd_api);
49584956

4959-
let (request_handle, receiver) = RpcClient::new();
4960-
let handle = RpcSession::new(request_handle, cmd_api);
4957+
let instance = dc_jsonrpc_instance_t { receiver, handle };
49614958

4962-
let instance = dc_jsonrpc_instance_t { receiver, handle };
4959+
Box::into_raw(Box::new(instance))
4960+
}
49634961

4964-
Box::into_raw(Box::new(instance))
4962+
#[no_mangle]
4963+
pub unsafe extern "C" fn dc_jsonrpc_unref(jsonrpc_instance: *mut dc_jsonrpc_instance_t) {
4964+
if jsonrpc_instance.is_null() {
4965+
eprintln!("ignoring careless call to dc_jsonrpc_unref()");
4966+
return;
49654967
}
4968+
drop(Box::from_raw(jsonrpc_instance));
4969+
}
49664970

4967-
#[no_mangle]
4968-
pub unsafe extern "C" fn dc_jsonrpc_unref(jsonrpc_instance: *mut dc_jsonrpc_instance_t) {
4969-
if jsonrpc_instance.is_null() {
4970-
eprintln!("ignoring careless call to dc_jsonrpc_unref()");
4971-
return;
4972-
}
4973-
drop(Box::from_raw(jsonrpc_instance));
4974-
}
4971+
fn spawn_handle_jsonrpc_request(handle: RpcSession<CommandApi>, request: String) {
4972+
spawn(async move {
4973+
handle.handle_incoming(&request).await;
4974+
});
4975+
}
49754976

4976-
fn spawn_handle_jsonrpc_request(handle: RpcSession<CommandApi>, request: String) {
4977-
spawn(async move {
4978-
handle.handle_incoming(&request).await;
4979-
});
4977+
#[no_mangle]
4978+
pub unsafe extern "C" fn dc_jsonrpc_request(
4979+
jsonrpc_instance: *mut dc_jsonrpc_instance_t,
4980+
request: *const libc::c_char,
4981+
) {
4982+
if jsonrpc_instance.is_null() || request.is_null() {
4983+
eprintln!("ignoring careless call to dc_jsonrpc_request()");
4984+
return;
49804985
}
49814986

4982-
#[no_mangle]
4983-
pub unsafe extern "C" fn dc_jsonrpc_request(
4984-
jsonrpc_instance: *mut dc_jsonrpc_instance_t,
4985-
request: *const libc::c_char,
4986-
) {
4987-
if jsonrpc_instance.is_null() || request.is_null() {
4988-
eprintln!("ignoring careless call to dc_jsonrpc_request()");
4989-
return;
4990-
}
4987+
let handle = &(*jsonrpc_instance).handle;
4988+
let request = to_string_lossy(request);
4989+
spawn_handle_jsonrpc_request(handle.clone(), request);
4990+
}
49914991

4992-
let handle = &(*jsonrpc_instance).handle;
4993-
let request = to_string_lossy(request);
4994-
spawn_handle_jsonrpc_request(handle.clone(), request);
4992+
#[no_mangle]
4993+
pub unsafe extern "C" fn dc_jsonrpc_next_response(
4994+
jsonrpc_instance: *mut dc_jsonrpc_instance_t,
4995+
) -> *mut libc::c_char {
4996+
if jsonrpc_instance.is_null() {
4997+
eprintln!("ignoring careless call to dc_jsonrpc_next_response()");
4998+
return ptr::null_mut();
49954999
}
5000+
let api = &*jsonrpc_instance;
5001+
block_on(api.receiver.recv())
5002+
.map(|result| serde_json::to_string(&result).unwrap_or_default().strdup())
5003+
.unwrap_or(ptr::null_mut())
5004+
}
49965005

4997-
#[no_mangle]
4998-
pub unsafe extern "C" fn dc_jsonrpc_next_response(
4999-
jsonrpc_instance: *mut dc_jsonrpc_instance_t,
5000-
) -> *mut libc::c_char {
5001-
if jsonrpc_instance.is_null() {
5002-
eprintln!("ignoring careless call to dc_jsonrpc_next_response()");
5003-
return ptr::null_mut();
5004-
}
5005-
let api = &*jsonrpc_instance;
5006-
block_on(api.receiver.recv())
5007-
.map(|result| serde_json::to_string(&result).unwrap_or_default().strdup())
5008-
.unwrap_or(ptr::null_mut())
5009-
}
5010-
5011-
#[no_mangle]
5012-
pub unsafe extern "C" fn dc_jsonrpc_blocking_call(
5013-
jsonrpc_instance: *mut dc_jsonrpc_instance_t,
5014-
input: *const libc::c_char,
5015-
) -> *mut libc::c_char {
5016-
if jsonrpc_instance.is_null() {
5017-
eprintln!("ignoring careless call to dc_jsonrpc_blocking_call()");
5018-
return ptr::null_mut();
5019-
}
5020-
let api = &*jsonrpc_instance;
5021-
let input = to_string_lossy(input);
5022-
let res = block_on(api.handle.process_incoming(&input));
5023-
match res {
5024-
Some(message) => {
5025-
if let Ok(message) = serde_json::to_string(&message) {
5026-
message.strdup()
5027-
} else {
5028-
ptr::null_mut()
5029-
}
5006+
#[no_mangle]
5007+
pub unsafe extern "C" fn dc_jsonrpc_blocking_call(
5008+
jsonrpc_instance: *mut dc_jsonrpc_instance_t,
5009+
input: *const libc::c_char,
5010+
) -> *mut libc::c_char {
5011+
if jsonrpc_instance.is_null() {
5012+
eprintln!("ignoring careless call to dc_jsonrpc_blocking_call()");
5013+
return ptr::null_mut();
5014+
}
5015+
let api = &*jsonrpc_instance;
5016+
let input = to_string_lossy(input);
5017+
let res = block_on(api.handle.process_incoming(&input));
5018+
match res {
5019+
Some(message) => {
5020+
if let Ok(message) = serde_json::to_string(&message) {
5021+
message.strdup()
5022+
} else {
5023+
ptr::null_mut()
50305024
}
5031-
None => ptr::null_mut(),
50325025
}
5026+
None => ptr::null_mut(),
50335027
}
50345028
}

node/scripts/rebuild-core.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ const buildArgs = [
99
'build',
1010
'--release',
1111
'--features',
12-
'vendored,jsonrpc',
12+
'vendored',
1313
'-p',
1414
'deltachat_ffi'
1515
]

python/doc/cffi/install.rst

+1-4
Original file line numberDiff line numberDiff line change
@@ -52,10 +52,7 @@ python3-venv` should give you a usable python installation.
5252

5353
First, build the core library::
5454

55-
cargo build --release -p deltachat_ffi --features jsonrpc
56-
57-
`jsonrpc` feature is required even if not used by the bindings
58-
because `deltachat.h` includes JSON-RPC functions unconditionally.
55+
cargo build --release -p deltachat_ffi
5956

6057
Create the virtual environment and activate it::
6158

scripts/make-python-testenv.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ set -euo pipefail
1111

1212
export DCC_RS_TARGET=debug
1313
export DCC_RS_DEV="$PWD"
14-
cargo build -p deltachat_ffi --features jsonrpc
14+
cargo build -p deltachat_ffi
1515

1616
tox -c python -e py --devenv venv
1717
venv/bin/pip install --upgrade pip

scripts/run-python-test.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ export DCC_RS_DEV=`pwd`
1212

1313
cd python
1414

15-
cargo build -p deltachat_ffi --features jsonrpc
15+
cargo build -p deltachat_ffi
1616

1717
# remove and inhibit writing PYC files
1818
rm -rf tests/__pycache__

scripts/run_all.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ set -e -x
88

99
# compile core lib
1010

11-
cargo build --release -p deltachat_ffi --features jsonrpc
11+
cargo build --release -p deltachat_ffi
1212

1313
# Statically link against libdeltachat.a.
1414
export DCC_RS_DEV="$PWD"

0 commit comments

Comments
 (0)