vsk created this revision.
vsk added reviewers: JDevlieghere, davide, friss.
Herald added a subscriber: mgorny.
Herald added a project: LLDB.
vsk requested review of this revision.

This patch configures LLDB.framework to build as a flat unversioned
framework on non-macOS Darwin targets, which have never supported the
macOS framework layout.

This patch also renames the 'IOS' cmake variable to 'APPLE_EMBEDDED' to
reflect the fact that lldb is built for several different kinds of embedded
Darwin targets, not just iOS.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D85770

Files:
  lldb/cmake/modules/LLDBConfig.cmake
  lldb/cmake/modules/LLDBFramework.cmake
  lldb/source/Host/CMakeLists.txt
  lldb/tools/debugserver/source/CMakeLists.txt
  lldb/tools/lldb-server/CMakeLists.txt
  lldb/unittests/debugserver/CMakeLists.txt

Index: lldb/unittests/debugserver/CMakeLists.txt
===================================================================
--- lldb/unittests/debugserver/CMakeLists.txt
+++ lldb/unittests/debugserver/CMakeLists.txt
@@ -20,7 +20,7 @@
     Support
   )
 
-if(IOS)
+if(APPLE_EMBEDDED)
   set_property(TARGET debugserverTests APPEND PROPERTY COMPILE_DEFINITIONS
       WITH_LOCKDOWN
       WITH_FBS
Index: lldb/tools/lldb-server/CMakeLists.txt
===================================================================
--- lldb/tools/lldb-server/CMakeLists.txt
+++ lldb/tools/lldb-server/CMakeLists.txt
@@ -16,7 +16,7 @@
   list(APPEND LLDB_PLUGINS lldbPluginObjectFileELF)
 endif()
 
-if(IOS)
+if(APPLE_EMBEDDED)
   if(LLDB_CODESIGN_IDENTITY)
     # Use explicit LLDB identity
     set(LLVM_CODESIGNING_IDENTITY ${LLDB_CODESIGN_IDENTITY})
Index: lldb/tools/debugserver/source/CMakeLists.txt
===================================================================
--- lldb/tools/debugserver/source/CMakeLists.txt
+++ lldb/tools/debugserver/source/CMakeLists.txt
@@ -99,7 +99,7 @@
   LLDB_DEBUGSERVER_CODESIGN_IDENTITY ${debugserver_codesign_identity})
 
 if(APPLE)
-  if(IOS)
+  if(APPLE_EMBEDDED)
     find_library(BACKBOARD_LIBRARY BackBoardServices
       PATHS ${CMAKE_OSX_SYSROOT}/System/Library/PrivateFrameworks)
     find_library(FRONTBOARD_LIBRARY FrontBoardServices
@@ -121,7 +121,7 @@
 endif()
 
 if(LLDB_USE_ENTITLEMENTS)
-  if(IOS)
+  if(APPLE_EMBEDDED)
     set(entitlements ${CMAKE_CURRENT_SOURCE_DIR}/debugserver-entitlements.plist)
   else()
     # Same entitlements file as used for lldb-server
@@ -258,7 +258,7 @@
 
 set_target_properties(debugserver PROPERTIES FOLDER "lldb libraries/debugserver")
 
-if(IOS)
+if(APPLE_EMBEDDED)
   set_property(TARGET lldbDebugserverCommon APPEND PROPERTY COMPILE_DEFINITIONS
     WITH_LOCKDOWN
     WITH_FBS
Index: lldb/source/Host/CMakeLists.txt
===================================================================
--- lldb/source/Host/CMakeLists.txt
+++ lldb/source/Host/CMakeLists.txt
@@ -93,7 +93,7 @@
       macosx/cfcpp/CFCMutableSet.cpp
       macosx/cfcpp/CFCString.cpp
       )
-    if(IOS)
+    if(APPLE_EMBEDDED)
       set_property(SOURCE macosx/Host.mm APPEND PROPERTY
                COMPILE_DEFINITIONS "NO_XPC_SERVICES=1")
     endif()
Index: lldb/cmake/modules/LLDBFramework.cmake
===================================================================
--- lldb/cmake/modules/LLDBFramework.cmake
+++ lldb/cmake/modules/LLDBFramework.cmake
@@ -3,22 +3,38 @@
 message(STATUS "LLDB.framework: resources subdirectory is 'Versions/${LLDB_FRAMEWORK_VERSION}/Resources'")
 
 # Configure liblldb as a framework bundle
-set_target_properties(liblldb PROPERTIES
-  FRAMEWORK ON
-  FRAMEWORK_VERSION ${LLDB_FRAMEWORK_VERSION}
+if(NOT APPLE_EMBEDDED)
+  set_target_properties(liblldb PROPERTIES
+    FRAMEWORK ON
+    FRAMEWORK_VERSION ${LLDB_FRAMEWORK_VERSION}
 
-  OUTPUT_NAME LLDB
-  VERSION ${LLDB_VERSION}
-  LIBRARY_OUTPUT_DIRECTORY ${LLDB_FRAMEWORK_ABSOLUTE_BUILD_DIR}
+    OUTPUT_NAME LLDB
+    VERSION ${LLDB_VERSION}
+    LIBRARY_OUTPUT_DIRECTORY ${LLDB_FRAMEWORK_ABSOLUTE_BUILD_DIR}
 
-  # Compatibility version
-  SOVERSION "1.0.0"
+    # Compatibility version
+    SOVERSION "1.0.0"
 
-  MACOSX_FRAMEWORK_IDENTIFIER com.apple.LLDB.framework
-  MACOSX_FRAMEWORK_BUNDLE_VERSION ${LLDB_VERSION}
-  MACOSX_FRAMEWORK_SHORT_VERSION_STRING ${LLDB_VERSION}
-  MACOSX_FRAMEWORK_INFO_PLIST ${LLDB_SOURCE_DIR}/resources/LLDB-Info.plist.in
-)
+    MACOSX_FRAMEWORK_IDENTIFIER com.apple.LLDB.framework
+    MACOSX_FRAMEWORK_BUNDLE_VERSION ${LLDB_VERSION}
+    MACOSX_FRAMEWORK_SHORT_VERSION_STRING ${LLDB_VERSION}
+    MACOSX_FRAMEWORK_INFO_PLIST ${LLDB_SOURCE_DIR}/resources/LLDB-Info.plist.in
+  )
+else()
+  set_target_properties(liblldb PROPERTIES
+    FRAMEWORK ON
+    FRAMEWORK_VERSION ${LLDB_FRAMEWORK_VERSION}
+
+    # Note: iOS doesn't specify version, as the framework layout is flat.
+    OUTPUT_NAME LLDB
+    LIBRARY_OUTPUT_DIRECTORY ${LLDB_FRAMEWORK_ABSOLUTE_BUILD_DIR}
+
+    MACOSX_FRAMEWORK_IDENTIFIER com.apple.LLDB.framework
+    MACOSX_FRAMEWORK_BUNDLE_VERSION ${LLDB_VERSION}
+    MACOSX_FRAMEWORK_SHORT_VERSION_STRING ${LLDB_VERSION}
+    MACOSX_FRAMEWORK_INFO_PLIST ${LLDB_SOURCE_DIR}/resources/LLDB-Info.plist.in
+  )
+endif()
 
 # Used in llvm_add_library() to set default output directories for multi-config
 # generators. Overwrite to account for special framework output directory.
@@ -30,7 +46,7 @@
 lldb_add_post_install_steps_darwin(liblldb ${LLDB_FRAMEWORK_INSTALL_DIR})
 
 # Affects the layout of the framework bundle (default is macOS layout).
-if(IOS)
+if(APPLE_EMBEDDED)
   set_target_properties(liblldb PROPERTIES
     XCODE_ATTRIBUTE_IPHONEOS_DEPLOYMENT_TARGET "${IPHONEOS_DEPLOYMENT_TARGET}")
 else()
@@ -41,13 +57,16 @@
 # Add -Wdocumentation parameter
 set(CMAKE_XCODE_ATTRIBUTE_CLANG_WARN_DOCUMENTATION_COMMENTS "YES")
 
-# Apart from this one, CMake creates all required symlinks in the framework bundle.
-add_custom_command(TARGET liblldb POST_BUILD
-  COMMAND ${CMAKE_COMMAND} -E create_symlink
-          Versions/Current/Headers
-          ${LLDB_FRAMEWORK_ABSOLUTE_BUILD_DIR}/LLDB.framework/Headers
-  COMMENT "LLDB.framework: create Headers symlink"
-)
+# On iOS, there is no versioned framework layout. Skip this symlink step.
+if(NOT APPLE_EMBEDDED)
+  # Apart from this one, CMake creates all required symlinks in the framework bundle.
+  add_custom_command(TARGET liblldb POST_BUILD
+    COMMAND ${CMAKE_COMMAND} -E create_symlink
+            Versions/Current/Headers
+            ${LLDB_FRAMEWORK_ABSOLUTE_BUILD_DIR}/LLDB.framework/Headers
+    COMMENT "LLDB.framework: create Headers symlink"
+  )
+endif()
 
 # At configuration time, collect headers for the framework bundle and copy them
 # into a staging directory. Later we can copy over the entire folder.
@@ -79,16 +98,14 @@
 
 # At build time, copy the staged headers into the framework bundle (and do
 # some post-processing in-place).
-if (NOT IOS)
 add_custom_command(TARGET liblldb POST_BUILD
   COMMAND ${CMAKE_COMMAND} -E copy_directory ${lldb_header_staging} $<TARGET_FILE_DIR:liblldb>/Headers
   COMMAND ${LLDB_SOURCE_DIR}/scripts/framework-header-fix.sh $<TARGET_FILE_DIR:liblldb>/Headers ${LLDB_VERSION}
   COMMENT "LLDB.framework: copy framework headers"
 )
-endif()
 
 # Copy vendor-specific headers from clang (without staging).
-if(NOT IOS)
+if(NOT APPLE_EMBEDDED)
   if (TARGET clang-resource-headers)
     add_dependencies(liblldb clang-resource-headers)
     set(clang_resource_headers_dir $<TARGET_PROPERTY:clang-resource-headers,RUNTIME_OUTPUT_DIRECTORY>)
@@ -120,6 +137,16 @@
   )
 endif()
 
