]> granicus.if.org Git - esp-idf/commitdiff
spiffs: follow symlinks feature during partition in spiffsgen
authorMarcin Borowicz <marcinbor85@gmail.com>
Sun, 14 Jul 2019 14:45:35 +0000 (16:45 +0200)
committerRenz Christian Bagaporo <renz@espressif.com>
Tue, 8 Oct 2019 09:55:59 +0000 (17:55 +0800)
components/spiffs/Kconfig
components/spiffs/Makefile.projbuild
components/spiffs/project_include.cmake
components/spiffs/spiffsgen.py
tools/ldgen/samples/sdkconfig

index c533b819ac7dcfcfb4eb668bd29b53a623f1ae7b..be191c24f4793b99b8800187e220d8571283fced 100644 (file)
@@ -76,6 +76,13 @@ menu "SPIFFS Configuration"
             SPIFFS_OBJ_NAME_LEN + SPIFFS_META_LENGTH should not exceed
             SPIFFS_PAGE_SIZE - 64.
 
+    config SPIFFS_FOLLOW_SYMLINKS
+        bool "Enable symbolic links for image creation"
+        default "n"
+        help
+            If this option is enabled, symbolic links are taken into account
+            during partition image creation.
+
     config SPIFFS_USE_MAGIC
         bool "Enable SPIFFS Filesystem Magic"
         default "y"
index 4d8f39c081c3dd7fa7b6b766c80c8506c731f7d5..87e1f59edf1fe7778fd495e5af5dbe86426bd6e8 100644 (file)
@@ -13,6 +13,12 @@ else
 USE_MAGIC_LEN = ""
 endif
 
+ifdef CONFIG_SPIFFS_FOLLOW_SYMLINKS
+FOLLOW_SYMLINKS = "--follow-symlinks" 
+else
+FOLLOW_SYMLINKS = ""
+endif
+
 # spiffs_create_partition_image
 #
 # Create a spiffs image of the specified directory on the host during build and optionally
@@ -27,6 +33,7 @@ $(1)_bin: $(PARTITION_TABLE_BIN) $(SPIFFS_IMAGE_DEPENDS) | check_python_dependen
        --page-size=$(CONFIG_SPIFFS_PAGE_SIZE) \
        --obj-name-len=$(CONFIG_SPIFFS_OBJ_NAME_LEN) \
        --meta-len=$(CONFIG_SPIFFS_META_LENGTH) \
+       $(FOLLOW_SYMLINKS) \
        $(USE_MAGIC) \
        $(USE_MAGIC_LEN) 
 
@@ -43,4 +50,4 @@ endef
 
 ESPTOOL_ALL_FLASH_ARGS += $(foreach partition,$(SPIFFSGEN_FLASH_IN_PROJECT), \
 $(shell $(GET_PART_INFO) --partition-table-file $(PARTITION_TABLE_BIN) \
-get_partition_info --partition-name $(partition) --info offset) $(BUILD_DIR_BASE)/$(partition).bin)
\ No newline at end of file
+get_partition_info --partition-name $(partition) --info offset) $(BUILD_DIR_BASE)/$(partition).bin)
index 31f63b511170767eaf771145343b64c2363735d5..061a67d0bb0809b56fffdd0d0f1343c7757fa808 100644 (file)
@@ -25,6 +25,10 @@ function(spiffs_create_partition_image partition base_dir)
         set(use_magic_len "--use-magic-len")
     endif()
 
+    if(CONFIG_SPIFFS_FOLLOW_SYMLINKS)
+        set(follow_symlinks "--follow-symlinks")
+    endif()
+
     # Execute SPIFFS image generation; this always executes as there is no way to specify for CMake to watch for
     # contents of the base dir changing.
     add_custom_target(spiffs_${partition}_bin ALL
@@ -32,6 +36,7 @@ function(spiffs_create_partition_image partition base_dir)
         --page-size=${CONFIG_SPIFFS_PAGE_SIZE}
         --obj-name-len=${CONFIG_SPIFFS_OBJ_NAME_LEN}
         --meta-len=${CONFIG_SPIFFS_META_LENGTH}
+        ${follow_symlinks}
         ${use_magic}
         ${use_magic_len}
         DEPENDS ${arg_DEPENDS}
@@ -46,4 +51,4 @@ function(spiffs_create_partition_image partition base_dir)
     else()
         esptool_py_flash_project_args(${partition} ${offset} ${image_file})
     endif()
-endfunction()
\ No newline at end of file
+endfunction()
index de160294d3c3a95a1cc002939362d5167c694e82..fc22d1b36b2236a1fa81fe3d81ee672ca75c54d0 100755 (executable)
@@ -488,6 +488,11 @@ def main():
                         action="store_true",
                         default=True)
 
+    parser.add_argument("--follow-symlinks",
+                        help="Take into account symbolic links during partition image creation.",
+                        action="store_true",
+                        default=False)
+
     parser.add_argument("--use-magic-len",
                         help="Use position in memory to create different magic numbers for each block. Specify if CONFIG_SPIFFS_USE_MAGIC_LENGTH.",
                         action="store_true",
@@ -513,7 +518,7 @@ def main():
 
         spiffs = SpiffsFS(image_size, spiffs_build_default)
 
-        for root, dirs, files in os.walk(args.base_dir):
+        for root, dirs, files in os.walk(args.base_dir, followlinks=args.follow_symlinks):
             for f in files:
                 full_path = os.path.join(root, f)
                 spiffs.create_file("/" + os.path.relpath(full_path, args.base_dir).replace("\\", "/"), full_path)
index 112abbec64cff598429fce0dc6f594e0b9ff363b..dd70883e860ff90801ebd046967379e16851be73 100644 (file)
@@ -516,6 +516,7 @@ CONFIG_SPIFFS_PAGE_SIZE=256
 CONFIG_SPIFFS_OBJ_NAME_LEN=32
 CONFIG_SPIFFS_USE_MAGIC=y
 CONFIG_SPIFFS_USE_MAGIC_LENGTH=y
+CONFIG_SPIFFS_FOLLOW_SYMLINKS=
 CONFIG_SPIFFS_META_LENGTH=4
 CONFIG_SPIFFS_USE_MTIME=y