@@ -8,6 +8,15 @@ set(CMAKE_EXECUTABLE_SUFFIX ".elf")
88option (ULP_COCPU_IS_RISCV "Use RISC-V based ULP" OFF )
99option (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+
1120message (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)
2231foreach (include ${COMPONENT_INCLUDES} )
2332 list (APPEND component_includes -I${include} )
2433endforeach ()
34+ list (REMOVE_DUPLICATES component_includes)
2535
2636list (APPEND ULP_PREPROCESSOR_ARGS ${component_includes} )
2737list (APPEND ULP_PREPROCESSOR_ARGS -I${COMPONENT_DIR} )
2838list (APPEND ULP_PREPROCESSOR_ARGS -I${sdkconfig_dir} )
2939
3040target_include_directories (${ULP_APP_NAME} PRIVATE ${COMPONENT_INCLUDES} )
3141
32- list (APPEND ULP_PREPROCESSOR_ARGS -D__ASSEMBLER__)
33-
3442# Pre-process the linker script
3543if (ULP_COCPU_IS_RISCV)
3644 set (ULP_LD_TEMPLATE ${IDF_PATH} /components/ulp/ld/ulp_riscv.ld)
@@ -41,8 +49,14 @@ else()
4149endif ()
4250
4351get_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+
4458add_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.
0 commit comments