77 lines · plain
1foreach (scope DIRECTORY TARGET)2 define_property(${scope} PROPERTY LLDB_PLUGIN_KIND INHERITED3 BRIEF_DOCS "LLDB plugin kind (Process, SymbolFile, etc.)"4 FULL_DOCS "See lldb/docs/resources/contributing.rst"5 )6 7 define_property(${scope} PROPERTY LLDB_ACCEPTABLE_PLUGIN_DEPENDENCIES INHERITED8 BRIEF_DOCS "LLDB plugin kinds which the plugin can depend on"9 FULL_DOCS "See lldb/docs/resources/contributing.rst"10 )11 12 define_property(${scope} PROPERTY LLDB_TOLERATED_PLUGIN_DEPENDENCIES INHERITED13 BRIEF_DOCS "LLDB plugin kinds which are depended on for historic reasons."14 FULL_DOCS "See lldb/docs/resources/contributing.rst"15 )16endforeach()17 18option(LLDB_GENERATE_PLUGIN_DEP_GRAPH OFF)19 20function(check_lldb_plugin_layering)21 get_property(plugins GLOBAL PROPERTY LLDB_PLUGINS)22 foreach (plugin ${plugins})23 get_property(plugin_kind TARGET ${plugin} PROPERTY LLDB_PLUGIN_KIND)24 get_property(acceptable_deps TARGET ${plugin}25 PROPERTY LLDB_ACCEPTABLE_PLUGIN_DEPENDENCIES)26 get_property(tolerated_deps TARGET ${plugin}27 PROPERTY LLDB_TOLERATED_PLUGIN_DEPENDENCIES)28 29 # A plugin is always permitted to depend on its own kind for the purposes30 # subclassing. Ideally the intra-kind dependencies should not form a loop,31 # but we're not checking that here.32 list(APPEND acceptable_deps ${plugin_kind})33 34 list(APPEND all_plugin_kinds ${plugin_kind})35 36 get_property(link_libs TARGET ${plugin} PROPERTY LINK_LIBRARIES)37 foreach (link_lib ${link_libs})38 if(link_lib IN_LIST plugins)39 get_property(lib_kind TARGET ${link_lib} PROPERTY LLDB_PLUGIN_KIND)40 if (lib_kind)41 if (lib_kind IN_LIST acceptable_deps)42 set(dep_kind green)43 elseif (lib_kind IN_LIST tolerated_deps)44 set(dep_kind yellow)45 else()46 set(dep_kind red)47 message(SEND_ERROR "Plugin ${plugin} cannot depend on ${lib_kind} "48 "plugin ${link_lib}")49 endif()50 list(APPEND dep_${dep_kind}_${plugin_kind}_${lib_kind} ${plugin})51 endif()52 endif()53 endforeach()54 endforeach()55 56 if (LLDB_GENERATE_PLUGIN_DEP_GRAPH)57 set(dep_graph "digraph Plugins {\n")58 list(REMOVE_DUPLICATES all_plugin_kinds)59 foreach (from ${all_plugin_kinds})60 foreach (to ${all_plugin_kinds})61 foreach (dep_kind green yellow red)62 if (dep_${dep_kind}_${from}_${to})63 list(REMOVE_DUPLICATES dep_${dep_kind}_${from}_${to})64 string(REGEX REPLACE "lldbPlugin|${from}" "" short_deps65 "${dep_${dep_kind}_${from}_${to}}")66 string(JOIN "\n" plugins ${short_deps})67 string(APPEND dep_graph68 " ${from}->${to}[color=\"${dep_kind}\" label=\"${plugins}\"];\n")69 endif()70 endforeach()71 endforeach()72 endforeach()73 string(APPEND dep_graph "}\n")74 file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/lldb-plugin-deps.dot" "${dep_graph}")75 endif()76endfunction()77