Lines Matching full:build

5   <title>scan-build: running the analyzer from the command line</title>
16 <h1>scan-build: running the analyzer from the command line</h1>
22 <p><b>scan-build</b> is a command line utility that enables a user to run the
23 static analyzer over their codebase as part of performing a regular build (from
27 <p>During a project build, as source files are compiled they are also analyzed
30 <p>Upon completion of the build, results are then presented to the user within a
33 <h3>Will it work with any build system?</h3>
34 <p><b>scan-build</b> has little or no knowledge about how you build your code.
36 (hopefully) change your build to use a &quot;fake&quot; compiler instead of the
37 one that would normally build your project. This fake compiler executes either
43 the best use of <b>scan-build</b>, which includes getting it to work when the
48 <img src="images/scan_build_cmd.png" width="450px" alt="scan-build"><br>
61 <li><a href="#scanbuild_output">Output of scan-build</a></li>
67 <li><a href="#recommended_verbose">Use Verbose Output when Debugging scan-build</a></li>
68 <li><a href="#recommended_autoconf">Run './configure' through scan-build</a></li>
76 <p>The <tt>scan-build</tt> command can be used to analyze an entire project by
77 essentially interposing on a project's build process. This means that to run the
78 analyzer using <tt>scan-build</tt>, you will use <tt>scan-build</tt> to analyze
79 the source files compiled by <tt>gcc</tt>/<tt>clang</tt> during a project build.
84 <p>Basic usage of <tt>scan-build</tt> is designed to be simple: just place the
85 word &quot;scan-build&quot; in front of your build command:</p>
88 $ <span class="code_highlight">scan-build</span> make
89 $ <span class="code_highlight">scan-build</span> xcodebuild
92 <p>In the first case <tt>scan-build</tt> analyzes the code of a project built
93 with <tt>make</tt> and in the second case <tt>scan-build</tt> analyzes a project
96 <p>Here is the general format for invoking <tt>scan-build</tt>:</p>
99 $ <span class="code_highlight">scan-build</span> <i>[scan-build options]</i> <span class="code_high…
102 <p>Operationally, <tt>scan-build</tt> literally runs &lt;command&gt; with all of the
104 <tt>make</tt> get a parallel build over 4 cores:</p>
107 $ scan-build make <span class="code_highlight">-j4</span>
110 <p>In almost all cases, <tt>scan-build</tt> makes no effort to interpret the
111 options after the build command; it simply passes them through. In general,
112 <tt>scan-build</tt> should support parallel builds, but <b>not distributed
115 <p>It is also possible to use <tt>scan-build</tt> to analyze specific
119 $ scan-build gcc -c <span class="code_highlight">t1.c t2.c</span>
127 <p>Windows users must have Perl installed to use scan-build.</p>
129 <p><tt>scan-build.bat</tt> script allows you to launch scan-build in the same
130 way as it described in the Basic Usage section above. To invoke scan-build from
131 an arbitrary location, add the path to the folder containing scan-build.bat to
134 <p>If you have unexpected compilation/make problems when running scan-build
148 $ <span class="code_highlight">scan-build</span> <i>[scan-build options]</i> sh -c "make <i>[make o…
157 <p>As mentioned above, extra options can be passed to <tt>scan-build</tt>. These
158 options prefix the build command. For example:</p>
161 $ scan-build <span class="code_highlight">-k -V</span> make
162 $ scan-build <span class="code_highlight">-k -V</span> xcodebuild
177 <tt>scan-build</tt> options.</td></tr>
180 going" option to the specified build command. <p>This option currently supports
182 can specify this behavior directly using build options.</p></td></tr>
184 <tr><td><b>-v</b></td><td>Verbose output from scan-build and the analyzer. <b>A
188 <tr><td><b>-V</b></td><td>View analysis results in a web browser when the build
192 <b>--use-analyzer [path to clang]</b></td><td><tt>scan-build</tt> uses the
197 <p>A complete list of options can be obtained by running <tt>scan-build</tt>
200 <h3 id="scanbuild_output">Output of scan-build</h3>
203 The output of scan-build is a set of HTML files, each one which represents a
211 <tt>scan-build</tt>. If <b>-o</b> isn't specified, a directory in <tt>/tmp</tt>
212 is created to store the files (<tt>scan-build</tt> will print a message telling
213 you where they are). If you want to view the reports immediately after the build
214 completes, pass <b>-V</b> to <tt>scan-build</tt>.
230 <b>scan-build</b> tool which would enable assertions automatically.</p>
232 <h3 id="recommend_verbose">Use verbose output when debugging scan-build</h3>
234 <p><tt>scan-build</tt> takes a <b>-v</b> option to emit verbose output about
236 output of <tt>scan-build</tt> to a text file (make sure to redirect standard
237 error) is useful for filing bug reports against <tt>scan-build</tt> or the
239 For more comprehensible logs, don't perform a parallel build.</p>
241 <h3 id="recommended_autoconf">Run './configure' through scan-build</h3>
245 <tt>scan-build</tt> in order to analyze the project.</p>
250 $ scan-build ./configure
251 $ scan-build make
255 <tt>scan-build</tt> is because <tt>scan-build</tt> scans your source files by
257 <tt>scan-build</tt> temporarily setting the environment variable <tt>CC</tt> to
264 <tt>scan-build</tt> that path is set to <tt>ccc-analyzer</tt>.</p>
274 <p>To analyze a project, <tt>scan-build</tt> simply sets the environment variable
287 <tt>scan-build</tt> so that configure sets up the location of <tt>CC</tt> based
288 on the environment passed in from <tt>scan-build</tt>:
291 $ scan-build <b>./configure</b>
294 <p><tt>scan-build</tt> has special knowledge about <tt>configure</tt>, so it in
308 their cousins for desktop applications. <b>scan-build</b> can analyze these
313 <h3>Recommendation: use &quot;Build and Analyze&quot;</h3>
325 <h3>Using scan-build directly</h3>
327 <p>If you wish to use <b>scan-build</b> with your iPhone project, keep the
336 easier to do when using Xcode's <i>Build and Analyze</i> feature.</li>
342 <b>scan-build</b> in the following manner from the command line:</p>
345 $ scan-build xcodebuild -configuration Debug -sdk iphonesimulator2.2
351 $ scan-build xcodebuild -configuration Debug -sdk iphonesimulator3.0
356 <p>Recall that <b>scan-build</b> analyzes your project by using a compiler to
360 iPhone projects, <b>scan-build</b> may pick the wrong compiler than the one
361 Xcode would use to build your project. For example, this could be because
365 <p>When compiling your application to run on the simulator, it is important that <b>scan-build</b>
366 finds the correct version of <tt>gcc/clang</tt>. Otherwise, you may see strange build
367 errors that only happen when you run <tt>scan-build</tt>.
369 <p><b>scan-build</b> provides the <tt>--use-cc</tt> and <tt>--use-c++</tt>
370 options to hardwire which compiler scan-build should use for building your code.
372 mind that running the analyzer is intimately tied to the build, and not being
375 <p>If you aren't certain which compiler Xcode uses to build your project, try
376 just running <tt>xcodebuild</tt> (without <b>scan-build</b>). You should see the