The symbols are now more or less properly exported

Clang strips everything, some symbols left in GCC for some reason...
This commit is contained in:
Paul Ferrand 2020-01-18 17:32:30 +01:00
parent 3599940283
commit d3cb36dcc8
3 changed files with 55 additions and 46 deletions

View file

@ -13,7 +13,6 @@ set (LV2PLUGIN_TTL_SRC_FILES
)
add_library (${LV2PLUGIN_PRJ_NAME} SHARED ${PROJECT_NAME}.c ${LV2PLUGIN_TTL_SRC_FILES})
target_link_libraries (${LV2PLUGIN_PRJ_NAME} ${PROJECT_NAME}::${PROJECT_NAME})
target_include_directories(${LV2PLUGIN_PRJ_NAME} PRIVATE .)
sfizz_enable_lto_if_needed (${LV2PLUGIN_PRJ_NAME})
# Remove the "lib" prefix, rename the target name and build it in the .lv build dir

View file

@ -20,23 +20,18 @@ target_include_directories (sfizz_parser PUBLIC external)
target_link_libraries (sfizz_parser PRIVATE absl::strings)
# Sfizz core library
add_library (sfizz STATIC ${SFIZZ_SOURCES} sfizz/sfizz_wrapper.cpp)
target_include_directories (sfizz PUBLIC sfizz)
add_library(sfizz STATIC)
target_sources(sfizz PRIVATE ${SFIZZ_SOURCES} sfizz/sfizz_wrapper.cpp)
target_include_directories (sfizz PUBLIC .)
target_include_directories (sfizz PUBLIC external)
target_link_libraries (sfizz PRIVATE sfizz_parser)
find_package (Threads REQUIRED)
target_link_libraries (sfizz PUBLIC absl::strings)
target_link_libraries (sfizz PRIVATE absl::flat_hash_map Threads::Threads)
target_include_directories (sfizz PRIVATE external)
target_link_libraries (sfizz PRIVATE absl::strings absl::span sfizz_parser absl::flat_hash_map Threads::Threads)
sfizz_link_libsndfile(sfizz)
sfizz_enable_lto_if_needed(sfizz)
if (UNIX AND NOT APPLE)
target_link_libraries (sfizz PUBLIC atomic)
target_link_libraries (sfizz PRIVATE atomic)
endif()
sfizz_enable_lto_if_needed(sfizz_parser)
sfizz_enable_lto_if_needed(sfizz)
add_library (sfizz::parser ALIAS sfizz_parser)
add_library (sfizz::sfizz ALIAS sfizz)
@ -45,9 +40,14 @@ add_library (sfizz::sfizz ALIAS sfizz)
# Shared library and installation target
if (SFIZZ_SHARED)
add_library (sfizz_shared SHARED sfizz.h)
add_library (sfizz_shared SHARED)
target_compile_options(sfizz_shared PRIVATE -DSFIZZ_EXPORT_SYMBOLS)
target_sources(sfizz_shared PRIVATE ${SFIZZ_SOURCES} sfizz/sfizz_wrapper.cpp)
target_include_directories (sfizz_shared PRIVATE .)
target_link_libraries (sfizz_shared PRIVATE sfizz_parser absl::flat_hash_map Threads::Threads absl::strings absl::span)
set_target_properties (sfizz_shared PROPERTIES OUTPUT_NAME sfizz PUBLIC_HEADER sfizz.h)
target_link_libraries (sfizz_shared sfizz::sfizz)
sfizz_link_libsndfile(sfizz_shared)
sfizz_enable_lto_if_needed(sfizz_shared)
configure_file (${PROJECT_SOURCE_DIR}/scripts/sfizz.pc.in sfizz.pc @ONLY)
if (UNIX)
include (GNUInstallDirs)

View file

