Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

sync-with-eclipse-ecal-2024-10-18 #79

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 4 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
22 changes: 0 additions & 22 deletions .github/workflows/build-macos.yml
Original file line number Diff line number Diff line change
Expand Up @@ -212,28 +212,6 @@ jobs:
ECAL_THIRDPARTY_BUILD_PROTOBUF: "OFF"
BUILD_SHARED_LIBS: "OFF"
CMAKE_BUILD_TYPE: "Release"
########################################
- name: "monitoring_only"
########################################
ECAL_CORE_HAS_PROTOBUF: "ON"
ECAL_CORE_BUILD_SAMPLES: "ON"
ECAL_CORE_BUILD_TESTS: "ON"
ECAL_CORE_CONFIGURATION: "OFF"
ECAL_CORE_COMMAND_LINE: "OFF"
ECAL_CORE_REGISTRATION: "ON"
ECAL_CORE_REGISTRATION_SHM: "OFF"
ECAL_CORE_MONITORING: "ON"
ECAL_CORE_PUBLISHER: "OFF"
ECAL_CORE_SUBSCRIBER: "OFF"
ECAL_CORE_SERVICE: "OFF"
ECAL_CORE_TIMEPLUGIN: "OFF"
ECAL_CORE_TRANSPORT_UDP: "OFF"
ECAL_CORE_TRANSPORT_TCP: "OFF"
ECAL_CORE_TRANSPORT_SHM: "OFF"
ECAL_CORE_NPCAP_SUPPORT: "OFF"
ECAL_THIRDPARTY_BUILD_PROTOBUF: "OFF"
BUILD_SHARED_LIBS: "OFF"
CMAKE_BUILD_TYPE: "Release"

steps:
- name: Install Dependencies
Expand Down
22 changes: 0 additions & 22 deletions .github/workflows/build-ubuntu.yml
Original file line number Diff line number Diff line change
Expand Up @@ -212,28 +212,6 @@ jobs:
ECAL_THIRDPARTY_BUILD_PROTOBUF: "OFF"
BUILD_SHARED_LIBS: "OFF"
CMAKE_BUILD_TYPE: "Release"
########################################
- name: "monitoring_only"
########################################
ECAL_CORE_HAS_PROTOBUF: "ON"
ECAL_CORE_BUILD_SAMPLES: "ON"
ECAL_CORE_BUILD_TESTS: "ON"
ECAL_CORE_CONFIGURATION: "OFF"
ECAL_CORE_COMMAND_LINE: "OFF"
ECAL_CORE_REGISTRATION: "ON"
ECAL_CORE_REGISTRATION_SHM: "OFF"
ECAL_CORE_MONITORING: "ON"
ECAL_CORE_PUBLISHER: "OFF"
ECAL_CORE_SUBSCRIBER: "OFF"
ECAL_CORE_SERVICE: "OFF"
ECAL_CORE_TIMEPLUGIN: "OFF"
ECAL_CORE_TRANSPORT_UDP: "OFF"
ECAL_CORE_TRANSPORT_TCP: "OFF"
ECAL_CORE_TRANSPORT_SHM: "OFF"
ECAL_CORE_NPCAP_SUPPORT: "OFF"
ECAL_THIRDPARTY_BUILD_PROTOBUF: "OFF"
BUILD_SHARED_LIBS: "OFF"
CMAKE_BUILD_TYPE: "Release"

runs-on: ${{ matrix.os }}

Expand Down
21 changes: 0 additions & 21 deletions .github/workflows/build-windows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -203,27 +203,6 @@ jobs:
ECAL_CORE_NPCAP_SUPPORT: "OFF"
BUILD_SHARED_LIBS: "OFF"
CMAKE_BUILD_TYPE: "Release"
########################################
- name: "monitoring_only"
########################################
ECAL_CORE_HAS_PROTOBUF: "ON"
ECAL_CORE_BUILD_SAMPLES: "ON"
ECAL_CORE_BUILD_TESTS: "ON"
ECAL_CORE_CONFIGURATION: "OFF"
ECAL_CORE_COMMAND_LINE: "OFF"
ECAL_CORE_REGISTRATION: "ON"
ECAL_CORE_REGISTRATION_SHM: "OFF"
ECAL_CORE_MONITORING: "ON"
ECAL_CORE_PUBLISHER: "OFF"
ECAL_CORE_SUBSCRIBER: "OFF"
ECAL_CORE_SERVICE: "OFF"
ECAL_CORE_TIMEPLUGIN: "OFF"
ECAL_CORE_TRANSPORT_UDP: "OFF"
ECAL_CORE_TRANSPORT_TCP: "OFF"
ECAL_CORE_TRANSPORT_SHM: "OFF"
ECAL_CORE_NPCAP_SUPPORT: "OFF"
BUILD_SHARED_LIBS: "OFF"
CMAKE_BUILD_TYPE: "Release"

