Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(931)

Side by Side Diff: native_client_sdk/src/doc/_developer.chrome.com_generated/sdk/examples.html

Issue 140993006: [NaCl SDK Docs] Check in the generated NaCl SDK Documentation. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: try without pepper_{dev,beta,stable} Created 6 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
1 {{+bindTo:partials.standard_nacl_article}}
2
3 <section id="running-the-sdk-examples">
4 <span id="sdk-examples-2"></span><h1 id="running-the-sdk-examples"><span id="sdk -examples-2"></span>Running the SDK Examples</h1>
5 <p>Every Native Client SDK bundle comes with a folder of example applications.
6 Each example demonstrates one or two key Native Client programming concepts.
7 After you&#8217;ve <a class="reference internal" href="/native-client/sdk/downlo ad.html"><em>downloaded the SDK</em></a>, follow the instructions
8 on this page to build and run the examples.</p>
9 <section id="configure-the-google-chrome-browser">
10 <h2 id="configure-the-google-chrome-browser">Configure the Google Chrome Browser </h2>
11 <ol class="arabic">
12 <li><p class="first">Your version of Chrome must be equal to or greater than the version of
13 your SDK bundle. For example, if you&#8217;re developing with the <code>pepper_3 1</code>
14 bundle, you must use Google Chrome version 31 or greater. To find out what
15 version of Chrome you&#8217;re using, type <code>about:chrome</code> or <code>ab out:version</code>
16 in the Chrome address bar.</p>
17 </li>
18 <li><p class="first">For Portable Native Client, no extra Chrome flags are neede d as of
19 Chrome version 31.</p>
20 <p>For other Native Client applications, or to <strong>debug</strong> Portable N ative
21 Client applications by translating the <strong>pexe</strong> to a <strong>nexe</ strong> ahead of
22 time, enable the Native Client flag. Native Client is enabled by default
23 only for applications distributed through the Chrome Web Store. To run
24 Native Client applications that are not distributed through the Chrome
25 Web Store, like the SDK examples, you must specifically enable the Native
26 Client flag in Chrome:</p>
27 <ul class="small-gap">
28 <li><p class="first">Type <code>about:flags</code> in the Chrome address bar and scroll down to
29 &#8220;Native Client&#8221;.</p>
30 </li>
31 <li><p class="first">If the link below &#8220;Native Client&#8221; says &#8220;D isable&#8221;, then Native Client is
32 already enabled and you don&#8217;t need to do anything else.</p>
33 </li>
34 <li><p class="first">If the link below &#8220;Native Client&#8221; says &#8220;E nable&#8221;, click the &#8220;Enable&#8221;
35 link, scroll down to the bottom of the page, and click the &#8220;Relaunch
36 Now&#8221; button. All browser windows will restart when you relaunch Chrome.</p >
37 </li>
38 </ul>
39 </li>
40 <li><p class="first">Disable the Chrome cache. Chrome caches resources aggressiv ely; when you
41 are building a Native Client application you should disable the cache to
42 make sure that Chrome loads the latest version:</p>
43 <ul class="small-gap">
44 <li><p class="first">Open Chrome&#8217;s developer tools by clicking the menu ic on <img alt="menu-icon" src="/native-client/images/menu-icon.png" /> and
45 choosing Tools &gt; Developer tools.</p>
46 </li>
47 <li><p class="first">Click the gear icon <img alt="gear-icon" src="/native-clien t/images/gear-icon.png" /> in the bottom right corner of the
48 Chrome window.</p>
49 </li>
50 <li><p class="first">Under the &#8220;General&#8221; settings, check the box nex t to &#8220;Disable cache&#8221;.</p>
51 </li>
52 </ul>
53 </li>
54 </ol>
55 </section><section id="build-the-sdk-examples">
56 <h2 id="build-the-sdk-examples">Build the SDK examples</h2>
57 <p>Starting with the <code>pepper_24</code> bundle, the Makefile scripts for the SDK
58 examples build multiple versions of the examples using all three SDK
59 toolchains (newlib, glibc, and PNaCl) and in both release and debug
60 configurations. (Note that some examples build only with the particular
61 toolchains).</p>
62 <p>To build all the examples, go to the examples directory in a specific SDK
63 bundle and run <code>make</code>:</p>
64 <pre class="prettyprint">
65 $ cd pepper_31/examples
66 $ make
67 make -C api all
68 make[1]: Entering directory `pepper_31/examples/api'
69 make -C audio all
70 make[2]: Entering directory `pepper_31/examples/api/audio'
71 CXX newlib/Debug/audio_x86_32.o
72 LINK newlib/Debug/audio_x86_32.nexe
73 CXX newlib/Debug/audio_x86_64.o
74 LINK newlib/Debug/audio_x86_64.nexe
75 CXX newlib/Debug/audio_arm.o
76 LINK newlib/Debug/audio_arm.nexe
77 CREATE_NMF newlib/Debug/audio.nmf
78 make[2]: Leaving directory `pepper_31/examples/api/audio'
79 make -C url_loader all
80 make[2]: Entering directory `pepper_31/examples/api/url_loader'
81 CXX newlib/Debug/url_loader_x86_32.o
82 ...
83 </pre>
84 <p>Calling <code>make</code> from inside a particular example&#8217;s directory will build only
85 that example:</p>
86 <pre class="prettyprint">
87 $ cd pepper_31/examples/api/core
88 $ make
89 CXX newlib/Debug/core_x86_32.o
90 LINK newlib/Debug/core_x86_32.nexe
91 CXX newlib/Debug/core_x86_64.o
92 LINK newlib/Debug/core_x86_64.nexe
93 CXX newlib/Debug/core_arm.o
94 LINK newlib/Debug/core_arm.nexe
95 CREATE_NMF newlib/Debug/core.nmf
96 </pre>
97 <p>You can call <code>make</code> with the <code>TOOLCHAIN</code> and <code>CONF IG</code> parameters to
98 override the defaults:</p>
99 <pre class="prettyprint">
100 $ make TOOLCHAIN=pnacl CONFIG=Release
101 CXX pnacl/Release/core_pnacl.o
102 LINK pnacl/Release/core.bc
103 FINALIZE pnacl/Release/core.pexe
104 CREATE_NMF pnacl/Release/core.nmf
105 </pre>
106 <p>You can also set <code>TOOLCHAIN</code> to &#8220;all&#8221; to build one or more examples with
107 all available toolchains:</p>
108 <pre class="prettyprint">
109 $ make TOOLCHAIN=all
110 make TOOLCHAIN=newlib
111 make[1]: Entering directory `pepper_31/examples/api/core'
112 CXX newlib/Debug/core_x86_32.o
113 LINK newlib/Debug/core_x86_32.nexe
114 CXX newlib/Debug/core_x86_64.o
115 LINK newlib/Debug/core_x86_64.nexe
116 CXX newlib/Debug/core_arm.o
117 LINK newlib/Debug/core_arm.nexe
118 CREATE_NMF newlib/Debug/core.nmf
119 make[1]: Leaving directory `pepper_31/examples/api/core'
120 make TOOLCHAIN=glibc
121 make[1]: Entering directory `pepper_31/examples/api/core'
122 CXX glibc/Debug/core_x86_32.o
123 LINK glibc/Debug/core_x86_32.nexe
124 CXX glibc/Debug/core_x86_64.o
125 LINK glibc/Debug/core_x86_64.nexe
126 CREATE_NMF glibc/Debug/core.nmf
127 make[1]: Leaving directory `pepper_31/examples/api/core'
128 make TOOLCHAIN=pnacl
129 make[1]: Entering directory `pepper_31/examples/api/core'
130 CXX pnacl/Debug/core_pnacl.o
131 LINK pnacl/Debug/core.bc
132 FINALIZE pnacl/Debug/core.pexe
133 TRANSLATE pnacl/Debug/core_x86_32.nexe
134 TRANSLATE pnacl/Debug/core_x86_64.nexe
135 TRANSLATE pnacl/Debug/core_arm.nexe
136 CREATE_NMF pnacl/Debug/core.nmf
137 make[1]: Leaving directory `pepper_31/examples/api/core'
138 make TOOLCHAIN=linux
139 make[1]: Entering directory `pepper_31/examples/api/core'
140 CXX linux/Debug/core.o
141 LINK linux/Debug/core.so
142 make[1]: Leaving directory `pepper_31/examples/api/core'
143 </pre>
144 <p>After running <code>make</code>, each example directory will contain one or m ore of
145 the following subdirectories:</p>
146 <ul class="small-gap">
147 <li>a <code>newlib</code> directory with subdirectories <code>Debug</code> and < code>Release</code>;</li>
148 <li>a <code>glibc</code> directory with subdirectories <code>Debug</code> and <c ode>Release</code>;</li>
149 <li>a <code>pnacl</code> directory with subdirectories <code>Debug</code> and <c ode>Release</code>;</li>
150 </ul>
151 <p>For the newlib and glibc toolchains the Debug and Release subdirectories
152 contain .nexe files for all target architectures. For the PNaCl toolchain
153 they contain a single .pexe file. PNaCl debug also produces pre-translated
154 .nexe files, for ease of debugging. All Debug and Release directories contain
155 a manifest (.nmf) file that references the associated .nexe or .pexe files.
156 For information about Native Client manifest files, see the <a class="reference internal" href="/native-client/overview.html"><em>Technical
157 Overview</em></a>.</p>
158 <p>For details on how to use <code>make</code>, see the <a class="reference exte rnal" href="http://www.gnu.org/software/make/manual/make.html">GNU &#8216;make&# 8217; Manual</a>. For details on how to
159 use the SDK toolchain itself, see <a class="reference internal" href="/native-cl ient/devguide/devcycle/building.html"><em>Building Native Client Modules</em></a >.</p>
160 </section><section id="run-the-sdk-examples">
161 <span id="id1"></span><h2 id="run-the-sdk-examples"><span id="id1"></span>Run th e SDK examples</h2>
162 <p>To run the SDK examples, you can use the <code>make run</code> command:</p>
163 <pre class="prettyprint">
164 $ cd pepper_31/examples/api/core
165 $ make run
166 </pre>
167 <p>This will launch a local HTTP server which will serve the data for the
168 example. It then launches Chrome with the address of this server, usually
169 <a class="reference external" href="http://localhost:5103">http://localhost:5103 </a>. After you close Chrome, the local HTTP server is
170 automatically shutdown.</p>
171 <p>This command will try to find an executable named <code>google-chrome</code> in your
172 <code>PATH</code> environment variable. If it can&#8217;t, you&#8217;ll get an e rror message like
173 this:</p>
174 <pre class="prettyprint">
175 pepper_31/tools/common.mk:415: No valid Chrome found at CHROME_PATH=
176 pepper_31/tools/common.mk:415: *** Set CHROME_PATH via an environment variable, or command-line.. Stop.
177 </pre>
178 <p>Set the CHROME_PATH environment variable to the location of your Chrome
179 executable.</p>
180 <ul class="small-gap">
181 <li><p class="first">On Windows:</p>
182 <p>The default install location of Chrome is
183 <code>C:\Program Files (x86)\Google\Chrome\Application\chrome.exe</code> for Chr ome
184 stable and
185 <code>C:\Users\&lt;username&gt;\AppData\Local\Google\Chrome SxS\Application\chro me.exe</code>
186 for Chrome Canary; try looking in those directories first:</p>
187 <pre class="prettyprint">
188 &gt; set CHROME_PATH=&lt;Path to chrome.exe&gt;
189 </pre>
190 </li>
191 <li><p class="first">On Linux:</p>
192 <pre class="prettyprint">
193 $ export CHROME_PATH=&lt;Path to google-chrome&gt;
194 </pre>
195 </li>
196 <li><p class="first">On Mac:</p>
197 <p>The default install location of Chrome is
198 <code>/Applications/Google Chrome.app/Contents/MacOS/Google Chrome</code> for
199 Chrome Stable and
200 <code>Applications/Google Chrome Canary.app/Contents/MacOS/Google Chrome Canary< /code>
201 for Chrome Canary. Note that you have to reference the executable inside the
202 application bundle, not the top-level <code>.app</code> directory:</p>
203 <pre class="prettyprint">
204 $ export CHROME_PATH=&lt;Path to Google Chrome&gt;
205 </pre>
206 </li>
207 </ul>
208 <p>You can run via a different toolchain or configuration by using the
209 <code>TOOLCHAIN</code> and <code>CONFIG</code> parameters to make:</p>
210 <pre class="prettyprint">
211 $ make run TOOLCHAIN=pnacl CONFIG=Debug
212 </pre>
213 </section><section id="run-the-sdk-examples-as-packaged-apps">
214 <span id="run-sdk-examples-as-packaged"></span><h2 id="run-the-sdk-examples-as-p ackaged-apps"><span id="run-sdk-examples-as-packaged"></span>Run the SDK example s as packaged apps</h2>
215 <p>Each example can also be launched as a packaged app. For more information abo ut
216 using Native Client for packaged apps, see <a class="reference internal" href="/ native-client/devguide/distributing.html#distributing-packaged"><em>Packaged app liction</em></a>. For general information about packaged apps, see the
217 <a class="reference external" href="http://developer.chrome.com/apps/about_apps. html">Chrome apps documentation</a>.</p>
218 <p>Some Pepper features, such as TCP/UDP socket access, are only allowed in
219 packaged apps. The examples that use these features must be run as packaged
220 apps, by using the <code>make run_package</code> command:</p>
221 <pre class="prettyprint">
222 $ make run_package
223 </pre>
224 <p>You can use <code>TOOLCHAIN</code> and <code>CONFIG</code> parameters as abov e to run with a
225 different toolchain or configuration.</p>
226 </section><section id="debugging-the-sdk-examples">
227 <span id="id2"></span><h2 id="debugging-the-sdk-examples"><span id="id2"></span> Debugging the SDK examples</h2>
228 <p>The NaCl SDK uses <a class="reference external" href="https://www.gnu.org/sof tware/gdb/">GDB</a> to debug Native
229 Client code. The SDK includes a prebuilt version of GDB that is compatible with
230 NaCl code. To use it, run the <code>make debug</code> command from an example di rectory:</p>
231 <pre class="prettyprint">
232 $ make debug
233 </pre>
234 <p>This will launch Chrome with the <code>--enable-nacl-debug</code> flag set. T his flag
235 will cause Chrome to pause when a NaCl module is first loaded, waiting for a
236 connection from gdb. The <code>make debug</code> command also simultaneously lau nches
237 GDB and loads the symbols for that NEXE. To connect GDB to Chrome, in the GDB
238 console, type:</p>
239 <pre class="prettyprint">
240 (gdb) target remote :4014
241 </pre>
242 <p>This tells GDB to connect to a TCP port on localhost:4014&#8211;the port that
243 Chrome is listening on. GDB will respond:</p>
244 <pre class="prettyprint">
245 Remote debugging using :4014
246 0x000000000fa00080 in ?? ()
247 </pre>
248 <p>At this point, you can use the standard GDB commands to debug your NaCl modul e.
249 The most common commands you will use to debug are <code>continue</code>, <code> step</code>,
250 <code>next</code>, <code>break</code> and <code>backtrace</code>. See <a class=" reference internal" href="/native-client/devguide/devcycle/debugging.html"><em>D ebugging</em></a> for more information about debugging a Native Client
251 application.</p>
252 </section></section>
253
254 {{/partials.standard_nacl_article}}
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698