Skip to content

Commit

Permalink
Changed inclusion of export definition files - to be compatible with …
Browse files Browse the repository at this point in the history
…Windows and Linux
  • Loading branch information
hkhauke committed May 28, 2024
1 parent 3c00d91 commit 7f4ce70
Show file tree
Hide file tree
Showing 10 changed files with 83 additions and 22 deletions.
10 changes: 8 additions & 2 deletions cmake/common_local_lib_foot.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -480,8 +480,14 @@ if(BUILD_SHARED)
else()
message(" > Javox component library (shared)")
set(ADDITIONAL_COMPILE_DEFINITIONS_SHARED "${ADDITIONAL_COMPILE_DEFINITIONS_SHARED};JVX_MODULE_NAME=${JVX_MODULE_NAME};;JVX_COMPONENT_ACCESS_TYPE_COMPONENT=JVX_COMPONENT_ACCESS_DYNAMIC_LIB;JVX_IMPORT_DECLARATION=/*export in module file*/")
set(ADDITIONAL_LINKER_FLAGS "${ADDITIONAL_LINKER_FLAGS} ${JVX_CMAKE_LINKER_FLAGS_SHARED_EXPORT_COMPONENTS}")
set(ADDITIONAL_SOURCES ${ADDITIONAL_SOURCES} ${JVX_EXPORTS_SHARED_COMPONENT})

# Use this new macro which translates in a different way in Linux and Windows
add_export_definition_linker(LOCAL_SOURCES ADDITIONAL_LINKER_FLAGS ${JVX_EXPORTS_SHARED_COMPONENT})
# message("In my scope I: LOCAL_SOURCES = ${LOCAL_SOURCES}")
# set(ADDITIONAL_LINKER_FLAGS "${ADDITIONAL_LINKER_FLAGS} ${JVX_CMAKE_LINKER_FLAGS_SHARED_EXPORT_COMPONENTS}")
# set(ADDITIONAL_SOURCES ${ADDITIONAL_SOURCES} ${JVX_EXPORTS_SHARED_COMPONENT})
# message("In my scope II: ADDITIONAL_SOURCES = ${ADDITIONAL_SOURCES}")

set(JVX_COLLECT_COMPONENTS_MAC_BUNDLE "${JVX_COLLECT_COMPONENTS_MAC_BUNDLE};${JVX_TARGET_NAME}.${JVX_SHARED_EXTENSION}" CACHE INTERNAL "all components")
endif()

Expand Down
15 changes: 13 additions & 2 deletions cmake/linux.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,10 @@ if(JVX_GCC_LINKER_SYMBOLIC)
endif()

# Flags for shared objects with export file list
set(JVX_CMAKE_LINKER_FLAGS_SHARED_EXPORT_COMPONENTS "${JVX_CMAKE_LINKER_FLAGS_SHARED} -Wl,--retain-symbols-file=${JVX_BASE_ROOT}/software/exports/components/linux/exports.def")
set(JVX_CMAKE_LINKER_FLAGS_SHARED_EXPORT_LOCAL "${JVX_CMAKE_LINKER_FLAGS_SHARED} -Wl,--retain-symbols-file=${JVX_BASE_ROOT}/software/exports/components/linux/exports.def")
#set(JVX_CMAKE_LINKER_FLAGS_SHARED_EXPORT_COMPONENTS "${JVX_CMAKE_LINKER_FLAGS_SHARED} -Wl,--retain-symbols-file=${JVX_BASE_ROOT}/software/exports/components/linux/exports.def")
#set(JVX_CMAKE_LINKER_FLAGS_SHARED_EXPORT_LOCAL "${JVX_CMAKE_LINKER_FLAGS_SHARED} -Wl,--retain-symbols-file=${JVX_BASE_ROOT}/software/exports/components/linux/exports.def")
set(JVX_EXPORTS_SHARED_COMPONENT "${JVX_BASE_ROOT}/software/exports/components/${JVX_OS}/exports.def")
# set(JVX_EXPORTS_SHARED_LOCAL "${CMAKE_CURRENT_SOURCE_DIR}/exports/${JVX_OS}/exports.def")

