[lldb/Host] Use Host/Config.h entries instead of a global define.
authorJonas Devlieghere <jonas@devlieghere.com>
Tue, 10 Dec 2019 16:54:30 +0000 (08:54 -0800)
committerJonas Devlieghere <jonas@devlieghere.com>
Tue, 10 Dec 2019 19:16:52 +0000 (11:16 -0800)
As suggested by Pavel in a code review:

> Can we replace this (and maybe python too, while at it) with a
> Host/Config.h entry? A global definition means that one has to
> recompile everything when these change in any way, whereas in
> practice only a handful of files need this..

Differential revision: https://reviews.llvm.org/D71280

22 files changed:
lldb/cmake/modules/LLDBConfig.cmake
lldb/include/lldb/Core/IOHandler.h
lldb/include/lldb/Host/Config.h.cmake
lldb/source/API/SBDebugger.cpp
lldb/source/API/SBHostOS.cpp
lldb/source/API/SystemInitializerFull.cpp
lldb/source/Commands/CommandObjectFrame.cpp
lldb/source/Commands/CommandObjectGUI.cpp
lldb/source/Commands/CommandObjectType.cpp
lldb/source/Core/IOHandlerCursesGUI.cpp
lldb/source/Core/ValueObject.cpp
lldb/source/Interpreter/CommandInterpreter.cpp
lldb/source/Interpreter/CommandObjectScript.cpp
lldb/source/Plugins/OperatingSystem/Python/OperatingSystemPython.cpp
lldb/source/Plugins/OperatingSystem/Python/OperatingSystemPython.h
lldb/source/Plugins/ScriptInterpreter/Python/PythonDataObjects.cpp
lldb/source/Plugins/ScriptInterpreter/Python/PythonDataObjects.h
lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp
lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.h
lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPythonImpl.h
lldb/source/Plugins/ScriptInterpreter/Python/lldb-python.h
lldb/unittests/Editline/EditlineTest.cpp

index 54c6283..f1763f5 100644 (file)
@@ -108,13 +108,8 @@ if ((NOT MSVC) OR MSVC12)
   add_definitions( -DHAVE_ROUND )
 endif()
 
-if (LLDB_DISABLE_CURSES)
-  add_definitions( -DLLDB_DISABLE_CURSES )
-endif()
 
-if (LLDB_DISABLE_LIBEDIT)
-  add_definitions( -DLLDB_DISABLE_LIBEDIT )
-else()
+if (NOT LLDB_DISABLE_LIBEDIT)
   find_package(LibEdit REQUIRED)
 
   # Check if we libedit capable of handling wide characters (built with
@@ -291,7 +286,6 @@ if (NOT LLDB_DISABLE_PYTHON)
   if ("${CMAKE_SYSTEM_NAME}" STREQUAL "Windows")
     if (NOT LLDB_RELOCATABLE_PYTHON)
       file(TO_CMAKE_PATH "${PYTHON_HOME}" LLDB_PYTHON_HOME)
-      add_definitions( -DLLDB_PYTHON_HOME="${LLDB_PYTHON_HOME}" )
     endif()
   else()
     find_package(PythonInterp REQUIRED)
@@ -321,7 +315,6 @@ if (LLDB_DISABLE_PYTHON)
   unset(PYTHON_INCLUDE_DIR)
   unset(PYTHON_LIBRARY)
   unset(PYTHON_EXECUTABLE)
-  add_definitions( -DLLDB_DISABLE_PYTHON )
 endif()
 
 if (LLVM_EXTERNAL_CLANG_SOURCE_DIR)
index 5c12467..b31f8d3 100644 (file)
@@ -10,6 +10,7 @@
 #define liblldb_IOHandler_h_
 
 #include "lldb/Core/ValueObjectList.h"
+#include "lldb/Host/Config.h"
 #include "lldb/Utility/CompletionRequest.h"
 #include "lldb/Utility/ConstString.h"
 #include "lldb/Utility/Flags.h"
index 662c076..cd2cdf0 100644 (file)
@@ -17,8 +17,6 @@
 
 #cmakedefine LLDB_DISABLE_POSIX
 
-#define LLDB_LIBDIR_SUFFIX "${LLVM_LIBDIR_SUFFIX}"
-
 #cmakedefine01 HAVE_SYS_TYPES_H
 
 #cmakedefine01 HAVE_SYS_EVENT_H
 
 #cmakedefine01 LLDB_ENABLE_LZMA
 
