tmedicci commented on code in PR #17236: URL: https://github.com/apache/nuttx/pull/17236#discussion_r2497597114
########## arch/risc-v/src/common/espressif/Make.defs: ########## @@ -199,41 +199,177 @@ ifndef ESP_HAL_3RDPARTY_VERSION endif ifndef ESP_HAL_3RDPARTY_URL - ESP_HAL_3RDPARTY_URL = https://github.com/espressif/esp-hal-3rdparty.git + ESP_HAL_3RDPARTY_URL = https://github.com/espressif/esp-hal-3rdparty/archive endif -ifndef DISABLE_GIT_DEPTH -ifndef GIT_DEPTH - GIT_DEPTH=1 +ESP_HAL_3RDPARTY_ZIP = $(ESP_HAL_3RDPARTY_VERSION).zip + +ifeq ($(STORAGETMP),y) +define DOWNLOAD_ESP_HAL_3RDPARTY_REPO + $(call DOWNLOAD,$(ESP_HAL_3RDPARTY_URL),$(ESP_HAL_3RDPARTY_ZIP),chip/$(ESP_HAL_3RDPARTY_ZIP),$(NXTMPDIR)/$(ESP_HAL_3RDPARTY_ZIP)) +endef +else +define DOWNLOAD_ESP_HAL_3RDPARTY_REPO + $(call DOWNLOAD,$(ESP_HAL_3RDPARTY_URL),$(ESP_HAL_3RDPARTY_ZIP),chip/$(ESP_HAL_3RDPARTY_ZIP)) +endef endif - GIT_DEPTH_PARAMETER = --depth=$(GIT_DEPTH) + +$(ESP_HAL_3RDPARTY_ZIP): + $(Q) $(call DOWNLOAD_ESP_HAL_3RDPARTY_REPO) + +chip/$(ESP_HAL_3RDPARTY_REPO): $(ESP_HAL_3RDPARTY_ZIP) + $(Q) echo "Unpacking: Espressif HAL for 3rd Party Platforms" + $(Q) unzip -oqq chip/$(ESP_HAL_3RDPARTY_ZIP) -d chip/ + $(Q) mv chip/$(ESP_HAL_3RDPARTY_REPO)-$(ESP_HAL_3RDPARTY_VERSION) chip/$(ESP_HAL_3RDPARTY_REPO) + +ESP_COMPONENTS_MBEDTLS_UNPACK = mbedtls +ifndef ESP_COMPONENTS_MBEDTLS_VERSION + ESP_COMPONENTS_MBEDTLS_VERSION = mbedtls-3.6.3-idf +endif + +ifndef ESP_COMPONENTS_MBEDTLS_URL + ESP_COMPONENTS_MBEDTLS_URL = https://github.com/espressif/mbedtls/archive endif +ESP_COMPONENTS_MBEDTLS_ZIP = $(ESP_COMPONENTS_MBEDTLS_VERSION).zip + ifeq ($(STORAGETMP),y) -define CLONE_ESP_HAL_3RDPARTY_REPO - $(call CHECK_COMMITSHA, $(NXTMPDIR)/$(ESP_HAL_3RDPARTY_REPO),$(ESP_HAL_3RDPARTY_VERSION)) - $(call CLONE, $(ESP_HAL_3RDPARTY_URL),chip/$(ESP_HAL_3RDPARTY_REPO),$(NXTMPDIR)/$(ESP_HAL_3RDPARTY_REPO)) +define DOWNLOAD_ESP_COMPONENTS_MBEDTLS_UNPACK + $(call DOWNLOAD,$(ESP_COMPONENTS_MBEDTLS_URL),$(ESP_COMPONENTS_MBEDTLS_ZIP),chip/$(ESP_COMPONENTS_MBEDTLS_ZIP),$(NXTMPDIR)/$(ESP_COMPONENTS_MBEDTLS_ZIP)) endef else -define CLONE_ESP_HAL_3RDPARTY_REPO - $(call CLONE, $(ESP_HAL_3RDPARTY_URL),chip/$(ESP_HAL_3RDPARTY_REPO)) +define DOWNLOAD_ESP_COMPONENTS_MBEDTLS_UNPACK + $(call DOWNLOAD,$(ESP_COMPONENTS_MBEDTLS_URL),$(ESP_COMPONENTS_MBEDTLS_ZIP),chip/$(ESP_COMPONENTS_MBEDTLS_ZIP)) endef endif -chip/$(ESP_HAL_3RDPARTY_REPO): - $(Q) echo "Cloning Espressif HAL for 3rd Party Platforms" - $(Q) $(call CLONE_ESP_HAL_3RDPARTY_REPO) - $(Q) echo "Espressif HAL for 3rd Party Platforms: ${ESP_HAL_3RDPARTY_VERSION}" - $(Q) git -C chip/$(ESP_HAL_3RDPARTY_REPO) checkout --quiet $(ESP_HAL_3RDPARTY_VERSION) - $(Q) git -C chip/$(ESP_HAL_3RDPARTY_REPO) submodule --quiet update --init $(GIT_DEPTH_PARAMETER) components/mbedtls/mbedtls -ifeq ($(CONFIG_ESP_WIRELESS),y) - $(Q) echo "Espressif HAL for 3rd Party Platforms: initializing submodules..." - $(Q) git -C chip/$(ESP_HAL_3RDPARTY_REPO) submodule --quiet update --init $(GIT_DEPTH_PARAMETER) components/esp_phy/lib components/esp_wifi/lib components/bt/controller/lib_esp32c3_family components/esp_coex/lib - $(Q) git -C chip/$(ESP_HAL_3RDPARTY_REPO)/components/mbedtls/mbedtls reset --quiet --hard +$(ESP_COMPONENTS_MBEDTLS_ZIP): + $(call DOWNLOAD_ESP_COMPONENTS_MBEDTLS_UNPACK) + +chip/$(ESP_COMPONENTS_MBEDTLS_UNPACK): $(ESP_COMPONENTS_MBEDTLS_ZIP) chip/$(ESP_HAL_3RDPARTY_REPO) + $(Q) unzip -oqq chip/$(ESP_COMPONENTS_MBEDTLS_ZIP) -d chip/ + $(Q) rm -fr chip/$(ESP_HAL_3RDPARTY_REPO)/components/mbedtls/mbedtls + $(Q) mv chip/$(ESP_COMPONENTS_MBEDTLS_UNPACK)-$(ESP_COMPONENTS_MBEDTLS_VERSION) chip/$(ESP_HAL_3RDPARTY_REPO)/components/mbedtls/mbedtls $(Q) echo "Applying patches..." - $(Q) cd chip/$(ESP_HAL_3RDPARTY_REPO)/components/mbedtls/mbedtls && git apply ../../../nuttx/patches/components/mbedtls/mbedtls/*.patch + $(Q) cd chip/$(ESP_HAL_3RDPARTY_REPO)/components/mbedtls/mbedtls && patch -p1 < ../../../nuttx/patches/components/mbedtls/mbedtls/0001-mbedtls_add_prefix.patch + $(Q) cd chip/$(ESP_HAL_3RDPARTY_REPO)/components/mbedtls/mbedtls && patch -p1 < ../../../nuttx/patches/components/mbedtls/mbedtls/0002-mbedtls_add_prefix_to_macro.patch + +ESP_COMPONENTS_ESP_PHY_LIB_UNPACK = esp-phy-lib +ifndef ESP_COMPONENTS_ESP_PHY_LIB_VERSION Review Comment: > Since it isn't good to download 3rd party library from github every time in the enterprise automation CI environment. it need provide a method to let the end user pin to a fix version of 3rd party package and skip the download or update. I got it, but this is exactly what `nxtmpdir` does, see: 1. Use `./tools/configure.sh` with the `-S` parameter: ``` make -j distclean && ./tools/configure.sh -S esp32c6-devkitc:wifi && make ``` 2. Check for the `nxtmpdir`: ``` ls -la ../nxtmpdir total 12 drwxr-xr-x 3 tiago tiago 4096 nov 6 13:51 . drwxr-xr-x 18 tiago tiago 4096 nov 6 13:51 .. drwxr-xr-x 4 tiago tiago 4096 nov 6 13:51 esp-hal-3rdparty ``` 3. Run `make distclean` 4. Check again for `../nxtmpdir`: ``` ls -la ../nxtmpdir total 12 drwxr-xr-x 3 tiago tiago 4096 nov 6 13:51 . drwxr-xr-x 18 tiago tiago 4096 nov 6 13:51 .. drwxr-xr-x 4 tiago tiago 4096 nov 6 13:51 esp-hal-3rdparty ``` We had this very same problem internally. If you you run the pipelines in a single job, just use `nxtmpdir` as-is (and it will be kept between different builds, even after using `make distclean`). If you have different build jobs, you can either 1) just enable cache and set `DISABLE_GIT_DEPTH` env variable (so you have the full repository in case you need to check out) or 2) clone the repository externally to the same location (outside the build system). We ended up with 2) because we can check for newer commits very fast, once we already have the full repository and we only need the incremental commits (it speeds up the development workflow). -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
