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

[Tooling] Configuring default paths by environment variable #30790

Open
farshidtz opened this issue Dec 4, 2023 · 4 comments · May be fixed by #33846
Open

[Tooling] Configuring default paths by environment variable #30790

farshidtz opened this issue Dec 4, 2023 · 4 comments · May be fixed by #33846

Comments

@farshidtz
Copy link
Contributor

farshidtz commented Dec 4, 2023

Reproduction steps / Feature

The applications built with the SDK inherit several default paths, such as for local state and KVS. These can only be modified in source or via build flags. This is problematic because the target file structure and permissions need to be assumed during build time. Moreover, it makes it impossible to use an application by different users on the same host (since they'll end up sharing the same state and KVS).

Example macros which can be overridden during compilation:

#ifndef LOCALSTATEDIR
#define LOCALSTATEDIR "/tmp"
#endif
#define CHIP_DEFAULT_FACTORY_PATH \
FATCONFDIR "/" \
"chip_factory.ini"
#define CHIP_DEFAULT_CONFIG_PATH \
SYSCONFDIR "/" \
"chip_config.ini"
#define CHIP_DEFAULT_DATA_PATH \
LOCALSTATEDIR "/" \
"chip_counters.ini"

#ifndef CHIP_CONFIG_KVS_PATH
#define CHIP_CONFIG_KVS_PATH "/tmp/chip_kvs"
#endif // CHIP_CONFIG_KVS_PATH

Chip Tool's interactive history path (no macro):

constexpr const char * kInteractiveModeHistoryFilePath = "/tmp/chip_tool_history";

The request is to make such paths configurable via environment variables, rather than macros. This way, the paths can be adjusted per use case on runtime. It also simplifies development and testing because it allows maintaining multiple states for each applications (e.g. Chip Tool).

In all above cases, only the parent directory (/tmp) needs to become configurable, so I suppose a single macro can define it globally and an environment variable can be used to override the whole storage path directory.

Platform

core (please add to version below)

Platform Version(s)

No response

Type

Manually tested with SDK

(Optional) If manually tested please explain why this is only manually tested

No response

Anything else?

No response

@bzbarsky-apple
Copy link
Contributor

chip-tool already has a way to set its temp path... The interactive history should just be using that setting instead of hardcoding /tmp.

bzbarsky-apple added a commit to bzbarsky-apple/connectedhomeip that referenced this issue Dec 4, 2023
bzbarsky-apple added a commit to bzbarsky-apple/connectedhomeip that referenced this issue Dec 4, 2023
mergify bot pushed a commit that referenced this issue Dec 5, 2023
…directory. (#30803)

Addresses part of #30790

Co-authored-by: Andrei Litvin <[email protected]>
@adis-ikea
Copy link
Contributor

It would be nice if this was an argument similar to the --KVS so we can pass it when starting the application. Or just simply use the same directory that we pass via --KVS.

@adis-ikea
Copy link
Contributor

@bzbarsky-apple any chance you could look into this?

@bzbarsky-apple
Copy link
Contributor

I fixed chip-tool to store its history in the same place it stores its other data: see the PR above.

Past that, I do not have the bandwidth to look into the Linux-specific bits right now, especially since I have no convenient way to compile/test them.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants