beanz created this revision.
Herald added subscribers: mgorny, srhines, emaste.

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.


https://reviews.llvm.org/D31969

Files:
  cmake/modules/LLDBConfig.cmake
  include/lldb/Host/Config.h
  include/lldb/Host/Config.h.cmake
  include/lldb/Host/android/Config.h
  include/lldb/Host/freebsd/Config.h
  include/lldb/Host/linux/Config.h
  include/lldb/Host/macosx/Config.h
  include/lldb/Host/mingw/Config.h
  include/lldb/Host/msvc/Config.h
  include/lldb/Host/netbsd/Config.h
  include/lldb/Host/openbsd/Config.h

Index: include/lldb/Host/openbsd/Config.h
===================================================================
--- include/lldb/Host/openbsd/Config.h
+++ /dev/null
@@ -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_
Index: include/lldb/Host/netbsd/Config.h
===================================================================
--- include/lldb/Host/netbsd/Config.h
+++ /dev/null
@@ -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_
Index: include/lldb/Host/msvc/Config.h
===================================================================
--- include/lldb/Host/msvc/Config.h
+++ /dev/null
@@ -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_
Index: include/lldb/Host/mingw/Config.h
===================================================================
--- include/lldb/Host/mingw/Config.h
+++ /dev/null
@@ -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_
Index: include/lldb/Host/macosx/Config.h
===================================================================
--- include/lldb/Host/macosx/Config.h
+++ /dev/null
@@ -1,31 +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 LLDB_HOST_MACOSX_CONFIG_H
-#define LLDB_HOST_MACOSX_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
-
-// FIXME: This should be set by a configure-time check.
-#define HAVE_SYS_EVENT_H 1
-
-#endif // LLDB_HOST_MACOSX_CONFIG_H
Index: include/lldb/Host/linux/Config.h
===================================================================
--- include/lldb/Host/linux/Config.h
+++ /dev/null
@@ -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_
Index: include/lldb/Host/freebsd/Config.h
===================================================================
--- include/lldb/Host/freebsd/Config.h
+++ /dev/null
@@ -1,31 +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
-
-// FIXME: This should be set by a configure-time check.
-#define HAVE_SYS_EVENT_H 1
-
-#endif // #ifndef liblldb_Platform_Config_h_
Index: include/lldb/Host/android/Config.h
===================================================================
--- include/lldb/Host/android/Config.h
+++ /dev/null
@@ -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_
Index: include/lldb/Host/Config.h.cmake
===================================================================
--- /dev/null
+++ include/lldb/Host/Config.h.cmake
@@ -0,0 +1,21 @@
+//===-- 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 liblldb_Config_h_
+#define liblldb_Config_h_
+
+#cmakedefine01 LLDB_CONFIG_TERMIOS_SUPPORTED
+
+#cmakedefine01 LLDB_CONFIG_FCNTL_GETPATH_SUPPORTED
+
+#cmakedefine LLDB_DISABLE_POSIX
+
+#cmakedefine01 HAVE_SYS_EVENT_H
+
+#endif // #ifndef liblldb_Generated_Config_h_
Index: include/lldb/Host/Config.h
===================================================================
--- include/lldb/Host/Config.h
+++ include/lldb/Host/Config.h
@@ -9,42 +9,20 @@
 
 #ifndef liblldb_Config_h_
 #define liblldb_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"
+// 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
 
-#elif defined(_MSC_VER)
+#define LLDB_CONFIG_FCNTL_GETPATH_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
 
Index: cmake/modules/LLDBConfig.cmake
===================================================================
--- cmake/modules/LLDBConfig.cmake
+++ cmake/modules/LLDBConfig.cmake
@@ -270,17 +270,18 @@
 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)
-  install(DIRECTORY include/
+  install(DIRECTORY include/ ${CMAKE_CURRENT_BINARY_DIR}/include/
     COMPONENT lldb_headers
     DESTINATION include
     FILES_MATCHING
     PATTERN "*.h"
     PATTERN ".svn" EXCLUDE
+    PATTERN ".cmake" EXCLUDE
     )
 endif()
 
@@ -421,3 +422,20 @@
 endif()
 
 find_package(Backtrace)
+
+check_include_file(termios.h HAVE_TERMIOS_H)
+check_include_file(fcntl.h HAVE_FCNTL_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})
+set(LLDB_CONFIG_FCNTL_GETPATH_SUPPORTED ${HAVE_FCNTL_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)
_______________________________________________
lldb-commits mailing list
lldb-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits

Reply via email to