diff options
author | Patrick Steinhardt <psteinhardt@gitlab.com> | 2021-03-05 13:00:52 +0300 |
---|---|---|
committer | Patrick Steinhardt <psteinhardt@gitlab.com> | 2021-03-09 10:56:30 +0300 |
commit | 88edbea810ee68a806b823bf80e124105b5e754d (patch) | |
tree | c0805bb290b4331201208ccb7d501b469f537df0 /Makefile | |
parent | fcffd63f502bbfdf29f29f16f73da292e75c8fef (diff) |
Makefile: Use per-tool version files
Right now, we determine whether tools need a rebuild based on whether
the Makefile has changed or not. This is kind of a sledge hammer: it
works in most cases, but is overly general. Also, it fails in case the
user specifies a version e.g. via `config.mak` or via the command line.
Refactor this to use per-tool version files and drop the
`Makefile.sha256` hack.
Diffstat (limited to 'Makefile')
-rw-r--r-- | Makefile | 20 |
1 files changed, 8 insertions, 12 deletions
@@ -408,22 +408,17 @@ ${DEPENDENCY_DIR}: | ${BUILD_DIR} ${Q}mkdir -p ${DEPENDENCY_DIR} # This is a build hack to avoid excessive rebuilding of targets. Instead of -# depending on the timestamp of the Makefile, which will change e.g. between -# jobs of a CI pipeline, we start depending on its hash. Like this, we only -# rebuild if the Makefile actually has changed contents. -${BUILD_DIR}/Makefile.sha256: Makefile | ${BUILD_DIR} - ${Q}sha256sum -c $@ >/dev/null 2>&1 || >$@ sha256sum Makefile - -# This is in the same spirit as the Makefile.sha256 optimization: we want to -# rebuild only if the dependency's version changes. The dependency on the phony -# target is required to always rebuild these targets. +# depending on the Makefile, we start to depend on tool versions as defined in +# the Makefile. Like this, we only rebuild if the tool versions actually +# change. The dependency on the phony target is required to always rebuild +# these targets. .PHONY: dependency-version ${DEPENDENCY_DIR}/libgit2.version: dependency-version | ${DEPENDENCY_DIR} ${Q}[ x"$$(cat "$@" 2>/dev/null)" = x"${LIBGIT2_VERSION}" ] || >$@ echo -n "${LIBGIT2_VERSION}" ${DEPENDENCY_DIR}/git.version: dependency-version | ${DEPENDENCY_DIR} ${Q}[ x"$$(cat "$@" 2>/dev/null)" = x"${GIT_VERSION}" ] || >$@ echo -n "${GIT_VERSION}" -${TOOLS_DIR}/protoc.version: dependency-version | ${TOOLS_DIR} - ${Q}[ x"$$(cat "$@" 2>/dev/null)" = x"${PROTOC_VERSION}" ] || >$@ echo -n "${PROTOC_VERSION}" +${TOOLS_DIR}/%.version: dependency-version | ${TOOLS_DIR} + ${Q}[ x"$$(cat "$@" 2>/dev/null)" = x"${TOOL_VERSION}" ] || >$@ echo -n "${TOOL_VERSION}" ${LIBGIT2_INSTALL_DIR}/lib/libgit2.a: ${DEPENDENCY_DIR}/libgit2.version ${Q}${GIT} init --initial-branch=master ${GIT_QUIET} ${LIBGIT2_SOURCE_DIR} @@ -459,6 +454,7 @@ ${GIT_INSTALL_DIR}/bin/git: ${DEPENDENCY_DIR}/git_full_bins.tgz tar -C ${GIT_INSTALL_DIR} -xvzf ${DEPENDENCY_DIR}/git_full_bins.tgz endif +${TOOLS_DIR}/protoc.zip: TOOL_VERSION = ${PROTOC_VERSION} ${TOOLS_DIR}/protoc.zip: ${TOOLS_DIR}/protoc.version ${Q}if [ -z "${PROTOC_URL}" ]; then echo "Cannot generate protos on unsupported platform ${OS}" && exit 1; fi curl -o $@.tmp --silent --show-error -L ${PROTOC_URL} @@ -476,7 +472,7 @@ ${TOOLS_DIR}/%/go.mod: | ${TOOLS_DIR} ${Q}cd $(dir $@) && go mod init _build ${TOOLS_DIR}/%: GOBIN = ${TOOLS_DIR} -${TOOLS_DIR}/%: ${BUILD_DIR}/Makefile.sha256 ${TOOLS_DIR}/.%/go.mod +${TOOLS_DIR}/%: ${TOOLS_DIR}/%.version ${TOOLS_DIR}/.%/go.mod ${Q}cd ${TOOLS_DIR}/.$(notdir $@) && go get ${TOOL_PACKAGE}@${TOOL_VERSION} # Tools hosted by Gitaly itself |