]> granicus.if.org Git - esp-idf/commitdiff
build: Fix a warning from git describe
authorKonstantin Kondrashov <konstantin@espressif.com>
Thu, 13 Dec 2018 05:48:34 +0000 (13:48 +0800)
committerKonstantin Kondrashov <konstantin@espressif.com>
Tue, 18 Dec 2018 07:58:22 +0000 (15:58 +0800)
Fixed a fatal message when run `git describe`.

CMakeLists.txt
components/app_update/component.mk
docs/en/api-guides/build-system-cmake.rst
docs/en/api-guides/build-system.rst
tools/cmake/idf_functions.cmake

index fcf70d9aa9618cc373d978dfa321c834c9c71597..362c68984e83c6b47b746c0cb06f699f3cb2109d 100644 (file)
@@ -75,7 +75,9 @@ idf_get_git_revision()
 idf_check_config_target()
 
 ## get PROJECT_VER
-app_get_revision("${CMAKE_SOURCE_DIR}")
+if(NOT BOOTLOADER_BUILD)
+    app_get_revision("${CMAKE_SOURCE_DIR}")
+endif()
 
 # Add some idf-wide definitions
 idf_set_global_compile_options()
index 28125e242becbfe8919fbb16961bfbd2214b6d31..4d4097f26766f7028818f341e3abbe6ab41b62fb 100644 (file)
@@ -11,11 +11,13 @@ ifndef IS_BOOTLOADER_BUILD
 GET_PROJECT_VER ?=
 ifeq ("${PROJECT_VER}", "")
 ifeq ("$(wildcard ${PROJECT_PATH}/version.txt)","")
-GET_PROJECT_VER := $(shell cd ${PROJECT_PATH} && git describe --always --tags --dirty || echo "Not found git repo")
-ifeq ("${GET_PROJECT_VER}", "Not found git repo")
-$(info Project do not have git repo, it needs to get PROJECT_VER from `git describe` command.)
-GET_PROJECT_VER := ""
+
+GET_PROJECT_VER := $(shell cd ${PROJECT_PATH} && git describe --always --tags --dirty 2> /dev/null)
+ifeq ("${GET_PROJECT_VER}", "")
+GET_PROJECT_VER := "1"
+$(info Project is not inside a git repository, will not use 'git describe' to determine PROJECT_VER.)
 endif
+
 else
 # read from version.txt
 GET_PROJECT_VER := $(shell cat ${PROJECT_PATH}/version.txt)
@@ -24,7 +26,7 @@ endif
 # If ``PROJECT_VER`` variable set in project Makefile file, its value will be used.
 # Else, if the ``$PROJECT_PATH/version.txt`` exists, its contents will be used as ``PROJECT_VER``.
 # Else, if the project is located inside a Git repository, the output of git describe will be used.
-# Otherwise, ``PROJECT_VER`` will be empty.
+# Otherwise, ``PROJECT_VER`` will be "1".
 
 ifeq ("${PROJECT_VER}", "")
 PROJECT_VER:= $(GET_PROJECT_VER)
index e142b2a71e121192b5be2c500673a677e2fdeda5..24f8b651fef02abf3f6f99744157a92e079e2d52 100644 (file)
@@ -330,7 +330,7 @@ The following variables are set at the project level, but available for use in c
 * If ``PROJECT_VER`` variable set in project CMakeLists.txt file, its value will be used.
 * Else, if the ``$PROJECT_PATH/version.txt`` exists, its contents will be used as ``PROJECT_VER``.
 * Else, if the project is located inside a Git repository, the output of git describe will be used.
-* Otherwise, ``PROJECT_VER`` will be empty.
+* Otherwise, ``PROJECT_VER`` will be "1".
 
 If you modify any of these variables inside ``CMakeLists.txt`` then this will not prevent other components from building but it may make your component hard to build and/or debug.
 
index f52143cc8c3104bc35ae90e45d1c61e0f13e5260..a489d5e456d075d25f578d94f95d6ab0a6991700 100644 (file)
@@ -192,7 +192,7 @@ The following variables are set at the project level, but exported for use in th
 * If ``PROJECT_VER`` variable set in project Makefile file, its value will be used.
 * Else, if the ``$PROJECT_PATH/version.txt`` exists, its contents will be used as ``PROJECT_VER``.
 * Else, if the project is located inside a Git repository, the output of git describe will be used.
-* Otherwise, ``PROJECT_VER`` will be empty.
+* Otherwise, ``PROJECT_VER`` will be "1".
 
 If you modify any of these variables inside ``component.mk`` then this will not prevent other components from building but it may make your component hard to build and/or debug.
 
index a06aa81298e8ef99e0b7bf10b565b1f403af548a..230ac96a483ea3a5ce3b5ec62c590f913115d9db 100644 (file)
@@ -227,19 +227,24 @@ endfunction()
 # If PROJECT_VER variable set in project CMakeLists.txt file, its value will be used.
 # Else, if the _project_path/version.txt exists, its contents will be used as PROJECT_VER.
 # Else, if the project is located inside a Git repository, the output of git describe will be used.
-# Otherwise, PROJECT_VER will be empty.
+# Otherwise, PROJECT_VER will be "1".
 function(app_get_revision _project_path)
-    git_describe(PROJECT_VER_GIT "${_project_path}")
     if(NOT DEFINED PROJECT_VER)
         if(EXISTS "${_project_path}/version.txt")
             file(STRINGS "${_project_path}/version.txt" PROJECT_VER)
             set_property(DIRECTORY APPEND PROPERTY CMAKE_CONFIGURE_DEPENDS "${_project_path}/version.txt")
         else()
-            set(PROJECT_VER ${PROJECT_VER_GIT})
+            git_describe(PROJECT_VER_GIT "${_project_path}")
+            if(PROJECT_VER_GIT)
+                set(PROJECT_VER ${PROJECT_VER_GIT})
+            else()
+                message(STATUS "Project is not inside a git repository, \
+                        will not use 'git describe' to determine PROJECT_VER.")
+                set(PROJECT_VER "1")
+            endif()
         endif()
     endif()
     message(STATUS "Project version: ${PROJECT_VER}")
-    git_submodule_check("${_project_path}")
     set(PROJECT_VER ${PROJECT_VER} PARENT_SCOPE)
 endfunction()