+#cmakedefine LLDB_DISABLE_CURSES
+
+#cmakedefine LLDB_DISABLE_LIBEDIT
+
+#cmakedefine LLDB_DISABLE_PYTHON
+
+#cmakedefine LLDB_PYTHON_HOME "${LLDB_PYTHON_HOME}"
+
+#define LLDB_LIBDIR_SUFFIX "${LLVM_LIBDIR_SUFFIX}"
+
 #endif // #ifndef LLDB_HOST_CONFIG_H
index e938727..d9dd7d4 100644 (file)
@@ -40,6 +40,7 @@
 #include "lldb/Core/StreamFile.h"
 #include "lldb/Core/StructuredDataImpl.h"
 #include "lldb/DataFormatters/DataVisualization.h"
+#include "lldb/Host/Config.h"
 #include "lldb/Host/XML.h"
 #include "lldb/Initialization/SystemLifetimeManager.h"
 #include "lldb/Interpreter/CommandInterpreter.h"
index c3c92e6..2a1d17a 100644 (file)
@@ -6,9 +6,10 @@
 //
 //===----------------------------------------------------------------------===//
 
+#include "lldb/API/SBHostOS.h"
 #include "SBReproducerPrivate.h"
 #include "lldb/API/SBError.h"
-#include "lldb/API/SBHostOS.h"
+#include "lldb/Host/Config.h"
 #include "lldb/Host/FileSystem.h"
 #include "lldb/Host/Host.h"
 #include "lldb/Host/HostInfo.h"
index 0acc496..ffb302d 100644 (file)
@@ -7,8 +7,8 @@
 //===----------------------------------------------------------------------===//
 
 #include "SystemInitializerFull.h"
-
 #include "lldb/API/SBCommandInterpreter.h"
+#include "lldb/Host/Config.h"
 
 #if !defined(LLDB_DISABLE_PYTHON)
 #include "Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.h"
index 4eef444..d743900 100644 (file)
@@ -14,6 +14,7 @@
 #include "lldb/Core/ValueObjectVariable.h"
 #include "lldb/DataFormatters/DataVisualization.h"
 #include "lldb/DataFormatters/ValueObjectPrinter.h"
+#include "lldb/Host/Config.h"
 #include "lldb/Host/Host.h"
 #include "lldb/Host/OptionParser.h"
 #include "lldb/Host/StringConvert.h"
index 898468a..0ee526e 100644 (file)
@@ -9,6 +9,7 @@
 #include "CommandObjectGUI.h"
 
 #include "lldb/Core/IOHandlerCursesGUI.h"
+#include "lldb/Host/Config.h"
 #include "lldb/Interpreter/CommandInterpreter.h"
 #include "lldb/Interpreter/CommandReturnObject.h"
 #include "lldb/lldb-private.h"
index 7e75c00..265acb4 100644 (file)
@@ -11,6 +11,7 @@
 #include "lldb/Core/Debugger.h"
 #include "lldb/Core/IOHandler.h"
 #include "lldb/DataFormatters/DataVisualization.h"
+#include "lldb/Host/Config.h"
 #include "lldb/Host/OptionParser.h"
 #include "lldb/Interpreter/CommandInterpreter.h"
 #include "lldb/Interpreter/CommandObject.h"
index a9114aa..23c185a 100644 (file)
@@ -7,6 +7,7 @@
 //===----------------------------------------------------------------------===//
 
 #include "lldb/Core/IOHandlerCursesGUI.h"
+#include "lldb/Host/Config.h"
 
 #ifndef LLDB_DISABLE_CURSES
 #include <curses.h>
index 0245300..9eebea5 100644 (file)
@@ -25,6 +25,7 @@
 #include "lldb/DataFormatters/TypeValidator.h"
 #include "lldb/DataFormatters/ValueObjectPrinter.h"
 #include "lldb/Expression/ExpressionVariable.h"
+#include "lldb/Host/Config.h"
 #include "lldb/Symbol/ClangASTContext.h"
 #include "lldb/Symbol/CompileUnit.h"
 #include "lldb/Symbol/CompilerType.h"
index 5a4e466..ace7e4d 100644 (file)
@@ -48,6 +48,7 @@
 #include "lldb/Utility/Stream.h"
 #include "lldb/Utility/Timer.h"
 
+#include "lldb/Host/Config.h"
 #ifndef LLDB_DISABLE_LIBEDIT
 #include "lldb/Host/Editline.h"
 #endif
@@ -362,8 +363,8 @@ void CommandInterpreter::Initialize() {
                   "controlled by the type's author.");
       po->SetHelpLong("");
     }
