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 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
50 <h3 id="simplifying-the-makefile">Simplifying the Makefile</h3> | 50 <h3 id="simplifying-the-makefile">Simplifying the Makefile</h3> |
51 <p>The makefile from part1 only supports one toolchain (PNaCl) and one | 51 <p>The makefile from part1 only supports one toolchain (PNaCl) and one |
52 configuration (Release). It also only supports one source file. It’s relat
ively | 52 configuration (Release). It also only supports one source file. It’s relat
ively |
53 simple, but if we want to add support for multiple toolchains, configurations, | 53 simple, but if we want to add support for multiple toolchains, configurations, |
54 source files, or build steps, it would grow increasingly complex. The SDK build | 54 source files, or build steps, it would grow increasingly complex. The SDK build |
55 system uses a set of variables and macros to make this possible, without | 55 system uses a set of variables and macros to make this possible, without |
56 significantly increasing the complexity of the makefile.</p> | 56 significantly increasing the complexity of the makefile.</p> |
57 <p>Here is the new makefile, supporting three toolchains (PNaCl, Newlib NaCl, | 57 <p>Here is the new makefile, supporting three toolchains (PNaCl, Newlib NaCl, |
58 Glibc NaCl) and two configurations (Debug, Release).</p> | 58 Glibc NaCl) and two configurations (Debug, Release).</p> |
59 <pre class="prettyprint"> | 59 <pre class="prettyprint"> |
60 VALID_TOOLCHAINS := pnacl newlib glibc | 60 VALID_TOOLCHAINS := pnacl clang-newlib glibc |
61 | 61 |
62 NACL_SDK_ROOT ?= $(abspath $(CURDIR)/../..) | 62 NACL_SDK_ROOT ?= $(abspath $(CURDIR)/../..) |
63 include $(NACL_SDK_ROOT)/tools/common.mk | 63 include $(NACL_SDK_ROOT)/tools/common.mk |
64 | 64 |
65 TARGET = part2 | 65 TARGET = part2 |
66 LIBS = ppapi_cpp ppapi | 66 LIBS = ppapi_cpp ppapi |
67 | 67 |
68 CFLAGS = -Wall | 68 CFLAGS = -Wall |
69 SOURCES = hello_tutorial.cc | 69 SOURCES = hello_tutorial.cc |
70 | 70 |
(...skipping 12 matching lines...) Expand all Loading... |
83 | 83 |
84 $(eval $(call NMF_RULE,$(TARGET),)) | 84 $(eval $(call NMF_RULE,$(TARGET),)) |
85 </pre> | 85 </pre> |
86 <h3 id="choosing-valid-toolchains-and-including-common-mk">Choosing valid toolch
ains, and including common.mk</h3> | 86 <h3 id="choosing-valid-toolchains-and-including-common-mk">Choosing valid toolch
ains, and including common.mk</h3> |
87 <p>The makefile begins by specifying the toolchains that are valid for this | 87 <p>The makefile begins by specifying the toolchains that are valid for this |
88 project. The Native Client SDK build system supports multi-toolchain projects | 88 project. The Native Client SDK build system supports multi-toolchain projects |
89 for its examples and libraries, but generally you will choose one toolchain | 89 for its examples and libraries, but generally you will choose one toolchain |
90 when you begin your project and never change it. Please see the | 90 when you begin your project and never change it. Please see the |
91 <a class="reference internal" href="/native-client/overview.html#toolchains"><em
>Toolchains section of the Native Client overview</em></a> for more | 91 <a class="reference internal" href="/native-client/overview.html#toolchains"><em
>Toolchains section of the Native Client overview</em></a> for more |
92 information.</p> | 92 information.</p> |
93 <p>For this example, we support the <code>pnacl</code>, <code>newlib</code> and
<code>glibc</code> toolchains.</p> | 93 <p>For this example, we support the <code>pnacl</code>, <code>clang-newlib</code
> and <code>glibc</code> |
| 94 toolchains.</p> |
94 <pre class="prettyprint"> | 95 <pre class="prettyprint"> |
95 VALID_TOOLCHAINS := pnacl newlib glibc | 96 VALID_TOOLCHAINS := pnacl clang-newlib glibc |
96 </pre> | 97 </pre> |
97 <p>Next, as a convenience, we specify where to find <code>NACL_SDK_ROOT</code>.
Because | 98 <p>Next, as a convenience, we specify where to find <code>NACL_SDK_ROOT</code>.
Because |
98 this example is located in <code>pepper_$(VERSION)/getting_started/part2</code>,
the | 99 this example is located in <code>pepper_$(VERSION)/getting_started/part2</code>,
the |
99 root of the SDK is two directories up.</p> | 100 root of the SDK is two directories up.</p> |
100 <pre class="prettyprint"> | 101 <pre class="prettyprint"> |
101 NACL_SDK_ROOT ?= $(abspath $(CURDIR)/../..) | 102 NACL_SDK_ROOT ?= $(abspath $(CURDIR)/../..) |
102 </pre> | 103 </pre> |
103 <aside class="note"> | 104 <aside class="note"> |
104 <blockquote> | 105 <blockquote> |
105 <div>In your own projects, you can use the absolute path to your installed SDK | 106 <div>In your own projects, you can use the absolute path to your installed SDK |
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
237 </pre> | 238 </pre> |
238 <p>This logic is now handled by <code>common.js</code>.</p> | 239 <p>This logic is now handled by <code>common.js</code>.</p> |
239 <h3 id="making-index-html-support-different-toolchains-and-configurations">Makin
g index.html support different toolchains and configurations</h3> | 240 <h3 id="making-index-html-support-different-toolchains-and-configurations">Makin
g index.html support different toolchains and configurations</h3> |
240 <p>Finally, there are a few changes to <code>index.html</code> that are not nece
ssary for | 241 <p>Finally, there are a few changes to <code>index.html</code> that are not nece
ssary for |
241 CSP-compliance, but help make the SDK examples more generic.</p> | 242 CSP-compliance, but help make the SDK examples more generic.</p> |
242 <p>First, we add some <a class="reference external" href="https://developer.mozi
lla.org/en-US/docs/Web/Guide/HTML/Using_data_attributes">data attributes</a> | 243 <p>First, we add some <a class="reference external" href="https://developer.mozi
lla.org/en-US/docs/Web/Guide/HTML/Using_data_attributes">data attributes</a> |
243 to the body element to specify the name, supported toolchains, supported | 244 to the body element to specify the name, supported toolchains, supported |
244 configurations, and path to the <code>.nmf</code> file:</p> | 245 configurations, and path to the <code>.nmf</code> file:</p> |
245 <pre class="prettyprint"> | 246 <pre class="prettyprint"> |
246 <body data-name="part2" | 247 <body data-name="part2" |
247 data-tools="newlib glibc pnacl" | 248 data-tools="clang-newlib glibc pnacl" |
248 data-configs="Debug Release" | 249 data-configs="Debug Release" |
249 data-path="{tc}/{config}"> | 250 data-path="{tc}/{config}"> |
250 ... | 251 ... |
251 </pre> | 252 </pre> |
252 <p><code>common.js</code> will read these data attributes to allow you to load t
he same | 253 <p><code>common.js</code> will read these data attributes to allow you to load t
he same |
253 example with different toolchains by changing the URL’s <a class="referenc
e external" href="http://en.wikipedia.org/wiki/Query_string">query string</a>. F
or example, you can load the | 254 example with different toolchains by changing the URL’s <a class="referenc
e external" href="http://en.wikipedia.org/wiki/Query_string">query string</a>. F
or example, you can load the |
254 glibc Debug version of this example by navigating to | 255 glibc Debug version of this example by navigating to |
255 <code>index.html?tc=glibc&config=Debug</code>. Path URI’s such as <co
de>../</code>, for example | 256 <code>index.html?tc=glibc&config=Debug</code>. Path URI’s such as <co
de>../</code>, for example |
256 do not work for either the data-path parameter or its corresponding query | 257 do not work for either the data-path parameter or its corresponding query |
257 string.</p> | 258 string.</p> |
(...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
433 </li> | 434 </li> |
434 <li><p class="first">Re-run the application by reloading <code>http://localhost:
5103/part2</code> in | 435 <li><p class="first">Re-run the application by reloading <code>http://localhost:
5103/part2</code> in |
435 Chrome.</p> | 436 Chrome.</p> |
436 <p>After Chrome loads the Native Client module, you should see the message sent | 437 <p>After Chrome loads the Native Client module, you should see the message sent |
437 from the module.</p> | 438 from the module.</p> |
438 </li> | 439 </li> |
439 </ol> | 440 </ol> |
440 </section> | 441 </section> |
441 | 442 |
442 {{/partials.standard_nacl_article}} | 443 {{/partials.standard_nacl_article}} |
OLD | NEW |