fix(system): fix idf.py build ulp examples containing spaces in path on Win

pull/13517/merge
Marek Fiala 2024-04-05 10:27:51 +02:00
rodzic 96c81c87bf
commit f2b75d81b3
2 zmienionych plików z 28 dodań i 12 usunięć

Wyświetl plik

@ -8,6 +8,15 @@ set(CMAKE_EXECUTABLE_SUFFIX ".elf")
option(ULP_COCPU_IS_RISCV "Use RISC-V based ULP" OFF)
option(ULP_COCPU_IS_LP_CORE "Use RISC-V based LP Core" OFF)
function(create_arg_file arguments output_file)
# Escape all spaces
list(TRANSFORM arguments REPLACE " " "\\\\ ")
# Create a single string with all args separated by space
list(JOIN arguments " " arguments)
# Write it into the response file
file(WRITE ${output_file} ${arguments})
endfunction()
message(STATUS "Building ULP app ${ULP_APP_NAME}")
# Check the supported assembler version
@ -22,6 +31,7 @@ get_filename_component(sdkconfig_dir ${SDKCONFIG_HEADER} DIRECTORY)
foreach(include ${COMPONENT_INCLUDES})
list(APPEND component_includes -I${include})
endforeach()
list(REMOVE_DUPLICATES component_includes)
list(APPEND ULP_PREPROCESSOR_ARGS ${component_includes})
list(APPEND ULP_PREPROCESSOR_ARGS -I${COMPONENT_DIR})
@ -29,8 +39,6 @@ list(APPEND ULP_PREPROCESSOR_ARGS -I${sdkconfig_dir})
target_include_directories(${ULP_APP_NAME} PRIVATE ${COMPONENT_INCLUDES})
list(APPEND ULP_PREPROCESSOR_ARGS -D__ASSEMBLER__)
# Pre-process the linker script
if(ULP_COCPU_IS_RISCV)
set(ULP_LD_TEMPLATE ${IDF_PATH}/components/ulp/ld/ulp_riscv.ld)
@ -41,8 +49,14 @@ else()
endif()
get_filename_component(ULP_LD_SCRIPT ${ULP_LD_TEMPLATE} NAME)
# Put all arguments to the list
set(preprocessor_args -D__ASSEMBLER__ -E -P -xc -o ${ULP_LD_SCRIPT} ${ULP_PREPROCESSOR_ARGS} ${ULP_LD_TEMPLATE})
set(compiler_arguments_file ${CMAKE_CURRENT_BINARY_DIR}/${ULP_LD_SCRIPT}_args.txt)
create_arg_file("${preprocessor_args}" "${compiler_arguments_file}")
add_custom_command(OUTPUT ${ULP_LD_SCRIPT}
COMMAND ${CMAKE_C_COMPILER} -E -P -xc -o ${ULP_LD_SCRIPT} ${ULP_PREPROCESSOR_ARGS} ${ULP_LD_TEMPLATE}
COMMAND ${CMAKE_C_COMPILER} @${compiler_arguments_file}
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
MAIN_DEPENDENCY ${ULP_LD_TEMPLATE}
DEPENDS ${SDKCONFIG_HEADER}
@ -130,11 +144,15 @@ else()
foreach(ulp_s_source ${ULP_S_SOURCES})
get_filename_component(ulp_ps_source ${ulp_s_source} NAME_WE)
set(ulp_ps_output ${CMAKE_CURRENT_BINARY_DIR}/${ulp_ps_source}.ulp.S)
# Put all arguments to the list
set(preprocessor_args -D__ASSEMBLER__ -E -P -xc -o ${ulp_ps_output} ${ULP_PREPROCESSOR_ARGS} ${ulp_s_source})
set(compiler_arguments_file ${CMAKE_CURRENT_BINARY_DIR}/${ulp_ps_source}_args.txt)
create_arg_file("${preprocessor_args}" "${compiler_arguments_file}")
# Generate preprocessed assembly files.
add_custom_command(OUTPUT ${ulp_ps_output}
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
COMMAND ${CMAKE_C_COMPILER} -E -P -xc ${ULP_PREPROCESSOR_ARGS}
-o ${ulp_ps_output} ${ulp_s_source}
COMMAND ${CMAKE_C_COMPILER} @${compiler_arguments_file}
DEPENDS ${ulp_s_source}
VERBATIM)
# During assembly file compilation, output listing files as well.

Wyświetl plik

@ -10,7 +10,7 @@ from pathlib import Path
import pytest
from test_build_system_helpers import run_idf_py
# In this test file the test are grouped into 3 bundels
# In this test file the test are grouped into 3 bundles
# It would be better to have every test separate,
# but that would mean doing idf_copy each time, and copying takes most of the time
@ -27,12 +27,10 @@ def test_spaces_bundle1(idf_copy: Path) -> None:
run_idf_py('build', workdir=(idf_copy / 'examples' / 'get-started' / 'hello_world'))
# test spiffsgen
run_idf_py('build', workdir=(idf_copy / 'examples' / 'storage' / 'spiffsgen'))
# bug reported in IDF-9151
if sys.platform != 'win32':
# test build ulp_fsm
run_idf_py('build', workdir=(idf_copy / 'examples' / 'system' / 'ulp' / 'ulp_fsm' / 'ulp'))
# test build ulp_riscv
run_idf_py('-DIDF_TARGET=esp32s2', 'build', workdir=(idf_copy / 'examples' / 'system' / 'ulp' / 'ulp_riscv' / 'gpio'))
# test build ulp_fsm
run_idf_py('build', workdir=(idf_copy / 'examples' / 'system' / 'ulp' / 'ulp_fsm' / 'ulp'))
# test build ulp_riscv
run_idf_py('-DIDF_TARGET=esp32s2', 'build', workdir=(idf_copy / 'examples' / 'system' / 'ulp' / 'ulp_riscv' / 'gpio'))
@pytest.mark.idf_copy('esp idf with spaces')