-    CommandAlias *parray_alias = AddAlias("parray", cmd_obj_sp, 
-            "--element-count %1 --");
+    CommandAlias *parray_alias =
+        AddAlias("parray", cmd_obj_sp, "--element-count %1 --");
     if (parray_alias) {
         parray_alias->SetHelp
           ("parray <COUNT> <EXPRESSION> -- lldb will evaluate EXPRESSION "
index edb1f67..d9ee30c 100644 (file)
@@ -7,12 +7,9 @@
 //===----------------------------------------------------------------------===//
 
 #include "CommandObjectScript.h"
-
-
 #include "lldb/Core/Debugger.h"
-
 #include "lldb/DataFormatters/DataVisualization.h"
-
+#include "lldb/Host/Config.h"
 #include "lldb/Interpreter/CommandInterpreter.h"
 #include "lldb/Interpreter/CommandReturnObject.h"
 #include "lldb/Interpreter/ScriptInterpreter.h"
index 5761b39..3ed48e1 100644 (file)
@@ -6,6 +6,8 @@
 //
 //===----------------------------------------------------------------------===//
 
+#include "lldb/Host/Config.h"
+
 #ifndef LLDB_DISABLE_PYTHON
 
 #include "OperatingSystemPython.h"
index e76227d..e38f0f8 100644 (file)
@@ -9,6 +9,8 @@
 #ifndef liblldb_OperatingSystemPython_h_
 #define liblldb_OperatingSystemPython_h_
 
+#include "lldb/Host/Config.h"
+
 #ifndef LLDB_DISABLE_PYTHON
 
 #include "lldb/Target/OperatingSystem.h"
index 9dee25c..7880c3a 100644 (file)
@@ -6,11 +6,9 @@
 //
 //===----------------------------------------------------------------------===//
 
-#ifdef LLDB_DISABLE_PYTHON
+#include "lldb/Host/Config.h"
 
-// Python is disabled in this build
-
-#else
+#ifndef LLDB_DISABLE_PYTHON
 
 #include "PythonDataObjects.h"
 #include "ScriptInterpreterPython.h"
index b6d6337..ea33d44 100644 (file)
@@ -48,6 +48,8 @@
 #ifndef LLDB_PLUGINS_SCRIPTINTERPRETER_PYTHON_PYTHONDATAOBJECTS_H
 #define LLDB_PLUGINS_SCRIPTINTERPRETER_PYTHON_PYTHONDATAOBJECTS_H
 
+#include "lldb/Host/Config.h"
+
 #ifndef LLDB_DISABLE_PYTHON
 
 // LLDB Python header must be included first
index f6b9183..5c668bf 100644 (file)
@@ -6,11 +6,9 @@
 //
 //===----------------------------------------------------------------------===//
 
-#ifdef LLDB_DISABLE_PYTHON
+#include "lldb/Host/Config.h"
 
-// Python is disabled in this build
-
-#else
+#ifndef LLDB_DISABLE_PYTHON
 
 // LLDB Python header must be included first
 #include "lldb-python.h"
index 9ae4a03..88f6975 100644 (file)
@@ -9,6 +9,8 @@
 #ifndef LLDB_PLUGINS_SCRIPTINTERPRETER_PYTHON_SCRIPTINTERPRETERPYTHON_H
 #define LLDB_PLUGINS_SCRIPTINTERPRETER_PYTHON_SCRIPTINTERPRETERPYTHON_H
 
+#include "lldb/Host/Config.h"
+
 #ifdef LLDB_DISABLE_PYTHON
 
 // Python is disabled in this build
index 7983049..281cfb1 100644 (file)
@@ -6,11 +6,9 @@
 //
 //===----------------------------------------------------------------------===//
 
-#ifdef LLDB_DISABLE_PYTHON
+#include "lldb/Host/Config.h"
 
-// Python is disabled in this build
-
-#else
+#ifndef LLDB_DISABLE_PYTHON
 
 #include "lldb-python.h"
 
index 884514d..b2cd7a6 100644 (file)
@@ -9,6 +9,8 @@
 #ifndef LLDB_PLUGINS_SCRIPTINTERPRETER_PYTHON_LLDB_PYTHON_H
 #define LLDB_PLUGINS_SCRIPTINTERPRETER_PYTHON_LLDB_PYTHON_H
 
+#include "lldb/Host/Config.h"
+
 // Python.h needs to be included before any system headers in order to avoid
 // redefinition of macros
 
index 55845ae..5bbe753 100644 (file)
@@ -6,6 +6,8 @@
 //
 //===----------------------------------------------------------------------===//
 
+#include "lldb/Host/Config.h"
+
 #ifndef LLDB_DISABLE_LIBEDIT
 
 #define EDITLINE_TEST_DUMP_OUTPUT 0