steps:
- name: Checkout
Expand Down
1 change: 1 addition & 0 deletions build/windows/nanopb/compile-nanopb.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
python compile-nanopb.py --nano_pb_path c:\nanopb\nanopb-0.4.9 --ecal_repository "..\..\.."
112 changes: 112 additions & 0 deletions build/windows/nanopb/compile-nanopb.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@
import sys
import re
import subprocess
import logging
from pathlib import Path
import shutil
import argparse

def setup_logging():
"""Sets up the logging configuration."""
logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s')


def list_files(directory: Path, extension: str) -> list[Path]:
"""Returns a list of files with specific extension in the given directory."""
if not directory.exists():
logging.error(f"Directory {directory} does not exist.")
return []
return list(directory.glob(f"*{extension}"))


def copy_files(source_dir: Path, target_dir: Path, file_types: list[str]):
"""Copies files of specific types from source to target directory."""
target_dir.mkdir(parents=True, exist_ok=True)
for file_type in file_types:
for file in source_dir.glob(file_type):
try:
shutil.copy2(file, target_dir)
logging.info(f"Copied {file.name} to {target_dir}")
except Exception as e:
logging.error(f"Error copying {file.name} to {target_dir}: {e}")


def check_nanopb_compiler_exists(compiler_path: Path):
"""Checks if the nanopb_generator exists."""
if not compiler_path.exists():
logging.error(f"nanopb generator not found at {compiler_path}")
sys.exit(1)


def run_nanopb_generator(proto_files: list[Path], compiler: Path, ecal_pb_base_path: Path, ecal_pb_sub_path: Path, target_dir: Path):
"""Runs the nanopb generator for each proto file."""
for proto_file_path in proto_files:
proto_file_name = proto_file_path.name

command = [
str(compiler),
"-I" + str(ecal_pb_base_path),
"-I" + str(ecal_pb_base_path / ecal_pb_sub_path),
"-D" + str(target_dir / ecal_pb_sub_path),
"-e" + ".npb",
proto_file_name
]

logging.info(f"Running: {' '.join(command)}")

try:
result = subprocess.run(command, check=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True, cwd=proto_file_path.parent)
logging.info(f"Success: {proto_file_name} processed.")
logging.debug(result.stdout)
except subprocess.CalledProcessError as e:
logging.error(f"Error running nanopb_generator for {proto_file_name}: {e.stderr}")


def main(nano_pb_path: Path, ecal_repository: Path):
setup_logging()

# Define paths based on the provided arguments
ecal_pb_base_path = Path(ecal_repository / "ecal/core_pb/src")
ecal_pb_sub_path = Path("ecal/core/pb")
ecal_target_path = Path("../../core/src/serialization/nanopb")

# Combine paths and list .proto files
proto_files_dir = ecal_pb_base_path / ecal_pb_sub_path
ecal_pb_files = list_files(proto_files_dir, ".proto")

# Check if nanopb generator exists
nano_pb_compiler = nano_pb_path / "generator-bin/nanopb_generator.exe"
check_nanopb_compiler_exists(nano_pb_compiler)

# Check if any .proto files are found
if not ecal_pb_files:
logging.error(f"No .proto files found in {proto_files_dir}")
sys.exit(1)

# Prepare target directory
absolute_target_path = (ecal_pb_base_path / ecal_target_path).resolve()
absolute_target_path.mkdir(parents=True, exist_ok=True)

# Copy nanopb common decoder and encoder to target nanopb directory
target_nanopb_dir = absolute_target_path
copy_files(nano_pb_path, target_nanopb_dir, ["*.c", "*.h"])

# Run nanopb_generator for each .proto file
run_nanopb_generator(ecal_pb_files, nano_pb_compiler, ecal_pb_base_path, ecal_pb_sub_path, absolute_target_path)


if __name__ == "__main__":
# Set up argument parsing
parser = argparse.ArgumentParser(description="Process nanopb and eCAL protobuf files.")
parser.add_argument("--nano_pb_path", type=Path, required=True, help="Path to the nanopb directory")
parser.add_argument("--ecal_repository", type=Path, required=True, help="Path to the eCAL repository")

