[Lldb-commits] [lldb] r334393 - [cmake] Detect presence of wide-char libedit at build time
Pavel Labath via lldb-commits
lldb-commits at lists.llvm.org
Mon Jun 11 02:14:26 PDT 2018
Author: labath
Date: Mon Jun 11 02:14:26 2018
New Revision: 334393
URL: http://llvm.org/viewvc/llvm-project?rev=334393&view=rev
Log:
[cmake] Detect presence of wide-char libedit at build time
Summary:
Instead of hardcoding a list of platforms where libedit is known to have
wide char support we detect this in cmake. The main motivation for this
is attempting to improve compatibility with different versions of
libedit, as the interface of non-wide-char functions varies slightly
between versions.
Reviewers: krytarowski, uweigand, jankratochvil, timshen, beanz
Subscribers: mgorny, lldb-commits
Differential Revision: https://reviews.llvm.org/D47625
Modified:
lldb/trunk/cmake/modules/LLDBGenerateConfig.cmake
lldb/trunk/include/lldb/Host/Config.h
lldb/trunk/include/lldb/Host/Config.h.cmake
lldb/trunk/include/lldb/Host/Editline.h
Modified: lldb/trunk/cmake/modules/LLDBGenerateConfig.cmake
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/cmake/modules/LLDBGenerateConfig.cmake?rev=334393&r1=334392&r2=334393&view=diff
==============================================================================
--- lldb/trunk/cmake/modules/LLDBGenerateConfig.cmake (original)
+++ lldb/trunk/cmake/modules/LLDBGenerateConfig.cmake Mon Jun 11 02:14:26 2018
@@ -4,6 +4,7 @@ include(CheckSymbolExists)
include(CheckIncludeFile)
include(CheckIncludeFiles)
include(CheckLibraryExists)
+include(CheckTypeSize)
set(CMAKE_REQUIRED_DEFINITIONS -D_GNU_SOURCE)
check_symbol_exists(ppoll poll.h HAVE_PPOLL)
@@ -27,6 +28,24 @@ if(NOT UNIX)
set(LLDB_DISABLE_POSIX 1)
endif()
+if (NOT LLDB_DISABLE_LIBEDIT)
+ # Check if we libedit capable of handling wide characters (built with
+ # '--enable-widec').
+ set(CMAKE_REQUIRED_LIBRARIES ${libedit_LIBRARIES})
+ set(CMAKE_REQUIRED_INCLUDES ${libedit_INCLUDE_DIRS})
+ check_symbol_exists(el_winsertstr histedit.h LLDB_EDITLINE_USE_WCHAR)
+ set(CMAKE_EXTRA_INCLUDE_FILES histedit.h)
+ check_type_size(el_rfunc_t LLDB_EL_RFUNC_T_SIZE)
+ if (LLDB_EL_RFUNC_T_SIZE STREQUAL "")
+ set(LLDB_HAVE_EL_RFUNC_T 0)
+ else()
+ set(LLDB_HAVE_EL_RFUNC_T 1)
+ endif()
+ set(CMAKE_REQUIRED_LIBRARIES)
+ set(CMAKE_REQUIRED_INCLUDES)
+ set(CMAKE_EXTRA_INCLUDE_FILES)
+endif()
+
if(NOT LLDB_CONFIG_HEADER_INPUT)
set(LLDB_CONFIG_HEADER_INPUT ${LLDB_INCLUDE_ROOT}/lldb/Host/Config.h.cmake)
endif()
Modified: lldb/trunk/include/lldb/Host/Config.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Host/Config.h?rev=334393&r1=334392&r2=334393&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Host/Config.h (original)
+++ lldb/trunk/include/lldb/Host/Config.h Mon Jun 11 02:14:26 2018
@@ -16,6 +16,10 @@
// absence of a configuration step.
#define LLDB_CONFIG_TERMIOS_SUPPORTED 1
+#define LLDB_EDITLINE_USE_WCHAR 1
+
+#define LLDB_HAVE_EL_RFUNC_T 1
+
#define HAVE_SYS_EVENT_H 1
#define HAVE_PPOLL 0
Modified: lldb/trunk/include/lldb/Host/Config.h.cmake
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Host/Config.h.cmake?rev=334393&r1=334392&r2=334393&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Host/Config.h.cmake (original)
+++ lldb/trunk/include/lldb/Host/Config.h.cmake Mon Jun 11 02:14:26 2018
@@ -12,6 +12,10 @@
#cmakedefine LLDB_CONFIG_TERMIOS_SUPPORTED
+#cmakedefine01 LLDB_EDITLINE_USE_WCHAR
+
+#cmakedefine01 LLDB_HAVE_EL_RFUNC_T
+
#cmakedefine LLDB_DISABLE_POSIX
#define LLDB_LIBDIR_SUFFIX "${LLVM_LIBDIR_SUFFIX}"
Modified: lldb/trunk/include/lldb/Host/Editline.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Host/Editline.h?rev=334393&r1=334392&r2=334393&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Host/Editline.h (original)
+++ lldb/trunk/include/lldb/Host/Editline.h Mon Jun 11 02:14:26 2018
@@ -33,23 +33,11 @@
#define liblldb_Editline_h_
#if defined(__cplusplus)
+#include <codecvt>
#include <locale>
#include <sstream>
#include <vector>
-// components needed to handle wide characters ( <codecvt>, codecvt_utf8,
-// libedit built with '--enable-widec' ) are available on some platforms. The
-// wchar_t versions of libedit functions will only be used in cases where this
-// is true. This is a compile time dependecy, for now selected per target
-// Platform
-#if defined(__APPLE__) || defined(__FreeBSD__) || defined(__NetBSD__) || \
- defined(__OpenBSD__)
-#define LLDB_EDITLINE_USE_WCHAR 1
-#include <codecvt>
-#else
-#define LLDB_EDITLINE_USE_WCHAR 0
-#endif
-
#include "lldb/Host/ConnectionFileDescriptor.h"
#include "lldb/lldb-private.h"
@@ -81,7 +69,11 @@ using EditLineStringStreamType = std::st
using EditLineCharType = char;
#endif
-#ifdef EL_CLIENTDATA /* editline with wide support + wide char read function */
+// At one point the callback type of el_set getchar callback changed from char
+// to wchar_t. It is not possible to detect differentiate between the two
+// versions exactly, but this is a pretty good approximation and allows us to
+// build against almost any editline version out there.
+#if LLDB_EDITLINE_USE_WCHAR || defined(EL_CLIENTDATA) || LLDB_HAVE_EL_RFUNC_T
using EditLineGetCharType = wchar_t;
#else
using EditLineGetCharType = char;
More information about the lldb-commits
mailing list