Makefile: track version using p-r-project VERSION file#782
Conversation
JIRA: RTOS-1318
There was a problem hiding this comment.
Code Review
This pull request simplifies the versioning logic in the Makefile by replacing complex git description parsing with a short git hash and reading the release version from an external file. Feedback identifies a shell syntax error in the dummy revision string, suggests handling missing version files to prevent build noise, and recommends restoring the 'dirty' tree flag to aid in debugging kernel issues.
| VERSION := $(VERSION)\ $(word 4,$(DESC)) | ||
| endif | ||
| RELEASE := $(subst v,,$(word 1,$(DESC))) | ||
| DUMMY_REVISION := \"(unknown)\" |
There was a problem hiding this comment.
The escaped quotes in DUMMY_REVISION will cause a shell syntax error when the fallback echo "$(DUMMY_REVISION)" is executed (e.g., echo ""(unknown)"" results in bash: syntax error near unexpected token '('). Additionally, since VERSION is wrapped in escaped quotes in CPPFLAGS (line 23), this would lead to incorrect double-quoting in the C macro definition (e.g., ""(unknown)"") compared to the git-based version which lacks internal quotes.
DUMMY_REVISION := (unknown)
| endif | ||
| RELEASE := $(subst v,,$(word 1,$(DESC))) | ||
| DUMMY_REVISION := \"(unknown)\" | ||
| RELEASE := $(shell cat ../VERSION) |
There was a problem hiding this comment.
Reading ../VERSION directly will produce an error message on stderr if the file is missing (e.g., in standalone builds or non-standard directory structures). It is better to suppress this error and provide a sensible default value to ensure the build output remains clean.
RELEASE := $(shell cat ../VERSION 2>/dev/null || echo "unknown")
| RELEASE := $(subst v,,$(word 1,$(DESC))) | ||
| DUMMY_REVISION := \"(unknown)\" | ||
| RELEASE := $(shell cat ../VERSION) | ||
| GIT_REVISION := $(shell git rev-parse --short HEAD || echo "$(DUMMY_REVISION)") |
There was a problem hiding this comment.
The change from git describe --dirty to git rev-parse --short HEAD loses the information about whether the build was performed on a dirty git tree. This information is often crucial for debugging kernel issues. Using git describe --always --dirty allows you to keep the dirty flag while still falling back to the hash if no tags are present.
GIT_REVISION := $(shell git describe --always --dirty --abbrev=8 2>/dev/null || echo "$(DUMMY_REVISION)")
JIRA: RTOS-1318
Types of changes
How Has This Been Tested?
Checklist:
Special treatment