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

Feature/export headers #524

Merged
merged 19 commits into from
Apr 27, 2023
Merged
Show file tree
Hide file tree
Changes from 15 commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
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
3 changes: 3 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,9 @@ include(CheckLinkerFlag)
check_linker_flag(CXX LINKER:--wrap,celix_nonexistent_symbol LINKER_WRAP_SUPPORTED)
cmake_pop_check_state()

#Add generate_export_header to cmake
include(GenerateExportHeader)

#Libraries and Launcher
add_subdirectory(libs)

Expand Down
19 changes: 13 additions & 6 deletions libs/dfi/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -36,19 +36,26 @@ if (CELIX_DFI)
)

add_library(dfi SHARED ${SOURCES})
set_target_properties(dfi PROPERTIES OUTPUT_NAME "celix_dfi")
target_include_directories(dfi PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_LIST_DIR}/include>
$<INSTALL_INTERFACE:include/celix/dfi>
)
target_link_libraries(dfi PRIVATE libffi::libffi)
$<INSTALL_INTERFACE:include/celix/dfi>)
target_link_libraries(dfi PRIVATE libffi::libffi Celix::utils)
target_link_libraries(dfi PUBLIC jansson::jansson)
target_link_libraries(dfi PRIVATE Celix::utils)
set_target_properties(dfi PROPERTIES "SOVERSION" 1)
set_target_properties(dfi PROPERTIES
C_VISIBILITY_PRESET hidden
VERSION "1.0.0"
"SOVERSION" 1
OUTPUT_NAME "celix_dfi")

generate_export_header(dfi
BASE_NAME "CELIX_DFI"
EXPORT_FILE_NAME "${CMAKE_BINARY_DIR}/celix/gen/includes/dfi/celix_dfi_export.h")
target_include_directories(dfi PUBLIC $<BUILD_INTERFACE:${CMAKE_BINARY_DIR}/celix/gen/includes/dfi>)

install(TARGETS dfi EXPORT celix DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT dfi
INCLUDES DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/celix/dfi)
install(DIRECTORY include/ DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/celix/dfi COMPONENT dfi)
install(DIRECTORY ${CMAKE_BINARY_DIR}/celix/gen/includes/dfi/ DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/celix/dfi COMPONENT dfi)

#Alias setup to match external usage
add_library(Celix::dfi ALIAS dfi)
Expand Down
9 changes: 5 additions & 4 deletions libs/dfi/include/avrobin_serializer.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
#include "dyn_type.h"
#include "dyn_function.h"
#include "dyn_interface.h"
#include "celix_dfi_export.h"

