Merge pull request #26326 from ksooo/pvr-delete-watched-ctx-menu
[xbmc.git] / cmake / scripts / windowsstore / Install.cmake
blob082f1af15188928f62e2768b4eef82b728786622
1 # Fix UWP addons security issue caused by empty __init__.py Python Lib files packaged with Kodi
2 # Encapsulate fix script to allow post generation execution in the event the python lib is
3 # built after project generation.
5 file(REMOVE ${CMAKE_BINARY_DIR}/${CORE_BUILD_DIR}/GeneratedUWPPythonInitFix.cmake)
6 file(APPEND ${CMAKE_BINARY_DIR}/${CORE_BUILD_DIR}/GeneratedUWPPythonInitFix.cmake
7 "set(uwp_pythonlibinit_filepattern \"\$\{DEPENDS_PATH\}/bin/Python/Lib/__init__.py\")
8 file(GLOB_RECURSE uwp_pythonlibinit_foundfiles \"\$\{uwp_pythonlibinit_filepattern\}\")
9 foreach(uwp_pythonlibinit_file \$\{uwp_pythonlibinit_foundfiles\})
10     file(SIZE \"\$\{uwp_pythonlibinit_file\}\" uwp_pythonlibinit_filesize)
11     if(\$\{uwp_pythonlibinit_filesize\} EQUAL 0)
12         message(\"Adding hash comment character in the following empty file: \$\{uwp_pythonlibinit_file\}\")
13         file(APPEND \$\{uwp_pythonlibinit_file\} \"#\")
14     endif()
15 endforeach()\n")
17 # Change to Python3::Python target when built internal
18 add_custom_target(generate-UWP-pythonfix
19                    COMMAND ${CMAKE_COMMAND} -DDEPENDS_PATH=${DEPENDS_PATH}
20                                             -P ${CMAKE_BINARY_DIR}/${CORE_BUILD_DIR}/GeneratedUWPPythonInitFix.cmake
21                    WORKING_DIRECTORY ${CMAKE_SOURCE_DIR})
23 # Make sure we apply fix to dependspath before we export-files copy to buildtree
24 add_dependencies(export-files generate-UWP-pythonfix)