OLD | NEW |
1 {{+bindTo:partials.standard_nacl_article}} | 1 {{+bindTo:partials.standard_nacl_article}} |
2 | 2 |
3 <section id="c-tutorial-getting-started-part-2"> | 3 <section id="c-tutorial-getting-started-part-2"> |
4 <span id="tutorial2"></span><h1 id="c-tutorial-getting-started-part-2"><span id=
"tutorial2"></span>C++ Tutorial: Getting Started (Part 2)</h1> | 4 <span id="tutorial2"></span><h1 id="c-tutorial-getting-started-part-2"><span id=
"tutorial2"></span>C++ Tutorial: Getting Started (Part 2)</h1> |
5 <div class="contents local" id="contents" style="display: none"> | 5 <div class="contents local" id="contents" style="display: none"> |
6 <ul class="small-gap"> | 6 <ul class="small-gap"> |
7 <li><a class="reference internal" href="#overview" id="id1">Overview</a></li> | 7 <li><a class="reference internal" href="#overview" id="id1">Overview</a></li> |
8 <li><p class="first"><a class="reference internal" href="#using-the-native-clien
t-sdk-build-system" id="id2">Using the Native Client SDK build system</a></p> | 8 <li><p class="first"><a class="reference internal" href="#using-the-native-clien
t-sdk-build-system" id="id2">Using the Native Client SDK build system</a></p> |
9 <ul class="small-gap"> | 9 <ul class="small-gap"> |
10 <li><a class="reference internal" href="#simplifying-the-makefile" id="id3">Simp
lifying the Makefile</a></li> | 10 <li><a class="reference internal" href="#simplifying-the-makefile" id="id3">Simp
lifying the Makefile</a></li> |
(...skipping 14 matching lines...) Expand all Loading... |
25 <li><a class="reference internal" href="#loading-the-page-and-creating-the-modul
e" id="id12">Loading the page and creating the module</a></li> | 25 <li><a class="reference internal" href="#loading-the-page-and-creating-the-modul
e" id="id12">Loading the page and creating the module</a></li> |
26 </ul> | 26 </ul> |
27 </li> | 27 </li> |
28 <li><a class="reference internal" href="#example-specific-behavior-with-example-
js" id="id13">Example-specific behavior with example.js</a></li> | 28 <li><a class="reference internal" href="#example-specific-behavior-with-example-
js" id="id13">Example-specific behavior with example.js</a></li> |
29 </ul> | 29 </ul> |
30 | 30 |
31 </div><section id="overview"> | 31 </div><section id="overview"> |
32 <h2 id="overview">Overview</h2> | 32 <h2 id="overview">Overview</h2> |
33 <p>This tutorial shows how to convert the finished PNaCl web application from | 33 <p>This tutorial shows how to convert the finished PNaCl web application from |
34 <a class="reference internal" href="/native-client/devguide/tutorial/tutorial-pa
rt1.html"><em>Part 1</em></a> to use the Native Client SDK build system and | 34 <a class="reference internal" href="/native-client/devguide/tutorial/tutorial-pa
rt1.html"><em>Part 1</em></a> to use the Native Client SDK build system and |
35 common JavaScript files. It also demonstrates some techniques to make your | 35 common JavaScript files. It also demonstrates some techniques to make your web |
36 web application <cite>Content Security Policy (CSP)-compliant | 36 application <a class="reference external" href="/apps/contentSecurityPolicy">Con
tent Security Policy (CSP)-compliant</a>, which is necessary for <a class="refer
ence external" href="/apps/about_apps">Chrome Apps</a>.</p> |
37 <http://developer.chrome.com/apps/contentSecurityPolicy.html></cite>, whic
h is | |
38 necessary for <a class="reference external" href="https://developer.chrome.com/a
pps/about_apps.html">Chrome Apps</a>.</p> | |
39 <p>Using the Native Client SDK build system makes it easy to build with all of t
he | 37 <p>Using the Native Client SDK build system makes it easy to build with all of t
he |
40 SDK toolchains, and switch between the Debug and Release configurations. It | 38 SDK toolchains, and switch between the Debug and Release configurations. It |
41 also simplifies the makefiles for your project, as we’ll see in the next | 39 also simplifies the makefiles for your project, as we’ll see in the next |
42 section. Finally, it adds some useful commands for <a class="reference internal"
href="/native-client/sdk/examples.html#id1"><em>running</em></a> and <a class="
reference internal" href="/native-client/sdk/examples.html#debugging-the-sdk-exa
mples"><em>debugging</em></a> | 40 section. Finally, it adds some useful commands for <a class="reference internal"
href="/native-client/sdk/examples.html#id1"><em>running</em></a> and <a class="
reference internal" href="/native-client/sdk/examples.html#debugging-the-sdk-exa
mples"><em>debugging</em></a> |
43 your application.</p> | 41 your application.</p> |
44 <p>The finished code for this example can be found in the | 42 <p>The finished code for this example can be found in the |
45 <code>pepper_$(VERSION)/getting_started/part2</code> directory in the Native Cli
ent SDK | 43 <code>pepper_$(VERSION)/getting_started/part2</code> directory in the Native Cli
ent SDK |
46 download.</p> | 44 download.</p> |
47 </section><section id="using-the-native-client-sdk-build-system"> | 45 </section><section id="using-the-native-client-sdk-build-system"> |
48 <h2 id="using-the-native-client-sdk-build-system">Using the Native Client SDK bu
ild system</h2> | 46 <h2 id="using-the-native-client-sdk-build-system">Using the Native Client SDK bu
ild system</h2> |
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
137 <dd>The name of the project to build. This variable determines the name of the | 135 <dd>The name of the project to build. This variable determines the name of the |
138 library or executable that will be generated. In the above example, we call | 136 library or executable that will be generated. In the above example, we call |
139 the target <code>part2</code>, which will generate an executable called | 137 the target <code>part2</code>, which will generate an executable called |
140 <code>part2.pexe</code> for PNaCl. For NaCl toolchains, the executable’s f
ile name | 138 <code>part2.pexe</code> for PNaCl. For NaCl toolchains, the executable’s f
ile name |
141 will be given a suffix for its architecture. For example, the ARM executable | 139 will be given a suffix for its architecture. For example, the ARM executable |
142 is called <code>part2_arm.nexe</code>.</dd> | 140 is called <code>part2_arm.nexe</code>.</dd> |
143 <dt>LIBS</dt> | 141 <dt>LIBS</dt> |
144 <dd>A list of libraries that this executable needs to link against. The library | 142 <dd>A list of libraries that this executable needs to link against. The library |
145 search path is already set up to only look in the directory for the current | 143 search path is already set up to only look in the directory for the current |
146 toolchain and architecture. In this example, we link against <code>ppapi_cpp</co
de> | 144 toolchain and architecture. In this example, we link against <code>ppapi_cpp</co
de> |
147 and <code>ppapi</code>. <code>ppapi_cpp</code> is needed to use the <a class="re
ference external" href="https://developers.google.com/native-client/peppercpp/">
Pepper C++ interface</a>. <code>ppapi</code> is | 145 and <code>ppapi</code>. <code>ppapi_cpp</code> is needed to use the <a class="re
ference external" href="/native-client/pepper_stable/cpp/">Pepper C++ interface<
/a>. <code>ppapi</code> is needed for communicating |
148 needed for communicating with the browser.</dd> | 146 with the browser.</dd> |
149 <dt>CFLAGS</dt> | 147 <dt>CFLAGS</dt> |
150 <dd>A list of extra flags to pass to the compiler. In this example, we pass | 148 <dd>A list of extra flags to pass to the compiler. In this example, we pass |
151 <code>-Wall</code>, which turns on all warnings.</dd> | 149 <code>-Wall</code>, which turns on all warnings.</dd> |
152 <dt>LDFLAGS</dt> | 150 <dt>LDFLAGS</dt> |
153 <dd>A list of additional flags to pass to the linker. This example does not need | 151 <dd>A list of additional flags to pass to the linker. This example does not need |
154 any special linker flags, so this variable is omitted.</dd> | 152 any special linker flags, so this variable is omitted.</dd> |
155 <dt>SOURCES</dt> | 153 <dt>SOURCES</dt> |
156 <dd>A list of C or C++ sources to compile, separated by spaces. If you have a | 154 <dd>A list of C or C++ sources to compile, separated by spaces. If you have a |
157 long list of sources, it may be easier to read if you put each file on its | 155 long list of sources, it may be easier to read if you put each file on its |
158 own line, and use <code>\</code> as a line-continuation character. Here’s
an example:</dd> | 156 own line, and use <code>\</code> as a line-continuation character. Here’s
an example:</dd> |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
202 $(eval $(call LINK_RULE,$(TARGET),$(SOURCES),$(LIBS),$(DEPS))) | 200 $(eval $(call LINK_RULE,$(TARGET),$(SOURCES),$(LIBS),$(DEPS))) |
203 endif | 201 endif |
204 </pre> | 202 </pre> |
205 <p>Finally, the NMF rule generates a NaCl manifest file (<code>.nmf</code>) that
references | 203 <p>Finally, the NMF rule generates a NaCl manifest file (<code>.nmf</code>) that
references |
206 each executable generated in the previous step:</p> | 204 each executable generated in the previous step:</p> |
207 <pre class="prettyprint"> | 205 <pre class="prettyprint"> |
208 $(eval $(call NMF_RULE,$(TARGET),)) | 206 $(eval $(call NMF_RULE,$(TARGET),)) |
209 </pre> | 207 </pre> |
210 </section></section><section id="making-index-html-work-for-chrome-apps"> | 208 </section></section><section id="making-index-html-work-for-chrome-apps"> |
211 <h2 id="making-index-html-work-for-chrome-apps">Making index.html work for Chrom
e Apps</h2> | 209 <h2 id="making-index-html-work-for-chrome-apps">Making index.html work for Chrom
e Apps</h2> |
212 <p>This section describes the changes necessary to make the HTML and JavaScript | 210 <p>This section describes the changes necessary to make the HTML and JavaScript
in |
213 in part1 CSP-compliant. This is required if you want to build a <a class="refere
nce external" href="https://developer.chrome.com/apps/about_apps.html">Chrome Ap
p</a>, but is not necessary | 211 part1 CSP-compliant. This is required if you want to build a <a class="reference
external" href="/apps/about_apps">Chrome App</a>, but is not necessary if you w
ant to use PNaCl on the open |
214 if you want to use PNaCl on the open web.</p> | 212 web.</p> |
215 <section id="csp-rules"> | 213 <section id="csp-rules"> |
216 <h3 id="csp-rules">CSP rules</h3> | 214 <h3 id="csp-rules">CSP rules</h3> |
217 <p><a class="reference external" href="http://developer.chrome.com/apps/contentS
ecurityPolicy.html#what">Chrome Apps CSP</a> | 215 <p><a class="reference external" href="/apps/contentSecurityPolicy#what">Chrome
Apps CSP</a> restricts you from doing |
218 restricts you from doing the following:</p> | 216 the following:</p> |
219 <ul class="small-gap"> | 217 <ul class="small-gap"> |
220 <li>You can’t use inline scripting in your Chrome App pages. The restriction | 218 <li>You can’t use inline scripting in your Chrome App pages. The restriction |
221 bans both <code><script></code> blocks and event handlers (<code><butto
n onclick="..."></code>).</li> | 219 bans both <code><script></code> blocks and event handlers (<code><butto
n onclick="..."></code>).</li> |
222 <li>You can’t reference any external resources in any of your app files (except | 220 <li>You can’t reference any external resources in any of your app files (except |
223 for video and audio resources). You can’t embed external resources in an | 221 for video and audio resources). You can’t embed external resources in an |
224 iframe.</li> | 222 iframe.</li> |
225 <li>You can’t use string-to-JavaScript methods like <code>eval()</code> and <cod
e>new | 223 <li>You can’t use string-to-JavaScript methods like <code>eval()</code> and <cod
e>new |
226 Function()</code>.</li> | 224 Function()</code>.</li> |
227 </ul> | 225 </ul> |
228 </section><section id="making-index-html-csp-compliant"> | 226 </section><section id="making-index-html-csp-compliant"> |
(...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
434 // This function is called by common.js when a message is received from the | 432 // This function is called by common.js when a message is received from the |
435 // NaCl module. | 433 // NaCl module. |
436 function handleMessage(message) { | 434 function handleMessage(message) { |
437 var logEl = document.getElementById('log'); | 435 var logEl = document.getElementById('log'); |
438 logEl.textContent += message.data; | 436 logEl.textContent += message.data; |
439 } | 437 } |
440 </pre> | 438 </pre> |
441 </section></section> | 439 </section></section> |
442 | 440 |
443 {{/partials.standard_nacl_article}} | 441 {{/partials.standard_nacl_article}} |
OLD | NEW |