Skip to content

Commit

Permalink
Merge pull request eclipse-iceoryx#2411 from elBoberido/iox-846-make-…
Browse files Browse the repository at this point in the history
…default-config-file-location-configurable

iox-eclipse-iceoryx#846 Make default config file location configurable
  • Loading branch information
elBoberido authored Jan 11, 2025
2 parents b4f81fc + 5cd467c commit f33d582
Show file tree
Hide file tree
Showing 15 changed files with 52 additions and 2 deletions.
1 change: 1 addition & 0 deletions doc/website/release-notes/iceoryx-unreleased.md
Original file line number Diff line number Diff line change
Expand Up @@ -237,6 +237,7 @@
- Fix new clang-tidy-18 warnings [#2274](https://github.com/eclipse-iceoryx/iceoryx/issues/2274)
- Mistype in readme file [#2384](https://github.com/eclipse-iceoryx/iceoryx/issues/2384)
- Typo in architecture.md [#2390](https://github.com/eclipse-iceoryx/iceoryx/issues/2390)
- Make platform paths like config location configurable via cmake [#846](https://github.com/eclipse-iceoryx/iceoryx/issues/846)

**Workflow:**

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,11 @@ configure_option(
DEFAULT_VALUE "/tmp/"
)

configure_option(
NAME IOX_PLATFORM_DEFAULT_CONFIG_LOCATION
DEFAULT_VALUE "/etc/"
)

option(IOX_PLATFORM_FEATURE_ACL "Use ACLs for access control" OFF)
message(STATUS "[i] IOX_PLATFORM_FEATURE_ACL: ${IOX_PLATFORM_FEATURE_ACL}")

Expand Down
1 change: 1 addition & 0 deletions iceoryx_platform/freertos/cmake/platform_settings.hpp.in
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ constexpr uint64_t IOX_UDS_SOCKET_MAX_MESSAGE_SIZE = 1024;
constexpr const char IOX_UDS_SOCKET_PATH_PREFIX[] = "@IOX_PLATFORM_UDS_SOCKET_PATH_PREFIX@";
constexpr const char IOX_LOCK_FILE_PATH_PREFIX[] = "@IOX_PLATFORM_LOCK_FILE_PATH_PREFIX@";
constexpr const char IOX_TEMP_DIR[] = "@IOX_PLATFORM_TEMP_DIR@";
constexpr const char IOX_DEFAULT_CONFIG_LOCATION[] = "@IOX_PLATFORM_DEFAULT_CONFIG_LOCATION@";

constexpr uint64_t MAX_USER_NAME_LENGTH = 32;
constexpr uint64_t MAX_GROUP_NAME_LENGTH = 16;
Expand Down
5 changes: 5 additions & 0 deletions iceoryx_platform/linux/cmake/IceoryxPlatformDeployment.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,11 @@ configure_option(
DEFAULT_VALUE "/tmp/"
)

configure_option(
NAME IOX_PLATFORM_DEFAULT_CONFIG_LOCATION
DEFAULT_VALUE "/etc/"
)

option(IOX_PLATFORM_FEATURE_ACL "Use ACLs for access control" ON)
message(STATUS "[i] IOX_PLATFORM_FEATURE_ACL: ${IOX_PLATFORM_FEATURE_ACL}")

Expand Down
1 change: 1 addition & 0 deletions iceoryx_platform/linux/cmake/platform_settings.hpp.in
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ constexpr uint64_t IOX_UDS_SOCKET_MAX_MESSAGE_SIZE = 4096;
constexpr const char IOX_UDS_SOCKET_PATH_PREFIX[] = "@IOX_PLATFORM_UDS_SOCKET_PATH_PREFIX@";
constexpr const char IOX_LOCK_FILE_PATH_PREFIX[] = "@IOX_PLATFORM_LOCK_FILE_PATH_PREFIX@";
constexpr const char IOX_TEMP_DIR[] = "@IOX_PLATFORM_TEMP_DIR@";
constexpr const char IOX_DEFAULT_CONFIG_LOCATION[] = "@IOX_PLATFORM_DEFAULT_CONFIG_LOCATION@";

constexpr uint64_t MAX_USER_NAME_LENGTH = 32;
constexpr uint64_t MAX_GROUP_NAME_LENGTH = 32;
Expand Down
5 changes: 5 additions & 0 deletions iceoryx_platform/mac/cmake/IceoryxPlatformDeployment.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,11 @@ configure_option(
DEFAULT_VALUE "/tmp/"
)

configure_option(
NAME IOX_PLATFORM_DEFAULT_CONFIG_LOCATION
DEFAULT_VALUE "/etc/"
)

option(IOX_PLATFORM_FEATURE_ACL "Use ACLs for access control" OFF)
message(STATUS "[i] IOX_PLATFORM_FEATURE_ACL: ${IOX_PLATFORM_FEATURE_ACL}")

Expand Down
1 change: 1 addition & 0 deletions iceoryx_platform/mac/cmake/platform_settings.hpp.in
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ constexpr uint64_t IOX_UDS_SOCKET_MAX_MESSAGE_SIZE = 2048;
constexpr const char IOX_UDS_SOCKET_PATH_PREFIX[] = "@IOX_PLATFORM_UDS_SOCKET_PATH_PREFIX@";
constexpr const char IOX_LOCK_FILE_PATH_PREFIX[] = "@IOX_PLATFORM_LOCK_FILE_PATH_PREFIX@";
constexpr const char IOX_TEMP_DIR[] = "@IOX_PLATFORM_TEMP_DIR@";
constexpr const char IOX_DEFAULT_CONFIG_LOCATION[] = "@IOX_PLATFORM_DEFAULT_CONFIG_LOCATION@";

constexpr uint64_t MAX_USER_NAME_LENGTH = 32;
constexpr uint64_t MAX_GROUP_NAME_LENGTH = 16;
Expand Down
5 changes: 5 additions & 0 deletions iceoryx_platform/qnx/cmake/IceoryxPlatformDeployment.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,11 @@ configure_option(
DEFAULT_VALUE "/tmp/"
)

configure_option(
NAME IOX_PLATFORM_DEFAULT_CONFIG_LOCATION
DEFAULT_VALUE "/etc/"
)

option(IOX_PLATFORM_FEATURE_ACL "Use ACLs for access control" ON)
message(STATUS "[i] IOX_PLATFORM_FEATURE_ACL: ${IOX_PLATFORM_FEATURE_ACL}")

Expand Down
1 change: 1 addition & 0 deletions iceoryx_platform/qnx/cmake/platform_settings.hpp.in
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ constexpr uint64_t IOX_UDS_SOCKET_MAX_MESSAGE_SIZE = 2048;
constexpr const char IOX_UDS_SOCKET_PATH_PREFIX[] = "@IOX_PLATFORM_UDS_SOCKET_PATH_PREFIX@";
constexpr const char IOX_LOCK_FILE_PATH_PREFIX[] = "@IOX_PLATFORM_LOCK_FILE_PATH_PREFIX@";
constexpr const char IOX_TEMP_DIR[] = "@IOX_PLATFORM_TEMP_DIR@";
constexpr const char IOX_DEFAULT_CONFIG_LOCATION[] = "@IOX_PLATFORM_DEFAULT_CONFIG_LOCATION@";

constexpr uint64_t MAX_USER_NAME_LENGTH = 32;
constexpr uint64_t MAX_GROUP_NAME_LENGTH = 16;
Expand Down
5 changes: 5 additions & 0 deletions iceoryx_platform/unix/cmake/IceoryxPlatformDeployment.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,11 @@ configure_option(
DEFAULT_VALUE "/tmp/"
)

configure_option(
NAME IOX_PLATFORM_DEFAULT_CONFIG_LOCATION
DEFAULT_VALUE "/etc/"
)

option(IOX_PLATFORM_FEATURE_ACL "Use ACLs for access control" OFF)
message(STATUS "[i] IOX_PLATFORM_FEATURE_ACL: ${IOX_PLATFORM_FEATURE_ACL}")

Expand Down
1 change: 1 addition & 0 deletions iceoryx_platform/unix/cmake/platform_settings.hpp.in
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ constexpr uint64_t IOX_UDS_SOCKET_MAX_MESSAGE_SIZE = 1024;
constexpr const char IOX_UDS_SOCKET_PATH_PREFIX[] = "@IOX_PLATFORM_UDS_SOCKET_PATH_PREFIX@";
constexpr const char IOX_LOCK_FILE_PATH_PREFIX[] = "@IOX_PLATFORM_LOCK_FILE_PATH_PREFIX@";
constexpr const char IOX_TEMP_DIR[] = "@IOX_PLATFORM_TEMP_DIR@";
constexpr const char IOX_DEFAULT_CONFIG_LOCATION[] = "@IOX_PLATFORM_DEFAULT_CONFIG_LOCATION@";

constexpr uint64_t MAX_USER_NAME_LENGTH = 32;
constexpr uint64_t MAX_GROUP_NAME_LENGTH = 16;
Expand Down
5 changes: 5 additions & 0 deletions iceoryx_platform/win/cmake/IceoryxPlatformDeployment.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,11 @@ configure_option(
DEFAULT_VALUE ""
)

configure_option(
NAME IOX_PLATFORM_DEFAULT_CONFIG_LOCATION
DEFAULT_VALUE "C:/ProgramData/"
)

option(IOX_PLATFORM_FEATURE_ACL "Use ACLs for access control" OFF)
message(STATUS "[i] IOX_PLATFORM_FEATURE_ACL: ${IOX_PLATFORM_FEATURE_ACL}")

Expand Down
1 change: 1 addition & 0 deletions iceoryx_platform/win/cmake/platform_settings.hpp.in
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ constexpr uint64_t IOX_UDS_SOCKET_MAX_MESSAGE_SIZE = 1024U;
constexpr const char IOX_UDS_SOCKET_PATH_PREFIX[] = "@IOX_PLATFORM_UDS_SOCKET_PATH_PREFIX@";
constexpr const char IOX_LOCK_FILE_PATH_PREFIX[] = "@IOX_PLATFORM_LOCK_FILE_PATH_PREFIX@";
constexpr const char IOX_TEMP_DIR[] = "@IOX_PLATFORM_TEMP_DIR@";
constexpr const char IOX_DEFAULT_CONFIG_LOCATION[] = "@IOX_PLATFORM_DEFAULT_CONFIG_LOCATION@";

constexpr uint64_t IOX_MAX_FILENAME_LENGTH = 128U;
constexpr uint64_t IOX_MAX_PATH_LENGTH = 255U;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ namespace iox
{
namespace config
{
static constexpr char defaultConfigFilePath[] = "/etc/iceoryx/roudi_config.toml";
static constexpr char defaultConfigFileRelativePath[] = "iceoryx/roudi_config.toml";

class TomlRouDiConfigFileProvider : public iox::roudi::RouDiConfigFileProvider
{
Expand Down
15 changes: 14 additions & 1 deletion iceoryx_posh/source/roudi/roudi_config_toml_file_provider.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@

#include "iceoryx_posh/roudi/roudi_config_toml_file_provider.hpp"
#include "iceoryx_platform/getopt.hpp"
#include "iceoryx_platform/platform_settings.hpp"
#include "iox/file_reader.hpp"
#include "iox/into.hpp"
#include "iox/logging.hpp"
Expand All @@ -43,11 +44,23 @@ TomlRouDiConfigFileProvider::TomlRouDiConfigFileProvider(config::CmdLineArgs_t&
m_roudiConfig = cmdLineArgs.roudiConfig;
if (cmdLineArgs.configFilePath.empty())
{
auto defaultConfigFilePath =
std::string(platform::IOX_DEFAULT_CONFIG_LOCATION) + defaultConfigFileRelativePath;

FileReader configFile(defaultConfigFilePath, "", FileReader::ErrorMode::Ignore);
if (configFile.isOpen())
{
IOX_LOG(Info, "No config file provided. Using '" << defaultConfigFilePath << "'");
m_customConfigFilePath = defaultConfigFilePath;
into<optional<roudi::ConfigFilePathString_t>>(defaultConfigFilePath)
.and_then([&](const auto& path) { m_customConfigFilePath = path; })
.or_else([&] {
IOX_LOG(Info,
"The config file path is too long. Only "
<< roudi::ConfigFilePathString_t::capacity()
<< " characters are allowed but the provided path has "
<< defaultConfigFilePath.length() << " characters: '" << defaultConfigFilePath
<< "'");
});
}
else
{
Expand Down

0 comments on commit f33d582

Please sign in to comment.