Skip to content

Commit

Permalink
Merge pull request eclipse-iceoryx#471 from elBoberido/iox2-460-add-d…
Browse files Browse the repository at this point in the history
…ev-permission-flag-to-cmake

[eclipse-iceoryx#460] Add Rust feature flag to cmake
  • Loading branch information
elBoberido authored Oct 16, 2024
2 parents b930be6 + a390fe3 commit 558c727
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 1 deletion.
36 changes: 36 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,19 @@ macro(add_param)
message(STATUS " ${ADD_PARAM_NAME}: ${${ADD_PARAM_NAME}} (Description: ${ADD_PARAM_DESCRIPTION})")
endmacro()

set(IOX2_RUST_FEATURES "")
macro(add_rust_feature)
set(ONE_VALUE_ARGS NAME DESCRIPTION DEFAULT_VALUE RUST_FEATURE)
cmake_parse_arguments(ADD_RUST_FEATURE "" "${ONE_VALUE_ARGS}" "" ${ARGN})

option(${ADD_RUST_FEATURE_NAME} ${ADD_RUST_FEATURE_DESCRIPTION} ${ADD_RUST_FEATURE_DEFAULT_VALUE})
message(STATUS " ${ADD_RUST_FEATURE_NAME}: ${${ADD_RUST_FEATURE_NAME}} (Description: ${ADD_RUST_FEATURE_DESCRIPTION})")

if(${ADD_RUST_FEATURE_NAME})
list(APPEND IOX2_RUST_FEATURES ${ADD_RUST_FEATURE_RUST_FEATURE})
endif()
endmacro()

message(STATUS "iceoryx2 options:")

add_option(
Expand Down Expand Up @@ -68,6 +81,29 @@ add_param(
DEFAULT_VALUE ""
)

message(STATUS "iceoryx2 Rust feature flags:")

add_rust_feature(
NAME IOX2_FEATURE_DEV_PERMISSIONS
DESCRIPTION "The permissions of all resources will be set to read, write, execute for everyone."
DEFAULT_VALUE OFF
RUST_FEATURE "iceoryx2/dev_permissions"
)

add_rust_feature(
NAME IOX2_FEATURE_LOGGER_LOG
DESCRIPTION "Enables https://crates.io/crates/log as default logger"
DEFAULT_VALUE OFF
RUST_FEATURE "iceoryx2/logger_log"
)

add_rust_feature(
NAME IOX2_FEATURE_LOGGER_TRACING
DESCRIPTION "Enables https://crates.io/crates/tracing as default logger"
DEFAULT_VALUE OFF
RUST_FEATURE "iceoryx2/logger_tracing"
)

if(SANITIZERS)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fsanitize=address -fsanitize=undefined")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize=address -fsanitize=undefined")
Expand Down
1 change: 1 addition & 0 deletions doc/release-notes/iceoryx2-unreleased.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@

* Add Event-Multiplexer `WaitSet` [#390](https://github.com/eclipse-iceoryx/iceoryx2/issues/390)
* Add `PeriodicTimer` into POSIX building blocks [#425](https://github.com/eclipse-iceoryx/iceoryx2/issues/425)
* Developer permissions for resources [#460](https://github.com/eclipse-iceoryx/iceoryx2/issues/460)

### Bugfixes

Expand Down
9 changes: 8 additions & 1 deletion iceoryx2-ffi/c/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -64,10 +64,17 @@ if(WIN32)
list(APPEND ICEORYX2_C_LIB_ARTIFACTS ${ICEORYX2_C_SHARED_LIB_DLL_FILE})
endif()

set(RUST_FEATURE_FLAGS "")
list(LENGTH IOX2_RUST_FEATURES IOX2_RUST_FEATURES_COUNT)
if(IOX2_RUST_FEATURES_COUNT GREATER 0)
list(JOIN IOX2_RUST_FEATURES "," RUST_FEATURE_FLAGS_STRING)
set(RUST_FEATURE_FLAGS "--features=${RUST_FEATURE_FLAGS_STRING}")
endif()

# run cargo
add_custom_target(
iceoryx2-build-step ALL
COMMAND cargo build ${RUST_BUILD_TYPE_FLAG} --package iceoryx2-ffi --target-dir=${RUST_TARGET_DIR} ${RUST_TARGET_TRIPLET_FLAG}
COMMAND cargo build ${RUST_BUILD_TYPE_FLAG} ${RUST_FEATURE_FLAGS} --package iceoryx2-ffi --target-dir=${RUST_TARGET_DIR} ${RUST_TARGET_TRIPLET_FLAG}
BYPRODUCTS
${ICEORYX2_C_INCLUDE_DIR}/iox2/iceoryx2.h
${ICEORYX2_C_STATIC_LIB_LINK_FILE}
Expand Down

0 comments on commit 558c727

Please sign in to comment.