Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
30 changes: 15 additions & 15 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,23 +39,23 @@ jobs:
if: matrix.os == 'macos-latest'
run: brew update-reset && brew install boost

- name: Configure CMake
run: >
cmake -G Ninja -B build -DCMAKE_BUILD_TYPE=${{ matrix.release }} -DENABLE_TESTING=ON -DENABLE_EXAMPLES=ON
# - name: Configure CMake
# run: >
# cmake -G Ninja -B build -DCMAKE_BUILD_TYPE=${{ matrix.release }} -DENABLE_TESTING=ON -DENABLE_EXAMPLES=ON

- name: Build
run: cmake --build build --config ${{ matrix.release }}

- name: Install
if: matrix.os != 'windows-latest'
run: sudo cmake --install build --config ${{ matrix.release }}
# - name: Build
# run: cmake --build build --config ${{ matrix.release }}

# - name: Install
# if: matrix.os == 'windows-latest'
# run: cmake --install build --config ${{ matrix.release }}
# if: matrix.os != 'windows-latest'
# run: sudo cmake --install build --config ${{ matrix.release }}

# # - name: Install
# # if: matrix.os == 'windows-latest'
# # run: cmake --install build --config ${{ matrix.release }}

- name: Test
run: ctest --test-dir build --output-on-failure
# - name: Test
# run: ctest --test-dir build --output-on-failure

- name: Examples
run: ./build/libtokamap/examples/simple_mapper/simple_mapper
# - name: Examples
# run: ./build/libtokamap/examples/simple_mapper/simple_mapper
26 changes: 17 additions & 9 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ list(
)

# Specify C++ standard for all targets
set( CMAKE_CXX_STANDARD 17 )
set( CMAKE_CXX_STANDARD 20 )
set( CMAKE_CXX_STANDARD_REQUIRED ON )
set( CMAKE_CXX_EXTENSIONS OFF )

Expand All @@ -42,24 +42,32 @@ if( POLICY CMP0167 )
endif()

# Set project options
include( StandardSettings )
include( StaticAnalyzers )
include( Utils )

option( ENABLE_TESTING "Enable unit tests for the project (from the `test` subfolder)." OFF )
option( ENABLE_PROFILING "Enable profiling for the project." OFF )
option( FETCH_LIBTOKAMAP "Fetch libtokamap as a dependency." OFF )

# add_clang_format_target()

if( ENABLE_TESTING )
enable_testing()
endif()

include( FetchContent )
FetchContent_Declare(
libtokamap
GIT_REPOSITORY git@github.com:jholloc/libtokamap.git
GIT_TAG main
)
if( FETCH_LIBTOKAMAP )
include( FetchContent )
FetchContent_Declare(
libtokamap
GIT_REPOSITORY https://github.com/ukaea/libtokamap.git
GIT_TAG develop
CMAKE_ARGS -DENABLE_TESTS=OFF -DENABLE_PROFILING=${ENABLE_PROFILING}
)

FetchContent_MakeAvailable( libtokamap )
FetchContent_MakeAvailable( libtokamap )
else()
add_clang_format_target()
endif()

find_package( UDA REQUIRED )
add_subdirectory( mapping_plugin )
56 changes: 0 additions & 56 deletions cmake/StandardSettings.cmake

This file was deleted.

2 changes: 1 addition & 1 deletion cmake/plugins.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ macro( uda_plugin )
"${ARGN}"
)

set( BUILT_PLUGINS ${BUILT_PLUGINS} "${PLUGIN_NAME}" PARENT_SCOPE )
set( BUILT_PLUGINS ${BUILT_PLUGINS} "${PLUGIN_NAME}" )

if( NOT PLUGIN_VERSION )
set( PLUGIN_VERSION "0.0.0" )
Expand Down
15 changes: 8 additions & 7 deletions mapping_plugin/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,7 @@

find_package( UDA 2.7.0 REQUIRED )
find_package( Boost REQUIRED )

