Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Simplify C/C++ headers using cbindgen's cpp-compat option #79

Merged
merged 1 commit into from
Oct 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand Down
11 changes: 0 additions & 11 deletions ci/before_deploy.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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/

Expand All @@ -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/

Expand Down
106 changes: 0 additions & 106 deletions includes-cpp/wooting-analog-common.h

This file was deleted.

18 changes: 0 additions & 18 deletions includes-cpp/wooting-analog-plugin-dev.h

This file was deleted.

161 changes: 0 additions & 161 deletions includes-cpp/wooting-analog-wrapper.h

This file was deleted.

8 changes: 8 additions & 0 deletions includes/wooting-analog-common.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
8 changes: 8 additions & 0 deletions includes/wooting-analog-plugin-dev.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,14 @@
#include <stdlib.h>
#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
8 changes: 8 additions & 0 deletions includes/wooting-analog-wrapper.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@
#include <stdlib.h>
#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
///
Expand Down Expand Up @@ -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
Loading