ExternalProject: declare byproducts for the download step

This can surface a conflict where two projects download the same file
and get scheduled against each other.
This commit is contained in:
Ben Boeckel
2023-09-21 07:56:20 -04:00
committed by Craig Scott
parent 4ac624debc
commit 872daff159
2 changed files with 17 additions and 5 deletions

View File

@@ -0,0 +1,8 @@
ExternalProject-declare-download-byproducts
-------------------------------------------
* The :module:`ExternalProject` module now declares ``BYPRODUCTS`` for the
downloaded file for generated ``download`` steps. Previously, if multiple
external projects downloaded to the same file, hash verification could fail.
Now, when using the :ref:`Ninja Generators`, this scenario is detected and
Ninja will raise an error stating that multiple rules generate the same file.

View File

@@ -2825,6 +2825,7 @@ function(_ep_add_download_command name)
set(comment)
set(work_dir)
set(extra_repo_info)
set(byproduct_file)
if(cmd_set)
set(work_dir ${download_dir})
@@ -3105,14 +3106,16 @@ hash=${hash}
get_filename_component(fname "${fname}" NAME)
else()
# Fall back to a default file name. The actual file name does not
# matter because it is used only internally and our extraction tool
# inspects the file content directly. If it turns out the wrong URL
# was given that will be revealed during the build which is an easier
# place for users to diagnose than an error here anyway.
set(fname "archive.tar")
# matter as long as it doesn't conflict with other projects because
# it is used only internally and our extraction tool inspects the
# file content directly. If it turns out the wrong URL was given
# that will be revealed during the build which is an easier place for
# users to diagnose than an error here anyway.
set(fname "${name}-archive.tar")
endif()
string(REPLACE ";" "-" fname "${fname}")
set(file ${download_dir}/${fname})
set(byproduct_file "${download_dir}/${fname}")
get_property(timeout TARGET ${name} PROPERTY _EP_TIMEOUT)
get_property(inactivity_timeout
TARGET ${name}
@@ -3289,6 +3292,7 @@ hash=${hash}
COMMAND ${__cmdQuoted}
WORKING_DIRECTORY \${work_dir}
DEPENDS \${depends}
BYPRODUCTS \${byproduct_file}
DEPENDEES mkdir
${log}
${uses_terminal}