Skip to content

Commit 50e94af

Browse files
committed
Generate empty *Revision.inc files during the build process
1 parent 56dfb08 commit 50e94af

File tree

2 files changed

+15
-25
lines changed

2 files changed

+15
-25
lines changed

lib/Basic/CMakeLists.txt

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -31,24 +31,27 @@ set(get_svn_script "${LLVM_MAIN_SRC_DIR}/cmake/modules/GetSVN.cmake")
3131

3232
function(generate_revision_inc revision_inc_var name dir)
3333
find_first_existing_vc_file(dep_file "${dir}")
34+
# Create custom target to generate the VC revision include.
35+
set(revision_inc "${CMAKE_CURRENT_BINARY_DIR}/${name}Revision.inc")
36+
string(TOUPPER ${name} upper_name)
3437
if(DEFINED dep_file)
35-
# Create custom target to generate the VC revision include.
36-
set(revision_inc "${CMAKE_CURRENT_BINARY_DIR}/${name}Revision.inc")
37-
string(TOUPPER ${name} upper_name)
3838
add_custom_command(OUTPUT "${revision_inc}"
3939
DEPENDS "${dep_file}" "${get_svn_script}"
4040
COMMAND
4141
${CMAKE_COMMAND} "-DFIRST_SOURCE_DIR=${dir}"
4242
"-DFIRST_NAME=${upper_name}"
4343
"-DHEADER_FILE=${revision_inc}"
4444
-P "${get_svn_script}")
45-
46-
# Mark the generated header as being generated.
47-
set_source_files_properties("${revision_inc}"
48-
PROPERTIES GENERATED TRUE
49-
HEADER_FILE_ONLY TRUE)
50-
set(${revision_inc_var} ${revision_inc} PARENT_SCOPE)
45+
else()
46+
# Generate an empty Revision.inc file if we are not using git or SVN.
47+
file(WRITE "${revision_inc}" "")
5148
endif()
49+
50+
# Mark the generated header as being generated.
51+
set_source_files_properties("${revision_inc}"
52+
PROPERTIES GENERATED TRUE
53+
HEADER_FILE_ONLY TRUE)
54+
set(${revision_inc_var} ${revision_inc} PARENT_SCOPE)
5255
endfunction()
5356

5457
generate_revision_inc(llvm_revision_inc LLVM "${LLVM_MAIN_SRC_DIR}")

lib/Basic/Version.cpp

Lines changed: 3 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -43,22 +43,9 @@
4343
SWIFT_MAKE_VERSION_STRING(SWIFT_VERSION_MAJOR, SWIFT_VERSION_MINOR)
4444
#endif
4545

46-
// MSVC doesn't support __has_include
47-
#if defined(_MSC_VER)
48-
# include "LLVMRevision.inc"
49-
# include "ClangRevision.inc"
50-
# include "SwiftRevision.inc"
51-
#else
52-
#if __has_include("LLVMRevision.inc")
53-
# include "LLVMRevision.inc"
54-
#endif
55-
#if __has_include("ClangRevision.inc")
56-
# include "ClangRevision.inc"
57-
#endif
58-
#if __has_include("SwiftRevision.inc")
59-
# include "SwiftRevision.inc"
60-
#endif
61-
#endif
46+
#include "LLVMRevision.inc"
47+
#include "ClangRevision.inc"
48+
#include "SwiftRevision.inc"
6249

6350
namespace swift {
6451
namespace version {

0 commit comments

Comments
 (0)