# Flags for static libraries

Expand Down Expand Up @@ -119,6 +121,15 @@ set(JVX_PRE_EXIT_MATLAB_HOOK "pause(1);")
# macros
###

function(add_export_definition_linker sourceslst linkerflags fileName)

# In linux, export files are added as linker options
set(linkerflags "${linkerflags} -Wl,--retain-symbols-file=${fileName}")

# We add this def file anyway to show up in project tables
set(sourceslst "${sourceslst} ${fileName}")
endfunction(add_export_definition_linker)

# configure FFT library
macro (find_fft)
message("--> Looking for fftw library")
Expand Down
11 changes: 11 additions & 0 deletions cmake/windows.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -237,6 +237,17 @@ endif()

include(${JVX_CMAKE_DIR}/install-libs.cmake)

function(add_export_definition_linker varNameSourcesLst varNameLinkerflags varNameFile)

# message("===add_export_definition_linker===> Enter with arguments - ${varNameSourcesLst} ${varNameLinkerflags} ${varNameFile}")

# In windows, export files are added as source files. DO NOT USE /"
set(${varNameSourcesLst} ${${varNameSourcesLst}} ${varNameFile} PARENT_SCOPE)

# message("===add_export_definition_linker===> Sources with added entry, ${varNameSourcesLst} = ${${varNameSourcesLst}}")

endfunction(add_export_definition_linker)

# configure FFT library
macro (find_fft)
set(FFTW_VERSION "3.3")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,5 @@ set(LOCAL_LIBS jvx-component-templates-base_static)
set(IS_JVX_COMPONENT TRUE)

include(${JVX_CMAKE_DIR}/common_local_lib_foot.cmake)

# message(FATAL_ERROR "Hier")
5 changes: 3 additions & 2 deletions sources/jvxLibraries/ayf-embedding-proxy/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,9 @@ set(LOCAL_SOURCES
${CMAKE_CURRENT_SOURCE_DIR}/include/ayf-embedding-proxy-entries.h
${CMAKE_CURRENT_SOURCE_DIR}/include/${JVX_OS}/ayf-embedding-libs.h

${CMAKE_CURRENT_SOURCE_DIR}/src/ayf-embedding-proxy.cpp
${CMAKE_CURRENT_SOURCE_DIR}/src/exports/${JVX_OS}/exports-embedding-proxy.def)
${CMAKE_CURRENT_SOURCE_DIR}/src/ayf-embedding-proxy.cpp)

add_export_definition_linker(LOCAL_SOURCES LOCAL_LINKER_FLAGS ${CMAKE_CURRENT_SOURCE_DIR}/src/exports/${JVX_OS}/exports-embedding-proxy.def)

set(BUILD_SHARED TRUE)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,9 @@ set(LOCAL_SOURCES
${CMAKE_CURRENT_SOURCE_DIR}/include/ayf-connection-host.h
${CMAKE_CURRENT_SOURCE_DIR}/src/CayfGlobalHostClass.h
${CMAKE_CURRENT_SOURCE_DIR}/src/CayfGlobalHostClass.cpp
${CMAKE_CURRENT_SOURCE_DIR}/src/CayfConnectionHostDll.cpp
${CMAKE_CURRENT_SOURCE_DIR}/src/exports/${JVX_OS}/exports-connect-host.def)
${CMAKE_CURRENT_SOURCE_DIR}/src/CayfConnectionHostDll.cpp)

add_export_definition_linker(LOCAL_SOURCES LOCAL_LINKER_FLAGS ${CMAKE_CURRENT_SOURCE_DIR}/src/exports/${JVX_OS}/exports-connect-host.def)

