[Lldb-commits] [lldb] r300372 - [CMake] Support generating Config.h

Chris Bieneman via lldb-commits lldb-commits at lists.llvm.org
Fri Apr 14 15:03:45 PDT 2017


Author: cbieneman
Date: Fri Apr 14 17:03:45 2017
New Revision: 300372

URL: http://llvm.org/viewvc/llvm-project?rev=300372&view=rev
Log:
[CMake] Support generating Config.h

Summary:
This patch removes the hand maintained config files in favor of auto-generating the config file. We will still need to maintain the defines for the Xcode builds on Mac, but all CMake builds use the generated header instead.

This will enable finer grained platform support tests and enable supporting LLDB on more platforms with less manual maintenance.

I have only tested this patch on Darwin, and any help testing it out on other platforms would be greatly appreciated. I've probably messed something up somewhere.

Reviewers: labath, zturner

Reviewed By: labath

Subscribers: krytarowski, emaste, srhines, lldb-commits, mgorny

Differential Revision: https://reviews.llvm.org/D31969

Added:
    lldb/trunk/include/lldb/Host/Config.h.cmake
Removed:
    lldb/trunk/include/lldb/Host/android/Config.h
    lldb/trunk/include/lldb/Host/freebsd/Config.h
    lldb/trunk/include/lldb/Host/linux/Config.h
    lldb/trunk/include/lldb/Host/macosx/Config.h
    lldb/trunk/include/lldb/Host/mingw/Config.h
    lldb/trunk/include/lldb/Host/msvc/Config.h
    lldb/trunk/include/lldb/Host/netbsd/Config.h
    lldb/trunk/include/lldb/Host/openbsd/Config.h
Modified:
    lldb/trunk/cmake/modules/LLDBConfig.cmake
    lldb/trunk/include/lldb/Host/Config.h
    lldb/trunk/source/Host/common/File.cpp

Modified: lldb/trunk/cmake/modules/LLDBConfig.cmake
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/cmake/modules/LLDBConfig.cmake?rev=300372&r1=300371&r2=300372&view=diff
==============================================================================
--- lldb/trunk/cmake/modules/LLDBConfig.cmake (original)
+++ lldb/trunk/cmake/modules/LLDBConfig.cmake Fri Apr 14 17:03:45 2017
@@ -270,8 +270,8 @@ string(REGEX MATCH "[0-9]+\\.[0-9]+(\\.[
 message(STATUS "LLDB version: ${LLDB_VERSION}")
 
 include_directories(BEFORE
-  ${CMAKE_CURRENT_BINARY_DIR}/include
   ${CMAKE_CURRENT_SOURCE_DIR}/include
+  ${CMAKE_CURRENT_BINARY_DIR}/include
   )
 
 if (NOT LLVM_INSTALL_TOOLCHAIN_ONLY)
@@ -281,6 +281,17 @@ if (NOT LLVM_INSTALL_TOOLCHAIN_ONLY)
     FILES_MATCHING
     PATTERN "*.h"
     PATTERN ".svn" EXCLUDE
+    PATTERN ".cmake" EXCLUDE
+    PATTERN "Config.h" EXCLUDE
+    )
+
+  install(DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/include/
+    COMPONENT lldb_headers
+    DESTINATION include
+    FILES_MATCHING
+    PATTERN "*.h"
+    PATTERN ".svn" EXCLUDE
+    PATTERN ".cmake" EXCLUDE
     )
 endif()
 
