Skip to content

Commit b4abd32

Browse files
committed
git forgot a file
1 parent 22a6b84 commit b4abd32

File tree

1 file changed

+35
-0
lines changed

1 file changed

+35
-0
lines changed

cmake/modules/GitCommit.cmake

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
# This source file is part of the Swift.org open source project
2+
#
3+
# Copyright (c) 2024–2025 Apple Inc. and the Swift project authors
4+
# Licensed under Apache License v2.0 with Runtime Library Exception
5+
#
6+
# See http://swift.org/LICENSE.txt for license information
7+
# See http://swift.org/CONTRIBUTORS.txt for Swift project authors
8+
9+
find_package(Git QUIET)
10+
if(Git_FOUND)
11+
# Get the commit hash corresponding to the current build.
12+
execute_process(
13+
COMMAND ${GIT_EXECUTABLE} rev-parse --verify HEAD
14+
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}
15+
OUTPUT_VARIABLE SWT_TESTING_LIBRARY_COMMIT_HASH
16+
OUTPUT_STRIP_TRAILING_WHITESPACE
17+
ERROR_QUIET)
18+
19+
# Check if there are local changes.
20+
execute_process(
21+
COMMAND ${GIT_EXECUTABLE} status -s
22+
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}
23+
OUTPUT_VARIABLE SWT_TESTING_LIBRARY_COMMIT_MODIFIED
24+
OUTPUT_STRIP_TRAILING_WHITESPACE)
25+
endif()
26+
27+
if(SWT_TESTING_LIBRARY_COMMIT_HASH)
28+
message(STATUS "Swift Testing commit hash: ${SWT_TESTING_LIBRARY_COMMIT_HASH}")
29+
add_compile_definitions(
30+
"$<$<COMPILE_LANGUAGE:CXX>:SWT_TESTING_LIBRARY_COMMIT_HASH=\"${SWT_TESTING_LIBRARY_COMMIT_HASH}\">")
31+
if(SWT_TESTING_LIBRARY_COMMIT_MODIFIED)
32+
add_compile_definitions(
33+
"$<$<COMPILE_LANGUAGE:CXX>:SWT_TESTING_LIBRARY_COMMIT_MODIFIED=1>")
34+
endif()
35+
endif()

0 commit comments

Comments
 (0)