Warning, /graphics/krita/3rdparty/ext_frameworks/0002-Android-Recursively-find-dependency-of-dependencies.patch is written in an unsupported language. File is not indexed.

0001 From f5f548479894a801738a8cdd109ca3cf310ef40c Mon Sep 17 00:00:00 2001
0002 From: Sharaf Zaman <shzam@sdf.org>
0003 Date: Tue, 6 Dec 2022 12:21:50 +0000
0004 Subject: [PATCH 2/2] Android: Recursively find dependency of dependencies.
0005 
0006 ---
0007  toolchain/specifydependencies.cmake | 70 ++++++++++++++++-------------
0008  1 file changed, 39 insertions(+), 31 deletions(-)
0009 
0010 diff --git a/toolchain/specifydependencies.cmake b/toolchain/specifydependencies.cmake
0011 index fac7c71d..b5cdc898 100644
0012 --- a/toolchain/specifydependencies.cmake
0013 +++ b/toolchain/specifydependencies.cmake
0014 @@ -1,37 +1,10 @@
0015 +set(indexed_libraries "")
0016  
0017 -function(list_dependencies target libs)
0018 -    execute_process(COMMAND readelf --wide --dynamic ${target} ERROR_VARIABLE readelf_errors OUTPUT_VARIABLE out RESULT_VARIABLE result)
0019 -
0020 -    if (NOT result EQUAL 0)
0021 -        message(FATAL_ERROR "readelf failed on ${target} exit(${result}): ${readelf_errors}")
0022 -    endif()
0023 -
0024 -    string(REPLACE "\n" ";" lines "${out}")
0025 -    set(extralibs ${${libs}})
0026 -    foreach(line ${lines})
0027 -        string(REGEX MATCH ".*\\(NEEDED\\) +Shared library: +\\[(.+)\\]$" matched ${line})
0028 -        set(currentLib ${CMAKE_MATCH_1})
0029 -
0030 -        if(NOT ${currentLib} MATCHES "libQt5.*" AND matched)
0031 -            find_file(ourlib-${currentLib} ${currentLib} HINTS ${OUTPUT_DIR} ${EXPORT_DIR} ${ECM_ADDITIONAL_FIND_ROOT_PATH} NO_DEFAULT_PATH PATH_SUFFIXES lib)
0032 -
0033 -            if(ourlib-${currentLib})
0034 -                list(APPEND extralibs "${ourlib-${currentLib}}")
0035 -            else()
0036 -                message(STATUS "could not find ${currentLib} in ${OUTPUT_DIR} ${EXPORT_DIR} ${ECM_ADDITIONAL_FIND_ROOT_PATH}")
0037 -            endif()
0038 -        endif()
0039 -    endforeach()
0040 -    set(${libs} ${extralibs} PARENT_SCOPE)
0041 -endfunction()
0042 -
0043 -list_dependencies(${TARGET} extralibs)
0044 -
0045 -function(contains_library libpath IS_EQUAL)
0046 +function(contains_library libraries libpath IS_EQUAL)
0047      get_filename_component (name ${libpath} NAME)
0048      unset (IS_EQUAL PARENT_SCOPE)
0049  
0050 -    foreach (extralib ${extralibs})
0051 +    foreach (extralib ${libraries})
0052          get_filename_component (extralibname ${extralib} NAME)
0053          if (${extralibname} STREQUAL ${name})
0054              set (IS_EQUAL TRUE PARENT_SCOPE)
0055 @@ -40,9 +13,44 @@ function(contains_library libpath IS_EQUAL)
0056      endforeach()
0057  endfunction()
0058  
0059 +macro(list_dependencies target libs)
0060 +    contains_library("${indexed_libraries}" ${target} IS_EQUAL)
0061 +    if(NOT IS_EQUAL)
0062 +        list(APPEND indexed_libraries ${target})
0063 +
0064 +        execute_process(COMMAND readelf --wide --dynamic ${target} ERROR_VARIABLE readelf_errors OUTPUT_VARIABLE out RESULT_VARIABLE result)
0065 +
0066 +        if (NOT result EQUAL 0)
0067 +            message(FATAL_ERROR "readelf failed on ${target} exit(${result}): ${readelf_errors}")
0068 +        endif()
0069 +
0070 +        string(REPLACE "\n" ";" lines "${out}")
0071 +        set(extralibs ${${libs}})
0072 +        foreach(line ${lines})
0073 +            string(REGEX MATCH ".*\\(NEEDED\\) +Shared library: +\\[(.+)\\]$" matched ${line})
0074 +            set(currentLib ${CMAKE_MATCH_1})
0075 +
0076 +            if(NOT ${currentLib} MATCHES "libQt5.*" AND matched)
0077 +                find_file(ourlib-${currentLib} ${currentLib} HINTS ${OUTPUT_DIR} ${EXPORT_DIR} ${ECM_ADDITIONAL_FIND_ROOT_PATH} NO_DEFAULT_PATH PATH_SUFFIXES lib)
0078 +
0079 +                if(ourlib-${currentLib})
0080 +                    set(_found_lib ${ourlib-${currentLib}})
0081 +                    list(APPEND extralibs "${_found_lib}")
0082 +                    list_dependencies(${_found_lib} extralibs)
0083 +                else()
0084 +                    message(STATUS "could not find ${currentLib} in ${OUTPUT_DIR} ${EXPORT_DIR}/lib/ ${ECM_ADDITIONAL_FIND_ROOT_PATH}")
0085 +                endif()
0086 +            endif()
0087 +        endforeach()
0088 +        set(${libs} ${extralibs})
0089 +    endif()
0090 +endmacro()
0091 +
0092 +list_dependencies(${TARGET} extralibs)
0093 +
0094  if (ANDROID_EXTRA_LIBS)
0095      foreach (extralib ${ANDROID_EXTRA_LIBS})
0096 -        contains_library(${extralib} IS_EQUAL)
0097 +        contains_library("${extralibs}" ${extralib} IS_EQUAL)
0098  
0099          if (IS_EQUAL)
0100              message (STATUS "found duplicate, skipping: " ${extralib})
0101 -- 
0102 2.37.1.windows.1
0103