]> granicus.if.org Git - esp-idf/commitdiff
build system: add IDF_VER environment variable and preprocessor define
authorIvan Grokhotkov <igrokhotkov@gmail.com>
Tue, 10 Jan 2017 16:24:50 +0000 (00:24 +0800)
committerIvan Grokhotkov <igrokhotkov@gmail.com>
Tue, 10 Jan 2017 16:24:50 +0000 (00:24 +0800)
components/bootloader/src/main/bootloader_config.h
components/bootloader/src/main/bootloader_start.c
docs/build_system.rst
make/project.mk

index d097083d2a8c4efafd2293cc7a1dc48598bcc6ab..6b37899ac3b6fbf6bb6bafb0832046d921957175 100644 (file)
@@ -23,7 +23,6 @@ extern "C"
 
 #include "esp_flash_data_types.h"
 
-#define BOOT_VERSION "V0.1"
 #define SPI_SEC_SIZE 0x1000
 #define IROM_LOW    0x400D0000
 #define IROM_HIGH   0x40400000
index e5fda9cf530fb0413fb21ff0b080ba9ea0566782..102e70c3def7bb8ca6a11f5d5937c185abe5d61a 100644 (file)
@@ -233,7 +233,7 @@ static bool ota_select_valid(const esp_ota_select_entry_t *s)
 void bootloader_main()
 {
     uart_console_configure();
-    ESP_LOGI(TAG, "Espressif ESP32 2nd stage bootloader v. %s", BOOT_VERSION);
+    ESP_LOGI(TAG, "ESP-IDF %s 2nd stage bootloader", IDF_VER);
 #if defined(CONFIG_SECURE_BOOT_ENABLED) || defined(CONFIG_FLASH_ENCRYPTION_ENABLED)
     esp_err_t err;
 #endif
index 2e388bd4956ec97a739fbb7a5858670b89467ff7..7a33a412560bb5dddd732bc9767ed2379a0f47e0 100644 (file)
@@ -166,6 +166,7 @@ The following variables are set at the project level, but exported for use in th
 - ``CONFIG_*``: Each value in the project configuration has a corresponding variable available in make. All names begin with ``CONFIG_``.
 - ``CC``, ``LD``, ``AR``, ``OBJCOPY``: Full paths to each tool from the gcc xtensa cross-toolchain.
 - ``HOSTCC``, ``HOSTLD``, ``HOSTAR``: Full names of each tool from the host native toolchain.
+- ``IDF_VER``: Git version of ESP-IDF (produced by ``git describe``)
 
 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.
 
@@ -267,6 +268,14 @@ To create a component KConfig file, it is easiest to start with one of the KConf
 
 For an example, see `Adding conditional configuration`.
 
+Preprocessor Definitions
+------------------------
+
+ESP-IDF build systems adds the following C preprocessor definitions on the command line:
+
+- ``ESP_PLATFORM`` — Can be used to detect that build happens within ESP-IDF.
+- ``IDF_VER`` — Defined to a git version string.  E.g. ``v2.0`` for a tagged release or ``v1.0-275-g0efaa4f`` for an arbitrary commit.
+
 Build Process Internals
 -----------------------
 
index e2a93ce1190ad3057947e2d9213386d4e818152a..6d9feaa7c4f71addc8c1a9377de74675b827aefe 100644 (file)
@@ -176,6 +176,10 @@ else
 endif
        @echo $(ESPTOOLPY_WRITE_FLASH) $(ESPTOOL_ALL_FLASH_ARGS)
 
+
+# Git version of ESP-IDF (of the form v1.0-285-g5c4f707)
+IDF_VER := $(shell git describe)
+
 # Set default LDFLAGS
 
 LDFLAGS ?= -nostdlib \
@@ -200,7 +204,7 @@ LDFLAGS ?= -nostdlib \
 
 # CPPFLAGS used by C preprocessor
 # If any flags are defined in application Makefile, add them at the end. 
-CPPFLAGS := -DESP_PLATFORM -MMD -MP $(CPPFLAGS) $(EXTRA_CPPFLAGS)
+CPPFLAGS := -DESP_PLATFORM -D IDF_VER=\"$(IDF_VER)\" -MMD -MP $(CPPFLAGS) $(EXTRA_CPPFLAGS)
 
 # Warnings-related flags relevant both for C and C++
 COMMON_WARNING_FLAGS = -Wall -Werror=all \