Skip to content

[Basic] Revise version printing #32345

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 1 commit into from
Jun 16, 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
1 change: 0 additions & 1 deletion lib/Basic/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ function(generate_revision_inc revision_inc_var name dir)
endfunction()

generate_revision_inc(llvm_revision_inc LLVM "${LLVM_MAIN_SRC_DIR}")
generate_revision_inc(clang_revision_inc Clang "${CLANG_MAIN_SRC_DIR}")
generate_revision_inc(swift_revision_inc Swift "${SWIFT_SOURCE_DIR}")

add_swift_host_library(swiftBasic STATIC
Expand Down
24 changes: 7 additions & 17 deletions lib/Basic/Version.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,34 +45,25 @@
#endif

#include "LLVMRevision.inc"
#include "ClangRevision.inc"
#include "SwiftRevision.inc"

namespace swift {
namespace version {

/// Print a string of the form "LLVM xxxxx, Clang yyyyy, Swift zzzzz",
/// where each placeholder is the revision for the associated repository.
/// Print a string of the form "LLVM xxxxx, Swift zzzzz", where each placeholder
/// is the revision for the associated repository.
static void printFullRevisionString(raw_ostream &out) {
// Arbitrarily truncate to 10 characters. This should be enough to unique
// Git hashes for the time being, and certainly enough for SVN revisions,
// while keeping the version string from being ridiculously long.
// Arbitrarily truncate to 15 characters. This should be enough to unique Git
// hashes while keeping the REPL version string from overflowing 80 columns.
#if defined(LLVM_REVISION)
out << "LLVM " << StringRef(LLVM_REVISION).slice(0, 10);
# if defined(CLANG_REVISION) || defined(SWIFT_REVISION)
out << ", ";
# endif
#endif

#if defined(CLANG_REVISION)
out << "Clang " << StringRef(CLANG_REVISION).slice(0, 10);
out << "LLVM " << StringRef(LLVM_REVISION).slice(0, 15);
# if defined(SWIFT_REVISION)
out << ", ";
# endif
#endif

#if defined(SWIFT_REVISION)
out << "Swift " << StringRef(SWIFT_REVISION).slice(0, 10);
out << "Swift " << StringRef(SWIFT_REVISION).slice(0, 15);
#endif
}

Expand Down Expand Up @@ -424,8 +415,7 @@ std::string getSwiftFullVersion(Version effectiveVersion) {
OS << " clang-" CLANG_COMPILER_VERSION;
#endif
OS << ")";
#elif defined(LLVM_REVISION) || defined(CLANG_REVISION) || \
defined(SWIFT_REVISION)
#elif defined(LLVM_REVISION) || defined(SWIFT_REVISION)
OS << " (";
printFullRevisionString(OS);
OS << ")";
Expand Down