Don't build `replay` target if its src files (.go) are unchanged (#12734)
This commit is contained in:
parent
8598b43fc0
commit
744717aaa2
|
|
@ -25,27 +25,23 @@ file(MAKE_DIRECTORY ${REPLAY_OUTPUT_DIR})
|
||||||
|
|
||||||
# Get all Go source files for dependency tracking
|
# Get all Go source files for dependency tracking
|
||||||
file(GLOB REPLAY_GO_SOURCES "${CMAKE_CURRENT_SOURCE_DIR}/*.go")
|
file(GLOB REPLAY_GO_SOURCES "${CMAKE_CURRENT_SOURCE_DIR}/*.go")
|
||||||
|
set(REPLAY_GO_MOD "${CMAKE_CURRENT_SOURCE_DIR}/go.mod")
|
||||||
|
set(REPLAY_GO_SUM "${CMAKE_CURRENT_SOURCE_DIR}/go.sum")
|
||||||
|
|
||||||
# Custom target to build replay
|
# Custom command to build replay - only rebuilds when source files change
|
||||||
# This handles all Go dependencies automatically - users just need Go installed
|
# go build handles dependencies automatically (downloads if needed)
|
||||||
# ALL means it builds by default (but only if Go is available - see check above)
|
add_custom_command(
|
||||||
add_custom_target(replay ALL
|
OUTPUT ${REPLAY_BINARY}
|
||||||
COMMAND ${CMAKE_COMMAND} -E echo "Downloading Go dependencies..."
|
|
||||||
COMMAND ${GO_EXECUTABLE} mod download
|
|
||||||
COMMAND ${CMAKE_COMMAND} -E echo "Tidying Go modules..."
|
|
||||||
COMMAND ${GO_EXECUTABLE} mod tidy
|
|
||||||
COMMAND ${CMAKE_COMMAND} -E echo "Building replay..."
|
|
||||||
COMMAND ${GO_EXECUTABLE} build -o ${REPLAY_BINARY} .
|
COMMAND ${GO_EXECUTABLE} build -o ${REPLAY_BINARY} .
|
||||||
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
|
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
|
||||||
COMMENT "Building FDB trace replay tool (all dependencies handled automatically)"
|
DEPENDS ${REPLAY_GO_SOURCES} ${REPLAY_GO_MOD} ${REPLAY_GO_SUM}
|
||||||
BYPRODUCTS ${REPLAY_BINARY}
|
COMMENT "Building FDB trace replay tool"
|
||||||
SOURCES ${REPLAY_GO_SOURCES}
|
|
||||||
)
|
)
|
||||||
|
|
||||||
# Make sure the binary is executable
|
# Target that depends on the binary - only triggers rebuild when deps change
|
||||||
add_custom_command(TARGET replay POST_BUILD
|
add_custom_target(replay ALL
|
||||||
COMMAND chmod +x ${REPLAY_BINARY}
|
DEPENDS ${REPLAY_BINARY}
|
||||||
COMMENT "Making replay executable"
|
SOURCES ${REPLAY_GO_SOURCES}
|
||||||
)
|
)
|
||||||
|
|
||||||
message(STATUS "replay will be built by default (Go found)")
|
message(STATUS "replay will be built by default (Go found)")
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue