build: bundle: clean binary dir with new downloads (#10411)

This is required to (re)build e.g. libluv when the version changes
(which triggers a new download).

With `make deps`, changing the `LUV_URL`/`LUV_SHA256`, and `make deps` again:

Before:

> Up-to-date: /home/daniel/Vcs/neovim/.deps/usr/lib/libluv.a

After:

> Installing: /home/daniel/Vcs/neovim/.deps/usr/lib/libluv.a

See with https://github.com/neovim/neovim/pull/10358 - where .deps
contained libluv 1.29, the merge updates it to 1.30, but then it failed
to link because `libluv.a` is considered to be up-to-date (after
downloading the new version).

Note that header files get installed, since they have the original time
stamp, but `libluv.a` is being generated (does not use the timestamp
from the archive here, but needs to get rebuild).

It could be argued that the build system of the included project should
catch/handle this, but it seems to be good practice to clean the binary
/ build dir with a new download to start from scratch.

Ref: https://gitlab.kitware.com/cmake/cmake/issues/19452

Also fixes cmake/BuildLuv / luv-static: use name with -DTARGET for
download command, and pass (shared) `SRC_DIR` explicitly instead.
This commit is contained in:
Daniel Hahler 2019-07-04 02:37:29 +02:00 committed by GitHub
parent f6298aba82
commit 99b870d61c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 14 additions and 2 deletions

View File

@ -42,7 +42,9 @@ function(BuildLuv)
-DDOWNLOAD_DIR=${DEPS_DOWNLOAD_DIR}/luv
-DURL=${LUV_URL}
-DEXPECTED_SHA256=${LUV_SHA256}
-DTARGET=luv
-DTARGET=luv-static
# The source is shared with BuildLuarocks (with USE_BUNDLED_LUV).
-DSRC_DIR=${DEPS_BUILD_DIR}/src/luv
-DUSE_EXISTING_SRC_DIR=${USE_EXISTING_SRC_DIR}
-P ${CMAKE_CURRENT_SOURCE_DIR}/cmake/DownloadAndExtractFile.cmake
PATCH_COMMAND "${_luv_PATCH_COMMAND}"

View File

@ -18,7 +18,10 @@ if(NOT DEFINED TARGET)
message(FATAL_ERROR "TARGET must be defined.")
endif()
set(SRC_DIR ${PREFIX}/src/${TARGET})
if(NOT DEFINED SRC_DIR)
set(SRC_DIR ${PREFIX}/src/${TARGET})
endif()
set(BINARY_DIR ${PREFIX}/src/${TARGET}-build)
# Check whether the source has been downloaded. If true, skip it.
# Useful for external downloads like homebrew.
@ -154,6 +157,13 @@ file(REMOVE_RECURSE ${SRC_DIR})
get_filename_component(contents ${contents} ABSOLUTE)
file(RENAME ${contents} ${SRC_DIR})
# Remove any existing BINARY_DIR, to force a new build.
# Without this a necessary output (e.g. libluv.a) might not be updated/installed.
#
message(STATUS "extracting... [clean binary dir]")
file(REMOVE_RECURSE ${BINARY_DIR})
file(MAKE_DIRECTORY ${BINARY_DIR})
# Clean up:
#
message(STATUS "extracting... [clean up]")