diff --git a/applications/about/about.c b/applications/about/about.c index b371e301deac..bda50a4b0c16 100644 --- a/applications/about/about.c +++ b/applications/about/about.c @@ -116,9 +116,10 @@ static DialogMessageButton fw_version_screen(DialogsApp* dialogs, DialogMessage* } else { string_cat_printf( buffer, - "%s [%s]\n%s [%s]\n[%d] %s", + "%s [%s]\n%s%s [%s]\n[%d] %s", version_get_version(ver), version_get_builddate(ver), + version_get_dirty_flag(ver) ? "[!] " : "", version_get_githash(ver), version_get_gitbranchnum(ver), version_get_target(ver), diff --git a/applications/cli/cli.c b/applications/cli/cli.c index 4b36521b1572..0453fb66925f 100644 --- a/applications/cli/cli.c +++ b/applications/cli/cli.c @@ -95,10 +95,11 @@ void cli_motd() { const Version* firmware_version = furi_hal_version_get_firmware_version(); if(firmware_version) { printf( - "Firmware version: %s %s (%s built on %s)\r\n", + "Firmware version: %s %s (%s%s built on %s)\r\n", version_get_gitbranch(firmware_version), version_get_version(firmware_version), version_get_githash(firmware_version), + version_get_dirty_flag(firmware_version) ? "-dirty" : "", version_get_builddate(firmware_version)); } } diff --git a/applications/desktop/views/desktop_view_debug.c b/applications/desktop/views/desktop_view_debug.c index 1050ab0c262d..0aed2adfc275 100644 --- a/applications/desktop/views/desktop_view_debug.c +++ b/applications/desktop/views/desktop_view_debug.c @@ -62,7 +62,8 @@ void desktop_debug_render(Canvas* canvas, void* model) { snprintf( buffer, sizeof(buffer), - "%s [%s]", + "%s%s [%s]", + version_get_dirty_flag(ver) ? "[!] " : "", version_get_githash(ver), version_get_gitbranchnum(ver)); canvas_draw_str(canvas, 5, 39 + STATUS_BAR_Y_SHIFT, buffer); diff --git a/core/flipper.c b/core/flipper.c index 782094c69a87..c7d7c5a6c2e1 100755 --- a/core/flipper.c +++ b/core/flipper.c @@ -11,13 +11,14 @@ static void flipper_print_version(const char* target, const Version* version) { TAG, "\r\n\t%s version:\t%s\r\n" "\tBuild date:\t\t%s\r\n" - "\tGit Commit:\t\t%s (%s)\r\n" + "\tGit Commit:\t\t%s (%s)%s\r\n" "\tGit Branch:\t\t%s", target, version_get_version(version), version_get_builddate(version), version_get_githash(version), version_get_gitbranchnum(version), + version_get_dirty_flag(version) ? " (dirty)" : "", version_get_gitbranch(version)); } else { FURI_LOG_I(TAG, "No build info for %s", target); diff --git a/firmware/targets/f7/furi_hal/furi_hal_info.c b/firmware/targets/f7/furi_hal/furi_hal_info.c index 80b9520d3da2..77eab1282cd1 100644 --- a/firmware/targets/f7/furi_hal/furi_hal_info.c +++ b/firmware/targets/f7/furi_hal/furi_hal_info.c @@ -54,6 +54,10 @@ void furi_hal_info_get(FuriHalInfoValueCallback out, void* context) { const Version* firmware_version = furi_hal_version_get_firmware_version(); if(firmware_version) { out("firmware_commit", version_get_githash(firmware_version), false, context); + out("firmware_commit_dirty", + version_get_dirty_flag(firmware_version) ? "true" : "false", + false, + context); out("firmware_branch", version_get_gitbranch(firmware_version), false, context); out("firmware_branch_num", version_get_gitbranchnum(firmware_version), false, context); out("firmware_version", version_get_version(firmware_version), false, context); @@ -127,4 +131,4 @@ void furi_hal_info_get(FuriHalInfoValueCallback out, void* context) { out("protobuf_version_minor", string_get_cstr(value), true, context); string_clear(value); -} +} \ No newline at end of file diff --git a/lib/toolbox/version.c b/lib/toolbox/version.c index eb4b39a1dffe..902be876c22a 100644 --- a/lib/toolbox/version.c +++ b/lib/toolbox/version.c @@ -7,6 +7,7 @@ struct Version { const char* build_date; const char* version; const uint8_t target; + const bool build_is_dirty; }; /* version of current running firmware (bootloader/flipper) */ @@ -21,6 +22,7 @@ static const Version version = { #endif , .target = TARGET, + .build_is_dirty = BUILD_DIRTY, }; const Version* version_get(void) { @@ -49,4 +51,8 @@ const char* version_get_version(const Version* v) { uint8_t version_get_target(const Version* v) { return v ? v->target : version.target; +} + +bool version_get_dirty_flag(const Version* v) { + return v ? v->build_is_dirty : version.build_is_dirty; } \ No newline at end of file diff --git a/lib/toolbox/version.h b/lib/toolbox/version.h index d3e1f9d1544c..7e82e45d4bd9 100644 --- a/lib/toolbox/version.h +++ b/lib/toolbox/version.h @@ -1,6 +1,7 @@ #pragma once #include +#include #ifdef __cplusplus extern "C" { @@ -72,6 +73,15 @@ const char* version_get_version(const Version* v); */ uint8_t version_get_target(const Version* v); +/** Get flag indicating if this build is "dirty" (source code had uncommited changes) + * + * @param v pointer to Version data. NULL for currently running + * software. + * + * @return build date + */ +bool version_get_dirty_flag(const Version* v); + #ifdef __cplusplus } -#endif +#endif \ No newline at end of file diff --git a/make/git.mk b/make/git.mk index eba883a415fb..9e5f7cb78a05 100644 --- a/make/git.mk +++ b/make/git.mk @@ -4,7 +4,12 @@ GIT_BRANCH_NUM := $(shell git rev-list --count HEAD || echo 'nan') BUILD_DATE := $(shell date '+%d-%m-%Y' || echo 'unknown') BUILD_TIME := $(shell date '+%H:%M:%S' || echo 'unknown') VERSION := $(shell git describe --tags --abbrev=0 --exact-match 2>/dev/null || echo 'unknown') -GIT_CLEAN_BUILD := $(shell git diff --quiet || echo '-dirty') +GIT_DIRTY_BUILD := $(shell git diff --quiet || echo $$?) + +GIT_DIRTY_SUFFIX := +ifeq ($(GIT_DIRTY_BUILD), 1) + GIT_DIRTY_SUFFIX := '-dirty' +endif CFLAGS += \ -DGIT_COMMIT=\"$(GIT_COMMIT)\" \ @@ -12,13 +17,14 @@ CFLAGS += \ -DGIT_BRANCH_NUM=\"$(GIT_BRANCH_NUM)\" \ -DBUILD_DATE=\"$(BUILD_DATE)\" \ -DVERSION=\"$(VERSION)\" \ - -DTARGET=$(HARDWARE_TARGET) + -DTARGET=$(HARDWARE_TARGET) \ + -DBUILD_DIRTY=$(GIT_DIRTY_BUILD) # if suffix is set in environment (by Github), use it ifeq (${DIST_SUFFIX},) - DIST_SUFFIX := local-$(GIT_COMMIT)$(GIT_CLEAN_BUILD) + DIST_SUFFIX := local-$(GIT_COMMIT)$(GIT_DIRTY_SUFFIX) else - DIST_SUFFIX := ${DIST_SUFFIX} + DIST_SUFFIX := ${DIST_SUFFIX}$(GIT_DIRTY_SUFFIX) endif #VERSION_STRING := $(VERSION) ($(GIT_BRANCH) @ $(GIT_COMMIT)), built $(BUILD_DATE) $(BUILD_TIME)