project-chip / connectedhomeip

Matter (formerly Project CHIP) creates more connections between more objects, simplifying development for manufacturers and increasing compatibility for consumers, guided by the Connectivity Standards Alliance.
https://buildwithmatter.com
Apache License 2.0
7.55k stars 2.04k forks source link

[Tooling] Configuring default paths by environment variable #30790

Open farshidtz opened 12 months ago

farshidtz commented 12 months ago

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:

https://github.com/project-chip/connectedhomeip/blob/2a4a2cada95a8cf0d8447996d47b8cbd77ebd73e/src/platform/Linux/CHIPLinuxStorage.h#L47-L59

https://github.com/project-chip/connectedhomeip/blob/2a4a2cada95a8cf0d8447996d47b8cbd77ebd73e/src/platform/Linux/CHIPPlatformConfig.h#L69-L71

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

https://github.com/project-chip/connectedhomeip/blob/2a4a2cada95a8cf0d8447996d47b8cbd77ebd73e/examples/chip-tool/commands/interactive/InteractiveCommands.cpp#L26

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 commented 12 months ago

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

adis-ikea commented 12 months ago

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 commented 11 months ago

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

bzbarsky-apple commented 11 months ago

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.