# Specify C++ standard for all targets
set( CMAKE_CXX_STANDARD 17 )
set( CMAKE_CXX_STANDARD_REQUIRED ON )
set( CMAKE_CXX_EXTENSIONS OFF )
find_package( libtokamap REQUIRED )

set( SOURCES
src/uda_data_source.cpp
Expand All @@ -31,11 +27,13 @@ add_library( libtokamap_uda_extension ${SOURCES} )
target_include_directories( libtokamap_uda_extension PRIVATE
${CMAKE_CURRENT_LIST_DIR}/src
${CMAKE_CURRENT_LIST_DIR}/ext_include
${CMAKE_SOURCE_DIR}/libtokamap/src
)
target_link_libraries( libtokamap_uda_extension PRIVATE Boost::boost LibTokaMap::libtokamap )

find_package( Boost REQUIRED )
set( EXTRA_DEFINITIONS )
if( ENABLE_PROFILING )
list( APPEND EXTRA_DEFINITIONS -DENABLE_PROFILING )
endif()

include( plugins )
uda_plugin(
Expand All @@ -58,6 +56,8 @@ uda_plugin(
LibTokaMap::libtokamap
libtokamap_uda_extension
uda_client
EXTRA_DEFINITIONS
${EXTRA_DEFINITIONS}
)

# Unit testing setup
Expand Down Expand Up @@ -98,6 +98,7 @@ install(
)

# Generate scripts
list( GET UDA_DIR 0 UDA_HOME )
string( REGEX REPLACE ";" " " PLUGINS "${BUILT_PLUGINS}" )
configure_file(
${CMAKE_CURRENT_SOURCE_DIR}/scripts/activate-plugins.sh.in
Expand Down
1 change: 1 addition & 0 deletions mapping_plugin/config/json_mapping.cfg.in
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# Needed at runtime to find the installed mappings locations on the server side machine
# Environmental Variables are available on server after install
export UDA_MAPPING_CONFIG_PATH=@CMAKE_INSTALL_PREFIX@/etc/plugins.d/libtokamap_config.json
export UDA_MAPPING_PROFILE_FILE=@CMAKE_INSTALL_PREFIX@/etc/profile.json
4 changes: 1 addition & 3 deletions mapping_plugin/config/libtokamap_config.json.in
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
{
"mapping_directory": "@CMAKE_INSTALL_PREFIX@/etc/JSON_mappings",
"globals_schema": "@CMAKE_BINARY_DIR@/_deps/libtokamap-src/schemas/mappings.schema.json",
"mapping_schema": "@CMAKE_BINARY_DIR@/_deps/libtokamap-src/schemas/globals.schema.json",
"mapping_config_schema": "@CMAKE_BINARY_DIR@/_deps/libtokamap-src/schemas/mappings.cfg.schema.json",
"schemas_directory": "@CMAKE_BINARY_DIR@/_deps/libtokamap-src/schemas",
"cache_enabled": false,
"cache_size": 100
}
58 changes: 54 additions & 4 deletions mapping_plugin/mapping_plugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,7 @@
#include <utility>

// LibTokaMap includes
#include <handlers/mapping_handler.hpp>
#include <map_types/data_source_mapping.hpp>
#include <libtokamap.hpp>

// UDA includes
#include <clientserver/errorLog.h>
Expand All @@ -33,6 +32,7 @@

#include "uda_data_source.hpp"
#include "uda_plugin_helpers.hpp"
#include "utils/profiler.hpp"

namespace
{
Expand Down Expand Up @@ -99,6 +99,13 @@ class JSONMappingPlugin
public:
int entry_handle(IDAM_PLUGIN_INTERFACE* plugin_interface);

~JSONMappingPlugin()
{
if (m_init) {
reset(nullptr);
}
}

private:
int execute(IDAM_PLUGIN_INTERFACE* plugin_interface);
int init(IDAM_PLUGIN_INTERFACE* plugin_interface);
Expand Down Expand Up @@ -133,6 +140,10 @@ int JSONMappingPlugin::init(IDAM_PLUGIN_INTERFACE* plugin_interface)
return 0;
}

#if ENABLE_PROFILING
libtokamap::Profiler::init();
#endif

const char* config_path = getenv("UDA_MAPPING_CONFIG_PATH");
if (config_path != nullptr) {
m_mapping_handler.init(std::filesystem::path{config_path});
Expand All @@ -143,10 +154,12 @@ int JSONMappingPlugin::init(IDAM_PLUGIN_INTERFACE* plugin_interface)
auto data_source = std::make_unique<json_plugin::UDADataSource>("UDA", "get", plugin_interface->pluginList, false);
m_mapping_handler.register_data_source("UDA", std::move(data_source));

auto mastu_data_source = std::make_unique<json_plugin::UDADataSource>("CUSTOM_MASTU", "get", plugin_interface->pluginList, false);
auto mastu_data_source =
std::make_unique<json_plugin::UDADataSource>("CUSTOM_MASTU", "get", plugin_interface->pluginList, false);
m_mapping_handler.register_data_source("CUSTOM_MASTU", std::move(mastu_data_source));

auto geom_data_source = std::make_unique<json_plugin::UDADataSource>("GEOMETRY", "get", plugin_interface->pluginList, false);
auto geom_data_source =
std::make_unique<json_plugin::UDADataSource>("GEOMETRY", "get", plugin_interface->pluginList, false);
m_mapping_handler.register_data_source("GEOMETRY", std::move(geom_data_source));

m_init = true;
Expand All @@ -164,6 +177,13 @@ int JSONMappingPlugin::init(IDAM_PLUGIN_INTERFACE* plugin_interface)
int JSONMappingPlugin::reset(IDAM_PLUGIN_INTERFACE* /*plugin_interface*/) // silence unused warning
{
if (m_init) {
#if ENABLE_PROFILING
const char* profile_file = getenv("UDA_MAPPING_PROFILE_FILE");
if (profile_file != nullptr) {
libtokamap::Profiler::write(profile_file);
}
#endif

// Free Heap & reset counters if initialised
m_mapping_handler.unregister_data_source("UDA");
m_mapping_handler.unregister_data_source("CUSTOM_MASTU");
Expand Down Expand Up @@ -235,6 +255,9 @@ int JSONMappingPlugin::get(IDAM_PLUGIN_INTERFACE* plugin_interface)

auto type_index = std::type_index{typeid(void)};
switch (datatype) {
case UDA_TYPE_SHORT:
type_index = std::type_index{typeid(short)};
break;
case UDA_TYPE_INT:
type_index = std::type_index{typeid(int)};
break;
Expand All @@ -247,6 +270,33 @@ int JSONMappingPlugin::get(IDAM_PLUGIN_INTERFACE* plugin_interface)
case UDA_TYPE_STRING:
type_index = std::type_index{typeid(char)};
break;
case UDA_TYPE_UNSIGNED_LONG64:
type_index = std::type_index{typeid(uint64_t)};
break;
case UDA_TYPE_UNSIGNED_INT:
type_index = std::type_index{typeid(unsigned int)};
break;
case UDA_TYPE_LONG:
type_index = std::type_index{typeid(long)};
break;
case UDA_TYPE_UNSIGNED_CHAR:
type_index = std::type_index{typeid(unsigned char)};
break;
case UDA_TYPE_UNSIGNED_SHORT:
type_index = std::type_index{typeid(unsigned short)};
break;
case UDA_TYPE_UNSIGNED_LONG:
type_index = std::type_index{typeid(unsigned long)};
break;
case UDA_TYPE_LONG64:
type_index = std::type_index{typeid(int64_t)};
break;
case UDA_TYPE_COMPLEX:
type_index = std::type_index{typeid(COMPLEX)};
break;
case UDA_TYPE_DCOMPLEX:
type_index = std::type_index{typeid(DCOMPLEX)};
break;
default:
break;
}
Expand Down
Loading