From 78fed26e3d7fb9ac0628505bac072a0811c64ffb Mon Sep 17 00:00:00 2001 From: Sainan Date: Fri, 23 Aug 2024 12:06:03 +0200 Subject: [PATCH] Simplify C/C++ headers using cbindgen's cpp-compat option The C headers can be used in C++ by simply wrapping it in `extern "C"`, which is exactly what the cpp-compat option does, removing the need for seperate header files. --- README.md | 2 +- ci/before_deploy.sh | 11 -- includes-cpp/wooting-analog-common.h | 106 --------------- includes-cpp/wooting-analog-plugin-dev.h | 18 --- includes-cpp/wooting-analog-wrapper.h | 161 ----------------------- includes/wooting-analog-common.h | 8 ++ includes/wooting-analog-plugin-dev.h | 8 ++ includes/wooting-analog-wrapper.h | 8 ++ wooting-analog-common/Makefile.toml | 11 +- wooting-analog-plugin-dev/Makefile.toml | 11 +- wooting-analog-wrapper/Makefile.toml | 11 +- 11 files changed, 31 insertions(+), 324 deletions(-) delete mode 100644 includes-cpp/wooting-analog-common.h delete mode 100644 includes-cpp/wooting-analog-plugin-dev.h delete mode 100644 includes-cpp/wooting-analog-wrapper.h diff --git a/README.md b/README.md index a576eab..3bbbf94 100644 --- a/README.md +++ b/README.md @@ -168,7 +168,7 @@ The deb package will be located in `$gitroot/target/debian` ### Outputs -All build outputs can be found under `target/debug`, with generated headers coming under the `includes` and `includes-cpp` directories. +All build outputs can be found under `target/debug`, with generated headers coming under the `includes` directory. Currently the headers have to be manually generated and kept in the repo. When intentional changes are made, the testing phase verifies that the pre-generated headers match what would be generated now to ensure that accidental changes aren't made to the output of the header generation. diff --git a/ci/before_deploy.sh b/ci/before_deploy.sh index 15ad0eb..cec26cb 100755 --- a/ci/before_deploy.sh +++ b/ci/before_deploy.sh @@ -46,12 +46,10 @@ main() { mkdir $stage/plugins mkdir $stage/plugins/lib mkdir $stage/plugins/includes - mkdir $stage/plugins/includes-cpp mkdir $stage/wrapper mkdir $stage/wrapper/lib mkdir $stage/wrapper/includes - mkdir $stage/wrapper/includes-cpp mkdir $stage/wrapper/sdk # Copy Plugin items @@ -62,11 +60,6 @@ main() { cp includes/plugin.h $stage/plugins/includes/ cp includes/wooting-analog-plugin-dev.h $stage/plugins/includes/ cp includes/wooting-analog-common.h $stage/plugins/includes/ - - ## Copy cpp headers - cp includes-cpp/wooting-analog-plugin-dev.h $stage/plugins/includes-cpp/ - cp includes-cpp/wooting-analog-common.h $stage/plugins/includes-cpp/ - ## Copy docs cp PLUGINS.md $stage/plugins/ @@ -85,10 +78,6 @@ main() { cp includes/wooting-analog-wrapper.h $stage/wrapper/includes/ cp includes/wooting-analog-common.h $stage/wrapper/includes/ - ## Copy cpp headers - cp includes-cpp/wooting-analog-wrapper.h $stage/wrapper/includes-cpp/ - cp includes-cpp/wooting-analog-common.h $stage/wrapper/includes-cpp/ - ## Copy docs cp SDK_USAGE.md $stage/wrapper/ diff --git a/includes-cpp/wooting-analog-common.h b/includes-cpp/wooting-analog-common.h deleted file mode 100644 index c8aab7c..0000000 --- a/includes-cpp/wooting-analog-common.h +++ /dev/null @@ -1,106 +0,0 @@ -/* This is a generated header file providing the common items to everything related to the Analog SDK */ - -/* Warning, this file is autogenerated by cbindgen. Don't modify this manually. */ - -#include -#include -#include -#include -#include - -enum class WootingAnalog_DeviceEventType { - /// Device has been connected - WootingAnalog_DeviceEventType_Connected = 1, - /// Device has been disconnected - WootingAnalog_DeviceEventType_Disconnected = 2, -}; - -enum class WootingAnalog_DeviceType { - /// Device is of type Keyboard - WootingAnalog_DeviceType_Keyboard = 1, - /// Device is of type Keypad - WootingAnalog_DeviceType_Keypad = 2, - /// Device - WootingAnalog_DeviceType_Other = 3, -}; - -enum class WootingAnalog_KeycodeType { - /// USB HID Keycodes https://www.usb.org/document-library/hid-usage-tables-112 pg53 - WootingAnalog_KeycodeType_HID = 0, - /// Scan code set 1 - WootingAnalog_KeycodeType_ScanCode1 = 1, - /// Windows Virtual Keys - WootingAnalog_KeycodeType_VirtualKey = 2, - /// Windows Virtual Keys which are translated to the current keyboard locale - WootingAnalog_KeycodeType_VirtualKeyTranslate = 3, -}; - -enum class WootingAnalogResult { - WootingAnalogResult_Ok = 1, - /// Item hasn't been initialized - WootingAnalogResult_UnInitialized = -2000, - /// No Devices are connected - WootingAnalogResult_NoDevices = -1999, - /// Device has been disconnected - WootingAnalogResult_DeviceDisconnected = -1998, - /// Generic Failure - WootingAnalogResult_Failure = -1997, - /// A given parameter was invalid - WootingAnalogResult_InvalidArgument = -1996, - /// No Plugins were found - WootingAnalogResult_NoPlugins = -1995, - /// The specified function was not found in the library - WootingAnalogResult_FunctionNotFound = -1994, - /// No Keycode mapping to HID was found for the given Keycode - WootingAnalogResult_NoMapping = -1993, - /// Indicates that it isn't available on this platform - WootingAnalogResult_NotAvailable = -1992, - /// Indicates that the operation that is trying to be used is for an older version - WootingAnalogResult_IncompatibleVersion = -1991, - /// Indicates that the Analog SDK could not be found on the system - WootingAnalogResult_DLLNotFound = -1990, -}; - -/// The core `DeviceInfo` struct which contains all the interesting information -/// for a particular device. This is for use internally and should be ignored if you're -/// trying to use it when trying to interact with the SDK using the wrapper -struct WootingAnalog_DeviceInfo; - -using WootingAnalog_DeviceID = uint64_t; - -/// The core `DeviceInfo` struct which contains all the interesting information -/// for a particular device. This is the version which the consumer of the SDK will receive -/// through the wrapper. This is not for use in the Internal workings of the SDK, that is what -/// DeviceInfo is for -struct WootingAnalog_DeviceInfo_FFI { - /// Device Vendor ID `vid` - uint16_t vendor_id; - /// Device Product ID `pid` - uint16_t product_id; - /// Device Manufacturer name - char *manufacturer_name; - /// Device name - char *device_name; - /// Unique device ID, which should be generated using `generate_device_id` - WootingAnalog_DeviceID device_id; - /// Hardware type of the Device - WootingAnalog_DeviceType device_type; -}; - -extern "C" { - -/// Create a new device info struct. This is only for use in Plugins that are written in C -/// Rust plugins should use the native constructor -/// The memory for the struct has been allocated in Rust. So `drop_device_info` must be called -/// for the memory to be properly released -WootingAnalog_DeviceInfo *new_device_info(uint16_t vendor_id, - uint16_t product_id, - char *manufacturer_name, - char *device_name, - WootingAnalog_DeviceID device_id, - WootingAnalog_DeviceType device_type); - -/// Drops the given `DeviceInfo` -void drop_device_info(WootingAnalog_DeviceInfo *device); - -} // extern "C" diff --git a/includes-cpp/wooting-analog-plugin-dev.h b/includes-cpp/wooting-analog-plugin-dev.h deleted file mode 100644 index 46f3159..0000000 --- a/includes-cpp/wooting-analog-plugin-dev.h +++ /dev/null @@ -1,18 +0,0 @@ -/* This is a generated header file providing the necessary items for Analog SDK plugins */ - -/* Warning, this file is autogenerated by cbindgen. Don't modify this manually. */ - -#include -#include -#include -#include -#include -#include "wooting-analog-common.h" - -extern "C" { - -WootingAnalog_DeviceID generate_device_id(const char* serial_number, - uint16_t vendor_id, - uint16_t product_id); - -} // extern "C" diff --git a/includes-cpp/wooting-analog-wrapper.h b/includes-cpp/wooting-analog-wrapper.h deleted file mode 100644 index 10dce0a..0000000 --- a/includes-cpp/wooting-analog-wrapper.h +++ /dev/null @@ -1,161 +0,0 @@ -/* This is a generated header file detailing the interface to the Analog SDK Wrapper */ - -/* Warning, this file is autogenerated by cbindgen. Don't modify this manually. */ - -#include -#include -#include -#include -#include -#include "wooting-analog-common.h" - -extern "C" { - -/// Initialises the Analog SDK, this needs to be successfully called before any other functions -/// of the SDK can be called -/// -/// # Expected Returns -/// * `ret>=0`: Meaning the SDK initialised successfully and the number indicates the number of devices that were found on plugin initialisation -/// * `NoPlugins`: Meaning that either no plugins were found or some were found but none were successfully initialised -/// * `FunctionNotFound`: The SDK is either not installed or could not be found -/// * `IncompatibleVersion`: The installed SDK is incompatible with this wrapper as they are on different Major versions -int wooting_analog_initialise(); - -/// Returns a bool indicating if the Analog SDK has been initialised -bool wooting_analog_is_initialised(); - -/// Uninitialises the SDK, returning it to an empty state, similar to how it would be before first initialisation -/// # Expected Returns -/// * `Ok`: Indicates that the SDK was successfully uninitialised -WootingAnalogResult wooting_analog_uninitialise(); - -/// Sets the type of Keycodes the Analog SDK will receive (in `read_analog`) and output (in `read_full_buffer`). -/// -/// By default, the mode is set to HID -/// -/// # Notes -/// * `VirtualKey` and `VirtualKeyTranslate` are only available on Windows -/// * With all modes except `VirtualKeyTranslate`, the key identifier will point to the physical key on the standard layout. i.e. if you ask for the Q key, it will be the key right to tab regardless of the layout you have selected -/// * With `VirtualKeyTranslate`, if you request Q, it will be the key that inputs Q on the current layout, not the key that is Q on the standard layout. -/// -/// # Expected Returns -/// * `Ok`: The Keycode mode was changed successfully -/// * `InvalidArgument`: The given `KeycodeType` is not one supported by the SDK -/// * `NotAvailable`: The given `KeycodeType` is present, but not supported on the current platform -/// * `UnInitialized`: The SDK is not initialised -WootingAnalogResult wooting_analog_set_keycode_mode(WootingAnalog_KeycodeType mode); - -/// Reads the Analog value of the key with identifier `code` from any connected device. The set of key identifiers that is used -/// depends on the Keycode mode set using `wooting_analog_set_mode`. -/// -/// # Examples -/// ```ignore -/// wooting_analog_set_mode(KeycodeType::ScanCode1); -/// wooting_analog_read_analog(0x10); //This will get you the value for the key which is Q in the standard US layout (The key just right to tab) -/// -/// wooting_analog_set_mode(KeycodeType::VirtualKey); //This will only work on Windows -/// wooting_analog_read_analog(0x51); //This will get you the value for the key that is Q on the standard layout -/// -/// wooting_analog_set_mode(KeycodeType::VirtualKeyTranslate); -/// wooting_analog_read_analog(0x51); //This will get you the value for the key that inputs Q on the current layout -/// ``` -/// -/// # Expected Returns -/// The float return value can be either a 0->1 analog value, or (if <0) is part of the WootingAnalogResult enum, which is how errors are given back on this call. -/// So if the value is below 0, you should cast it as WootingAnalogResult to see what the error is. -/// * `0.0f - 1.0f`: The Analog value of the key with the given id `code` -/// * `WootingAnalogResult::NoMapping`: No keycode mapping was found from the selected mode (set by wooting_analog_set_mode) and HID. -/// * `WootingAnalogResult::UnInitialized`: The SDK is not initialised -/// * `WootingAnalogResult::NoDevices`: There are no connected devices -float wooting_analog_read_analog(unsigned short code); - -/// Reads the Analog value of the key with identifier `code` from the device with id `device_id`. The set of key identifiers that is used -/// depends on the Keycode mode set using `wooting_analog_set_mode`. -/// -/// The `device_id` can be found through calling `wooting_analog_device_info` and getting the DeviceID from one of the DeviceInfo structs -/// -/// # Expected Returns -/// The float return value can be either a 0->1 analog value, or (if <0) is part of the WootingAnalogResult enum, which is how errors are given back on this call. -/// So if the value is below 0, you should cast it as WootingAnalogResult to see what the error is. -/// * `0.0f - 1.0f`: The Analog value of the key with the given id `code` from device with id `device_id` -/// * `WootingAnalogResult::NoMapping`: No keycode mapping was found from the selected mode (set by wooting_analog_set_mode) and HID. -/// * `WootingAnalogResult::UnInitialized`: The SDK is not initialised -/// * `WootingAnalogResult::NoDevices`: There are no connected devices with id `device_id` -float wooting_analog_read_analog_device(unsigned short code, - WootingAnalog_DeviceID device_id); - -/// Set the callback which is called when there is a DeviceEvent. Currently these events can either be Disconnected or Connected(Currently not properly implemented). -/// The callback gets given the type of event `DeviceEventType` and a pointer to the DeviceInfo struct that the event applies to -/// -/// # Notes -/// * You must copy the DeviceInfo struct or its data if you wish to use it after the callback has completed, as the memory will be freed straight after -/// * The execution of the callback is performed in a separate thread so it is fine to put time consuming code and further SDK calls inside your callback -/// -/// # Expected Returns -/// * `Ok`: The callback was set successfully -/// * `UnInitialized`: The SDK is not initialised -WootingAnalogResult wooting_analog_set_device_event_cb(void (*cb)(WootingAnalog_DeviceEventType, - WootingAnalog_DeviceInfo_FFI*)); - -/// Clears the device event callback that has been set -/// -/// # Expected Returns -/// * `Ok`: The callback was cleared successfully -/// * `UnInitialized`: The SDK is not initialised -WootingAnalogResult wooting_analog_clear_device_event_cb(); - -/// Fills up the given `buffer`(that has length `len`) with pointers to the DeviceInfo structs for all connected devices (as many that can fit in the buffer) -/// -/// # Notes -/// * The memory of the returned structs will only be kept until the next call of `get_connected_devices_info`, so if you wish to use any data from them, please copy it or ensure you don't reuse references to old memory after calling `get_connected_devices_info` again. -/// -/// # Expected Returns -/// Similar to wooting_analog_read_analog, the errors and returns are encoded into one type. Values >=0 indicate the number of items filled into the buffer, with `<0` being of type WootingAnalogResult -/// * `ret>=0`: The number of connected devices that have been filled into the buffer -/// * `WootingAnalogResult::UnInitialized`: Indicates that the AnalogSDK hasn't been initialised -int wooting_analog_get_connected_devices_info(WootingAnalog_DeviceInfo_FFI **buffer, - unsigned int len); - -/// Reads all the analog values for pressed keys for all devices and combines their values, filling up `code_buffer` with the -/// keycode identifying the pressed key and fills up `analog_buffer` with the corresponding float analog values. i.e. The analog -/// value for they key at index 0 of code_buffer, is at index 0 of analog_buffer. -/// -/// # Notes -/// * `len` is the length of code_buffer & analog_buffer, if the buffers are of unequal length, then pass the lower of the two, as it is the max amount of -/// key & analog value pairs that can be filled in. -/// * The codes that are filled into the `code_buffer` are of the KeycodeType set with wooting_analog_set_mode -/// * If two devices have the same key pressed, the greater value will be given -/// * When a key is released it will be returned with an analog value of 0.0f in the first read_full_buffer call after the key has been released -/// -/// # Expected Returns -/// Similar to other functions like `wooting_analog_device_info`, the return value encodes both errors and the return value we want. -/// Where >=0 is the actual return, and <0 should be cast as WootingAnalogResult to find the error. -/// * `>=0` means the value indicates how many keys & analog values have been read into the buffers -/// * `WootingAnalogResult::UnInitialized`: Indicates that the AnalogSDK hasn't been initialised -/// * `WootingAnalogResult::NoDevices`: Indicates no devices are connected -int wooting_analog_read_full_buffer(unsigned short *code_buffer, - float *analog_buffer, - unsigned int len); - -/// Reads all the analog values for pressed keys for the device with id `device_id`, filling up `code_buffer` with the -/// keycode identifying the pressed key and fills up `analog_buffer` with the corresponding float analog values. i.e. The analog -/// value for they key at index 0 of code_buffer, is at index 0 of analog_buffer. -/// -/// # Notes -/// * `len` is the length of code_buffer & analog_buffer, if the buffers are of unequal length, then pass the lower of the two, as it is the max amount of -/// key & analog value pairs that can be filled in. -/// * The codes that are filled into the `code_buffer` are of the KeycodeType set with wooting_analog_set_mode -/// * When a key is released it will be returned with an analog value of 0.0f in the first read_full_buffer call after the key has been released -/// -/// # Expected Returns -/// Similar to other functions like `wooting_analog_device_info`, the return value encodes both errors and the return value we want. -/// Where >=0 is the actual return, and <0 should be cast as WootingAnalogResult to find the error. -/// * `>=0` means the value indicates how many keys & analog values have been read into the buffers -/// * `WootingAnalogResult::UnInitialized`: Indicates that the AnalogSDK hasn't been initialised -/// * `WootingAnalogResult::NoDevices`: Indicates the device with id `device_id` is not connected -int wooting_analog_read_full_buffer_device(unsigned short *code_buffer, - float *analog_buffer, - unsigned int len, - WootingAnalog_DeviceID device_id); - -} // extern "C" diff --git a/includes/wooting-analog-common.h b/includes/wooting-analog-common.h index 3657cb0..b33e391 100644 --- a/includes/wooting-analog-common.h +++ b/includes/wooting-analog-common.h @@ -142,6 +142,10 @@ typedef struct WootingAnalog_DeviceInfo_FFI { enum WootingAnalog_DeviceType device_type; } WootingAnalog_DeviceInfo_FFI; +#ifdef __cplusplus +extern "C" { +#endif // __cplusplus + /** * Create a new device info struct. This is only for use in Plugins that are written in C * Rust plugins should use the native constructor @@ -159,3 +163,7 @@ struct WootingAnalog_DeviceInfo *new_device_info(uint16_t vendor_id, * Drops the given `DeviceInfo` */ void drop_device_info(struct WootingAnalog_DeviceInfo *device); + +#ifdef __cplusplus +} // extern "C" +#endif // __cplusplus diff --git a/includes/wooting-analog-plugin-dev.h b/includes/wooting-analog-plugin-dev.h index f754d18..bdbc271 100644 --- a/includes/wooting-analog-plugin-dev.h +++ b/includes/wooting-analog-plugin-dev.h @@ -8,6 +8,14 @@ #include #include "wooting-analog-common.h" +#ifdef __cplusplus +extern "C" { +#endif // __cplusplus + WootingAnalog_DeviceID generate_device_id(const char* serial_number, uint16_t vendor_id, uint16_t product_id); + +#ifdef __cplusplus +} // extern "C" +#endif // __cplusplus diff --git a/includes/wooting-analog-wrapper.h b/includes/wooting-analog-wrapper.h index 8a2c8af..b437c2f 100644 --- a/includes/wooting-analog-wrapper.h +++ b/includes/wooting-analog-wrapper.h @@ -8,6 +8,10 @@ #include #include "wooting-analog-common.h" +#ifdef __cplusplus +extern "C" { +#endif // __cplusplus + /// Initialises the Analog SDK, this needs to be successfully called before any other functions /// of the SDK can be called /// @@ -154,3 +158,7 @@ int wooting_analog_read_full_buffer_device(unsigned short *code_buffer, float *analog_buffer, unsigned int len, WootingAnalog_DeviceID device_id); + +#ifdef __cplusplus +} // extern "C" +#endif // __cplusplus diff --git a/wooting-analog-common/Makefile.toml b/wooting-analog-common/Makefile.toml index 339668b..5d159f7 100644 --- a/wooting-analog-common/Makefile.toml +++ b/wooting-analog-common/Makefile.toml @@ -1,21 +1,15 @@ [env] HEADER_OUTPUT_DIR_C="${CARGO_MAKE_WORKSPACE_WORKING_DIRECTORY}/includes" -HEADER_OUTPUT_DIR_CPP="${CARGO_MAKE_WORKSPACE_WORKING_DIRECTORY}/includes-cpp" HEADER_NAME="wooting-analog-common.h" HEADER_PATH_CLEAN="${HEADER_OUTPUT_DIR_C}/wooting-analog-common*" -HEADER_PATH_CLEAN_CPP="${HEADER_OUTPUT_DIR_CPP}/wooting-analog-common*" PLUGIN_GEN_PATH="${CARGO_MAKE_WORKING_DIRECTORY}/cbindgen-plugin.toml" -[tasks.header-cpp] -command = "cbindgen" -args = ["-l", "c++", "${CBINDGEN_ARGS}", "--clean", "-o", "${HEADER_OUTPUT_DIR_CPP}/${HEADER_NAME}"] - [tasks.header-c] command = "cbindgen" -args = ["-l", "c", "${CBINDGEN_ARGS}", "--clean", "-o", "${HEADER_OUTPUT_DIR_C}/${HEADER_NAME}"] +args = ["-l", "c", "--cpp-compat", "${CBINDGEN_ARGS}", "--clean", "-o", "${HEADER_OUTPUT_DIR_C}/${HEADER_NAME}"] [tasks.cbindgen-install] install_crate = { crate_name = "cbindgen", rustup_component_name="cbindgen", binary="cbindgen", test_arg = "--help" } @@ -24,7 +18,7 @@ args = ["--version"] [tasks.cbindgen] #TODO: Check the rustup_component_name arg to see if it is the correct name -dependencies=["cbindgen-install", "header-c", "header-cpp"] +dependencies=["cbindgen-install", "header-c"] [tasks.gen-headers] env = { CBINDGEN_ARGS="-v" } @@ -40,7 +34,6 @@ script_runner = "@shell" script = [ ''' rm ${HEADER_PATH_CLEAN} -rm ${HEADER_PATH_CLEAN_CPP} ''' ] diff --git a/wooting-analog-plugin-dev/Makefile.toml b/wooting-analog-plugin-dev/Makefile.toml index 2451551..f039ea3 100644 --- a/wooting-analog-plugin-dev/Makefile.toml +++ b/wooting-analog-plugin-dev/Makefile.toml @@ -1,20 +1,14 @@ [env] HEADER_OUTPUT_DIR_C="${CARGO_MAKE_WORKING_DIRECTORY}/../includes" -HEADER_OUTPUT_DIR_CPP="${CARGO_MAKE_WORKING_DIRECTORY}/../includes-cpp" HEADER_NAME="wooting-analog-plugin-dev.h" HEADER_PATH_CLEAN="${HEADER_OUTPUT_DIR_C}/wooting-analog-common*" -HEADER_PATH_CLEAN_CPP="${HEADER_OUTPUT_DIR_CPP}/wooting-analog-common*" -[tasks.header-cpp] -command = "cbindgen" -args = ["-l", "c++", "${CBINDGEN_ARGS}", "--clean", "-o", "${HEADER_OUTPUT_DIR_CPP}/${HEADER_NAME}"] - [tasks.header-c] command = "cbindgen" -args = ["-l", "c", "${CBINDGEN_ARGS}", "--clean", "-o", "${HEADER_OUTPUT_DIR_C}/${HEADER_NAME}"] +args = ["-l", "c", "--cpp-compat", "${CBINDGEN_ARGS}", "--clean", "-o", "${HEADER_OUTPUT_DIR_C}/${HEADER_NAME}"] [tasks.cbindgen-install] install_crate = { crate_name = "cbindgen", rustup_component_name="cbindgen", binary="cbindgen", test_arg = "--help" } @@ -22,7 +16,7 @@ command = "cbindgen" args = ["--version"] [tasks.cbindgen] -dependencies=["cbindgen-install", "header-c", "header-cpp"] +dependencies=["cbindgen-install", "header-c"] [tasks.gen-headers] env = { CBINDGEN_ARGS="-v" } @@ -38,7 +32,6 @@ script_runner = "@shell" script = [ ''' rm ${HEADER_PATH_CLEAN} -rm ${HEADER_PATH_CLEAN_CPP} ''' ] diff --git a/wooting-analog-wrapper/Makefile.toml b/wooting-analog-wrapper/Makefile.toml index 6ca48d6..a1993f8 100644 --- a/wooting-analog-wrapper/Makefile.toml +++ b/wooting-analog-wrapper/Makefile.toml @@ -1,16 +1,10 @@ [env] HEADER_NAME="wooting-analog-wrapper.h" HEADER_OUTPUT_DIR_C="${CARGO_MAKE_WORKSPACE_WORKING_DIRECTORY}/includes" -HEADER_OUTPUT_DIR_CPP="${CARGO_MAKE_WORKSPACE_WORKING_DIRECTORY}/includes-cpp" - -[tasks.header-cpp] -command = "cbindgen" -args = ["-l", "c++", "${CBINDGEN_ARGS}", "--clean", "-o", "${HEADER_OUTPUT_DIR_CPP}/${HEADER_NAME}"] -#Include clean on the second header gen as otherwise it'll strangely fail on windows and mac [tasks.header-c] command = "cbindgen" -args = ["-l", "c", "${CBINDGEN_ARGS}", "--clean", "-o", "${HEADER_OUTPUT_DIR_C}/${HEADER_NAME}"] +args = ["-l", "c", "--cpp-compat", "${CBINDGEN_ARGS}", "--clean", "-o", "${HEADER_OUTPUT_DIR_C}/${HEADER_NAME}"] #Have had to throw in clean as well as there's some weird cases where cbindgen will fail when generating all headers [tasks.cbindgen-install] @@ -19,7 +13,7 @@ command = "cbindgen" args = ["--version"] [tasks.cbindgen] -dependencies=["cbindgen-install", "header-c", "header-cpp"] +dependencies=["cbindgen-install", "header-c"] [tasks.gen-headers] env = { CBINDGEN_ARGS="-v" } @@ -34,7 +28,6 @@ run_task = "cbindgen" script_runner = "@shell" script = [ ''' -rm ${HEADER_OUTPUT_DIR_CPP}/${HEADER_NAME} rm ${HEADER_OUTPUT_DIR_C}/${HEADER_NAME} ''' ]