+# IOS framework bundles are flat
+if(NOT APPLE_EMBEDDED)
+  add_custom_command(TARGET liblldb POST_BUILD
+    COMMAND ${CMAKE_COMMAND} -E create_symlink
+            Versions/Current/XPCServices
+            ${LLDB_FRAMEWORK_ABSOLUTE_BUILD_DIR}/LLDB.framework/XPCServices
+    COMMENT "LLDB.framework: create symlink XPCServices"
+  )
+endif()
+
 # Add an rpath pointing to the directory where LLDB.framework is installed.
 # This allows frameworks (relying on @rpath) to be installed in the same folder and found at runtime.
 set_property(TARGET liblldb APPEND PROPERTY INSTALL_RPATH
Index: lldb/cmake/modules/LLDBConfig.cmake
===================================================================
--- lldb/cmake/modules/LLDBConfig.cmake
+++ lldb/cmake/modules/LLDBConfig.cmake
@@ -267,7 +267,7 @@
 
 # Find Apple-specific libraries or frameworks that may be needed.
 if (APPLE)
-  if(NOT IOS)
+  if(NOT APPLE_EMBEDDED)
     find_library(CARBON_LIBRARY Carbon)
     find_library(CORE_SERVICES_LIBRARY CoreServices)
   endif()
_______________________________________________
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits

Reply via email to