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

[#460] Add Rust feature flag to cmake #471

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
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
2 changes: 1 addition & 1 deletion Cargo.Bazel.lock
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"checksum": "f4b0efe0add514e7053794a25f1bdfb4b5425e10bb77c6212ba5157d14fca9d3",
"checksum": "d7b1759c5d28cbeb3fff8b9da5ca81261aa8c593891b9eff7d3c554d07b4c8dd",
"crates": {
"addr2line 0.24.2": {
"name": "addr2line",
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
Loading