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.17k stars 1.9k forks source link

[Trivial] chip-tool did not have version number or git hash in cli command #34067

Open resghst opened 1 week ago

resghst commented 1 week ago

Type

Other

Explanation

holp the chip-tool can add chip-tool --version or chip-tool version command.

Platform

raspi

Platform Version(s)

No response

Testing

Manually tested with SDK

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

No response

Anything else?

No response

andy31415 commented 1 week ago

The trick is to decide what version to expose here ... current version command line handling prints out hard-coded text I believe, which is only useful among manjor versions (which we probably could change), however that also creates churn (keep updating the version file).

To avoid churn, we had various requests to use git versions/info/logs for this however we intentionally avoided this due to slowing down builds (we try hard to not execute extra programs) and making builds potentially less reproducible (different output on the same code, depending on git checkout status/state).

The closest equivalent is defining an argument and allowing build systems to override it (and builds system may choose to take the extra time to figure out a good tag). sl_matter_version_str is an example of this being done ( it is slow when used, adds extra churn to maintain the version in the builder script).

bzbarsky-apple commented 1 week ago

@resghst Where is the chip-tool coming from whose version you want to know? Understanding that will make it easier to figure out how best to address this.

resghst commented 1 week ago

Sometimes, I built the chip-tool a few months ago. I only leave the chip-tool bin file, so I can not easily get the chip-tool version.

For instance, the chip-tool builds from:

I holp chip-tool version command will show: master-v1.3.0.0-b63c271 at least show the hash code.

Thanks reply, @bzbarsky-apple @andy31415

resghst commented 1 week ago

I think only project-chip git-hash will fine

bzbarsky-apple commented 1 week ago

@resghst Build it into a directory whose name is the SHA?

resghst commented 1 week ago

for example, the following command can control the node 1 endpoint 1. $ ./chip-tool onoff on 1 1 I want get the chip-tool version with $ ./chip-tool version it will return "master-v1.3.0.0-b63c271" or "b63c271"   The chip-tool has many modules, so we may let the version become a command group. $ ./chip-tool version