Skip to content

Commit

Permalink
Enhance the output of --version with Git describe results. (MaskRay#342)
Browse files Browse the repository at this point in the history
  • Loading branch information
madscientist authored and MaskRay committed Nov 10, 2019
1 parent 4d68101 commit 5853071
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
17 changes: 17 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -209,3 +209,20 @@ target_sources(ccls PRIVATE
src/messages/textDocument_signatureHelp.cc
src/messages/workspace.cc
)

### Obtain CCLS version information from Git
### This only happens when cmake is re-run!

if(NOT CCLS_VERSION)
execute_process(COMMAND git describe --tag --long HEAD
OUTPUT_VARIABLE CCLS_VERSION
OUTPUT_STRIP_TRAILING_WHITESPACE
WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}")

if(NOT CCLS_VERSION)
set(CCLS_VERSION "<unknown>")
endif()
endif()

set_property(SOURCE src/main.cc APPEND PROPERTY
COMPILE_DEFINITIONS CCLS_VERSION=\"${CCLS_VERSION}\")
3 changes: 2 additions & 1 deletion src/main.cc
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,8 @@ int main(int argc, char **argv) {
TraceMe();
sys::PrintStackTraceOnErrorSignal(argv[0]);
cl::SetVersionPrinter([](raw_ostream &OS) {
OS << clang::getClangToolFullVersion("ccls") << "\n";
OS << clang::getClangToolFullVersion("ccls version " CCLS_VERSION "\nclang")
<< "\n";
});

for (auto &I : TopLevelSubCommand->OptionsMap)
Expand Down

0 comments on commit 5853071

Please sign in to comment.