Skip to content

Commit

Permalink
chore(build): Ensure GIT_TAG is never empty (#86)
Browse files Browse the repository at this point in the history
  • Loading branch information
Slider0007 authored Oct 25, 2023
1 parent ce61169 commit be07db0
Show file tree
Hide file tree
Showing 13 changed files with 13 additions and 129 deletions.
2 changes: 0 additions & 2 deletions code/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@
.vscode/ipch
version.cpp
sdkconfig.esp32cam
sdkconfig.esp32cam-localbuild
sdkconfig.esp32cam-debug
sdkconfig.esp32cam-board-rev3
sdkconfig.esp32cam-himem
sdkconfig.esp32cam-task-analysis
6 changes: 0 additions & 6 deletions code/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,6 @@ cmake_minimum_required(VERSION 3.16.0)

list(APPEND EXTRA_COMPONENT_DIRS $ENV{IDF_PATH}/examples/common_components/protocol_examples_common components/tflite-micro-esp-examples/components/tflite-lib)

ADD_CUSTOM_COMMAND(
OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/version.cpp
${CMAKE_CURRENT_BINARY_DIR}/_version.cpp
COMMAND ${CMAKE_COMMAND} -P
${CMAKE_CURRENT_SOURCE_DIR}/version.cmake)

if(EXISTS "${SDKCONFIG}.defaults")
if(EXISTS "sdkconfig.defaults")
set(SDKCONFIG_DEFAULTS "${SDKCONFIG}.defaults;sdkconfig.defaults")
Expand Down
17 changes: 12 additions & 5 deletions code/main/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
# without default 'CMakeLists.txt' file.

##################################################################
# Extract GIT infos and set variables in version.cpp
##################################################################
execute_process(COMMAND git log --pretty=format:'%h' -n 1
OUTPUT_VARIABLE GIT_REV
Expand All @@ -21,26 +22,32 @@ else()
execute_process(
COMMAND bash -c "git diff --quiet --exit-code || echo +"
OUTPUT_VARIABLE GIT_DIFF)
execute_process(
COMMAND git describe --exact-match --tags
OUTPUT_VARIABLE GIT_TAG ERROR_QUIET)
execute_process(
COMMAND git rev-parse --abbrev-ref HEAD
OUTPUT_VARIABLE GIT_BRANCH)
execute_process(
COMMAND git describe --exact-match --tags
OUTPUT_VARIABLE GIT_TAG ERROR_QUIET)

string(STRIP "${GIT_REV}" GIT_REV)
string(SUBSTRING "${GIT_REV}" 1 7 GIT_REV)
string(STRIP "${GIT_DIFF}" GIT_DIFF)
string(STRIP "${GIT_TAG}" GIT_TAG)
string(STRIP "${GIT_BRANCH}" GIT_BRANCH)

string(COMPARE NOTEQUAL "${GIT_TAG}" "" GitTagNotEmpty)
if(GitTagNotEmpty)
string(STRIP "${GIT_TAG}" GIT_TAG)
else()
set(GIT_TAG "N/A") # Set N/A if no tag was found
endif()
endif()

set(VERSION "const char* GIT_REV=\"${GIT_REV}${GIT_DIFF}\";
const char* GIT_TAG=\"${GIT_TAG}\";
const char* GIT_BRANCH=\"${GIT_BRANCH}\";
const char* BUILD_TIME=\"${BUILD_TIME}\";")

if ("${GIT_TAG}" STREQUAL "") # Tag not set, show branch
if ("${GIT_TAG}" STREQUAL "N/A" OR "${GIT_TAG}" STREQUAL "") # Tag not set, show branch
set(VERSION_HTML "Develop: ${GIT_BRANCH} (Commit: ${GIT_REV}${GIT_DIFF})\n${GIT_REV}")
else() # Tag is set, ignore branch
set(VERSION_HTML "Release: ${GIT_TAG} (Commit: ${GIT_REV}${GIT_DIFF})\n${GIT_REV}")
Expand Down
Binary file removed code/main/favicon.ico
Binary file not shown.
24 changes: 0 additions & 24 deletions code/main/gitversion.cmake

This file was deleted.

2 changes: 1 addition & 1 deletion code/main/version.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ const char* libfive_git_branch(void)

std::string getFwVersion(void) {
std::string buf;
if (std::string(GIT_TAG) == "") { // Tag not set, show branch
if ((std::string(GIT_TAG) == "N/A") || (std::string(GIT_TAG) == "")) { // Tag not set, show branch
buf = "Develop: " + std::string(GIT_BRANCH);
}
else { // Tag is set, ignore branch
Expand Down
Binary file removed docs/binary/bootloader.bin
Binary file not shown.
Binary file removed docs/binary/firmware.bin
Binary file not shown.
Binary file removed docs/binary/partitions.bin
Binary file not shown.
35 changes: 0 additions & 35 deletions docs/index.html

This file was deleted.

25 changes: 0 additions & 25 deletions docs/manifest.json

This file was deleted.

25 changes: 0 additions & 25 deletions docs/manifest_template.json

This file was deleted.

6 changes: 0 additions & 6 deletions firmware/README.md

This file was deleted.

0 comments on commit be07db0

Please sign in to comment.