* Further fixes of plugins.xml generation 1) Unregistration is done by name (e.g. CPU), not by file name (ov_cpu_plugin) 2) Unregistered line is searched by name="MULTI" instead of just 'MULTI' to not conflict with MULTI_WORK_MODE_AS_AUTO entry 3) Removed list of all possible plugins from ov_runtime as logic shall not rely on this (not possible to add 3rd party plugins) * Revert ov_runtime - some CI jobs require plugins.xml even though plugins are not built Registration - if some entry already exists in XML - don't copy it. E.g. - Registration of 'TEMPLATE' is performed - Registration loops through existing plugins.xml - If name="TEMPLATE" is found - don't take it to newContent - If name like "myCustomPlugin" is found - take it - As result - "myCustomPlugin" will exist after update, but old "TEMPLATE" will be removed * Add missing change
81 lines
2.2 KiB
CMake
81 lines
2.2 KiB
CMake
# Copyright (C) 2018-2022 Intel Corporation
|
|
# SPDX-License-Identifier: Apache-2.0
|
|
#
|
|
|
|
set(file_content
|
|
"<ie>
|
|
<plugins>
|
|
</plugins>
|
|
</ie>")
|
|
|
|
if(NOT EXISTS "${IE_CONFIG_OUTPUT_FILE}")
|
|
file(WRITE "${IE_CONFIG_OUTPUT_FILE}" "${file_content}")
|
|
endif()
|
|
|
|
# get list of plugin files
|
|
file(GLOB plugin_files "${IE_CONFIGS_DIR}/*.xml")
|
|
|
|
function(check_plugin_exists plugin_name outvar)
|
|
set(${outvar} OFF PARENT_SCOPE)
|
|
|
|
# check if config file already has this plugin
|
|
file(STRINGS "${IE_CONFIG_OUTPUT_FILE}" content REGEX "plugin .*=\"")
|
|
|
|
foreach(line IN LISTS content)
|
|
string(REGEX MATCH "location=\"([^\"]*)\"" location "${line}")
|
|
get_filename_component(location "${CMAKE_MATCH_1}" NAME_WE)
|
|
|
|
if("${CMAKE_SHARED_MODULE_PREFIX}${plugin_name}" MATCHES "${location}")
|
|
# plugin has already registered
|
|
set(${outvar} ON PARENT_SCOPE)
|
|
endif()
|
|
endforeach()
|
|
endfunction()
|
|
|
|
set(plugin_files_to_add)
|
|
foreach(plugin_file IN LISTS plugin_files)
|
|
get_filename_component(plugin_name "${plugin_file}" NAME_WE)
|
|
check_plugin_exists("${plugin_name}" exists)
|
|
|
|
if(NOT exists)
|
|
list(APPEND plugin_files_to_add "${plugin_file}")
|
|
endif()
|
|
endforeach()
|
|
|
|
# add plugin
|
|
set(newContent "")
|
|
file(STRINGS "${IE_CONFIG_OUTPUT_FILE}" content)
|
|
|
|
set(already_exists_in_xml OFF)
|
|
foreach(line IN LISTS content)
|
|
if(NOT already_exists_in_xml)
|
|
foreach(plugin_file IN LISTS plugin_files_to_add)
|
|
get_filename_component(plugin_name "${plugin_file}" NAME_WE)
|
|
if("${line}" MATCHES "name=\"${plugin_name}\"")
|
|
set(already_exists_in_xml ON)
|
|
endif()
|
|
endforeach()
|
|
endif()
|
|
if (NOT already_exists_in_xml)
|
|
if("${line}" MATCHES "</plugins>")
|
|
foreach(plugin_file IN LISTS plugin_files_to_add)
|
|
file(READ "${plugin_file}" content)
|
|
set(newContent "${newContent}
|
|
${content}")
|
|
endforeach()
|
|
endif()
|
|
|
|
if(newContent)
|
|
set(newContent "${newContent}\n${line}")
|
|
else()
|
|
set(newContent "${line}")
|
|
endif()
|
|
endif()
|
|
|
|
if("${line}" MATCHES "</plugin>")
|
|
set(already_exists_in_xml OFF)
|
|
endif()
|
|
endforeach()
|
|
|
|
file(WRITE "${IE_CONFIG_OUTPUT_FILE}" "${newContent}")
|