@@ -421,3 +432,18 @@ if ((CMAKE_SYSTEM_NAME MATCHES "Android"
 endif()
 
 find_package(Backtrace)
+
+check_include_file(termios.h HAVE_TERMIOS_H)
+
+# These checks exist in LLVM's configuration, so I want to match the LLVM names
+# so that the check isn't duplicated, but we translate them into the LLDB names
+# so that I don't have to change all the uses at the moment.
+set(LLDB_CONFIG_TERMIOS_SUPPORTED ${HAVE_TERMIOS_H})
+if(NOT UNIX)
+  set(LLDB_DISABLE_POSIX 1)
+endif()
+
+# This should be done at the end
+configure_file(
+  ${LLDB_INCLUDE_ROOT}/lldb/Host/Config.h.cmake
+  ${CMAKE_CURRENT_BINARY_DIR}/include/lldb/Host/Config.h)

Modified: lldb/trunk/include/lldb/Host/Config.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Host/Config.h?rev=300372&r1=300371&r2=300372&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Host/Config.h (original)
+++ lldb/trunk/include/lldb/Host/Config.h Fri Apr 14 17:03:45 2017
@@ -7,45 +7,21 @@
 //
 //===----------------------------------------------------------------------===//
 
-#ifndef liblldb_Config_h_
-#define liblldb_Config_h_
-
+#ifndef LLDB_HOST_CONFIG_H
+#define LLDB_HOST_CONFIG_H
+ 
 #if defined(__APPLE__)
 
-#include "lldb/Host/macosx/Config.h"
-
-#elif defined(__ANDROID__)
-
-#include "lldb/Host/android/Config.h"
-
-#elif defined(__linux__) || defined(__GNU__)
-
-#include "lldb/Host/linux/Config.h"
-
-#elif defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
-
-#include "lldb/Host/freebsd/Config.h"
-
-#elif defined(__NetBSD__)
-
-#include "lldb/Host/netbsd/Config.h"
-
-#elif defined(__OpenBSD__)
-
-#include "lldb/Host/openbsd/Config.h"
-
-#elif defined(__MINGW__) || defined(__MINGW32__)
-
-#include "lldb/Host/mingw/Config.h"
-
-#elif defined(_MSC_VER)
+// This block of code only exists to keep the Xcode project working in the
+// absence of a configuration step.
+#define LLDB_CONFIG_TERMIOS_SUPPORTED 1
 
-#include "lldb/Host/msvc/Config.h"
+#define HAVE_SYS_EVENT_H 1
 
 #else
 
-#error undefined platform
+#error This file is only used by the Xcode build.
 
 #endif
 
-#endif // #ifndef liblldb_Config_h_
+#endif // #ifndef LLDB_HOST_CONFIG_H

Added: lldb/trunk/include/lldb/Host/Config.h.cmake
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Host/Config.h.cmake?rev=300372&view=auto
==============================================================================
--- lldb/trunk/include/lldb/Host/Config.h.cmake (added)
+++ lldb/trunk/include/lldb/Host/Config.h.cmake Fri Apr 14 17:03:45 2017
@@ -0,0 +1,19 @@
+//===-- Config.h -----------------------------------------------*- C++ -*-===//
+//
+//                     The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef LLDB_HOST_CONFIG_H
+#define LLDB_HOST_CONFIG_H
+
+#cmakedefine01 LLDB_CONFIG_TERMIOS_SUPPORTED
+
+#cmakedefine LLDB_DISABLE_POSIX
+
+#cmakedefine01 HAVE_SYS_EVENT_H
+
+#endif // #ifndef LLDB_HOST_CONFIG_H

Removed: lldb/trunk/include/lldb/Host/android/Config.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Host/android/Config.h?rev=300371&view=auto
==============================================================================
--- lldb/trunk/include/lldb/Host/android/Config.h (original)
+++ lldb/trunk/include/lldb/Host/android/Config.h (removed)
@@ -1,28 +0,0 @@
-//===-- Config.h -----------------------------------------------*- C++ -*-===//
-//
-//                     The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
-//
-//===----------------------------------------------------------------------===//
-
-//----------------------------------------------------------------------
-// LLDB currently doesn't have a dynamic configuration mechanism, so we
-// are going to hardcode things for now. Eventually these files will
-// be auto generated by some configuration script that can detect
-// platform functionality availability.
-//----------------------------------------------------------------------
-
-#ifndef liblldb_Platform_Config_h_
-#define liblldb_Platform_Config_h_
-
-#define LLDB_CONFIG_TERMIOS_SUPPORTED 1
-
-//#define LLDB_CONFIG_TILDE_RESOLVES_TO_USER 1
-
-//#define LLDB_CONFIG_DLOPEN_RTLD_FIRST_SUPPORTED 1
-
-//#define LLDB_CONFIG_FCNTL_GETPATH_SUPPORTED 1
-
-#endif // #ifndef liblldb_Platform_Config_h_

Removed: lldb/trunk/include/lldb/Host/freebsd/Config.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Host/freebsd/Config.h?rev=300371&view=auto
==============================================================================
--- lldb/trunk/include/lldb/Host/freebsd/Config.h (original)
+++ lldb/trunk/include/lldb/Host/freebsd/Config.h (removed)
@@ -1,28 +0,0 @@
-//===-- Config.h -----------------------------------------------*- C++ -*-===//
-//
-//                     The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
-//
-//===----------------------------------------------------------------------===//
-
-//----------------------------------------------------------------------
-// LLDB currently doesn't have a dynamic configuration mechanism, so we
-// are going to hardcode things for now. Eventually these files will
-// be auto generated by some configuration script that can detect
-// platform functionality availability.
-//----------------------------------------------------------------------
-
-#ifndef liblldb_Platform_Config_h_
-#define liblldb_Platform_Config_h_
-
-#define LLDB_CONFIG_TERMIOS_SUPPORTED 1
-
-#define LLDB_CONFIG_TILDE_RESOLVES_TO_USER 1
-
-//#define LLDB_CONFIG_DLOPEN_RTLD_FIRST_SUPPORTED 1
-
-//#define LLDB_CONFIG_FCNTL_GETPATH_SUPPORTED 1
-
-#endif // #ifndef liblldb_Platform_Config_h_

Removed: lldb/trunk/include/lldb/Host/linux/Config.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Host/linux/Config.h?rev=300371&view=auto
==============================================================================
--- lldb/trunk/include/lldb/Host/linux/Config.h (original)
+++ lldb/trunk/include/lldb/Host/linux/Config.h (removed)
@@ -1,28 +0,0 @@
-//===-- Config.h -----------------------------------------------*- C++ -*-===//
-//
-//                     The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
-//
-//===----------------------------------------------------------------------===//
-
-//----------------------------------------------------------------------
-// LLDB currently doesn't have a dynamic configuration mechanism, so we
-// are going to hardcode things for now. Eventually these files will
-// be auto generated by some configuration script that can detect
-// platform functionality availability.
-//----------------------------------------------------------------------
-
-#ifndef liblldb_Platform_Config_h_
-#define liblldb_Platform_Config_h_
-
-#define LLDB_CONFIG_TERMIOS_SUPPORTED 1
-
-#define LLDB_CONFIG_TILDE_RESOLVES_TO_USER 1
-
-//#define LLDB_CONFIG_DLOPEN_RTLD_FIRST_SUPPORTED 1
-
-//#define LLDB_CONFIG_FCNTL_GETPATH_SUPPORTED 1
-
-#endif // #ifndef liblldb_Platform_Config_h_

Removed: lldb/trunk/include/lldb/Host/macosx/Config.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Host/macosx/Config.h?rev=300371&view=auto
==============================================================================
--- lldb/trunk/include/lldb/Host/macosx/Config.h (original)
+++ lldb/trunk/include/lldb/Host/macosx/Config.h (removed)
@@ -1,28 +0,0 @@
-//===-- Config.h -----------------------------------------------*- C++ -*-===//
-//
-//                     The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
-//
-//===----------------------------------------------------------------------===//
-
-//----------------------------------------------------------------------
-// LLDB currently doesn't have a dynamic configuration mechanism, so we
-// are going to hardcode things for now. Eventually these files will
-// be auto generated by some configuration script that can detect
-// platform functionality availability.
-//----------------------------------------------------------------------
-
-#ifndef liblldb_Platform_Config_h_
-#define liblldb_Platform_Config_h_
-
-#define LLDB_CONFIG_TERMIOS_SUPPORTED 1
-
-#define LLDB_CONFIG_TILDE_RESOLVES_TO_USER 1
-
-#define LLDB_CONFIG_DLOPEN_RTLD_FIRST_SUPPORTED 1
-
-#define LLDB_CONFIG_FCNTL_GETPATH_SUPPORTED 1
-
-#endif // #ifndef liblldb_Platform_Config_h_

Removed: lldb/trunk/include/lldb/Host/mingw/Config.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Host/mingw/Config.h?rev=300371&view=auto
==============================================================================
--- lldb/trunk/include/lldb/Host/mingw/Config.h (original)
+++ lldb/trunk/include/lldb/Host/mingw/Config.h (removed)
@@ -1,30 +0,0 @@
-//===-- Config.h -----------------------------------------------*- C++ -*-===//
-//
-//                     The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
-//
-//===----------------------------------------------------------------------===//
-
-//----------------------------------------------------------------------
-// LLDB currently doesn't have a dynamic configuration mechanism, so we
-// are going to hardcode things for now. Eventually these files will
-// be auto generated by some configuration script that can detect
-// platform functionality availability.
-//----------------------------------------------------------------------
-
-#ifndef liblldb_Platform_Config_h_
-#define liblldb_Platform_Config_h_
-
-#define LLDB_DISABLE_POSIX
-
-//#define LLDB_CONFIG_TERMIOS_SUPPORTED 1
-
-//#define LLDB_CONFIG_TILDE_RESOLVES_TO_USER 1
-
-//#define LLDB_CONFIG_DLOPEN_RTLD_FIRST_SUPPORTED 1
-
-//#define LLDB_CONFIG_FCNTL_GETPATH_SUPPORTED 1
-
-#endif // #ifndef liblldb_Platform_Config_h_

Removed: lldb/trunk/include/lldb/Host/msvc/Config.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Host/msvc/Config.h?rev=300371&view=auto
==============================================================================
--- lldb/trunk/include/lldb/Host/msvc/Config.h (original)
+++ lldb/trunk/include/lldb/Host/msvc/Config.h (removed)
@@ -1,30 +0,0 @@
-//===-- Config.h -----------------------------------------------*- C++ -*-===//
-//
-//                     The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
-//
-//===----------------------------------------------------------------------===//
-
-//----------------------------------------------------------------------
-// LLDB currently doesn't have a dynamic configuration mechanism, so we
-// are going to hardcode things for now. Eventually these files will
-// be auto generated by some configuration script that can detect
-// platform functionality availability.
-//----------------------------------------------------------------------
-
-#ifndef liblldb_host_msvc_Config_h_
-#define liblldb_host_msvc_Config_h_
-
-#define LLDB_DISABLE_POSIX
-
-//#define LLDB_CONFIG_TERMIOS_SUPPORTED 1
-
-//#define LLDB_CONFIG_TILDE_RESOLVES_TO_USER 1
-
-//#define LLDB_CONFIG_DLOPEN_RTLD_FIRST_SUPPORTED 1
-
-//#define LLDB_CONFIG_FCNTL_GETPATH_SUPPORTED 1
-
-#endif // #ifndef liblldb_Platform_Config_h_

Removed: lldb/trunk/include/lldb/Host/netbsd/Config.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Host/netbsd/Config.h?rev=300371&view=auto
==============================================================================
--- lldb/trunk/include/lldb/Host/netbsd/Config.h (original)
+++ lldb/trunk/include/lldb/Host/netbsd/Config.h (removed)
@@ -1,28 +0,0 @@
-//===-- Config.h -----------------------------------------------*- C++ -*-===//
-//
-//                     The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
-//
-//===----------------------------------------------------------------------===//
-
-//----------------------------------------------------------------------
-// LLDB currently doesn't have a dynamic configuration mechanism, so we
-// are going to hardcode things for now. Eventually these files will
-// be auto generated by some configuration script that can detect
-// platform functionality availability.
-//----------------------------------------------------------------------
-
-#ifndef liblldb_Platform_Config_h_
-#define liblldb_Platform_Config_h_
-
-#define LLDB_CONFIG_TERMIOS_SUPPORTED 1
-
-#define LLDB_CONFIG_TILDE_RESOLVES_TO_USER 1
-
-//#define LLDB_CONFIG_DLOPEN_RTLD_FIRST_SUPPORTED 1
-
-//#define LLDB_CONFIG_FCNTL_GETPATH_SUPPORTED 1
-
-#endif // #ifndef liblldb_Platform_Config_h_

Removed: lldb/trunk/include/lldb/Host/openbsd/Config.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Host/openbsd/Config.h?rev=300371&view=auto
==============================================================================
--- lldb/trunk/include/lldb/Host/openbsd/Config.h (original)
+++ lldb/trunk/include/lldb/Host/openbsd/Config.h (removed)
@@ -1,28 +0,0 @@
-//===-- Config.h -----------------------------------------------*- C++ -*-===//
-//
-//                     The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
-//
-//===----------------------------------------------------------------------===//
-
-//----------------------------------------------------------------------
-// LLDB currently doesn't have a dynamic configuration mechanism, so we
-// are going to hardcode things for now. Eventually these files will
-// be auto generated by some configuration script that can detect
-// platform functionality availability.
-//----------------------------------------------------------------------
-
-#ifndef liblldb_Platform_Config_h_
-#define liblldb_Platform_Config_h_
-
-#define LLDB_CONFIG_TERMIOS_SUPPORTED 1
-
-#define LLDB_CONFIG_TILDE_RESOLVES_TO_USER 1
-
-//#define LLDB_CONFIG_DLOPEN_RTLD_FIRST_SUPPORTED 1
-
-//#define LLDB_CONFIG_FCNTL_GETPATH_SUPPORTED 1
-
-#endif // #ifndef liblldb_Platform_Config_h_

Modified: lldb/trunk/source/Host/common/File.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Host/common/File.cpp?rev=300372&r1=300371&r2=300372&view=diff
==============================================================================
--- lldb/trunk/source/Host/common/File.cpp (original)
+++ lldb/trunk/source/Host/common/File.cpp Fri Apr 14 17:03:45 2017
@@ -307,7 +307,7 @@ void File::Clear() {
 
 Error File::GetFileSpec(FileSpec &file_spec) const {
   Error error;
-#ifdef LLDB_CONFIG_FCNTL_GETPATH_SUPPORTED
+#ifdef F_GETPATH
   if (IsValid()) {
     char path[PATH_MAX];
     if (::fcntl(GetDescriptor(), F_GETPATH, path) == -1)




More information about the lldb-commits mailing list