# Parse the arguments
args = parser.parse_args()

# Resolve paths to absolute paths to support relative paths
nano_pb_path = Path(args.nano_pb_path).resolve()
ecal_repository = Path(args.ecal_repository).resolve()

# Call the main function with resolved absolute paths
main(nano_pb_path, ecal_repository)
81 changes: 57 additions & 24 deletions ecal/core/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ set(ecal_config_src
src/config/ecal_cmd_parser.cpp
src/config/ecal_config.cpp
src/config/ecal_config_initializer.cpp
src/config/transport_layer.cpp
src/types/ecal_custom_data_types.cpp
)
if (ECAL_CORE_CONFIGURATION)
Expand Down Expand Up @@ -192,6 +193,8 @@ if(ECAL_CORE_MONITORING)
set(ecal_monitoring_src
src/monitoring/ecal_monitoring_def.cpp
src/monitoring/ecal_monitoring_def.h
src/monitoring/ecal_monitoring_filter.cpp
src/monitoring/ecal_monitoring_filter.h
src/monitoring/ecal_monitoring_impl.cpp
src/monitoring/ecal_monitoring_impl.h
)
Expand Down Expand Up @@ -286,6 +289,7 @@ if (ECAL_CORE_REGISTRATION)
set(ecal_registration_src
src/registration/ecal_process_registration.cpp
src/registration/ecal_process_registration.h
src/registration/ecal_registration.cpp
src/registration/ecal_registration_provider.cpp
src/registration/ecal_registration_provider.h
src/registration/ecal_registration_receiver.cpp
Expand All @@ -296,6 +300,8 @@ if (ECAL_CORE_REGISTRATION)
src/registration/ecal_registration_sample_applier_gates.h
src/registration/ecal_registration_sample_applier_user.cpp
src/registration/ecal_registration_sample_applier_user.h
src/registration/ecal_registration_timeout_provider.cpp
src/registration/ecal_registration_timeout_provider.h
src/registration/ecal_registration_sender.h
src/registration/udp/ecal_registration_receiver_udp.cpp
src/registration/udp/ecal_registration_receiver_udp.h
Expand Down Expand Up @@ -323,29 +329,29 @@ endif()
# serialization
######################################
set(ecal_serialization_src
src/serialization/nanopb/nanopb/pb.h
src/serialization/nanopb/nanopb/pb_common.c
src/serialization/nanopb/nanopb/pb_common.h
src/serialization/nanopb/nanopb/pb_decode.c
src/serialization/nanopb/nanopb/pb_decode.h
src/serialization/nanopb/nanopb/pb_encode.c
src/serialization/nanopb/nanopb/pb_encode.h
src/serialization/nanopb/ecal.pb.c
src/serialization/nanopb/ecal.pb.h
src/serialization/nanopb/host.pb.c
src/serialization/nanopb/host.pb.h
src/serialization/nanopb/layer.pb.c
src/serialization/nanopb/layer.pb.h
src/serialization/nanopb/logging.pb.c
src/serialization/nanopb/logging.pb.h
src/serialization/nanopb/monitoring.pb.c
src/serialization/nanopb/monitoring.pb.h
src/serialization/nanopb/process.pb.c
src/serialization/nanopb/process.pb.h
src/serialization/nanopb/service.pb.c
src/serialization/nanopb/service.pb.h
src/serialization/nanopb/topic.pb.c
src/serialization/nanopb/topic.pb.h
src/serialization/nanopb/pb.h
src/serialization/nanopb/pb_common.c
src/serialization/nanopb/pb_common.h
src/serialization/nanopb/pb_decode.c
src/serialization/nanopb/pb_decode.h
src/serialization/nanopb/pb_encode.c
src/serialization/nanopb/pb_encode.h
src/serialization/nanopb/ecal/core/pb/ecal.npb.c
src/serialization/nanopb/ecal/core/pb/ecal.npb.h
src/serialization/nanopb/ecal/core/pb/host.npb.c
src/serialization/nanopb/ecal/core/pb/host.npb.h
src/serialization/nanopb/ecal/core/pb/layer.npb.c
src/serialization/nanopb/ecal/core/pb/layer.npb.h
src/serialization/nanopb/ecal/core/pb/logging.npb.c
src/serialization/nanopb/ecal/core/pb/logging.npb.h
src/serialization/nanopb/ecal/core/pb/monitoring.npb.c
src/serialization/nanopb/ecal/core/pb/monitoring.npb.h
src/serialization/nanopb/ecal/core/pb/process.npb.c
src/serialization/nanopb/ecal/core/pb/process.npb.h
src/serialization/nanopb/ecal/core/pb/service.npb.c
src/serialization/nanopb/ecal/core/pb/service.npb.h
src/serialization/nanopb/ecal/core/pb/topic.npb.c
src/serialization/nanopb/ecal/core/pb/topic.npb.h
src/serialization/ecal_serialize_common.cpp
src/serialization/ecal_serialize_common.h
src/serialization/ecal_serialize_logging.cpp
Expand Down Expand Up @@ -404,6 +410,7 @@ endif()
set(ecal_util_src
src/util/ecal_expmap.h
src/util/ecal_thread.h
src/util/expanding_vector.h
src/util/frequency_calculator.h
src/util/getenvvar.h
)
Expand Down Expand Up @@ -440,6 +447,27 @@ if (WIN32)
)
endif()

######################################
# builder
######################################
set (ecal_builder_src
src/config/builder/logging_attribute_builder.cpp
src/config/builder/monitoring_attribute_builder.cpp
src/config/builder/registration_attribute_builder.cpp
src/logging/config/builder/udp_attribute_builder.cpp
src/pubsub/config/builder/reader_attribute_builder.cpp
src/pubsub/config/builder/writer_attribute_builder.cpp
src/readwrite/config/builder/shm_attribute_builder.cpp
src/readwrite/config/builder/tcp_attribute_builder.cpp
src/readwrite/config/builder/udp_attribute_builder.cpp
src/readwrite/tcp/config/builder/data_reader_tcp_attribute_builder.cpp
src/readwrite/udp/config/builder/udp_attribute_builder.cpp
src/registration/config/builder/udp_shm_attribute_builder.cpp
src/registration/config/builder/sample_applier_attribute_builder.cpp
src/registration/udp/config/builder/udp_attribute_builder.cpp
)


######################################
# c interface
######################################
Expand All @@ -452,6 +480,7 @@ set(ecal_c_src
src/cimpl/ecal_monitoring_cimpl.cpp
src/cimpl/ecal_process_cimpl.cpp
src/cimpl/ecal_publisher_cimpl.cpp
src/cimpl/ecal_registration_cimpl.cpp
src/cimpl/ecal_server_cimpl.cpp
src/cimpl/ecal_subscriber_cimpl.cpp
src/cimpl/ecal_time_cimpl.cpp
Expand Down Expand Up @@ -480,6 +509,7 @@ set(ecal_header_cmn
include/ecal/config/subscriber.h
include/ecal/ecal.h
include/ecal/ecal_callback.h
include/ecal/ecal_config.h
include/ecal/ecal_client.h
include/ecal/ecal_core.h
include/ecal/ecal_deprecate.h
Expand All @@ -491,6 +521,7 @@ set(ecal_header_cmn
include/ecal/ecal_monitoring.h
include/ecal/ecal_process.h
include/ecal/ecal_process_severity.h
include/ecal/ecal_registration.h
include/ecal/ecal_publisher.h
include/ecal/ecal_server.h
include/ecal/ecal_service_info.h
Expand All @@ -511,6 +542,7 @@ set(ecal_header_cimpl
include/ecal/cimpl/ecal_monitoring_cimpl.h
include/ecal/cimpl/ecal_process_cimpl.h
include/ecal/cimpl/ecal_publisher_cimpl.h
include/ecal/cimpl/ecal_registration_cimpl.h
include/ecal/cimpl/ecal_server_cimpl.h
include/ecal/cimpl/ecal_service_info_cimpl.h
include/ecal/cimpl/ecal_subscriber_cimpl.h
Expand Down Expand Up @@ -558,6 +590,7 @@ set(ecal_sources
${ecal_time_src}
${ecal_util_src}
${ecal_cmn_src}
${ecal_builder_src}
${ecal_header_cmn}
${ecal_header_msg}
)
Expand Down Expand Up @@ -673,8 +706,8 @@ target_link_libraries(${PROJECT_NAME}
target_include_directories(${PROJECT_NAME}
PRIVATE
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/src>
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/src/serialization/>
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/src/serialization/nanopb>
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/src/serialization/nanopb/nanopb>
PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
$<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}/include/>
Expand Down
Loading
Loading