facebookarchive / xctool

An extension for Apple's xcodebuild that makes it easier to test iOS and macOS apps.
Apache License 2.0
6.91k stars 737 forks source link

add 'analyze' action that emits structured output from the clang static analyzer #29

Closed fpotter closed 11 years ago

fpotter commented 11 years ago

I think the -[IDEActivityLogSection messages] method might contain some nicely structured analyzer info.

See -- https://github.com/facebook/xctool/blob/b081ed900de59b504002ebd1a676de102b0b37b9/xcodebuild-shim/xcodebuild-shim/xcodebuild_shim.m#L67

When I looked last, it seemed to include an item for everything that gets shown in the "Issue Navigator" thingy on the left hand side. (That pane that lets you jump to build warnings/errors).

sharplet commented 11 years ago

+1

yiding commented 11 years ago

IDEActivityLog is used for the build output log in xcode, I'm not sure that it updates for command line builds. These corresponds to the xcactivitylog files stored in DerivedData.

So when you set the build setting RUN_CLANG_STATIC_ANALYZER=YES, for each target xcode(build) will run "analyze" action on them.

The analyze action dumps stuff into $(TARGET_TEMP_DIR)/StaticAnalyzer and some execution logs are stored in build-state.dat in the same directory, this is the same as a normal build, where files go into Objects-normal.

The analyze action generates plist files for each source file containing structured analyzer warnings as the compiler output.

A method of collecting analyzer information is simply to build with RUN_CLANG_STATIC_ANALYZER=YES, and then deriving a list of source files for the targets, and then collecting the plist files (instead of simply looking at all the plist files, which may contain stale data for source files that no longer exist). This method will not require a full-rebuild to grab the analyzer output, which I assume is useful in some circumstances.

List of relevant source files can be retrieved from build-state.dat, which also includes the output and return value of each build step.

jasongregori commented 11 years ago

+1

yiding commented 11 years ago

Added some support for this, use the raw reporter to get structured output with context.