::writen by yikenan, 20210401 ::用于自动生成win下的动态库清单文件 ::注意,每个目录下的本文件内容(manifest_file、manifest_name)不同,不要随意复制 @echo off ::延迟变量扩展,否则for循环中的变量只有最后的值 @setlocal enabledelayedexpansion set install_path=%~dp0 cd /d %install_path% ::文件路径 SET manifest_path=..\..\product\windows10_debug ::文件名 SET manifest_file=product.manifest ::文件中的name SET manifest_name=..\..\product\windows10_debug\product ::删除已有文件 if exist %manifest_file% ( del %manifest_file% ) if exist %manifest_file% ( echo Error: can not delete file %manifest_file%! goto end ) ::写文件不变的部分,注意 > 与 >> 的区别 @echo ^ > %manifest_file% @echo. >> %manifest_file% @echo ^<^^!-- Generated by generate_manifest.bat, please do not modify^^! --^> >> %manifest_file% @echo. >> %manifest_file% @echo ^ >> %manifest_file% @echo ^ >> %manifest_file% ::获取动态库文件并输出到manifest :: manifest中写子目录的dll无效,所以无需这样处理,注释掉,用下面的方法 ::for /f %%s in ('dir /s /b ".\*.dll"') do ( :: ::绝对路径 :: set absolute_path=%%s :: ::截取为相对路径 :: set relative_path=!absolute_path:%install_path%=! :: @echo ^ >> %manifest_file% ::) for /f %%s in ('dir /b ".\*.dll"') do ( @echo ^ >> %manifest_file% ) ::额外依赖的清单文件,开始 @echo. >> %manifest_file% @echo ^ >> %manifest_file% ::QtAV用于视频解码 @echo ^ >> %manifest_file% @echo ^ >> %manifest_file% @echo ^ >> %manifest_file% ::额外依赖的清单文件,结束 @echo ^ >> %manifest_file% @echo. >> %manifest_file% ::写文件不变的部分 @echo ^ >> %manifest_file% @echo. >> %manifest_file% @echo ^<^^!-- Generated by generate_manifest.bat, please do not modify^^! --^> >> %manifest_file% @echo. >> %manifest_file% :success echo. echo File "%manifest_file%" has been generated successfully. echo. pause exit :end pause exit