Skip to content

Add a switch to not include git commit hash in the built artifacts #32998

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Jul 22, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,10 @@ include(CheckSymbolExists)
# This is primarily to support building smaller or faster project files.
#

option(SWIFT_APPEND_VC_REV
"Embed the version control system revision in Swift"
TRUE)

option(SWIFT_INCLUDE_TOOLS
"Generate build targets for swift tools"
TRUE)
Expand Down
9 changes: 7 additions & 2 deletions lib/Basic/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,12 @@ else()
endif()

function(generate_revision_inc revision_inc_var name dir)
find_first_existing_vc_file("${dir}" ${name}_vc)
if(SWIFT_APPEND_VC_REV)
# generate_vcs_version_script generates header with only `undef`s
# inside when source directory doesn't exist.
find_first_existing_vc_file("${dir}" ${name}_vc)
set(dir_when_append_enabled ${dir})
endif()

# Create custom target to generate the VC revision include.
set(version_inc "${CMAKE_CURRENT_BINARY_DIR}/${name}Revision.inc")
Expand All @@ -22,7 +27,7 @@ function(generate_revision_inc revision_inc_var name dir)
add_custom_command(OUTPUT "${version_inc}"
DEPENDS "${${name}_vc}" "${generate_vcs_version_script}"
COMMAND ${CMAKE_COMMAND} "-DNAMES=$<UPPER_CASE:${name}>"
"-D$<UPPER_CASE:${name}>_SOURCE_DIR=${dir}"
"-D$<UPPER_CASE:${name}>_SOURCE_DIR=${dir_when_append_enabled}"
"-DHEADER_FILE=${version_inc}"
-P "${generate_vcs_version_script}")

Expand Down