#ifdef __cplusplus
extern "C" {
Expand All @@ -31,13 +32,13 @@ extern "C" {
//logging
DFI_SETUP_LOG_HEADER(avrobinSerializer);

int avrobinSerializer_deserialize(dyn_type *type, const uint8_t *input, size_t inlen, void **result);
CELIX_DFI_DEPRECATED_EXPORT int avrobinSerializer_deserialize(dyn_type *type, const uint8_t *input, size_t inlen, void **result);

int avrobinSerializer_serialize(dyn_type *type, const void *input, uint8_t **output, size_t *outlen);
CELIX_DFI_DEPRECATED_EXPORT int avrobinSerializer_serialize(dyn_type *type, const void *input, uint8_t **output, size_t *outlen);

int avrobinSerializer_generateSchema(dyn_type *type, char **output);
CELIX_DFI_DEPRECATED_EXPORT int avrobinSerializer_generateSchema(dyn_type *type, char **output);

int avrobinSerializer_saveFile(const char *filename, const char *schema, const uint8_t *serdata, size_t serdatalen);
CELIX_DFI_DEPRECATED_EXPORT int avrobinSerializer_saveFile(const char *filename, const char *schema, const uint8_t *serdata, size_t serdatalen);

#ifdef __cplusplus
}
Expand Down
4 changes: 3 additions & 1 deletion libs/dfi/include/dfi_log_util.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@
#ifndef _DFI_LOG_UTIL_H_
#define _DFI_LOG_UTIL_H_

#include "celix_dfi_export.h"

#ifdef __cplusplus
extern "C" {
#endif
Expand All @@ -34,7 +36,7 @@ typedef void (*logf_ft)(void *handle, int level, const char *file, int line, con
static void *g_logHandle = NULL; \
static int g_currentLogLevel = 1; \
\
void cmp ## _logSetup(logf_ft logf, void *handle, int currentLogLevel) { \
CELIX_DFI_EXPORT void cmp ## _logSetup(logf_ft logf, void *handle, int currentLogLevel) { \
g_currentLogLevel = currentLogLevel; \
g_logHandle = handle; \
g_logf = logf; \
Expand Down
11 changes: 6 additions & 5 deletions libs/dfi/include/dyn_common.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
#include <sys/queue.h>

#include "dfi_log_util.h"
#include "celix_dfi_export.h"

#ifdef __cplusplus
extern "C" {
Expand All @@ -42,12 +43,12 @@ struct namval_entry {
TAILQ_ENTRY(namval_entry) entries;
};

int dynCommon_parseName(FILE *stream, char **result);
int dynCommon_parseNameAlsoAccept(FILE *stream, const char *acceptedChars, char **result);
int dynCommon_parseNameValue(FILE *stream, char **name, char **value);
int dynCommon_eatChar(FILE *stream, int c);
CELIX_DFI_EXPORT int dynCommon_parseName(FILE *stream, char **result);
CELIX_DFI_EXPORT int dynCommon_parseNameAlsoAccept(FILE *stream, const char *acceptedChars, char **result);
CELIX_DFI_EXPORT int dynCommon_parseNameValue(FILE *stream, char **name, char **value);
CELIX_DFI_EXPORT int dynCommon_eatChar(FILE *stream, int c);

void dynCommon_clearNamValHead(struct namvals_head *head);
CELIX_DFI_EXPORT void dynCommon_clearNamValHead(struct namvals_head *head);

#ifdef __cplusplus
}
Expand Down
27 changes: 14 additions & 13 deletions libs/dfi/include/dyn_function.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@

#include "dyn_type.h"
#include "dfi_log_util.h"
#include "celix_dfi_export.h"

#ifdef __cplusplus
extern "C" {
Expand Down Expand Up @@ -54,29 +55,29 @@ enum dyn_function_argument_meta {
DYN_FUNCTION_ARGUMENT_META__OUTPUT = 3
};

int dynFunction_parse(FILE *descriptorStream, struct types_head *refTypes, dyn_function_type **dynFunc);
int dynFunction_parseWithStr(const char *descriptor, struct types_head *refTypes, dyn_function_type **dynFunc);
CELIX_DFI_EXPORT int dynFunction_parse(FILE *descriptorStream, struct types_head *refTypes, dyn_function_type **dynFunc);
CELIX_DFI_EXPORT int dynFunction_parseWithStr(const char *descriptor, struct types_head *refTypes, dyn_function_type **dynFunc);

int dynFunction_nrOfArguments(dyn_function_type *dynFunc);
dyn_type *dynFunction_argumentTypeForIndex(dyn_function_type *dynFunc, int argumentNr);
enum dyn_function_argument_meta dynFunction_argumentMetaForIndex(dyn_function_type *dynFunc, int argumentNr);
dyn_type * dynFunction_returnType(dyn_function_type *dynFunction);
CELIX_DFI_EXPORT int dynFunction_nrOfArguments(dyn_function_type *dynFunc);
CELIX_DFI_EXPORT dyn_type *dynFunction_argumentTypeForIndex(dyn_function_type *dynFunc, int argumentNr);
CELIX_DFI_EXPORT enum dyn_function_argument_meta dynFunction_argumentMetaForIndex(dyn_function_type *dynFunc, int argumentNr);
CELIX_DFI_EXPORT dyn_type * dynFunction_returnType(dyn_function_type *dynFunction);

void dynFunction_destroy(dyn_function_type *dynFunc);
int dynFunction_call(dyn_function_type *dynFunc, void(*fn)(void), void *returnValue, void **argValues);
CELIX_DFI_EXPORT void dynFunction_destroy(dyn_function_type *dynFunc);
CELIX_DFI_EXPORT int dynFunction_call(dyn_function_type *dynFunc, void(*fn)(void), void *returnValue, void **argValues);

int dynFunction_createClosure(dyn_function_type *func, void (*bind)(void *, void **, void*), void *userData, void(**fn)(void));
int dynFunction_getFnPointer(dyn_function_type *func, void (**fn)(void));
CELIX_DFI_EXPORT int dynFunction_createClosure(dyn_function_type *func, void (*bind)(void *, void **, void*), void *userData, void(**fn)(void));
CELIX_DFI_EXPORT int dynFunction_getFnPointer(dyn_function_type *func, void (**fn)(void));

/**
* Returns whether the function has a return type.
* Will return false if return is void.
*/
bool dynFunction_hasReturn(dyn_function_type *dynFunction);
CELIX_DFI_EXPORT bool dynFunction_hasReturn(dyn_function_type *dynFunction);

// Avpr parsing
dyn_function_type * dynFunction_parseAvprWithStr(const char * avpr, const char * fqn);
dyn_function_type * dynFunction_parseAvpr(FILE * avprStream, const char * fqn);
CELIX_DFI_DEPRECATED_EXPORT dyn_function_type * dynFunction_parseAvprWithStr(const char * avpr, const char * fqn);
CELIX_DFI_DEPRECATED_EXPORT dyn_function_type * dynFunction_parseAvpr(FILE * avprStream, const char * fqn);

#ifdef __cplusplus
}
Expand Down
24 changes: 12 additions & 12 deletions libs/dfi/include/dyn_interface.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@
#include "dyn_type.h"
#include "dyn_function.h"
#include "dfi_log_util.h"

#include "celix_version.h"
#include "celix_dfi_export.h"

#ifdef __cplusplus
extern "C" {
Expand Down Expand Up @@ -57,20 +57,20 @@ struct method_entry {
TAILQ_ENTRY(method_entry) entries;
};

int dynInterface_parse(FILE *descriptor, dyn_interface_type **out);
void dynInterface_destroy(dyn_interface_type *intf);
CELIX_DFI_EXPORT int dynInterface_parse(FILE *descriptor, dyn_interface_type **out);
CELIX_DFI_EXPORT void dynInterface_destroy(dyn_interface_type *intf);

int dynInterface_getName(dyn_interface_type *intf, char **name);
int dynInterface_getVersion(dyn_interface_type *intf, celix_version_t** version);
int dynInterface_getVersionString(dyn_interface_type *intf, char **version);
int dynInterface_getHeaderEntry(dyn_interface_type *intf, const char *name, char **value);
int dynInterface_getAnnotationEntry(dyn_interface_type *intf, const char *name, char **value);
int dynInterface_methods(dyn_interface_type *intf, struct methods_head **list);
int dynInterface_nrOfMethods(dyn_interface_type *intf);
CELIX_DFI_EXPORT int dynInterface_getName(dyn_interface_type *intf, char **name);
CELIX_DFI_EXPORT int dynInterface_getVersion(dyn_interface_type *intf, celix_version_t** version);
CELIX_DFI_EXPORT int dynInterface_getVersionString(dyn_interface_type *intf, char **version);
CELIX_DFI_EXPORT int dynInterface_getHeaderEntry(dyn_interface_type *intf, const char *name, char **value);
CELIX_DFI_EXPORT int dynInterface_getAnnotationEntry(dyn_interface_type *intf, const char *name, char **value);
CELIX_DFI_EXPORT int dynInterface_methods(dyn_interface_type *intf, struct methods_head **list);
CELIX_DFI_EXPORT int dynInterface_nrOfMethods(dyn_interface_type *intf);

// Avpr parsing
dyn_interface_type * dynInterface_parseAvprWithStr(const char * avpr);
dyn_interface_type * dynInterface_parseAvpr(FILE * avprStream);
CELIX_DFI_DEPRECATED_EXPORT dyn_interface_type * dynInterface_parseAvprWithStr(const char * avpr);
CELIX_DFI_DEPRECATED_EXPORT dyn_interface_type * dynInterface_parseAvpr(FILE * avprStream);

#ifdef __cplusplus
}
Expand Down
22 changes: 11 additions & 11 deletions libs/dfi/include/dyn_message.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@
#include "dyn_common.h"
#include "dyn_type.h"
#include "dfi_log_util.h"

#include "celix_version.h"
#include "celix_dfi_export.h"

#ifdef __cplusplus
extern "C" {
Expand All @@ -46,19 +46,19 @@ DFI_SETUP_LOG_HEADER(dynMessage);
typedef struct _dyn_message_type dyn_message_type;


int dynMessage_parse(FILE *descriptor, dyn_message_type **out);
void dynMessage_destroy(dyn_message_type *msg);
CELIX_DFI_EXPORT int dynMessage_parse(FILE *descriptor, dyn_message_type **out);
CELIX_DFI_EXPORT void dynMessage_destroy(dyn_message_type *msg);

int dynMessage_getName(dyn_message_type *msg, char **name);
int dynMessage_getVersion(dyn_message_type *msg, celix_version_t** version);
int dynMessage_getVersionString(dyn_message_type *msg, char **version);
int dynMessage_getHeaderEntry(dyn_message_type *msg, const char *name, char **value);
int dynMessage_getAnnotationEntry(dyn_message_type *msg, const char *name, char **value);
int dynMessage_getMessageType(dyn_message_type *msg, dyn_type **type);
CELIX_DFI_EXPORT int dynMessage_getName(dyn_message_type *msg, char **name);
CELIX_DFI_EXPORT int dynMessage_getVersion(dyn_message_type *msg, celix_version_t** version);
CELIX_DFI_EXPORT int dynMessage_getVersionString(dyn_message_type *msg, char **version);
CELIX_DFI_EXPORT int dynMessage_getHeaderEntry(dyn_message_type *msg, const char *name, char **value);
CELIX_DFI_EXPORT int dynMessage_getAnnotationEntry(dyn_message_type *msg, const char *name, char **value);
CELIX_DFI_EXPORT int dynMessage_getMessageType(dyn_message_type *msg, dyn_type **type);

// avpr parsing
dyn_message_type * dynMessage_parseAvpr(FILE *avprDescriptorStream, const char *fqn);
dyn_message_type * dynMessage_parseAvprWithStr(const char *avprDescriptor, const char *fqn);
CELIX_DFI_DEPRECATED_EXPORT dyn_message_type * dynMessage_parseAvpr(FILE *avprDescriptorStream, const char *fqn);
CELIX_DFI_DEPRECATED_EXPORT dyn_message_type * dynMessage_parseAvprWithStr(const char *avprDescriptor, const char *fqn);

#ifdef __cplusplus
}
Expand Down
Loading