开发者

Any tools that do automated project/build settings checks for Visual-C++?

开发者 https://www.devze.com 2023-03-29 20:19 出处:网络
I would like to find out if there exist any tools that do \"static analysis\" of build settings, specifically of Visual-Studio C++ native project files. (*.vcproj for 2005/2008 - I think 2010 introduc

I would like to find out if there exist any tools that do "static analysis" of build settings, specifically of Visual-Studio C++ native project files. (*.vcproj for 2005/2008 - I think 2010 introduces a new filetype unified with MSBuild.)

The kind of st开发者_StackOverflowuff we would like to check automatically on all projects/modules checked into SCC is:

  • Check all preprocessor defines. (e.g., check that the release build has NDEBUG defined.)
  • Make sure compiler optimization settings are the same for all related projects.
  • Make sure that if a project links to module Y it also links to module Z, but never to module A.
  • Make sure all related projects use the same runtime library (linkage) settings etc.
  • Make sure the projects generate a usable and correctly named pdb file in release and debug mode.
  • Make sure that all projects in a group include abc.vsprops for additional settings.
  • ...

So basically we have a source repository with lots of projects, and we would like to make sure that all (groups of) projects do have valid build settings and also continue to have valid build settings.

Are there any tools for this, or are people just rolling their own?

How do you keep you project-settings / MSBuild-settings consistent when you have lots of developers?


Edit: I also posted this over at the VC++ forums and while I got zero answers here on SO, I got zero useful answers over there.

I'll scrap the makefile tag and add the visual-c++ tag and see if this makes some more sense like so:

We already have most of the above checks in place for our Visual-Studio-2005 projects. An upgrade to VC10 or VC11 is looming on the horizon, and -- because Microsoft changed the project file format -- I'll have to throw out the tools[a] we have and write new checks. This is the reality with MS. They will change their project file format . This is not to complain, they provide a decent converter after all, and they have their reasons. However, I would gladly pay for a product that allowed me to check for uniform settings without rewriting our check tools every time the project format is changed.

[a] : As you would expect. These tools were written in-house. Have 0.01 docs. And are horrible to maintain.


I did start work on a tool to do something similar to this to fix up some of the problems that we had locally (eg ensuring that all project configurations have the same include paths). I never got as far as making it generic, but I think the general principles may be of use. Because of the XML project structure XPath type queries make it easy to access the data you need. I wrote a couple of helper functions in Ruby that do this sort of thing:

require 'rexml/document'
include REXML

def GetIncludeDirsStringForConfig(root, config)
  incs=""
  name=config.attributes['Name']
  configs = root.each_element("//Tool[@Name='VCCLCompilerTool']") do |tool|
    incs=tool.attributes['AdditionalIncludeDirectories']
  end
  return incs
end

def FindConfig(root, name)
 root.each_element("//Configuration") do |config|
  thisName=config.attributes['Name']
  if (name==thisName || name=thisName + "|Win32") 
    return config
  end
 end
return nil
end

file=File.new(vcprojFilename)
doc = Document.new(file)
root = doc.root

# list configurations:
configs = root.each_element("//Configuration") do |config|
  name=config.attributes['Name']
  puts name
end

With a combination of a few helper functions like this and some search/replace functions you can make quite a useful analysis/fixer tool customised to your own requirements.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号