Skip to content

Commit 558c727

Browse files
authored
Merge pull request #471 from elBoberido/iox2-460-add-dev-permission-flag-to-cmake
[#460] Add Rust feature flag to cmake
2 parents b930be6 + a390fe3 commit 558c727

File tree

3 files changed

+45
-1
lines changed

3 files changed

+45
-1
lines changed

CMakeLists.txt

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,19 @@ macro(add_param)
3636
message(STATUS " ${ADD_PARAM_NAME}: ${${ADD_PARAM_NAME}} (Description: ${ADD_PARAM_DESCRIPTION})")
3737
endmacro()
3838

39+
set(IOX2_RUST_FEATURES "")
40+
macro(add_rust_feature)
41+
set(ONE_VALUE_ARGS NAME DESCRIPTION DEFAULT_VALUE RUST_FEATURE)
42+
cmake_parse_arguments(ADD_RUST_FEATURE "" "${ONE_VALUE_ARGS}" "" ${ARGN})
43+
44+
option(${ADD_RUST_FEATURE_NAME} ${ADD_RUST_FEATURE_DESCRIPTION} ${ADD_RUST_FEATURE_DEFAULT_VALUE})
45+
message(STATUS " ${ADD_RUST_FEATURE_NAME}: ${${ADD_RUST_FEATURE_NAME}} (Description: ${ADD_RUST_FEATURE_DESCRIPTION})")
46+
47+
if(${ADD_RUST_FEATURE_NAME})
48+
list(APPEND IOX2_RUST_FEATURES ${ADD_RUST_FEATURE_RUST_FEATURE})
49+
endif()
50+
endmacro()
51+
3952
message(STATUS "iceoryx2 options:")
4053

4154
add_option(
@@ -68,6 +81,29 @@ add_param(
6881
DEFAULT_VALUE ""
6982
)
7083

84+
message(STATUS "iceoryx2 Rust feature flags:")
85+
86+
add_rust_feature(
87+
NAME IOX2_FEATURE_DEV_PERMISSIONS
88+
DESCRIPTION "The permissions of all resources will be set to read, write, execute for everyone."
89+
DEFAULT_VALUE OFF
90+
RUST_FEATURE "iceoryx2/dev_permissions"
91+
)
92+
93+
add_rust_feature(
94+
NAME IOX2_FEATURE_LOGGER_LOG
95+
DESCRIPTION "Enables https://crates.io/crates/log as default logger"
96+
DEFAULT_VALUE OFF
97+
RUST_FEATURE "iceoryx2/logger_log"
98+
)
99+
100+
add_rust_feature(
101+
NAME IOX2_FEATURE_LOGGER_TRACING
102+
DESCRIPTION "Enables https://crates.io/crates/tracing as default logger"
103+
DEFAULT_VALUE OFF
104+
RUST_FEATURE "iceoryx2/logger_tracing"
105+
)
106+
71107
if(SANITIZERS)
72108
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fsanitize=address -fsanitize=undefined")
73109
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize=address -fsanitize=undefined")

doc/release-notes/iceoryx2-unreleased.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313

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

1718
### Bugfixes
1819

iceoryx2-ffi/c/CMakeLists.txt

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,10 +64,17 @@ if(WIN32)
6464
list(APPEND ICEORYX2_C_LIB_ARTIFACTS ${ICEORYX2_C_SHARED_LIB_DLL_FILE})
6565
endif()
6666

67+
set(RUST_FEATURE_FLAGS "")
68+
list(LENGTH IOX2_RUST_FEATURES IOX2_RUST_FEATURES_COUNT)
69+
if(IOX2_RUST_FEATURES_COUNT GREATER 0)
70+
list(JOIN IOX2_RUST_FEATURES "," RUST_FEATURE_FLAGS_STRING)
71+
set(RUST_FEATURE_FLAGS "--features=${RUST_FEATURE_FLAGS_STRING}")
72+
endif()
73+
6774
# run cargo
6875
add_custom_target(
6976
iceoryx2-build-step ALL
70-
COMMAND cargo build ${RUST_BUILD_TYPE_FLAG} --package iceoryx2-ffi --target-dir=${RUST_TARGET_DIR} ${RUST_TARGET_TRIPLET_FLAG}
77+
COMMAND cargo build ${RUST_BUILD_TYPE_FLAG} ${RUST_FEATURE_FLAGS} --package iceoryx2-ffi --target-dir=${RUST_TARGET_DIR} ${RUST_TARGET_TRIPLET_FLAG}
7178
BYPRODUCTS
7279
${ICEORYX2_C_INCLUDE_DIR}/iox2/iceoryx2.h
7380
${ICEORYX2_C_STATIC_LIB_LINK_FILE}

0 commit comments

Comments
 (0)