Extract useful file list (with path) from Visual Studio C++ project

不羁的心 提交于 2019-12-13 19:35:16

问题


I am working with a team on quite a few visual studio (2008) projects which share a lot of code. Some files are used by all projects, but some are only useful to 1 or 2. I am looking for a way to extract all useful files for one particular project.

The principle we use is to share directories. Each project selects the shared directories it wants to use in the inclusion-directory list (inside the project properties). All such directories are created inside a root directory (directly or not).

 project_dir/  
 shared1_dir/  
 shared2_dir/  
 ...

Given a project file, what it the most efficient way to copy all needed files, keeping the shared-directory structure, but in a new root directory ? The objective here is to make a strict archive of a project.

NB : source files in shared directories are usually not cpp files, but rather header files (our projects use a lot of templates).


回答1:


I have written a small tool in python that does the job. The principle is to launch a "rebuild all" command in devenv for the to-be-archived solution+project, and to interpret its output.

This command is applied to a special configuration (in my case "ReleaseInclude") to which a couple of subtle changes (compared to "Release" configuration) have been made : * enabled option "showIncludes" (compiler option) * enabled option "/verbose:lib" for libraries (linker option)

Now, * using regexp in visual studio project files, i have been able to retrieve all cpp and other ressource files. * using regexp on the output of the compilation (don't forget to enable the output for devenv !), i have been able to list all include and library files

I have also filtered this list of files to ignore visual-studio-centric files.

Tested and approved.



来源:https://stackoverflow.com/questions/3414985/extract-useful-file-list-with-path-from-visual-studio-c-project

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!