Skip to content

Commit 324dcbc

Browse files
committed
Merge branch 'feat/fix_idf_build_spaces' into 'master'
fix(system): fix ulp examples containing spaces in path on Win Closes IDF-9151 See merge request espressif/esp-idf!30060
2 parents f7fceb5 + f2b75d8 commit 324dcbc

File tree

2 files changed

+28
-12
lines changed

2 files changed

+28
-12
lines changed

components/ulp/cmake/CMakeLists.txt

Lines changed: 23 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,15 @@ set(CMAKE_EXECUTABLE_SUFFIX ".elf")
88
option(ULP_COCPU_IS_RISCV "Use RISC-V based ULP" OFF)
99
option(ULP_COCPU_IS_LP_CORE "Use RISC-V based LP Core" OFF)
1010

11+
function(create_arg_file arguments output_file)
12+
# Escape all spaces
13+
list(TRANSFORM arguments REPLACE " " "\\\\ ")
14+
# Create a single string with all args separated by space
15+
list(JOIN arguments " " arguments)
16+
# Write it into the response file
17+
file(WRITE ${output_file} ${arguments})
18+
endfunction()
19+
1120
message(STATUS "Building ULP app ${ULP_APP_NAME}")
1221

1322
# Check the supported assembler version
@@ -22,15 +31,14 @@ get_filename_component(sdkconfig_dir ${SDKCONFIG_HEADER} DIRECTORY)
2231
foreach(include ${COMPONENT_INCLUDES})
2332
list(APPEND component_includes -I${include})
2433
endforeach()
34+
list(REMOVE_DUPLICATES component_includes)
2535

2636
list(APPEND ULP_PREPROCESSOR_ARGS ${component_includes})
2737
list(APPEND ULP_PREPROCESSOR_ARGS -I${COMPONENT_DIR})
2838
list(APPEND ULP_PREPROCESSOR_ARGS -I${sdkconfig_dir})
2939

3040
target_include_directories(${ULP_APP_NAME} PRIVATE ${COMPONENT_INCLUDES})
3141

32-
list(APPEND ULP_PREPROCESSOR_ARGS -D__ASSEMBLER__)
33-
3442
# Pre-process the linker script
3543
if(ULP_COCPU_IS_RISCV)
3644
set(ULP_LD_TEMPLATE ${IDF_PATH}/components/ulp/ld/ulp_riscv.ld)
@@ -41,8 +49,14 @@ else()
4149
endif()
4250

4351
get_filename_component(ULP_LD_SCRIPT ${ULP_LD_TEMPLATE} NAME)
52+
53+
# Put all arguments to the list
54+
set(preprocessor_args -D__ASSEMBLER__ -E -P -xc -o ${ULP_LD_SCRIPT} ${ULP_PREPROCESSOR_ARGS} ${ULP_LD_TEMPLATE})
55+
set(compiler_arguments_file ${CMAKE_CURRENT_BINARY_DIR}/${ULP_LD_SCRIPT}_args.txt)
56+
create_arg_file("${preprocessor_args}" "${compiler_arguments_file}")
57+
4458
add_custom_command(OUTPUT ${ULP_LD_SCRIPT}
45-
COMMAND ${CMAKE_C_COMPILER} -E -P -xc -o ${ULP_LD_SCRIPT} ${ULP_PREPROCESSOR_ARGS} ${ULP_LD_TEMPLATE}
59+
COMMAND ${CMAKE_C_COMPILER} @${compiler_arguments_file}
4660
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
4761
MAIN_DEPENDENCY ${ULP_LD_TEMPLATE}
4862
DEPENDS ${SDKCONFIG_HEADER}
@@ -130,11 +144,15 @@ else()
130144
foreach(ulp_s_source ${ULP_S_SOURCES})
131145
get_filename_component(ulp_ps_source ${ulp_s_source} NAME_WE)
132146
set(ulp_ps_output ${CMAKE_CURRENT_BINARY_DIR}/${ulp_ps_source}.ulp.S)
147+
# Put all arguments to the list
148+
set(preprocessor_args -D__ASSEMBLER__ -E -P -xc -o ${ulp_ps_output} ${ULP_PREPROCESSOR_ARGS} ${ulp_s_source})
149+
set(compiler_arguments_file ${CMAKE_CURRENT_BINARY_DIR}/${ulp_ps_source}_args.txt)
150+
create_arg_file("${preprocessor_args}" "${compiler_arguments_file}")
151+
133152
# Generate preprocessed assembly files.
134153
add_custom_command(OUTPUT ${ulp_ps_output}
135154
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
136-
COMMAND ${CMAKE_C_COMPILER} -E -P -xc ${ULP_PREPROCESSOR_ARGS}
137-
-o ${ulp_ps_output} ${ulp_s_source}
155+
COMMAND ${CMAKE_C_COMPILER} @${compiler_arguments_file}
138156
DEPENDS ${ulp_s_source}
139157
VERBATIM)
140158
# During assembly file compilation, output listing files as well.

tools/test_build_system/test_spaces.py

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
import pytest
1111
from test_build_system_helpers import run_idf_py
1212

13-
# In this test file the test are grouped into 3 bundels
13+
# In this test file the test are grouped into 3 bundles
1414
# It would be better to have every test separate,
1515
# but that would mean doing idf_copy each time, and copying takes most of the time
1616

@@ -27,12 +27,10 @@ def test_spaces_bundle1(idf_copy: Path) -> None:
2727
run_idf_py('build', workdir=(idf_copy / 'examples' / 'get-started' / 'hello_world'))
2828
# test spiffsgen
2929
run_idf_py('build', workdir=(idf_copy / 'examples' / 'storage' / 'spiffsgen'))
30-
# bug reported in IDF-9151
31-
if sys.platform != 'win32':
32-
# test build ulp_fsm
33-
run_idf_py('build', workdir=(idf_copy / 'examples' / 'system' / 'ulp' / 'ulp_fsm' / 'ulp'))
34-
# test build ulp_riscv
35-
run_idf_py('-DIDF_TARGET=esp32s2', 'build', workdir=(idf_copy / 'examples' / 'system' / 'ulp' / 'ulp_riscv' / 'gpio'))
30+
# test build ulp_fsm
31+
run_idf_py('build', workdir=(idf_copy / 'examples' / 'system' / 'ulp' / 'ulp_fsm' / 'ulp'))
32+
# test build ulp_riscv
33+
run_idf_py('-DIDF_TARGET=esp32s2', 'build', workdir=(idf_copy / 'examples' / 'system' / 'ulp' / 'ulp_riscv' / 'gpio'))
3634

3735

3836
@pytest.mark.idf_copy('esp idf with spaces')

0 commit comments

Comments
 (0)