From 798e5df15680f293927d49ec98774349cb1dbe26 Mon Sep 17 00:00:00 2001 From: Christian Reimer Date: Wed, 31 Jul 2024 22:13:50 +0200 Subject: [PATCH 1/3] Static bundle for IAR toolchain hack --- ArchiveUtility.cmake | 37 ++++++++++++++++++++++++++++++++----- 1 file changed, 32 insertions(+), 5 deletions(-) diff --git a/ArchiveUtility.cmake b/ArchiveUtility.cmake index 1533764..a88c705 100644 --- a/ArchiveUtility.cmake +++ b/ArchiveUtility.cmake @@ -127,19 +127,28 @@ function (add_static_library_bundle target) string (APPEND mri_script "fi\n\n") endforeach() string (APPEND mri_script "echo save\n") - string (APPEND mri_script "echo end") + string (APPEND mri_script "echo end\n") - set (mri_script_file ${mri_script_dir}/script.mri.sh) + set (iar_script) + string (APPEND iar_script "--create") + foreach (bundle_library IN LISTS bundle_libraries) + string (APPEND iar_script " \$") + endforeach() + string (APPEND iar_script " -o ${output_directory}/${output_library}\n") + + set (iar_script_file ${mri_script_dir}/script.iar.sh) + set (iar_cp_file ${mri_script_dir}/script.iar_cp.sh) file (GENERATE - OUTPUT ${mri_script_file} - CONTENT "${mri_script}" + OUTPUT ${iar_script_file} + CONTENT "${iar_script}" CONDITION 1 ) + add_custom_command ( OUTPUT ${output_directory}/${output_library} - COMMAND bash ${mri_script_file} | ${CMAKE_AR} -M + COMMAND ${CMAKE_AR} -f ${iar_script_file} COMMAND_EXPAND_LISTS WORKING_DIRECTORY ${output_directory} @@ -147,6 +156,24 @@ function (add_static_library_bundle target) ${bundle_libraries} ) + # set (mri_script_file ${mri_script_dir}/script.mri.sh) + + # file (GENERATE + # OUTPUT ${mri_script_file} + # CONTENT "${mri_script}" + # CONDITION 1 + # ) + + # add_custom_command ( + # OUTPUT ${output_directory}/${output_library} + # COMMAND bash ${mri_script_file} | ${CMAKE_AR} -M + # COMMAND_EXPAND_LISTS + # WORKING_DIRECTORY + # ${output_directory} + # DEPENDS + # ${bundle_libraries} + # ) + add_custom_target (${target} ALL DEPENDS ${output_directory}/${output_library} ) From c248bf376aa9a3e65673d99f841fa357498c2f96 Mon Sep 17 00:00:00 2001 From: sokhealy Date: Wed, 31 Jul 2024 16:19:33 -0700 Subject: [PATCH 2/3] add ARCHIVE_IAR variable --- ArchiveUtility.cmake | 91 +++++++++++++++++++++++--------------------- 1 file changed, 47 insertions(+), 44 deletions(-) diff --git a/ArchiveUtility.cmake b/ArchiveUtility.cmake index a88c705..79be435 100644 --- a/ArchiveUtility.cmake +++ b/ArchiveUtility.cmake @@ -129,50 +129,53 @@ function (add_static_library_bundle target) string (APPEND mri_script "echo save\n") string (APPEND mri_script "echo end\n") - set (iar_script) - string (APPEND iar_script "--create") - foreach (bundle_library IN LISTS bundle_libraries) - string (APPEND iar_script " \$") - endforeach() - string (APPEND iar_script " -o ${output_directory}/${output_library}\n") - - set (iar_script_file ${mri_script_dir}/script.iar.sh) - set (iar_cp_file ${mri_script_dir}/script.iar_cp.sh) - - file (GENERATE - OUTPUT ${iar_script_file} - CONTENT "${iar_script}" - CONDITION 1 - ) - - - add_custom_command ( - OUTPUT ${output_directory}/${output_library} - COMMAND ${CMAKE_AR} -f ${iar_script_file} - COMMAND_EXPAND_LISTS - WORKING_DIRECTORY - ${output_directory} - DEPENDS - ${bundle_libraries} - ) - - # set (mri_script_file ${mri_script_dir}/script.mri.sh) - - # file (GENERATE - # OUTPUT ${mri_script_file} - # CONTENT "${mri_script}" - # CONDITION 1 - # ) - - # add_custom_command ( - # OUTPUT ${output_directory}/${output_library} - # COMMAND bash ${mri_script_file} | ${CMAKE_AR} -M - # COMMAND_EXPAND_LISTS - # WORKING_DIRECTORY - # ${output_directory} - # DEPENDS - # ${bundle_libraries} - # ) + if (NOT ARCHIVE_IAR) + set (mri_script_file ${mri_script_dir}/script.mri.sh) + + file (GENERATE + OUTPUT ${mri_script_file} + CONTENT "${mri_script}" + CONDITION 1 + ) + + add_custom_command ( + OUTPUT ${output_directory}/${output_library} + COMMAND bash ${mri_script_file} | ${CMAKE_AR} -M + COMMAND_EXPAND_LISTS + WORKING_DIRECTORY + ${output_directory} + DEPENDS + ${bundle_libraries} + ) + endif() + + if (ARCHIVE_IAR) + set (iar_script) + string (APPEND iar_script "--create") + foreach (bundle_library IN LISTS bundle_libraries) + string (APPEND iar_script " \$") + endforeach() + string (APPEND iar_script " -o ${output_directory}/${output_library}\n") + + set (iar_script_file ${mri_script_dir}/script.iar.sh) + set (iar_cp_file ${mri_script_dir}/script.iar_cp.sh) + + file (GENERATE + OUTPUT ${iar_script_file} + CONTENT "${iar_script}" + CONDITION 1 + ) + + add_custom_command ( + OUTPUT ${output_directory}/${output_library} + COMMAND ${CMAKE_AR} -f ${iar_script_file} + COMMAND_EXPAND_LISTS + WORKING_DIRECTORY + ${output_directory} + DEPENDS + ${bundle_libraries} + ) + endif() add_custom_target (${target} ALL DEPENDS ${output_directory}/${output_library} From 4ae995ebd70d481a25503834de76cf1d5c3701e6 Mon Sep 17 00:00:00 2001 From: sokhealy Date: Wed, 31 Jul 2024 17:19:30 -0700 Subject: [PATCH 3/3] update logic --- ArchiveUtility.cmake | 38 ++++++++++++++++++-------------------- 1 file changed, 18 insertions(+), 20 deletions(-) diff --git a/ArchiveUtility.cmake b/ArchiveUtility.cmake index 79be435..a530a60 100644 --- a/ArchiveUtility.cmake +++ b/ArchiveUtility.cmake @@ -129,26 +129,6 @@ function (add_static_library_bundle target) string (APPEND mri_script "echo save\n") string (APPEND mri_script "echo end\n") - if (NOT ARCHIVE_IAR) - set (mri_script_file ${mri_script_dir}/script.mri.sh) - - file (GENERATE - OUTPUT ${mri_script_file} - CONTENT "${mri_script}" - CONDITION 1 - ) - - add_custom_command ( - OUTPUT ${output_directory}/${output_library} - COMMAND bash ${mri_script_file} | ${CMAKE_AR} -M - COMMAND_EXPAND_LISTS - WORKING_DIRECTORY - ${output_directory} - DEPENDS - ${bundle_libraries} - ) - endif() - if (ARCHIVE_IAR) set (iar_script) string (APPEND iar_script "--create") @@ -175,6 +155,24 @@ function (add_static_library_bundle target) DEPENDS ${bundle_libraries} ) + else () + set (mri_script_file ${mri_script_dir}/script.mri.sh) + + file (GENERATE + OUTPUT ${mri_script_file} + CONTENT "${mri_script}" + CONDITION 1 + ) + + add_custom_command ( + OUTPUT ${output_directory}/${output_library} + COMMAND bash ${mri_script_file} | ${CMAKE_AR} -M + COMMAND_EXPAND_LISTS + WORKING_DIRECTORY + ${output_directory} + DEPENDS + ${bundle_libraries} + ) endif() add_custom_target (${target} ALL