@echo off
:: cmd run " create_filter > filter.vcproj "
set _plat_=Win32
REM set _plat_=x64
::ConfigurationType 0: 实用工具 1:应用程序
echo ^<?xml version="1.0" encoding="Windows-1252"?^>
echo ^<VisualStudioProject
echo ProjectType="Visual C++"
echo ProjectGUID="{769DD10E-E284-46BE-9172-A35184250A3A}"^>
echo ^<Platforms^>
echo ^<Platform Name="%_plat_%"/^>
echo ^</Platforms^>
echo ^<Configurations^>
echo ^<Configuration
echo Name="Debug|%_plat_%"
echo OutputDirectory="$(ConfigurationName)"
echo IntermediateDirectory="$(ConfigurationName)"
echo ConfigurationType="1"^>
echo ^</Configuration^>
echo ^<Configuration
echo Name="Release|%_plat_%"
echo OutputDirectory="$(ConfigurationName)"
echo IntermediateDirectory="$(ConfigurationName)"
echo ConfigurationType="1"^>
echo ^</Configuration^>
echo ^</Configurations^>
echo ^<References^>
echo ^</References^>
echo ^<Files^>
call :create_filter . "*.h" "Include Files" ""
call :create_filter . "*.c;*.cpp" "Source Files" ""
echo ^</Files^>
echo ^<Globals^>
echo ^</Globals^>
echo ^</VisualStudioProject^>
goto :end
:: **********************************************
:: find_path filter_regex filter_name tab_space
:create_filter
:: **********************************************
set _path_=%1
set _mask_=%2
set _name_=%3
set _tabs_=" "%4
set _next_=" "%_tabs_%
:: *********************
:: remove quotes
:: *********************
set _name_=%_name_:"=%
set _mask_=%_mask_:"=%
set _tabs_=%_tabs_:"=%
set _next_=%_next_:"=%
:: *********************
:: stop folders
:: *********************
for %%d in (data debian dist_docs docs html m4 pymod swig vb6) do (
if "%_name_%"=="%%d" (
goto :end
)
)
:: *********************
:: check whole folder tree
:: *********************
set _find_=0
for /R %%f in (%_mask_%) do set _find_=1
if %_find_%==0 (
goto :end
)
:: *********************
:: create filter
:: *********************
echo %_tabs_%^<Filter Name="%_name_%" Filter="%_mask_%"^>
:: *********************
:: add files
:: *********************
for %%f in (%_mask_%) do (
echo %_next_%^<File RelativePath="%_path_%\%%f" /^>
)
:: *********************
:: clib all the branches
:: *********************
for /D %%d in (*) do (
cd %%d
call :create_filter %_path_%\%%d "%_mask_%" %%d "%_tabs_%"
cd ..
)
echo %_tabs_%^</Filter^>
:: **********************************************
:end
:: **********************************************
creater_filter.bat 批处理生成 filter.vcproj
最新推荐文章于 2023-07-05 16:36:37 发布