component.mk 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. #
  2. # Component Makefile
  3. #
  4. # (Uses default behaviour of compiling all source files in directory, adding 'include' to include path.)
  5. # esp_app_desc structure is added as an undefined symbol because otherwise the
  6. # linker will ignore this structure as it has no other files depending on it.
  7. COMPONENT_ADD_LDFLAGS += -u esp_app_desc
  8. ifndef IS_BOOTLOADER_BUILD
  9. GET_PROJECT_VER ?=
  10. ifeq ("${PROJECT_VER}", "")
  11. ifeq ("$(wildcard ${PROJECT_PATH}/version.txt)","")
  12. GET_PROJECT_VER := $(shell cd ${PROJECT_PATH} && git describe --always --tags --dirty || echo "Not found git repo")
  13. ifeq ("${GET_PROJECT_VER}", "Not found git repo")
  14. $(info Project do not have git repo, it needs to get PROJECT_VER from `git describe` command.)
  15. GET_PROJECT_VER := ""
  16. endif
  17. else
  18. # read from version.txt
  19. GET_PROJECT_VER := $(shell cat ${PROJECT_PATH}/version.txt)
  20. endif
  21. endif
  22. # If ``PROJECT_VER`` variable set in project Makefile file, its value will be used.
  23. # Else, if the ``$PROJECT_PATH/version.txt`` exists, its contents will be used as ``PROJECT_VER``.
  24. # Else, if the project is located inside a Git repository, the output of git describe will be used.
  25. # Otherwise, ``PROJECT_VER`` will be empty.
  26. ifeq ("${PROJECT_VER}", "")
  27. PROJECT_VER:= $(GET_PROJECT_VER)
  28. else
  29. PROJECT_VER:= $(PROJECT_VER)
  30. endif
  31. $(info App "$(PROJECT_NAME)" version: $(PROJECT_VER))
  32. NEW_DEFINES:= $(PROJECT_VER) $(PROJECT_NAME) $(IDF_VER)
  33. ifeq ("$(wildcard ${TMP_DEFINES})","")
  34. OLD_DEFINES:=
  35. else
  36. OLD_DEFINES:= $(shell cat $(TMP_DEFINES))
  37. endif
  38. # If NEW_DEFINES (PROJECT_VER, PROJECT_NAME) were changed then rebuild only esp_app_desc.
  39. ifneq ("${NEW_DEFINES}", "${OLD_DEFINES}")
  40. $(shell echo $(NEW_DEFINES) > $(TMP_DEFINES); rm -f esp_app_desc.o;)
  41. endif
  42. esp_app_desc.o: CPPFLAGS += -D PROJECT_VER=\"$(PROJECT_VER)\" -D PROJECT_NAME=\"$(PROJECT_NAME)\"
  43. endif