add jsonrpc feature flag

This commit is contained in:
Simon Laux
2022-06-13 19:01:06 +02:00
parent 63e7179191
commit b51814aaaa
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"
@@ -28,7 +28,8 @@ rand = "0.7"
once_cell = "1.12.0"
[features]
default = ["vendored"]
default = ["vendored", "jsonrpc"]
vendored = ["deltachat/vendored"]
nightly = ["deltachat/nightly"]
jsonrpc = ["deltachat-jsonrpc"]

View File

@@ -4439,14 +4439,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,
@@ -4467,6 +4471,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() {
@@ -4477,6 +4482,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,
@@ -4495,6 +4501,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'
]