forked from OSchip/llvm-project
Unify Darwin and Non-Darwin printing of version output
Summary: This change unifies and simplifies the code paths between the Darwin and non-Darwin code to print the LLDB version information. It also introduces a new variable in CMake LLDB_VERSION_STRING which can be used to specify custom version information. On Darwin this value is implicitly set based on the resource/LLDB-Info.plist file. With the LLDB_VERSION_STRING variable set to lldb-360.99.0, the -version output is: > ./bin/lldb -version lldb version 4.0.0 (lldb-360.99.0) clang revision 286264 llvm revision 286265 This behavior is unified across all target platforms. Reviewers: lldb-commits Subscribers: mgorny, tfiala Differential Revision: https://reviews.llvm.org/D26478 llvm-svn: 286479
This commit is contained in:
parent
56cec3d662
commit
b92cfe6804
|
@ -0,0 +1,11 @@
|
|||
execute_process(COMMAND /usr/libexec/PlistBuddy -c "Print:CFBundleVersion" ${LLDB_INFO_PLIST}
|
||||
OUTPUT_VARIABLE BundleVersion
|
||||
OUTPUT_STRIP_TRAILING_WHITESPACE)
|
||||
|
||||
file(APPEND "${HEADER_FILE}.tmp"
|
||||
"#define LLDB_VERSION_STRING \"lldb-${BundleVersion}\"\n")
|
||||
|
||||
execute_process(COMMAND ${CMAKE_COMMAND} -E copy_if_different
|
||||
"${HEADER_FILE}.tmp" "${HEADER_FILE}")
|
||||
|
||||
file(REMOVE "${HEADER_FILE}.tmp")
|
|
@ -8775,6 +8775,20 @@
|
|||
"\"$(SYSTEM_LIBRARY_DIR)/PrivateFrameworks\"",
|
||||
);
|
||||
GCC_INLINES_ARE_PRIVATE_EXTERN = NO;
|
||||
GCC_PREPROCESSOR_DEFINITIONS = (
|
||||
__STDC_CONSTANT_MACROS,
|
||||
__STDC_LIMIT_MACROS,
|
||||
LLDB_CONFIGURATION_DEBUG,
|
||||
"LLDB_VERSION_STRING=\"lldb-${CURRENT_PROJECT_VERSION}\"",
|
||||
);
|
||||
"GCC_PREPROCESSOR_DEFINITIONS[sdk=iphoneos*][arch=*]" = (
|
||||
__STDC_CONSTANT_MACROS,
|
||||
__STDC_LIMIT_MACROS,
|
||||
LLDB_CONFIGURATION_DEBUG,
|
||||
LLDB_DISABLE_PYTHON,
|
||||
NO_XPC_SERVICES,
|
||||
"LLDB_VERSION_STRING=\"lldb-${CURRENT_PROJECT_VERSION}\"",
|
||||
);
|
||||
HEADER_SEARCH_PATHS = /usr/include/libxml2;
|
||||
LLDB_COMPRESSION_CFLAGS = "";
|
||||
"LLDB_COMPRESSION_CFLAGS[sdk=macosx10.11]" = "-DHAVE_LIBCOMPRESSION=1";
|
||||
|
@ -8820,6 +8834,20 @@
|
|||
"\"$(SYSTEM_LIBRARY_DIR)/PrivateFrameworks\"",
|
||||
);
|
||||
GCC_INLINES_ARE_PRIVATE_EXTERN = NO;
|
||||
GCC_PREPROCESSOR_DEFINITIONS = (
|
||||
__STDC_CONSTANT_MACROS,
|
||||
__STDC_LIMIT_MACROS,
|
||||
LLDB_CONFIGURATION_RELEASE,
|
||||
"LLDB_VERSION_STRING=\"lldb-${CURRENT_PROJECT_VERSION}\"",
|
||||
);
|
||||
"GCC_PREPROCESSOR_DEFINITIONS[sdk=iphoneos*][arch=*]" = (
|
||||
__STDC_CONSTANT_MACROS,
|
||||
__STDC_LIMIT_MACROS,
|
||||
LLDB_CONFIGURATION_RELEASE,
|
||||
LLDB_DISABLE_PYTHON,
|
||||
NO_XPC_SERVICES,
|
||||
"LLDB_VERSION_STRING=\"lldb-${CURRENT_PROJECT_VERSION}\"",
|
||||
);
|
||||
HEADER_SEARCH_PATHS = /usr/include/libxml2;
|
||||
LLDB_COMPRESSION_CFLAGS = "";
|
||||
"LLDB_COMPRESSION_CFLAGS[sdk=macosx10.11]" = "-DHAVE_LIBCOMPRESSION=1";
|
||||
|
@ -8865,6 +8893,20 @@
|
|||
"\"$(SYSTEM_LIBRARY_DIR)/PrivateFrameworks\"",
|
||||
);
|
||||
GCC_INLINES_ARE_PRIVATE_EXTERN = NO;
|
||||
GCC_PREPROCESSOR_DEFINITIONS = (
|
||||
__STDC_CONSTANT_MACROS,
|
||||
__STDC_LIMIT_MACROS,
|
||||
LLDB_CONFIGURATION_BUILD_AND_INTEGRATION,
|
||||
"LLDB_VERSION_STRING=\"lldb-${CURRENT_PROJECT_VERSION}\"",
|
||||
);
|
||||
"GCC_PREPROCESSOR_DEFINITIONS[sdk=iphoneos*][arch=*]" = (
|
||||
__STDC_CONSTANT_MACROS,
|
||||
__STDC_LIMIT_MACROS,
|
||||
LLDB_CONFIGURATION_BUILD_AND_INTEGRATION,
|
||||
LLDB_DISABLE_PYTHON,
|
||||
NO_XPC_SERVICES,
|
||||
"LLDB_VERSION_STRING=\"lldb-${CURRENT_PROJECT_VERSION}\"",
|
||||
);
|
||||
HEADER_SEARCH_PATHS = /usr/include/libxml2;
|
||||
LLDB_COMPRESSION_CFLAGS = "";
|
||||
"LLDB_COMPRESSION_CFLAGS[sdk=macosx10.11]" = "-DHAVE_LIBCOMPRESSION=1";
|
||||
|
@ -9864,6 +9906,20 @@
|
|||
"\"$(SYSTEM_LIBRARY_DIR)/PrivateFrameworks\"",
|
||||
);
|
||||
GCC_INLINES_ARE_PRIVATE_EXTERN = NO;
|
||||
GCC_PREPROCESSOR_DEFINITIONS = (
|
||||
__STDC_CONSTANT_MACROS,
|
||||
__STDC_LIMIT_MACROS,
|
||||
LLDB_CONFIGURATION_DEBUG,
|
||||
"LLDB_VERSION_STRING=\"lldb-${CURRENT_PROJECT_VERSION}\"",
|
||||
);
|
||||
"GCC_PREPROCESSOR_DEFINITIONS[sdk=iphoneos*][arch=*]" = (
|
||||
__STDC_CONSTANT_MACROS,
|
||||
__STDC_LIMIT_MACROS,
|
||||
LLDB_CONFIGURATION_DEBUG,
|
||||
LLDB_DISABLE_PYTHON,
|
||||
NO_XPC_SERVICES,
|
||||
"LLDB_VERSION_STRING=\"lldb-${CURRENT_PROJECT_VERSION}\"",
|
||||
);
|
||||
HEADER_SEARCH_PATHS = /usr/include/libxml2;
|
||||
LLDB_COMPRESSION_CFLAGS = "";
|
||||
"LLDB_COMPRESSION_CFLAGS[sdk=macosx10.11]" = "-DHAVE_LIBCOMPRESSION=1";
|
||||
|
|
|
@ -25,21 +25,6 @@ set(lldbBase_SOURCES
|
|||
lldb.cpp
|
||||
)
|
||||
|
||||
if (CMAKE_SYSTEM_NAME MATCHES "Darwin")
|
||||
set(LLDB_VERS_GENERATED_FILE ${LLDB_BINARY_DIR}/source/LLDB_vers.c)
|
||||
add_custom_command(OUTPUT ${LLDB_VERS_GENERATED_FILE}
|
||||
COMMAND ${LLDB_SOURCE_DIR}/scripts/generate-vers.pl
|
||||
${LLDB_SOURCE_DIR}/lldb.xcodeproj/project.pbxproj liblldb_core
|
||||
> ${LLDB_VERS_GENERATED_FILE}
|
||||
DEPENDS ${LLDB_SOURCE_DIR}/scripts/generate-vers.pl
|
||||
${LLDB_SOURCE_DIR}/lldb.xcodeproj/project.pbxproj)
|
||||
set_source_files_properties(${LLDB_VERS_GENERATED_FILE} PROPERTIES GENERATED 1)
|
||||
# Add this to lldbBase since lldb.cpp uses the symbol defined here.
|
||||
list(APPEND lldbBase_SOURCES ${LLDB_VERS_GENERATED_FILE})
|
||||
add_custom_target(lldbGeneratedVersion
|
||||
DEPENDS ${LLDB_VERS_GENERATED_FILE})
|
||||
endif()
|
||||
|
||||
foreach(file
|
||||
"${LLDB_SOURCE_DIR}/.git/logs/HEAD" # Git
|
||||
"${LLDB_SOURCE_DIR}/.svn/wc.db" # SVN 1.7
|
||||
|
@ -75,14 +60,37 @@ if(DEFINED lldb_vc)
|
|||
list(APPEND lldbBase_SOURCES ${version_inc})
|
||||
endif()
|
||||
|
||||
if(APPLE)
|
||||
set(apple_version_inc "${CMAKE_CURRENT_BINARY_DIR}/AppleVersion.inc")
|
||||
set(apple_version_script "${LLDB_SOURCE_DIR}/cmake/modules/EmbedAppleVersion.cmake")
|
||||
set(info_plist ${LLDB_SOURCE_DIR}/resources/LLDB-Info.plist)
|
||||
|
||||
# Create custom target to generate the VC revision include.
|
||||
add_custom_command(OUTPUT "${apple_version_inc}"
|
||||
DEPENDS "${apple_version_script}" "${info_plist}"
|
||||
COMMAND
|
||||
${CMAKE_COMMAND} "-DLLDB_INFO_PLIST=${info_plist}"
|
||||
"-DHEADER_FILE=${apple_version_inc}"
|
||||
-P "${apple_version_script}")
|
||||
|
||||
# Mark the generated header as being generated.
|
||||
set_source_files_properties("${apple_version_inc}"
|
||||
PROPERTIES GENERATED TRUE
|
||||
HEADER_FILE_ONLY TRUE)
|
||||
|
||||
# Tell Version.cpp that it needs to build with -DHAVE_SVN_VERSION_INC.
|
||||
set_source_files_properties(lldb.cpp
|
||||
PROPERTIES COMPILE_DEFINITIONS "HAVE_APPLE_VERSION_INC")
|
||||
list(APPEND lldbBase_SOURCES ${apple_version_inc})
|
||||
elseif(LLDB_VERSION_STRING)
|
||||
set_source_files_properties(lldb.cpp
|
||||
PROPERTIES COMPILE_DEFINITIONS "LLDB_VERSION_STRING=\"${LLDB_VERSION_STRING}\"")
|
||||
endif()
|
||||
|
||||
add_lldb_library(lldbBase
|
||||
${lldbBase_SOURCES}
|
||||
)
|
||||
|
||||
if (CMAKE_SYSTEM_NAME MATCHES "Darwin")
|
||||
add_dependencies(lldbBase lldbGeneratedVersion)
|
||||
endif()
|
||||
|
||||
add_subdirectory(Breakpoint)
|
||||
add_subdirectory(Commands)
|
||||
add_subdirectory(Core)
|
||||
|
|
|
@ -12,16 +12,16 @@
|
|||
using namespace lldb;
|
||||
using namespace lldb_private;
|
||||
|
||||
#if defined(__APPLE__)
|
||||
extern "C" const unsigned char liblldb_coreVersionString[];
|
||||
#else
|
||||
|
||||
#include "clang/Basic/Version.h"
|
||||
|
||||
#ifdef HAVE_SVN_VERSION_INC
|
||||
# include "SVNVersion.inc"
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_APPLE_VERSION_INC
|
||||
# include "AppleVersion.inc"
|
||||
#endif
|
||||
|
||||
static const char *GetLLDBRevision() {
|
||||
#ifdef LLDB_REVISION
|
||||
return LLDB_REVISION;
|
||||
|
@ -38,33 +38,8 @@ static const char *GetLLDBRepository() {
|
|||
#endif
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
const char *lldb_private::GetVersion() {
|
||||
#if defined(__APPLE__)
|
||||
static char g_version_string[32];
|
||||
if (g_version_string[0] == '\0') {
|
||||
const char *version_string =
|
||||
::strstr((const char *)liblldb_coreVersionString, "PROJECT:");
|
||||
|
||||
if (version_string)
|
||||
version_string += sizeof("PROJECT:") - 1;
|
||||
else
|
||||
version_string = "unknown";
|
||||
|
||||
const char *newline_loc = strchr(version_string, '\n');
|
||||
|
||||
size_t version_len = sizeof(g_version_string) - 1;
|
||||
|
||||
if (newline_loc &&
|
||||
(newline_loc - version_string < static_cast<ptrdiff_t>(version_len)))
|
||||
version_len = newline_loc - version_string;
|
||||
|
||||
::snprintf(g_version_string, version_len + 1, "%s", version_string);
|
||||
}
|
||||
|
||||
return g_version_string;
|
||||
#else
|
||||
// On platforms other than Darwin, report a version number in the same style
|
||||
// as the clang tool.
|
||||
static std::string g_version_str;
|
||||
|
@ -81,21 +56,24 @@ const char *lldb_private::GetVersion() {
|
|||
if (lldb_rev) {
|
||||
g_version_str += " revision ";
|
||||
g_version_str += lldb_rev;
|
||||
g_version_str += ")";
|
||||
}
|
||||
#ifdef LLDB_VERSION_STRING
|
||||
g_version_str += " (";
|
||||
g_version_str += LLDB_VERSION_STRING;
|
||||
g_version_str += ")";
|
||||
#endif
|
||||
std::string clang_rev(clang::getClangRevision());
|
||||
if (clang_rev.length() > 0) {
|
||||
g_version_str += " clang revision ";
|
||||
g_version_str += "\n clang revision ";
|
||||
g_version_str += clang_rev;
|
||||
}
|
||||
std::string llvm_rev(clang::getLLVMRevision());
|
||||
if (llvm_rev.length() > 0) {
|
||||
g_version_str += " llvm revision ";
|
||||
g_version_str += "\n llvm revision ";
|
||||
g_version_str += llvm_rev;
|
||||
}
|
||||
|
||||
if (lldb_repo)
|
||||
g_version_str += ")";
|
||||
|
||||
}
|
||||
return g_version_str.c_str();
|
||||
#endif
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue