Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Static bundles for the IAR toolchain[DRAFT] #177

Merged
merged 3 commits into from
Aug 8, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
66 changes: 47 additions & 19 deletions ArchiveUtility.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -127,25 +127,53 @@ 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")

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}
)
string (APPEND mri_script "echo end\n")

if (ARCHIVE_IAR)
set (iar_script)
string (APPEND iar_script "--create")
foreach (bundle_library IN LISTS bundle_libraries)
string (APPEND iar_script " \$<TARGET_FILE:${bundle_library}>")
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}
)
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
DEPENDS ${output_directory}/${output_library}
Expand Down
Loading