@ -32,6 +32,16 @@
extern "C" {
#endif
#if defined SFIZZ_EXPORT_SYMBOLS
#if defined _WIN32
#define SFIZZ_EXPORTED_API
#else
#define SFIZZ_EXPORTED_API __attribute__ ((visibility ("default")))
#endif
#else
#define SFIZZ_EXPORTED_API
#endif
typedef struct sfizz_synth_t sfizz_synth_t;
typedef enum {
SFIZZ_OVERSAMPLING_X1 = 1,
@ -46,13 +56,13 @@ typedef enum {
*
* @return sfizz_synth_t*
*/
sfizz_synth_t* sfizz_create_synth();
SFIZZ_EXPORTED_API sfizz_synth_t* sfizz_create_synth();
/**
* @brief Frees an existing sfizz synth.
*
* @param synth The synth to destroy
*/
void sfizz_free(sfizz_synth_t* synth);
SFIZZ_EXPORTED_API void sfizz_free(sfizz_synth_t* synth);
/**
* @brief Loads an SFZ file. The file path can be absolute or relative. All
@ -66,7 +76,7 @@ void sfizz_free(sfizz_synth_t* synth);
* @return true when file loading went OK.
* @return false if some error occured while loading.
*/
bool sfizz_load_file(sfizz_synth_t* synth, const char* path);
SFIZZ_EXPORTED_API bool sfizz_load_file(sfizz_synth_t* synth, const char* path);
/**
* @brief Returns the number of regions in the currently loaded SFZ file.
@ -75,7 +85,7 @@ bool sfizz_load_file(sfizz_synth_t* synth, const char* path);
*
* @return int the number of regions
*/
int sfizz_get_num_regions(sfizz_synth_t* synth);
SFIZZ_EXPORTED_API int sfizz_get_num_regions(sfizz_synth_t* synth);
/**
* @brief Returns the number of groups in the currently loaded SFZ file.
*
@ -83,7 +93,7 @@ int sfizz_get_num_regions(sfizz_synth_t* synth);
*
* @return int the number of groups
*/
int sfizz_get_num_groups(sfizz_synth_t* synth);
SFIZZ_EXPORTED_API int sfizz_get_num_groups(sfizz_synth_t* synth);
/**
* @brief Returns the number of masters in the currently loaded SFZ file.
*
@ -91,7 +101,7 @@ int sfizz_get_num_groups(sfizz_synth_t* synth);
*
* @return int the number of masters
*/
int sfizz_get_num_masters(sfizz_synth_t* synth);
SFIZZ_EXPORTED_API int sfizz_get_num_masters(sfizz_synth_t* synth);
/**
* @brief Returns the number of curves in the currently loaded SFZ file.
*
@ -99,7 +109,7 @@ int sfizz_get_num_masters(sfizz_synth_t* synth);
*
* @return int the number of curves
*/
int sfizz_get_num_curves(sfizz_synth_t* synth);
SFIZZ_EXPORTED_API int sfizz_get_num_curves(sfizz_synth_t* synth);
/**
* @brief Returns the number of preloaded samples for the current SFZ file.
*
@ -107,7 +117,7 @@ int sfizz_get_num_curves(sfizz_synth_t* synth);
*
* @return int the number of preloaded samples
*/
size_t sfizz_get_num_preloaded_samples(sfizz_synth_t* synth);
SFIZZ_EXPORTED_API size_t sfizz_get_num_preloaded_samples(sfizz_synth_t* synth);
/**
* @brief Returns the number of active voices. Note that this function is a
* basic indicator and does not aim to be perfect. In particular, it
@ -118,7 +128,7 @@ size_t sfizz_get_num_preloaded_samples(sfizz_synth_t* synth);
*
* @return size_t the number of playing voices
*/
int sfizz_get_num_active_voices(sfizz_synth_t* synth);
SFIZZ_EXPORTED_API int sfizz_get_num_active_voices(sfizz_synth_t* synth);
/**
* @brief Sets the expected number of samples per block. If unsure, give an
@ -128,7 +138,7 @@ int sfizz_get_num_active_voices(sfizz_synth_t* synth);
* @param synth The synth
* @param samples_per_block the number of samples per block
*/
void sfizz_set_samples_per_block(sfizz_synth_t* synth, int samples_per_block);
SFIZZ_EXPORTED_API void sfizz_set_samples_per_block(sfizz_synth_t* synth, int samples_per_block);
/**
* @brief Sets the sample rate for the synth. This is the output sample
* rate. This setting does not affect the internal processing.
@ -136,7 +146,7 @@ void sfizz_set_samples_per_block(sfizz_synth_t* synth, int samples_per_block);
* @param synth The synth
* @param sample_rate the sample rate
*/
void sfizz_set_sample_rate(sfizz_synth_t* synth, float sample_rate);
SFIZZ_EXPORTED_API void sfizz_set_sample_rate(sfizz_synth_t* synth, float sample_rate);
/**
* @brief Send a note on event to the synth. As with all MIDI events, this
@ -148,7 +158,7 @@ void sfizz_set_sample_rate(sfizz_synth_t* synth, float sample_rate);
* @param note_number the MIDI note number
* @param velocity the MIDI velocity
*/
void sfizz_send_note_on(sfizz_synth_t* synth, int delay, int note_number, char velocity);
SFIZZ_EXPORTED_API void sfizz_send_note_on(sfizz_synth_t* synth, int delay, int note_number, char velocity);
/**
* @brief Send a note off event to the synth. As with all MIDI events, this
@ -162,7 +172,7 @@ void sfizz_send_note_on(sfizz_synth_t* synth, int delay, int note_number, char v
* @param note_number the MIDI note number
* @param velocity the MIDI velocity
*/
void sfizz_send_note_off(sfizz_synth_t* synth, int delay, int note_number, char velocity);
SFIZZ_EXPORTED_API void sfizz_send_note_off(sfizz_synth_t* synth, int delay, int note_number, char velocity);
/**
* @brief Send a CC event to the synth. As with all MIDI events, this needs
@ -174,7 +184,7 @@ void sfizz_send_note_off(sfizz_synth_t* synth, int delay, int note_number, char
* @param cc_number the MIDI CC number
* @param cc_value the MIDI CC value
*/
void sfizz_send_cc(sfizz_synth_t* synth, int delay, int cc_number, char cc_value);
SFIZZ_EXPORTED_API void sfizz_send_cc(sfizz_synth_t* synth, int delay, int cc_number, char cc_value);
/**
* @brief Send a pitch wheel event. As with all MIDI events, this needs
* to happen before the call to sfizz_render_block in each block and
@ -184,7 +194,7 @@ void sfizz_send_cc(sfizz_synth_t* synth, int delay, int cc_number, char cc_value
* @param delay The delay
* @param pitch The pitch
*/
void sfizz_send_pitch_wheel(sfizz_synth_t* synth, int delay, int pitch);
SFIZZ_EXPORTED_API void sfizz_send_pitch_wheel(sfizz_synth_t* synth, int delay, int pitch);
/**
* @brief Send an aftertouch event. (CURRENTLY UNIMPLEMENTED)
@ -193,7 +203,7 @@ void sfizz_send_pitch_wheel(sfizz_synth_t* synth, int delay, int pitch);
* @param delay
* @param aftertouch
*/
void sfizz_send_aftertouch(sfizz_synth_t* synth, int delay, char aftertouch);
SFIZZ_EXPORTED_API void sfizz_send_aftertouch(sfizz_synth_t* synth, int delay, char aftertouch);
/**
* @brief Send a tempo event. (CURRENTLY UNIMPLEMENTED)
@ -202,7 +212,7 @@ void sfizz_send_aftertouch(sfizz_synth_t* synth, int delay, char aftertouch);
* @param delay The delay
* @param seconds_per_quarter The seconds per quarter
*/
void sfizz_send_tempo(sfizz_synth_t* synth, int delay, float seconds_per_quarter);
SFIZZ_EXPORTED_API void sfizz_send_tempo(sfizz_synth_t* synth, int delay, float seconds_per_quarter);
/**
* @brief Render a block audio data into a stereo channel. No other channel
@ -219,7 +229,7 @@ void sfizz_send_tempo(sfizz_synth_t* synth, int delay, float seconds_per_quarter
* @param num_frames number of frames to fill. This should be less than
* or equal to the expected samples_per_block.
*/
void sfizz_render_block(sfizz_synth_t* synth, float** channels, int num_channels, int num_frames);
SFIZZ_EXPORTED_API void sfizz_render_block(sfizz_synth_t* synth, float** channels, int num_channels, int num_frames);
/**
* @brief Get the size of the preloaded data. This returns the number of
@ -229,7 +239,7 @@ void sfizz_render_block(sfizz_synth_t* synth, float** channels, int num_channels
*
* @return the preloaded data size in sizeof(floats)
*/
unsigned int sfizz_get_preload_size(sfizz_synth_t* synth);
SFIZZ_EXPORTED_API unsigned int sfizz_get_preload_size(sfizz_synth_t* synth);
/**
* @brief Sets the size of the preloaded data in number of floats (not
* bytes). This will disable the callbacks for the duration of the
@ -238,7 +248,7 @@ unsigned int sfizz_get_preload_size(sfizz_synth_t* synth);
* @param synth The synth
* @param[in] preload_size The preload size
*/
void sfizz_set_preload_size(sfizz_synth_t* synth, unsigned int preload_size);
SFIZZ_EXPORTED_API void sfizz_set_preload_size(sfizz_synth_t* synth, unsigned int preload_size);
/**
* @brief Get the internal oversampling rate. This is the sampling rate of
@ -249,7 +259,7 @@ void sfizz_set_preload_size(sfizz_synth_t* synth, unsigned int preload_size);
*
* @return The internal sample rate of the engine
*/
sfizz_oversampling_factor_t sfizz_get_oversampling_factor(sfizz_synth_t* synth);
SFIZZ_EXPORTED_API sfizz_oversampling_factor_t sfizz_get_oversampling_factor(sfizz_synth_t* synth);
/**
* @brief Set the internal oversampling rate. This is the sampling rate of
* the engine, not the output or expected rate of the calling
@ -270,7 +280,7 @@ sfizz_oversampling_factor_t sfizz_get_oversampling_factor(sfizz_synth_t* synth);
*
* @return True if the oversampling factor was correct
*/
bool sfizz_set_oversampling_factor(sfizz_synth_t* synth, sfizz_oversampling_factor_t oversampling);
SFIZZ_EXPORTED_API bool sfizz_set_oversampling_factor(sfizz_synth_t* synth, sfizz_oversampling_factor_t oversampling);
/**
* @brief Set the global instrument volume.
@ -278,7 +288,7 @@ bool sfizz_set_oversampling_factor(sfizz_synth_t* synth, sfizz_oversampling_fact
* @param synth The synth
* @param volume the new volume
*/
void sfizz_set_volume(sfizz_synth_t* synth, float volume);
SFIZZ_EXPORTED_API void sfizz_set_volume(sfizz_synth_t* synth, float volume);
/**
* @brief Get the global instrument volume.
@ -287,7 +297,7 @@ void sfizz_set_volume(sfizz_synth_t* synth, float volume);
*
* @return float the instrument volume
*/
float sfizz_get_volume(sfizz_synth_t* synth);
SFIZZ_EXPORTED_API float sfizz_get_volume(sfizz_synth_t* synth);
/**
* @brief Sets the number of voices used by the synth
@ -295,14 +305,14 @@ float sfizz_get_volume(sfizz_synth_t* synth);
* @param synth The synth
* @param num_voices The number voices
*/
void sfizz_set_num_voices(sfizz_synth_t* synth, int num_voices);
SFIZZ_EXPORTED_API void sfizz_set_num_voices(sfizz_synth_t* synth, int num_voices);
/**
* @brief Returns the number of voices
*
* @param synth
* @return num_voices
*/
int sfizz_get_num_voices(sfizz_synth_t* synth);
SFIZZ_EXPORTED_API int sfizz_get_num_voices(sfizz_synth_t* synth);
/**
* @brief Get the number of allocated buffers from the synth.
@ -311,7 +321,7 @@ int sfizz_get_num_voices(sfizz_synth_t* synth);
*
* @return The number of buffers held by the synth
*/
int sfizz_get_num_buffers(sfizz_synth_t* synth);
SFIZZ_EXPORTED_API int sfizz_get_num_buffers(sfizz_synth_t* synth);
/**
* @brief Get the number of bytes allocated from the synth. Note that this
* value can be less than the actual memory usage since it only
@ -321,20 +331,20 @@ int sfizz_get_num_buffers(sfizz_synth_t* synth);
*
* @return The number of bytes held by the synth in buffers;
*/
int sfizz_get_num_bytes(sfizz_synth_t* synth);
SFIZZ_EXPORTED_API int sfizz_get_num_bytes(sfizz_synth_t* synth);
/**
* @brief Enables freewheeling on the synth.
*
* @param synth
*/
void sfizz_enable_freewheeling(sfizz_synth_t* synth);
SFIZZ_EXPORTED_API void sfizz_enable_freewheeling(sfizz_synth_t* synth);
/**
* @brief Disables freewheeling on the synth.
*
* @param synth
*/
void sfizz_disable_freewheeling(sfizz_synth_t* synth);
SFIZZ_EXPORTED_API void sfizz_disable_freewheeling(sfizz_synth_t* synth);
/**
* @brief Get a comma separated list of unknown opcodes. The caller has to free()
* the string returned. This function allocates memory, do not call on the
@ -343,7 +353,7 @@ void sfizz_disable_freewheeling(sfizz_synth_t* synth);
* @param synth
* @return char*
*/
char* sfizz_get_unknown_opcodes(sfizz_synth_t* synth);
SFIZZ_EXPORTED_API char* sfizz_get_unknown_opcodes(sfizz_synth_t* synth);
/**
* @brief Check if the SFZ should be reloaded.
@ -355,7 +365,7 @@ char* sfizz_get_unknown_opcodes(sfizz_synth_t* synth);
* been modified since the sfz file was loaded.
* @return false
*/
bool sfizz_should_reload_file(sfizz_synth_t* synth);
SFIZZ_EXPORTED_API bool sfizz_should_reload_file(sfizz_synth_t* synth);
#ifdef __cplusplus
}