From 9f8587360ca9fbd29a585360331cd9c7d4bdd37d Mon Sep 17 00:00:00 2001 From: Angus Gratton Date: Wed, 5 Dec 2018 18:29:28 +1100 Subject: [PATCH 1/4] ldgen: Fix crash if --sections argument not supplied --- tools/ldgen/ldgen.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/tools/ldgen/ldgen.py b/tools/ldgen/ldgen.py index 5078d142fe..33b9cd4f77 100755 --- a/tools/ldgen/ldgen.py +++ b/tools/ldgen/ldgen.py @@ -73,14 +73,17 @@ def main(): fragment_files = [] if not args.fragments else args.fragments config_file = args.config output_path = args.output - sections_info_files = [] if not args.sections else args.sections kconfig_file = args.kconfig + sections = args.sections try: sections_infos = SectionsInfo() - section_info_contents = [s.strip() for s in sections_info_files.read().split("\n")] - section_info_contents = [s for s in section_info_contents if s] + if sections: + section_info_contents = [s.strip() for s in sections.read().split("\n")] + section_info_contents = [s for s in section_info_contents if s] + else: + section_info_contents = [] for sections_info_file in section_info_contents: with open(sections_info_file) as sections_info_file_obj: From ef4a4105f439f926d2a241d592c0b6fb824172f0 Mon Sep 17 00:00:00 2001 From: Angus Gratton Date: Wed, 5 Dec 2018 18:29:44 +1100 Subject: [PATCH 2/4] make/ldgen: Fix generation of ldgen.section_infos file when shell is bash bash doesn't escape by default from "echo", so use "printf" Closes https://github.com/espressif/esp-idf/pull/2797 Closes https://github.com/espressif/esp-idf/issues/2796 --- make/ldgen.mk | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/make/ldgen.mk b/make/ldgen.mk index 53a20b7054..bc7fdc681a 100644 --- a/make/ldgen.mk +++ b/make/ldgen.mk @@ -6,17 +6,13 @@ LDGEN_FRAGMENT_FILES = $(COMPONENT_LDFRAGMENTS) # Target to generate linker script generator from fragments presented by each of # the components define ldgen_process_template -ifeq ($(OS), Windows_NT) -$(BUILD_DIR_BASE)/ldgen.section_infos: $(LDGEN_SECTIONS_INFO_FILES) - echo -ne "$(foreach section_info,$(LDGEN_SECTIONS_INFO_FILES),$(section_info)\n)" > $(BUILD_DIR_BASE)/ldgen.section_infos +$(BUILD_DIR_BASE)/ldgen.section_infos: $(LDGEN_SECTIONS_INFO_FILES) $(IDF_PATH)/make/ldgen.mk + printf "$(foreach section_info,$(LDGEN_SECTIONS_INFO_FILES),$(section_info)\n)" > $(BUILD_DIR_BASE)/ldgen.section_infos sed -i 's|^[[:blank:]]*||g' $(BUILD_DIR_BASE)/ldgen.section_infos +ifeq ($(OS), Windows_NT) mv $(BUILD_DIR_BASE)/ldgen.section_infos $(BUILD_DIR_BASE)/ldgen.section_infos.temp cygpath -w -f $(BUILD_DIR_BASE)/ldgen.section_infos.temp > $(BUILD_DIR_BASE)/ldgen.section_infos rm -f $(BUILD_DIR_BASE)/ldgen.section_infos.temp -else -$(BUILD_DIR_BASE)/ldgen.section_infos: $(LDGEN_SECTIONS_INFO_FILES) - echo "$(foreach section_info,$(LDGEN_SECTIONS_INFO_FILES),$(section_info)\n)" > $(BUILD_DIR_BASE)/ldgen.section_infos - sed -i 's|^[[:blank:]]*||g' $(BUILD_DIR_BASE)/ldgen.section_infos endif $(2): $(1) $(LDGEN_FRAGMENT_FILES) $(SDKCONFIG) $(BUILD_DIR_BASE)/ldgen.section_infos From 8ab2f20c3a458fa6a217a2504d68472e2fbadf44 Mon Sep 17 00:00:00 2001 From: Angus Gratton Date: Thu, 6 Dec 2018 15:07:24 +1100 Subject: [PATCH 3/4] ldgen make: Use "sed -E" for extended POSIX regular expression syntax w/ BSD sed --- make/ldgen.mk | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/make/ldgen.mk b/make/ldgen.mk index bc7fdc681a..2cbb6f43f8 100644 --- a/make/ldgen.mk +++ b/make/ldgen.mk @@ -8,7 +8,8 @@ LDGEN_FRAGMENT_FILES = $(COMPONENT_LDFRAGMENTS) define ldgen_process_template $(BUILD_DIR_BASE)/ldgen.section_infos: $(LDGEN_SECTIONS_INFO_FILES) $(IDF_PATH)/make/ldgen.mk printf "$(foreach section_info,$(LDGEN_SECTIONS_INFO_FILES),$(section_info)\n)" > $(BUILD_DIR_BASE)/ldgen.section_infos - sed -i 's|^[[:blank:]]*||g' $(BUILD_DIR_BASE)/ldgen.section_infos + sed -E -i.bak 's|^[[:blank:]]*||g' $(BUILD_DIR_BASE)/ldgen.section_infos + rm $(BUILD_DIR_BASE)/ldgen.section_infos.bak ifeq ($(OS), Windows_NT) mv $(BUILD_DIR_BASE)/ldgen.section_infos $(BUILD_DIR_BASE)/ldgen.section_infos.temp cygpath -w -f $(BUILD_DIR_BASE)/ldgen.section_infos.temp > $(BUILD_DIR_BASE)/ldgen.section_infos From 54532c6189b3ba68f2b80e16e62917406b017c28 Mon Sep 17 00:00:00 2001 From: Angus Gratton Date: Thu, 6 Dec 2018 15:14:59 +1100 Subject: [PATCH 4/4] build example tests: Use portable "sed -i" form --- tools/ci/test_build_system.sh | 3 +-- tools/ci/test_build_system_cmake.sh | 20 ++++++++++---------- 2 files changed, 11 insertions(+), 12 deletions(-) diff --git a/tools/ci/test_build_system.sh b/tools/ci/test_build_system.sh index c8c2768156..56daa383c8 100755 --- a/tools/ci/test_build_system.sh +++ b/tools/ci/test_build_system.sh @@ -254,8 +254,7 @@ function run_tests() rm -f ${TESTDIR}/template/version.txt print_status "Build fails if partitions don't fit in flash" - cp sdkconfig sdkconfig.bak - sed -i "s/CONFIG_ESPTOOLPY_FLASHSIZE.\+//" sdkconfig # remove all flashsize config + sed -i.bak "s/CONFIG_ESPTOOLPY_FLASHSIZE.\+//" sdkconfig # remove all flashsize config echo "CONFIG_ESPTOOLPY_FLASHSIZE_1MB=y" >> sdkconfig # introduce undersize flash make defconfig || failure "Failed to reconfigure with smaller flash" ( make 2>&1 | grep "does not fit in configured flash size 1MB" ) || failure "Build didn't fail with expected flash size failure message" diff --git a/tools/ci/test_build_system_cmake.sh b/tools/ci/test_build_system_cmake.sh index b2f9cae7f2..b308b9afe6 100755 --- a/tools/ci/test_build_system_cmake.sh +++ b/tools/ci/test_build_system_cmake.sh @@ -180,7 +180,7 @@ function run_tests() idf.py build take_build_snapshot # need to actually change config, or cmake is too smart to rebuild - sed -i s/^\#\ CONFIG_FREERTOS_UNICORE\ is\ not\ set/CONFIG_FREERTOS_UNICORE=y/ sdkconfig + sed -i.bak s/^\#\ CONFIG_FREERTOS_UNICORE\ is\ not\ set/CONFIG_FREERTOS_UNICORE=y/ sdkconfig idf.py build # check the sdkconfig.h file was rebuilt assert_rebuilt config/sdkconfig.h @@ -189,6 +189,7 @@ function run_tests() assert_rebuilt esp-idf/newlib/CMakeFiles/${IDF_COMPONENT_PREFIX}_newlib.dir/syscall_table.c.obj assert_rebuilt esp-idf/nvs_flash/CMakeFiles/${IDF_COMPONENT_PREFIX}_nvs_flash.dir/src/nvs_api.cpp.obj assert_rebuilt esp-idf/freertos/CMakeFiles/${IDF_COMPONENT_PREFIX}_freertos.dir/xtensa_vectors.S.obj + mv sdkconfig.bak sdkconfig print_status "Updating project CMakeLists.txt triggers full recompile" clean_build_dir @@ -196,13 +197,14 @@ function run_tests() take_build_snapshot # Need to actually change the build config, or CMake won't do anything cp CMakeLists.txt CMakeLists.bak - sed -i 's/^project(/add_compile_options("-DUSELESS_MACRO_DOES_NOTHING=1")\nproject\(/' CMakeLists.txt + sed -i.bak 's/^project(/add_compile_options("-DUSELESS_MACRO_DOES_NOTHING=1")\nproject\(/' CMakeLists.txt idf.py build || failure "Build failed" mv CMakeLists.bak CMakeLists.txt # similar to previous test assert_rebuilt esp-idf/newlib/CMakeFiles/${IDF_COMPONENT_PREFIX}_newlib.dir/syscall_table.c.obj assert_rebuilt esp-idf/nvs_flash/CMakeFiles/${IDF_COMPONENT_PREFIX}_nvs_flash.dir/src/nvs_api.cpp.obj assert_rebuilt esp-idf/freertos/CMakeFiles/${IDF_COMPONENT_PREFIX}_freertos.dir/xtensa_vectors.S.obj + mv sdkconfig.bak sdkconfig print_status "Can build with Ninja (no idf.py)" clean_build_dir @@ -217,23 +219,21 @@ function run_tests() print_status "Can build with IDF_PATH set via cmake cache not environment" clean_build_dir - cp CMakeLists.txt CMakeLists.bak - sed -i 's/ENV{IDF_PATH}/{IDF_PATH}/' CMakeLists.txt + sed -i.bak 's/ENV{IDF_PATH}/{IDF_PATH}/' CMakeLists.txt export IDF_PATH_BACKUP="$IDF_PATH" (unset IDF_PATH && cd build && cmake -G Ninja .. -DIDF_PATH=${IDF_PATH_BACKUP} && ninja) || failure "Ninja build failed" - mv CMakeLists.bak CMakeLists.txt + mv CMakeLists.txt.bak CMakeLists.txt assert_built ${APP_BINS} ${BOOTLOADER_BINS} ${PARTITION_BIN} print_status "Can build with IDF_PATH unset and inferred by build system" clean_build_dir - cp CMakeLists.txt CMakeLists.bak - sed -i "s%\$ENV{IDF_PATH}%${IDF_PATH}%" CMakeLists.txt # expand to a hardcoded path + sed -i.bak "s%\$ENV{IDF_PATH}%${IDF_PATH}%" CMakeLists.txt # expand to a hardcoded path (unset IDF_PATH && cd build && cmake -G Ninja .. && ninja) || failure "Ninja build failed" - mv CMakeLists.bak CMakeLists.txt + mv CMakeLists.txt.bak CMakeLists.txt assert_built ${APP_BINS} ${BOOTLOADER_BINS} ${PARTITION_BIN} # Next two tests will use this fake 'esp31b' target @@ -241,7 +241,7 @@ function run_tests() mkdir -p components/$fake_target touch components/$fake_target/CMakeLists.txt cp ${IDF_PATH}/tools/cmake/toolchain-esp32.cmake components/$fake_target/toolchain-$fake_target.cmake - sed -i.old '/cmake_minimum_required/ a\ + sed -i.bak '/cmake_minimum_required/ a\ set(COMPONENTS esptool_py)' CMakeLists.txt print_status "Can override IDF_TARGET from environment" @@ -261,7 +261,7 @@ function run_tests() grep "IDF_TARGET:STRING=${fake_target}" build/CMakeCache.txt || failure "IDF_TARGET not set in CMakeCache.txt using idf.py -D" # Clean up modifications for the fake target - mv CMakeLists.txt.old CMakeLists.txt + mv CMakeLists.txt.bak CMakeLists.txt rm -rf components print_status "Can find toolchain file in component directory"