set(BUILD_SHARED TRUE)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,13 @@ set(LOCAL_SOURCES

${CMAKE_CURRENT_SOURCE_DIR}/include/jvx-flutter-native.h
${CMAKE_CURRENT_SOURCE_DIR}/src/jvx-flutter-forward.cpp
${JVX_SUBPRODUCT_ROOT}/sources/jvxLibraries/jvx-flutter-native-static/exports/${JVX_OS}/exports-flutter-native.def

)

# Add the shared object export definition
add_export_definition_linker(LOCAL_SOURCES LOCAL_LINKER_FLAGS ${JVX_SUBPRODUCT_ROOT}/sources/jvxLibraries/jvx-flutter-native-static/exports/${JVX_OS}/exports-flutter-native.def)

# message(FATAL_ERROR "XYX -> ${LOCAL_SOURCES}")
set(LOCAL_LIBS jvx-flutter-native-static_static)

## ======================================================================
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,11 @@ include_directories(
# Add local sources (header files only for project workspace generation!)
set(LOCAL_SOURCES

${CMAKE_CURRENT_SOURCE_DIR}/exports/${JVX_OS}/exports-flutter-native.def
# We do not need this here!
# ${CMAKE_CURRENT_SOURCE_DIR}/exports/${JVX_OS}/exports-flutter-native.def

${CMAKE_CURRENT_SOURCE_DIR}/include/flutter_native_local.h
${CMAKE_CURRENT_SOURCE_DIR}/include/flutter_native_macros.h
${CMAKE_CURRENT_SOURCE_DIR}/include/flutter_native_api.h
${CMAKE_CURRENT_SOURCE_DIR}/include/flutter_native_host_config.h

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
#ifndef __FLUTTER_NATIVE_API_H__
#define __FLUTTER_NATIVE_API_H__

#include "flutter_native_macros.h"

JVX_OPTIONAL_EXTERN_C_START

#include "flutter_native_types.h"

// ==============================================================
Expand Down Expand Up @@ -48,25 +52,30 @@
// ==============================================================
// ==============================================================
//! Sync and asynchronous callback function to re-enter the host
int ffi_host_request_command_fwd(void* opaque_hdl, void* request_command, int async);
int ffi_host_request_command_reschedule(void* request_command);
int ffi_host_request_command_fwd(void* opaque_hdl, void* request_command, int async);
int ffi_host_request_command_reschedule(void* request_command);

// ==============================================================
// Miscfunction calls for administration
// ==============================================================
char* ffi_transfer_command(void* opaque_hdl, const char* cmd, int json_out);

// ==============================================================
// Miscfunction calls for administration
// ==============================================================
char* ffi_transfer_command(void* opaque_hdl, const char* cmd, int json_out);

char* ffi_encode_component_identification(int cpTp, int slotid, int slotsubid);

char* ffi_encode_component_identification(int cpTp, int slotid, int slotsubid);
int ffi_last_error();

int ffi_last_error();
//! Delete a buffer. The tp argument specifies the type
int ffi_host_delete(void* ptr, ffiDeleteDatatype tp);

//! Delete a buffer. The tp argument specifies the type
int ffi_host_delete(void* ptr, ffiDeleteDatatype tp);
//! Test function to run a test command via ffi bridge
int ffi_simple_call();

//! Test function to run a test command via ffi bridge
int ffi_simple_call();
// The Dart init function is not exposed via symbol file as we get access from within the flutter manually.
// We might change this in the future
// void InitDartApiDL(void* data);

JVX_OPTIONAL_EXTERN_C_STOP

//! Dll main default implementation
#define NATIVE_DLL_DEFINE_DLL_MAIN \
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#ifndef __FLUTTER_NATIVE_MACROS_H__
#define __FLUTTER_NATIVE_MACROS_H__

#ifdef JVX_DEFINE_EXTERN_C_API
#define JVX_OPTIONAL_EXTERN_C_START extern "C" {}
#define JVX_OPTIONAL_EXTERN_C_STOP }

#else

#define JVX_OPTIONAL_EXTERN_C_START
#define JVX_OPTIONAL_EXTERN_C_STOP
#endif

#endif

0 comments on commit 7f4ce70

Please sign in to comment.