xref: /freebsd/contrib/llvm-project/lld/Common/Version.cpp (revision 5ffd83dbcc34f10e07f6d3e968ae6365869615f4)
10b57cec5SDimitry Andric //===- lib/Common/Version.cpp - LLD Version Number ---------------*- C++-=====//
20b57cec5SDimitry Andric //
30b57cec5SDimitry Andric // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
40b57cec5SDimitry Andric // See https://llvm.org/LICENSE.txt for license information.
50b57cec5SDimitry Andric // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
60b57cec5SDimitry Andric //
70b57cec5SDimitry Andric //===----------------------------------------------------------------------===//
80b57cec5SDimitry Andric //
90b57cec5SDimitry Andric // This file defines several version-related utility functions for LLD.
100b57cec5SDimitry Andric //
110b57cec5SDimitry Andric //===----------------------------------------------------------------------===//
120b57cec5SDimitry Andric 
130b57cec5SDimitry Andric #include "lld/Common/Version.h"
140b57cec5SDimitry Andric 
150b57cec5SDimitry Andric #ifdef HAVE_VCS_VERSION_INC
160b57cec5SDimitry Andric #include "VCSVersion.inc"
170b57cec5SDimitry Andric #endif
180b57cec5SDimitry Andric 
190b57cec5SDimitry Andric // Returns a version string, e.g.:
200b57cec5SDimitry Andric // lld 9.0.0 (https://github.com/llvm/llvm-project.git 9efdd7ac5e914d3c9fa1ef)
210b57cec5SDimitry Andric std::string lld::getLLDVersion() {
22*5ffd83dbSDimitry Andric #ifdef LLD_VENDOR
23*5ffd83dbSDimitry Andric #define LLD_VENDOR_DISPLAY LLD_VENDOR " "
240b57cec5SDimitry Andric #else
25*5ffd83dbSDimitry Andric #define LLD_VENDOR_DISPLAY
260b57cec5SDimitry Andric #endif
27*5ffd83dbSDimitry Andric #if defined(LLD_REPOSITORY) && defined(LLD_REVISION)
28*5ffd83dbSDimitry Andric   return LLD_VENDOR_DISPLAY "LLD " LLD_VERSION_STRING " (" LLD_REPOSITORY
29*5ffd83dbSDimitry Andric                             " " LLD_REVISION ")";
30*5ffd83dbSDimitry Andric #else
31*5ffd83dbSDimitry Andric   return LLD_VENDOR_DISPLAY "LLD " LLD_VERSION_STRING;
32*5ffd83dbSDimitry Andric #endif
33*5ffd83dbSDimitry Andric #undef LLD_VENDOR_DISPLAY
340b57cec5SDimitry Andric }
35