add jsonrpc feature flag

This commit is contained in:
Simon Laux
2022-06-13 19:01:06 +02:00
parent 3ce70ee244
commit a0b4d016d5
4 changed files with 12 additions and 4 deletions

View File

@@ -21,7 +21,7 @@ add_custom_command(
PREFIX=${CMAKE_INSTALL_PREFIX}
LIBDIR=${CMAKE_INSTALL_FULL_LIBDIR}
INCLUDEDIR=${CMAKE_INSTALL_FULL_INCLUDEDIR}
${CARGO} build --release --no-default-features
${CARGO} build --release --no-default-features --features jsonrpc
# Build in `deltachat-ffi` directory instead of using
# `--package deltachat_ffi` to avoid feature resolver version

View File

@@ -16,7 +16,7 @@ crate-type = ["cdylib", "staticlib"]
[dependencies]
deltachat = { path = "../", default-features = false }
deltachat-jsonrpc = { path = "../deltachat-jsonrpc" }
deltachat-jsonrpc = { path = "../deltachat-jsonrpc", optional = true }
libc = "0.2"
human-panic = "1"
num-traits = "0.2"
@@ -27,7 +27,8 @@ thiserror = "1"
rand = "0.7"
[features]
default = ["vendored"]
default = ["vendored", "jsonrpc"]
vendored = ["deltachat/vendored"]
nightly = ["deltachat/nightly"]
jsonrpc = ["deltachat-jsonrpc"]

View File

@@ -4426,14 +4426,18 @@ pub unsafe extern "C" fn dc_accounts_get_next_event(
.unwrap_or_else(ptr::null_mut)
}
#[cfg(feature = "jsonrpc")]
use deltachat_jsonrpc::api::CommandApi;
#[cfg(feature = "jsonrpc")]
use deltachat_jsonrpc::yerpc::{MessageHandle, RpcHandle};
#[cfg(feature = "jsonrpc")]
pub struct dc_json_api_instance_t {
receiver: async_std::channel::Receiver<deltachat_jsonrpc::yerpc::Message>,
handle: MessageHandle<CommandApi>,
}
#[cfg(feature = "jsonrpc")]
#[no_mangle]
pub unsafe extern "C" fn dc_get_json_api(
account_manager: *mut dc_accounts_t,
@@ -4454,6 +4458,7 @@ pub unsafe extern "C" fn dc_get_json_api(
Box::into_raw(Box::new(instance))
}
#[cfg(feature = "jsonrpc")]
#[no_mangle]
pub unsafe extern "C" fn dc_json_api_unref(json_api_instance: *mut dc_json_api_instance_t) {
if json_api_instance.is_null() {
@@ -4464,6 +4469,7 @@ pub unsafe extern "C" fn dc_json_api_unref(json_api_instance: *mut dc_json_api_i
Box::from_raw(json_api_instance);
}
#[cfg(feature = "jsonrpc")]
#[no_mangle]
pub unsafe extern "C" fn dc_json_request(
json_api_instance: *mut dc_json_api_instance_t,
@@ -4482,6 +4488,7 @@ pub unsafe extern "C" fn dc_json_request(
});
}
#[cfg(feature = "jsonrpc")]
#[no_mangle]
pub unsafe extern "C" fn dc_get_next_json_response(
json_api_instance: *mut dc_json_api_instance_t,

View File

@@ -9,7 +9,7 @@ const buildArgs = [
'build',
'--release',
'--features',
'vendored',
'vendored,jsonrpc',
'-p',
'deltachat_ffi'
]