Skip to content
Open
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
3 changes: 2 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ else()
set(KICKCAT_INSTALL_DEFAULT OFF)
endif()

# Host-only components (tests, simulation, GUI tools, ESI parser, master examples) need desktop
# Host-only components (tests, simulation, GUI tools, ESI/ENI parsers, master examples) need desktop
# deps and default ON for Linux/Windows only; embedded targets get the library + their slave example.
if (UNIX OR WIN32)
set(KICKCAT_HOST ON)
Expand All @@ -28,6 +28,7 @@ option(BUILD_UNIT_TESTS "Build unit tests" OFF)
option(BUILD_SIMULATION "Build simulation" ${KICKCAT_HOST})
option(BUILD_TOOLS "Build tools" ${KICKCAT_HOST})
option(ENABLE_ESI_PARSER "Enable ESI XML parser" ${KICKCAT_HOST})
option(ENABLE_ENI_PARSER "Enable ENI XML parser" ${KICKCAT_HOST})
option(ENABLE_AF_XDP "Enable AF_XDP socket for improved performance (requires libxdp, libbpf, clang)" OFF)
option(ENABLE_CODE_COVERAGE "Enable code coverage (requires gcovr)" OFF)
option(ENABLE_ASAN "Build with AddressSanitizer" OFF)
Expand Down
3 changes: 2 additions & 1 deletion cmake/KickCATConfig.cmake.in
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,10 @@
include(CMakeFindDependencyMacro)

set(KICKCAT_ENABLE_ESI_PARSER @ENABLE_ESI_PARSER@)
set(KICKCAT_ENABLE_ENI_PARSER @ENABLE_ENI_PARSER@)
set(KICKCAT_ENABLE_AF_XDP @ENABLE_AF_XDP@)

if(KICKCAT_ENABLE_ESI_PARSER)
if(KICKCAT_ENABLE_ESI_PARSER OR KICKCAT_ENABLE_ENI_PARSER)
find_dependency(tinyxml2 CONFIG)
endif()

Expand Down
7 changes: 4 additions & 3 deletions conan/all/conanfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ class KickCATRecipe(ConanFile):
topics = ("ethercat")
package_type = "library"
settings = "os", "compiler", "build_type", "arch"
options = {"shared": [True, False], "fPIC": [True, False], "with_esi_parser": [True, False]}
default_options = {"shared": False, "fPIC": True, "with_esi_parser": False}
options = {"shared": [True, False], "fPIC": [True, False], "with_esi_parser": [True, False], "with_eni_parser": [True, False]}
default_options = {"shared": False, "fPIC": True, "with_esi_parser": False, "with_eni_parser": False}

def export_sources(self):
# This method is used for local development to copy sources into the recipe
Expand Down Expand Up @@ -61,13 +61,14 @@ def validate(self):

def requirements(self):
self.requires("argparse/3.2")
if self.options.with_esi_parser:
if self.options.with_esi_parser or self.options.with_eni_parser:
self.requires("tinyxml2/11.0.0")


def generate(self):
tc = CMakeToolchain(self)
tc.cache_variables["ENABLE_ESI_PARSER"] = bool(self.options.with_esi_parser)
tc.cache_variables["ENABLE_ENI_PARSER"] = bool(self.options.with_eni_parser)
tc.cache_variables["BUILD_UNIT_TESTS"] = "OFF"
tc.cache_variables["BUILD_MASTER_EXAMPLES"] = "OFF"
tc.cache_variables["BUILD_SLAVE_EXAMPLES"] = "OFF"
Expand Down
4 changes: 3 additions & 1 deletion conan/conanfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ class KickCATDev(ConanFile):
options = {
"unit_tests": [True, False],
"esi_parser": [True, False],
"eni_parser": [True, False],
"simulation": [True, False],
"tools": [True, False],
"master_examples": [True, False],
Expand All @@ -21,6 +22,7 @@ class KickCATDev(ConanFile):
default_options = {
"unit_tests": False,
"esi_parser": True,
"eni_parser": True,
"simulation": True,
"tools": True,
"master_examples": True,
Expand All @@ -34,7 +36,7 @@ def requirements(self):
if self.options.unit_tests:
self.requires("gtest/1.15.0")

if self.options.esi_parser:
if self.options.esi_parser or self.options.eni_parser:
self.requires("tinyxml2/11.0.0")

if self.options.simulation:
Expand Down
13 changes: 10 additions & 3 deletions lib/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -89,12 +89,19 @@ elseif (WIN32)
set(OS_LIBRARIES npcap::npcap pthread)
endif()

if (ENABLE_ESI_PARSER)
if (ENABLE_ESI_PARSER OR ENABLE_ENI_PARSER)
find_package(tinyxml2 CONFIG REQUIRED)
list(APPEND OS_LIBRARIES tinyxml2::tinyxml2)
list(APPEND KICKCAT_SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/src/utils/xml.cc)
endif()

if (ENABLE_ESI_PARSER)
list(APPEND KICKCAT_SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/src/ESI/Parser.cc)
list(APPEND KICKCAT_SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/src/ESI/SIIBuilder.cc)
list(APPEND KICKCAT_SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/src/utils/xml.cc)
list(APPEND OS_LIBRARIES tinyxml2::tinyxml2)
endif()

if (ENABLE_ENI_PARSER)
list(APPEND KICKCAT_SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/src/ENI/Parser.cc)
endif()

if (ENABLE_AF_XDP AND LINUX)
Expand Down
15 changes: 15 additions & 0 deletions lib/include/kickcat/ENI/Parser.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#ifndef KICKCAT_ENI_PARSER_H
#define KICKCAT_ENI_PARSER_H

#include <string>

#include "kickcat/ENI/Config.h"

namespace kickcat::ENI
{
// Throw std::invalid_argument on malformed input, with the offending element path.
Config loadFile(std::string const& path);
Config loadString(std::string const& xml);
}

#endif
Loading
Loading