Skip to content

Commit

Permalink
cpio.cmake: allow passing a directory also
Browse files Browse the repository at this point in the history
This allows creating the archive in a subfolder, so "pollution" of the
root folder can be avoided.

Signed-off-by: Axel Heider <[email protected]>
  • Loading branch information
Axel Heider committed May 4, 2023
1 parent bb3f3c7 commit 6efeec5
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions cmake-tool/helpers/cpio.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,16 @@ function(MakeCPIO output_name input_files)
set(archive_symbol ${MAKE_CPIO_CPIO_SYMBOL})
endif()

set(cpio_archive "${CMAKE_CURRENT_BINARY_DIR}/archive.${output_name}.cpio")
get_filename_component(cpio_lib_name "${output_name}" NAME)
get_filename_component(cpio_lib_dir "${output_name}" DIRECTORY)
if(NOT cpio_lib_dir)
set(cpio_lib_dir "${CMAKE_CURRENT_BINARY_DIR}")
else()
set(cpio_lib_dir "${CMAKE_CURRENT_BINARY_DIR}/${cpio_lib_dir}")
endif()

# intermediate files
set(cpio_archive "${cpio_lib_dir}/${cpio_lib_name}.cpio")

# Create a script that prepares CPIO archive contents in a tmp folder and
# then builds the archive. We have to pass the files to cpio in the same
Expand All @@ -55,7 +64,7 @@ function(MakeCPIO output_name input_files)
# "touch -date @0 <file>" the 'modified time' is set to 0. The cpio
# parameter "--owner=+0:+0" sets user and group values to 0:0.
CheckCPIOArgument(cpio_reproducible_flag "--reproducible")
set(cpio_archive_creator "${CMAKE_CURRENT_BINARY_DIR}/${output_name}.sh")
set(cpio_archive_creator "${cpio_lib_dir}/${cpio_lib_name}.sh")
file(
WRITE
"${cpio_archive_creator}"
Expand All @@ -74,7 +83,7 @@ function(MakeCPIO output_name input_files)

# Create a "program" that makes the compiler generate and object file that
# contains the cpio archive.
set(cpio_archive_s "${CMAKE_CURRENT_BINARY_DIR}/${output_name}.S")
set(cpio_archive_s "${cpio_lib_dir}/${cpio_lib_name}.S")
file(
WRITE
"${cpio_archive_s}"
Expand Down

0 comments on commit 6efeec5

Please sign in to comment.