Makefile: refactor generators to be PWD-independent

We have multiple scripts that generate headers from other data. All of
these scripts have the assumption built-in that they are executed in the
current source directory, which makes them a bit unwieldy to use during
out-of-tree builds.

Refactor them to instead take the source directory as well as the output
file as arguments.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
Patrick Steinhardt
2024-12-06 14:24:49 +01:00
committed by Junio C Hamano
parent 19d8fe7da6
commit 3f145a4fe3
5 changed files with 68 additions and 34 deletions

View File

@ -638,23 +638,24 @@ set(EXCLUSION_PROGS_CACHE ${EXCLUSION_PROGS} CACHE STRING "Programs not built" F
if(NOT EXISTS ${CMAKE_BINARY_DIR}/command-list.h OR NOT EXCLUSION_PROGS_CACHE STREQUAL EXCLUSION_PROGS)
list(REMOVE_ITEM EXCLUSION_PROGS empty)
message("Generating command-list.h")
execute_process(COMMAND ${SH_EXE} ${CMAKE_SOURCE_DIR}/generate-cmdlist.sh ${EXCLUSION_PROGS} command-list.txt
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
OUTPUT_FILE ${CMAKE_BINARY_DIR}/command-list.h)
execute_process(COMMAND "${SH_EXE}" "${CMAKE_SOURCE_DIR}/generate-cmdlist.sh"
${EXCLUSION_PROGS}
"${CMAKE_SOURCE_DIR}"
"${CMAKE_BINARY_DIR}/command-list.h")
endif()
if(NOT EXISTS ${CMAKE_BINARY_DIR}/config-list.h)
message("Generating config-list.h")
execute_process(COMMAND ${SH_EXE} ${CMAKE_SOURCE_DIR}/generate-configlist.sh
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
OUTPUT_FILE ${CMAKE_BINARY_DIR}/config-list.h)
execute_process(COMMAND "${SH_EXE}" "${CMAKE_SOURCE_DIR}/generate-configlist.sh"
"${CMAKE_SOURCE_DIR}"
"${CMAKE_BINARY_DIR}/config-list.h")
endif()
if(NOT EXISTS ${CMAKE_BINARY_DIR}/hook-list.h)
message("Generating hook-list.h")
execute_process(COMMAND ${SH_EXE} ${CMAKE_SOURCE_DIR}/generate-hooklist.sh
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
OUTPUT_FILE ${CMAKE_BINARY_DIR}/hook-list.h)
execute_process(COMMAND "${SH_EXE}" ${CMAKE_SOURCE_DIR}/generate-hooklist.sh
"${CMAKE_SOURCE_DIR}"
"${CMAKE_BINARY_DIR}/hook-list.h")
endif()
include_directories(${CMAKE_BINARY_DIR})