diff --git a/CMakeLists.txt b/CMakeLists.txt index 7d9c21c6..694fbfea 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -86,13 +86,16 @@ dynamically loaded plugins." OFF "SAIL_BUILD_SHARED_LIBS" ON) option(SAIL_BUILD_TYPE "Set build type: Release, Debug, or RelWithDebugInfo." "Release") option(SAIL_DEV "Enable developer mode. Be more strict when compiling source code, for example." OFF) option(SAIL_ENABLE_OPENMP "Enable OpenMP support if it's available in the compiler." ON) -option(SAIL_ENABLE_EMBED "Enable this if Sail is a submodule for another project (like a game engine or developer tool). This disables top level cmake option caching, so you'll want to manually enable where needed." OFF) +option(SAIL_ENABLE_EMBED "Enable this if Sail is a submodule for another project (like a game engine or developer tool)." OFF) option(SAIL_INSTALL_PDB "Install PDB files along with libraries." ON) option(SAIL_THIRD_PARTY_CODECS_PATH "Enable loading third-party codecs from the ';'-separated paths specified in \ the SAIL_THIRD_PARTY_CODECS_PATH environment variable." ON) option(SAIL_THREAD_SAFE "Enable working in multi-threaded environments by locking the internal context with a mutex." ON) +if (WIN32) + option(SAIL_WINDOWS_UTF8_PATHS "Convert file paths to UTF-8 on Windows." ON) +endif() -# Embedded options +# Cached String options # set(SAIL_ENABLE_CODECS "" CACHE STRING "Forcefully enable the codecs specified in this ';'-separated list. \ If an enabled codec fails to find its dependencies, the configuration process fails. \ @@ -106,10 +109,6 @@ If an enabled codec fails to find its dependencies, the configuration process fa One can also specify not just individual codecs but codec groups by their priority like that: highest-priority;xbm.") set(SAIL_OPENMP_SCHEDULE "dynamic" CACHE STRING "OpenMP scheduling algorithm.") -if (WIN32) - option(SAIL_WINDOWS_UTF8_PATHS "Convert file paths to UTF-8 on Windows." ON) -endif() - if (SAIL_ENABLE_OPENMP) sail_check_openmp() else() @@ -168,13 +167,20 @@ if (SAIL_DEV) add_definitions(-DSAIL_DEV) endif() -# Cosmetic change for developers - Brad +# Allow for building both Static and Shared libs at the same time with this +# if (SAIL_BUILD_STATIC_LIBS) set(SAIL_BUILD_STATIC_LIBS ON) + add_definitions(-DSAIL_STATIC) endif() +# When building for release, print out less debug info unless the developer requests it +# if (SAIL_BUILD_TYPE STREQUAL "Debug" OR "RelWithDebugInfo") add_definitions(-DDEBUG) + if (SAIL_BUILD_TYPE STREQUAL "RelWithDebugInfo") + add_definitions(-DINFO) + endif() endif() # Enable as many warnings as possible @@ -212,7 +218,7 @@ if (CMAKE_C_COMPILER_ID STREQUAL "GNU") string(APPEND CMAKE_SHARED_LINKER_FLAGS " " "-Wl,--no-undefined") endif() if (SAIL_BUILD_STATIC_LIBS) - string(APPEND CMAKE_STATIC_LINKER_FLAGS " " "-Wl,--no-undefined") + string(APPEND CMAKE_STATIC_LINKER_FLAGS " " "") endif() string(APPEND CMAKE_MODULE_LINKER_FLAGS " " "-Wl,--no-undefined") elseif (CMAKE_C_COMPILER_ID MATCHES "Clang") @@ -220,7 +226,7 @@ elseif (CMAKE_C_COMPILER_ID MATCHES "Clang") string(APPEND CMAKE_SHARED_LINKER_FLAGS " " "-Wl,-undefined,error") endif() if (SAIL_BUILD_STATIC_LIBS) - string(APPEND CMAKE_STATIC_LINKER_FLAGS " " "-Wl,-undefined,error") + string(APPEND CMAKE_STATIC_LINKER_FLAGS " " "") endif() string(APPEND CMAKE_MODULE_LINKER_FLAGS " " "-Wl,-undefined,error") endif() @@ -364,9 +370,10 @@ message("* CMake static link flags: ${CMAKE_STATIC_LINKER_FLAGS}") message("* CMake module link flags: ${CMAKE_MODULE_LINKER_FLAGS}") message("*") if (SAIL_ENABLE_EMBED) - message("* [*] - Embedded mode enabled. The following options can be set in any CMakeLists.txt file in") - message("* your project by using 'set(OPTION VALUE CACHE INTERNAL \"\")'. More information here:") + message("* [*] - Embedded mode enabled. The following options can be set in a CMakeLists.txt file in") + message("* a subdirectory containing Sail by using 'set(OPTION VALUE CACHE INTERNAL \"\")'. More information here:") message("* https://cmake.org/cmake/help/book/mastering-cmake/chapter/CMake%20Cache.html") + message("* NOTE: This may break Cmake-GUI documentation. See: https://github.com/HappySeaFox/sail/issues/215#issuecomment-2366814504") message("*") endif() message("* SAIL version: ${PROJECT_VERSION}") diff --git a/src/sail-codecs/avif/helpers.c b/src/sail-codecs/avif/helpers.c index 0602dcf8..be86d612 100644 --- a/src/sail-codecs/avif/helpers.c +++ b/src/sail-codecs/avif/helpers.c @@ -116,9 +116,11 @@ sail_status_t avif_private_fetch_iccp(const struct avifRWData *avif_iccp, struct if (avif_iccp->data != NULL) { SAIL_TRY(sail_alloc_iccp_from_data(avif_iccp->data, avif_iccp->size, iccp)); +#ifdef DEBUG SAIL_LOG_DEBUG("AVIF: Found ICC profile %u bytes long", (unsigned)avif_iccp->size); } else { SAIL_LOG_DEBUG("AVIF: ICC profile is not found"); +#endif } return SAIL_OK; diff --git a/src/sail-codecs/common/bmp/bmp.c b/src/sail-codecs/common/bmp/bmp.c index 67ed1ed4..bf89b718 100644 --- a/src/sail-codecs/common/bmp/bmp.c +++ b/src/sail-codecs/common/bmp/bmp.c @@ -263,11 +263,13 @@ sail_status_t bmp_private_read_init(struct sail_io *io, const struct sail_load_o SAIL_TRY(bmp_private_bit_count_to_pixel_format(bmp_state->version == SAIL_BMP_V1 ? bmp_state->v1.bit_count : bmp_state->v2.bit_count, &bmp_state->source_pixel_format)); +#ifdef DEBUG if (bmp_state->version < SAIL_BMP_V3) { SAIL_LOG_DEBUG("BMP: Version(%d)", bmp_state->version); } else { SAIL_LOG_DEBUG("BMP: Version(%d), compression(%u)", bmp_state->version, bmp_state->v3.compression); } +#endif /* Read palette. */ if (bmp_state->version == SAIL_BMP_V1) { diff --git a/src/sail-codecs/jpeg/helpers.c b/src/sail-codecs/jpeg/helpers.c index 162cb19e..5967f40a 100644 --- a/src/sail-codecs/jpeg/helpers.c +++ b/src/sail-codecs/jpeg/helpers.c @@ -148,9 +148,11 @@ sail_status_t jpeg_private_fetch_iccp(struct jpeg_decompress_struct *decompress_ JOCTET *data = NULL; unsigned data_size = 0; +#ifdef DEBUG SAIL_LOG_DEBUG("JPEG: ICC profile is %sfound", jpeg_read_icc_profile(decompress_context, &data, &data_size) ? "" : "not "); +#endif if (data != NULL && data_size > 0) { SAIL_TRY_OR_CLEANUP(sail_alloc_iccp_from_shallow_data(data, data_size, iccp), diff --git a/src/sail-codecs/jpeg/jpeg.c b/src/sail-codecs/jpeg/jpeg.c index 701e355f..73e09324 100644 --- a/src/sail-codecs/jpeg/jpeg.c +++ b/src/sail-codecs/jpeg/jpeg.c @@ -349,14 +349,18 @@ SAIL_EXPORT sail_status_t sail_codec_save_seek_next_frame_v8_jpeg(void *state, c /* Save meta data. */ if (jpeg_state->save_options->options & SAIL_OPTION_META_DATA && image->meta_data_node != NULL) { SAIL_TRY(jpeg_private_write_meta_data(jpeg_state->compress_context, image->meta_data_node)); +#ifdef DEBUG SAIL_LOG_DEBUG("JPEG: Meta data has been written"); +#endif } /* Save ICC profile. */ #ifdef SAIL_HAVE_JPEG_ICCP if (jpeg_state->save_options->options & SAIL_OPTION_ICCP && image->iccp != NULL) { jpeg_write_icc_profile(jpeg_state->compress_context, image->iccp->data, (unsigned)image->iccp->size); +#ifdef DEBUG SAIL_LOG_DEBUG("JPEG: ICC profile has been written"); +#endif } #endif diff --git a/src/sail-codecs/png/helpers.c b/src/sail-codecs/png/helpers.c index 4ff5d797..af38db6c 100644 --- a/src/sail-codecs/png/helpers.c +++ b/src/sail-codecs/png/helpers.c @@ -391,11 +391,15 @@ sail_status_t png_private_write_meta_data(png_structp png_ptr, png_infop info_pt if (meta_data->value->type == SAIL_VARIANT_TYPE_DATA) { /* Skip "Exif\0\0" if any. */ if (meta_data->value->size >= 4 && memcmp(sail_variant_to_data(meta_data->value), "Exif", 4) == 0) { +#ifdef DEBUG SAIL_LOG_DEBUG("PNG: Saving raw EXIF %u bytes long w/o header", (unsigned)meta_data->value->size - 6); +#endif png_set_eXIf_1(png_ptr, info_ptr, (png_uint_32)meta_data->value->size - 6, ((png_bytep)sail_variant_to_data(meta_data->value)) + 6); } else { +#ifdef DEBUG SAIL_LOG_DEBUG("PNG: Saving raw EXIF %u bytes long", (unsigned)meta_data->value->size); +#endif png_set_eXIf_1(png_ptr, info_ptr, (png_uint_32)meta_data->value->size, meta_data->value->value); } } else { @@ -478,9 +482,11 @@ sail_status_t png_private_fetch_iccp(png_structp png_ptr, png_infop info_ptr, st if (ok) { SAIL_TRY(sail_alloc_iccp_from_data(data, data_size, iccp)); +#ifdef DEBUG SAIL_LOG_DEBUG("PNG: Found ICC profile '%s' %u bytes long", name, data_size); } else { SAIL_LOG_DEBUG("PNG: ICC profile is not found"); +#endif } return SAIL_OK; diff --git a/src/sail-codecs/png/png.c b/src/sail-codecs/png/png.c index e6190045..c4fceb27 100644 --- a/src/sail-codecs/png/png.c +++ b/src/sail-codecs/png/png.c @@ -303,7 +303,9 @@ SAIL_EXPORT sail_status_t sail_codec_load_seek_next_frame_v8_png(void *state, st if (png_state->is_apng) { /* APNG feature: a hidden frame. */ if (!png_state->skipped_hidden && png_get_first_frame_is_hidden(png_state->png_ptr, png_state->info_ptr)) { +#ifdef DEBUG SAIL_LOG_DEBUG("PNG: Skipping hidden frame"); +#endif SAIL_TRY_OR_CLEANUP(png_private_skip_hidden_frame(png_state->first_image->bytes_per_line, png_state->first_image->height, png_state->png_ptr, @@ -531,7 +533,9 @@ SAIL_EXPORT sail_status_t sail_codec_save_seek_next_frame_v8_png(void *state, co /* Save meta data. */ if (png_state->save_options->options & SAIL_OPTION_META_DATA && image->meta_data_node != NULL) { SAIL_TRY(png_private_write_meta_data(png_state->png_ptr, png_state->info_ptr, image->meta_data_node)); +#ifdef DEBUG SAIL_LOG_DEBUG("PNG: Meta data has been written"); +#endif } png_set_IHDR(png_state->png_ptr, @@ -556,7 +560,9 @@ SAIL_EXPORT sail_status_t sail_codec_save_seek_next_frame_v8_png(void *state, co (const png_bytep)image->iccp->data, (unsigned)image->iccp->size); +#ifdef DEBUG SAIL_LOG_DEBUG("PNG: ICC profile has been written"); +#endif } /* Save palette. */ diff --git a/src/sail-codecs/tiff/tiff.c b/src/sail-codecs/tiff/tiff.c index d32f0c4f..030647a1 100644 --- a/src/sail-codecs/tiff/tiff.c +++ b/src/sail-codecs/tiff/tiff.c @@ -301,12 +301,16 @@ SAIL_EXPORT sail_status_t sail_codec_save_seek_next_frame_v8_tiff(void *state, c /* Save ICC profile. */ if (tiff_state->save_options->options & SAIL_OPTION_ICCP && image->iccp != NULL) { TIFFSetField(tiff_state->tiff, TIFFTAG_ICCPROFILE, image->iccp->size, image->iccp->data); +#ifdef DEBUG SAIL_LOG_DEBUG("TIFF: ICC profile has been saved"); +#endif } /* Save meta data. */ if (tiff_state->save_options->options & SAIL_OPTION_META_DATA && image->meta_data_node != NULL) { +#ifdef DEBUG SAIL_LOG_DEBUG("TIFF: Saving meta data"); +#endif SAIL_TRY(tiff_private_write_meta_data(tiff_state->tiff, image->meta_data_node)); } diff --git a/src/sail/codec_info.c b/src/sail/codec_info.c index edeeb4e7..2a7ee112 100644 --- a/src/sail/codec_info.c +++ b/src/sail/codec_info.c @@ -34,7 +34,9 @@ sail_status_t sail_codec_info_from_path(const char *path, const struct sail_code SAIL_CHECK_PTR(path); SAIL_CHECK_PTR(codec_info); +#ifdef DEBUG SAIL_LOG_DEBUG("Finding codec info for path '%s'", path); +#endif const char *file_name; @@ -135,7 +137,9 @@ sail_status_t sail_codec_info_by_magic_number_from_io(struct sail_io *io, const } *(hex_numbers_ptr-1) = '\0'; +#ifdef DEBUG SAIL_LOG_DEBUG("Read magic number: '%s'", hex_numbers); +#endif } /* Find the codec info. */ @@ -186,7 +190,9 @@ sail_status_t sail_codec_info_by_magic_number_from_io(struct sail_io *io, const magic_number_node = magic_number_node->next; } else { *codec_info = codec_bundle->codec_info; +#ifdef DEBUG SAIL_LOG_DEBUG("Found codec info: %s", (*codec_info)->name); +#endif return SAIL_OK; } } @@ -201,7 +207,9 @@ sail_status_t sail_codec_info_from_extension(const char *extension, const struct SAIL_CHECK_PTR(extension); SAIL_CHECK_PTR(codec_info); +#ifdef DEBUG SAIL_LOG_DEBUG("Finding codec info for extension '%s'", extension); +#endif struct sail_context *context; SAIL_TRY(fetch_global_context_guarded(&context)); @@ -222,7 +230,9 @@ sail_status_t sail_codec_info_from_extension(const char *extension, const struct if (strcmp(extension_node->string, extension_copy) == 0) { sail_free(extension_copy); *codec_info = codec_bundle->codec_info; +#ifdef DEBUG SAIL_LOG_DEBUG("Found codec info: %s", (*codec_info)->name); +#endif return SAIL_OK; } else { SAIL_LOG_TRACE("Extension mismatch '%s' != '%s'", extension_copy, extension_node->string); @@ -242,7 +252,9 @@ sail_status_t sail_codec_info_from_mime_type(const char *mime_type, const struct SAIL_CHECK_PTR(mime_type); SAIL_CHECK_PTR(codec_info); +#ifdef DEBUG SAIL_LOG_DEBUG("Finding codec info for mime type '%s'", mime_type); +#endif struct sail_context *context; SAIL_TRY(fetch_global_context_guarded(&context)); @@ -263,7 +275,9 @@ sail_status_t sail_codec_info_from_mime_type(const char *mime_type, const struct if (strcmp(mime_type_node->string, mime_type_copy) == 0) { sail_free(mime_type_copy); *codec_info = codec_bundle->codec_info; +#ifdef DEBUG SAIL_LOG_DEBUG("Found codec info: %s", (*codec_info)->name); +#endif return SAIL_OK; } else { SAIL_LOG_TRACE("MIME type mismatch '%s' != '%s'", mime_type_copy, mime_type_node->string); diff --git a/src/sail/codec_info_private.c b/src/sail/codec_info_private.c index f1e0bc35..e50f6436 100644 --- a/src/sail/codec_info_private.c +++ b/src/sail/codec_info_private.c @@ -424,7 +424,9 @@ sail_status_t codec_read_info_from_file(const char *path, struct sail_codec_info SAIL_CHECK_PTR(path); SAIL_CHECK_PTR(codec_info); +#ifdef DEBUG SAIL_LOG_DEBUG("Loading codec info '%s'", path); +#endif SAIL_TRY(codec_read_info_from_input(path, ini_parse, codec_info)); diff --git a/src/sail/context_private.c b/src/sail/context_private.c index 8c6b060a..c75a504b 100644 --- a/src/sail/context_private.c +++ b/src/sail/context_private.c @@ -55,7 +55,9 @@ static void initialize_global_context_guard_mutex_callback(void) { SAIL_TRY_OR_EXECUTE(threading_init_mutex(&global_context_guard_mutex), /* on error */ return); +#ifdef DEBUG SAIL_LOG_DEBUG("Allocated new global context mutex"); +#endif global_context_guard_mutex_initialized = true; } @@ -78,7 +80,9 @@ static sail_status_t add_dll_directory(const char *path) { SAIL_CHECK_PTR(path); +#ifdef DEBUG SAIL_LOG_DEBUG("Add '%s' to the DLL search paths", path); +#endif wchar_t *path_w; SAIL_TRY(sail_to_wchar(path, &path_w)); @@ -160,11 +164,13 @@ static const char* client_codecs_path(void) { env = getenv("SAIL_THIRD_PARTY_CODECS_PATH"); #endif +#ifdef DEBUG if (env == NULL) { SAIL_LOG_DEBUG("SAIL_THIRD_PARTY_CODECS_PATH environment variable is not set. Not loading codecs from it"); } else { SAIL_LOG_DEBUG("SAIL_THIRD_PARTY_CODECS_PATH environment variable is set. Loading codecs from '%s'", env); } +#endif return env; } @@ -203,7 +209,9 @@ static sail_status_t allocate_global_context(struct sail_context **context) { if (global_context == NULL) { SAIL_TRY(alloc_context(&global_context)); +#ifdef DEBUG SAIL_LOG_DEBUG("Allocated new context %p", global_context); +#endif } *context = global_context; @@ -229,7 +237,9 @@ static sail_status_t preload_codecs(struct sail_context *context) { SAIL_TRY(lock_context()); +#ifdef DEBUG SAIL_LOG_DEBUG("Preloading codecs"); +#endif for (struct sail_codec_bundle_node *codec_bundle_node = context->codec_bundle_node; codec_bundle_node != NULL; codec_bundle_node = codec_bundle_node->next) { const struct sail_codec *codec; @@ -314,14 +324,17 @@ static sail_status_t print_enumerated_codecs(struct sail_context *context) { return SAIL_OK; } +#ifdef DEBUG /* Print the found codec infos. */ SAIL_LOG_DEBUG("Enumerated codecs:"); +#endif +#ifdef DEBUG for (int counter = 1; codec_bundle_node != NULL; codec_bundle_node = codec_bundle_node->next, counter++) { const struct sail_codec_info *codec_info = codec_bundle_node->codec_bundle->codec_info; - SAIL_LOG_DEBUG("%d. [p%d] %s [%s] %s", counter, codec_info->priority, codec_info->name, codec_info->description, codec_info->version); } +#endif return SAIL_OK; } @@ -335,7 +348,9 @@ static sail_status_t add_lib_subdir_to_dll_search_path(const char *codecs_path) SAIL_TRY(sail_concat(&full_path_to_lib, 2, codecs_path, "\\lib")); if (!sail_is_dir(full_path_to_lib)) { +#ifdef DEBUG SAIL_LOG_DEBUG("Optional DLL directory '%s' doesn't exist, so not loading DLLs from it", full_path_to_lib); +#endif sail_free(full_path_to_lib); return SAIL_OK; } @@ -349,7 +364,9 @@ static sail_status_t add_lib_subdir_to_dll_search_path(const char *codecs_path) SAIL_TRY(sail_concat(&full_path_to_lib, 2, codecs_path, "/lib")); if (!sail_is_dir(full_path_to_lib)) { +#ifdef DEBUG SAIL_LOG_DEBUG("Optional LIB directory '%s' doesn't exist, so not updating LD_LIBRARY_PATH with it", full_path_to_lib); +#endif sail_free(full_path_to_lib); return SAIL_OK; } @@ -366,7 +383,9 @@ static sail_status_t add_lib_subdir_to_dll_search_path(const char *codecs_path) } sail_free(full_path_to_lib); +#ifdef DEBUG SAIL_LOG_DEBUG("Set LD_LIBRARY_PATH to '%s'", combined_ld_library_path); +#endif if (setenv("LD_LIBRARY_PATH", combined_ld_library_path, true) != 0) { SAIL_LOG_ERROR("Failed to update library search path: %s", strerror(errno)); @@ -459,7 +478,9 @@ static sail_status_t enumerate_codecs_in_paths(struct sail_context *context, con SAIL_TRY(add_lib_subdir_to_dll_search_path(codecs_path)); +#ifdef DEBUG SAIL_LOG_DEBUG("Enumerating codecs in '%s'", codecs_path); +#endif #ifdef SAIL_WIN32 const char *plugs_info_mask = "\\*.codec.info"; @@ -495,7 +516,9 @@ static sail_status_t enumerate_codecs_in_paths(struct sail_context *context, con SAIL_TRY_OR_EXECUTE(build_full_path(codecs_path, data.cFileName, &full_path), /* on error */ continue); +#ifdef DEBUG SAIL_LOG_DEBUG("Found codec info '%s'", data.cFileName); +#endif if (build_codec_bundle_from_codec_info_path(full_path, &codec_bundle_node) == SAIL_OK) { *last_codec_bundle_node = codec_bundle_node; @@ -534,7 +557,9 @@ static sail_status_t enumerate_codecs_in_paths(struct sail_context *context, con bool is_codec_info = strstr(full_path, ".codec.info") != NULL; if (is_codec_info) { +#ifdef DEBUG SAIL_LOG_DEBUG("Found codec info '%s'", dir->d_name); +#endif if (build_codec_bundle_from_codec_info_path(full_path, &codec_bundle_node) == SAIL_OK) { *last_codec_bundle_node = codec_bundle_node; @@ -660,10 +685,14 @@ static sail_status_t init_context_impl(struct sail_context *context) { if (env == NULL) { our_codecs_path = sail_codecs_path(); +#ifdef DEBUG SAIL_LOG_DEBUG("SAIL_CODECS_PATH environment variable is not set. Loading codecs from '%s'", our_codecs_path); +#endif } else { our_codecs_path = env; +#ifdef DEBUG SAIL_LOG_DEBUG("SAIL_CODECS_PATH environment variable is set. Loading codecs from '%s'", env); +#endif } /* Construct a list of paths to search. */ @@ -707,6 +736,7 @@ static void print_no_codecs_found(void) { static void print_build_statistics(void) { +#ifdef INFO SAIL_LOG_INFO("Version: %s", SAIL_VERSION_STRING); #ifdef SAIL_VCPKG @@ -738,6 +768,7 @@ static void print_build_statistics(void) { #else SAIL_LOG_INFO("SAIL_THIRD_PARTY_CODECS_PATH: disabled"); #endif +#endif } /* Initializes the context and loads all the codec info files if the context is not initialized. */ @@ -751,9 +782,6 @@ static sail_status_t init_context(struct sail_context *context, int flags) { context->initialized = true; - /* Time counter. */ - uint64_t start_time = sail_now(); - print_build_statistics(); /* Always search DLLs in the sail.dll location so custom codecs can hold dependencies there. */ @@ -778,7 +806,12 @@ static sail_status_t init_context(struct sail_context *context, int flags) { SAIL_TRY(preload_codecs(context)); } +#ifdef DEBUG + /* Time counter. */ + uint64_t start_time = sail_now(); + SAIL_LOG_DEBUG("Initialized in %lu ms.", (unsigned long)(sail_now() - start_time)); +#endif return SAIL_OK; } @@ -791,7 +824,9 @@ sail_status_t destroy_global_context(void) { SAIL_TRY(lock_context()); +#ifdef DEBUG SAIL_LOG_DEBUG("Destroyed context %p", global_context); +#endif destroy_context(global_context); global_context = NULL; @@ -848,7 +883,9 @@ sail_status_t sail_unload_codecs_private(void) { if (global_context == NULL) { unlock_context(); +#ifdef DEBUG SAIL_LOG_DEBUG("Context doesn't exist so not unloading codecs from it"); +#endif return SAIL_OK; } @@ -870,7 +907,9 @@ sail_status_t sail_unload_codecs_private(void) { SAIL_TRY(unlock_context()); +#ifdef DEBUG SAIL_LOG_DEBUG("Unloaded codecs number: %d", counter); +#endif return SAIL_OK; } diff --git a/src/sail/io_file.c b/src/sail/io_file.c index 2cc554c3..56af0164 100644 --- a/src/sail/io_file.c +++ b/src/sail/io_file.c @@ -186,7 +186,9 @@ static sail_status_t alloc_io_file(const char *path, const char *mode, struct sa SAIL_CHECK_PTR(mode); SAIL_CHECK_PTR(io); +#ifdef DEBUG SAIL_LOG_DEBUG("Opening file '%s' in '%s' mode", path, mode); +#endif /* Try to open the file first */ FILE *fptr; diff --git a/src/sail/io_memory.c b/src/sail/io_memory.c index 85d0823c..5cc9a368 100644 --- a/src/sail/io_memory.c +++ b/src/sail/io_memory.c @@ -245,7 +245,9 @@ sail_status_t sail_alloc_io_read_memory(const void *buffer, size_t length, struc SAIL_CHECK_PTR(buffer); SAIL_CHECK_PTR(io); +#ifdef DEBUG SAIL_LOG_DEBUG("Opening memory buffer of size %lu for reading", length); +#endif struct sail_io *io_local; SAIL_TRY(sail_alloc_io(&io_local)); @@ -281,7 +283,9 @@ sail_status_t sail_alloc_io_read_write_memory(void *buffer, size_t length, struc SAIL_CHECK_PTR(buffer); SAIL_CHECK_PTR(io); +#ifdef DEBUG SAIL_LOG_DEBUG("Opening memory buffer of size %lu for reading/writing", length); +#endif struct sail_io *io_local; SAIL_TRY(sail_alloc_io(&io_local)); diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 1b9448a8..d932af53 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -14,4 +14,6 @@ add_subdirectory(sail-dump) add_subdirectory(sail-common) add_subdirectory(sail) add_subdirectory(sail-manip) -add_subdirectory(bindings/c++) +if (SAIL_BUILD_BINDINGS) + add_subdirectory(bindings/c++) +endif()