Skip to content

Commit

Permalink
Cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
Stephane Gouache committed Apr 19, 2024
1 parent cad1c6e commit 6d382d1
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 24 deletions.
8 changes: 4 additions & 4 deletions .github/workflows/hosted-ninja-vcpkg_submod.yml
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,8 @@ jobs:
uses: lukka/run-cmake@v10
with:
configurePreset: 'ninja-multi-vcpkg'
#buildPreset: 'ninja-vcpkg-release'
buildPreset: 'ninja-vcpkg-debug'
buildPreset: 'ninja-vcpkg-release'
#buildPreset: 'ninja-vcpkg-debug'
testPreset: 'test-release'

- name: List $RUNNER_WORKSPACE after build
Expand All @@ -82,5 +82,5 @@ jobs:
uses: actions/upload-artifact@v3
with:
name: binary-${{ matrix.os }}
#path: builds/ninja-multi-vcpkg/Release/*
path: builds/ninja-multi-vcpkg/Debug/*
path: builds/ninja-multi-vcpkg/Release/*
#path: builds/ninja-multi-vcpkg/Debug/*
4 changes: 2 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,14 @@ project(khiops-gcs)
# Find dependencies provided by vcpkg (via vcpkg.cmake)
find_package(google_cloud_cpp_storage CONFIG REQUIRED)
find_package(spdlog REQUIRED)
find_package(Threads)

add_library(khiopsdriver_file_gcs MODULE src/gcsplugin.cpp)
add_executable(KhiopsPluginTest src/khiopsplugintest.cpp)

target_link_libraries(KhiopsPluginTest PRIVATE dl)

target_link_libraries(khiopsdriver_file_gcs
PRIVATE google-cloud-cpp::storage spdlog::spdlog Threads::Threads)
PRIVATE google-cloud-cpp::storage spdlog::spdlog_header_only)

# Debugging WIN compilation
add_executable(MainTest src/maintest.cpp)
Expand Down
8 changes: 7 additions & 1 deletion src/gcsplugin.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,13 @@
#include <cstdlib>

#if defined(__unix__) || defined(__unix) || \
(defined(__APPLE__) && defined(__MACH__))
(defined(__APPLE__) && defined(__MACH__))
#define __unix_or_mac__
#else
#define __windows__
#endif

#ifdef __unix_or_mac__
#define VISIBLE __attribute__((visibility("default")))
#else
/* Windows Visual C++ only */
Expand Down
32 changes: 15 additions & 17 deletions src/khiopsplugintest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,13 @@
#include <string.h>

#if defined(__unix__) || defined(__unix) || \
(defined(__APPLE__) && defined(__MACH__))
(defined(__APPLE__) && defined(__MACH__))
#define __unix_or_mac__
#else
#define __windows__
#endif

#ifdef __unix_or_mac__
#include <unistd.h>
#include <dlfcn.h>
#else
Expand Down Expand Up @@ -61,8 +67,7 @@ int main(int argc, char* argv[])
if (!library_handle)
{
fprintf(stderr, "Error while loading library %s", argv[1]);
#if defined(__unix__) || defined(__unix) || \
(defined(__APPLE__) && defined(__MACH__))
#ifdef __unix_or_mac__
fprintf(stderr, " (%s). ", dlerror());
#else
fwprintf(stderr, L" (0x%x). ", GetLastError());
Expand Down Expand Up @@ -155,39 +160,35 @@ void usage()

void* load_shared_library(const char* library_name)
{
#if defined(WIN32)
#ifdef __windows__
void* handle = (void*)LoadLibrary(library_name);
return handle;
#elif defined(__unix__) || defined(__unix) || \
(defined(__APPLE__) && defined(__MACH__))
#elif defined(__unix_or_mac__)
return dlopen(library_name, RTLD_NOW);
#endif
}

int free_shared_library(void* library_handle)
{
#if defined(_MSC_VER) | defined(_WIN32)
#ifdef __windows__
return FreeLibrary((HINSTANCE)library_handle);
#elif defined(__unix__) || defined(__unix) || \
(defined(__APPLE__) && defined(__MACH__))
#elif defined(__unix_or_mac__)
return dlclose(library_handle);
#endif
}

void* get_shared_library_function(void* library_handle, const char* function_name, int mandatory)
{
void* ptr;
#if defined(WIN32)
#ifdef __windows__
ptr = (void*)GetProcAddress((HINSTANCE)library_handle, function_name);
#elif defined(__unix__) || defined(__unix) || \
(defined(__APPLE__) && defined(__MACH__))
#elif defined(__unix_or_mac__)
ptr = dlsym(library_handle, function_name);
#endif
if (ptr == NULL && mandatory)
{
global_error = 1;
#if defined(__unix__) || defined(__unix) || \
(defined(__APPLE__) && defined(__MACH__))
#ifdef __unix_or_mac__
fprintf(stderr, "Unable to load %s (%s)\n", function_name, dlerror());
#else
fprintf(stderr, "Unable to load %s", function_name);
Expand Down Expand Up @@ -244,12 +245,9 @@ void test_read(const char* file_name_input, void* file, long long int maxBytes=3
void do_test(const char* file_name_input, const char* file_name_output, const char* file_name_local)
{
printf("Starting test\n");
fflush(NULL);
// Basic information of the scheme
printf("scheme: %s\n", ptr_driver_getScheme());
fflush(NULL);
printf("is read-only: %d\n", ptr_driver_isReadOnly());
fflush(NULL);

/*
// Check existence of directory
Expand Down

0 comments on commit 6d382d1

Please sign in to comment.