Roll src/third_party/WebKit e0eac24:489c548 (svn 193311:193320)
[chromium-blink-merge.git] / native_client_sdk / doc_generated / reference / nacl-manifest-format.html
blobb796f0cc4c983b6c26463a9ef10907e59f63b402
1 {{+bindTo:partials.standard_nacl_article}}
3 <section id="native-client-manifest-nmf-format">
4 <h1 id="native-client-manifest-nmf-format">Native Client Manifest (nmf) Format</h1>
5 <div class="contents local" id="contents" style="display: none">
6 <ul class="small-gap">
7 <li><a class="reference internal" href="#overview" id="id1">Overview</a></li>
8 <li><a class="reference internal" href="#field-summary" id="id2">Field summary</a></li>
9 <li><p class="first"><a class="reference internal" href="#field-details" id="id3">Field details</a></p>
10 <ul class="small-gap">
11 <li><a class="reference internal" href="#program" id="id4">program</a></li>
12 <li><a class="reference internal" href="#files" id="id5">files</a></li>
13 </ul>
14 </li>
15 <li><p class="first"><a class="reference internal" href="#semantics" id="id6">Semantics</a></p>
16 <ul class="small-gap">
17 <li><a class="reference internal" href="#schema-validation" id="id7">Schema validation</a></li>
18 <li><a class="reference internal" href="#nexe-matching" id="id8">Nexe matching</a></li>
19 <li><a class="reference internal" href="#file-matching" id="id9">File matching</a></li>
20 <li><a class="reference internal" href="#url-of-the-nmf-file-from-embed-src-and-data-uri" id="id10">URL of the nmf file, from <code>&lt;embed&gt;</code> src, and data URI</a></li>
21 <li><a class="reference internal" href="#url-resolution" id="id11">URL resolution</a></li>
22 </ul>
23 </li>
24 </ul>
26 </div><h2 id="overview">Overview</h2>
27 <p>Every Native Client application has a <a class="reference external" href="http://www.json.org/">JSON-formatted</a>
28 NaCl Manifest File (<code>nmf</code>). The <code>nmf</code> tells the browser where to
29 download and load your Native Client application files and libraries.
30 The file can also contain configuration options.</p>
31 <h2 id="field-summary">Field summary</h2>
32 <p>The following shows the supported top-level manifest fields. There is one
33 section that discusses each field in detail. The only field that is required
34 is the <code>program</code> field.</p>
35 <pre class="prettyprint">
37 // Required
38 &quot;program&quot;: { ... }
40 // Only required for glibc
41 &quot;files&quot;: { ... }
43 </pre>
44 <h2 id="field-details">Field details</h2>
45 <h3 id="program">program</h3>
46 <p>The <code>program</code> field specifies the main program that will be loaded
47 in the Native Client runtime environment. For a Portable Native Client
48 application, this is a URL for the statically linked bitcode <code>pexe</code> file.
49 For architecture-specific Native Client applications, this is a list
50 of URLs, one URL for each supported architecture (currently the choices
51 are &#8220;arm&#8221;, &#8220;x86-32&#8221;, and &#8220;x86-64&#8221;). For a dynamically linked executable,
52 <code>program</code> is the dynamic loader used to load the dynamic executable
53 and its dynamic libraries. See the <a class="reference internal" href="#nmf-url-resolution"><em>semantics</em></a>
54 section for the rules on URL resolution.</p>
55 <h4 id="example-of-a-program-for-portable-native-client">Example of a <code>program</code> for Portable Native Client:</h4>
56 <pre class="prettyprint">
58 &quot;program&quot;: {
59 &quot;portable&quot;: {
60 // Required
61 &quot;pnacl-translate&quot;: {
62 // url is required
63 &quot;url&quot;: &quot;url_to_my_pexe&quot;,
65 // optlevel is optional
66 &quot;optlevel&quot;: 2
68 // pnacl-debug is optional
69 &quot;pnacl-debug&quot;: {
70 // url is required
71 &quot;url&quot;: &quot;url_to_my_bitcode_bc&quot;,
73 // optlevel is optional
74 &quot;optlevel&quot;: 0
79 </pre>
80 <p>Portable Native Client applications can also specify an <code>optlevel</code> field.
81 The <code>optlevel</code> field is an optimization level <em>hint</em>, which is a number
82 (zero and higher). Higher numbers indicate more optimization effort.
83 Setting a higher optimization level will improve the application&#8217;s
84 performance, but it will also slow down the first load experience.
85 The default is <code>optlevel</code> is currently <code>2</code>, and values higher
86 than 2 are no different than 2. If compute speed is not as important
87 as first load speed, an application could specify an <code>optlevel</code>
88 of <code>0</code>. Note that <code>optlevel</code> is only a <em>hint</em>. In the future, the
89 Portable Native Client translator and runtime may <em>automatically</em> choose
90 an <code>optlevel</code> to best balance load time and application performance.</p>
91 <p>A <code>pnacl-debug</code> section can specify an unfinalized pnacl llvm bitcode file
92 for debugging. The <code>url</code> provided in this section will be used when Native
93 Client debugging is enabled with either the <code>--enable-nacl-debug</code> Chrome
94 command line switch, or via <code>about://flags</code>.</p>
95 <h4 id="example-of-a-program-for-statically-linked-native-client-executables">Example of a <code>program</code> for statically linked Native Client executables</h4>
96 <pre class="prettyprint">
98 &quot;program&quot;: {
99 // Required: at least one entry
100 // Add one of these for each architecture supported by the application.
101 &quot;arm&quot;: { &quot;url&quot;: &quot;url_to_arm_nexe&quot; },
102 &quot;x86-32&quot;: { &quot;url&quot;: &quot;url_to_x86_32_nexe&quot; },
103 &quot;x86-64&quot;: { &quot;url&quot;: &quot;url_to_x86_64_nexe&quot; }
106 </pre>
107 <h4 id="example-of-a-program-for-dynamically-linked-native-client-executables">Example of a <code>program</code> for dynamically linked Native Client executables</h4>
108 <pre class="prettyprint">
110 &quot;program&quot;: {
111 // Required: at least one entry
112 // Add one of these for each architecture supported by the application.
113 &quot;x86-32&quot;: { &quot;url&quot;: &quot;lib32/runnable-ld.so&quot; },
114 &quot;x86-64&quot;: { &quot;url&quot;: &quot;lib64/runnable-ld.so&quot; }
116 // discussed in next section
117 &quot;files&quot;: {
118 &quot;main.nexe&quot;: {
119 &quot;x86-32&quot;: { &quot;url&quot;: &quot;url_to_x86_32_nexe&quot; },
120 &quot;x86-64&quot;: { &quot;url&quot;: &quot;url_to_x86_64_nexe&quot; }
122 // ...
125 </pre>
126 <h3 id="files">files</h3>
127 <p>The <code>files</code> field specifies a dictionary of file resources to be used by a
128 Native Client application. This is not supported and not needed by Portable
129 Native Client applications (use the PPAPI <a class="reference external" href="/native-client/pepper_stable/cpp/classpp_1_1_u_r_l_loader">URL Loader interfaces</a> to load resources
130 instead). However, the <code>files</code> manifest field is important for dynamically
131 linked executables, which must load files before PPAPI is initialized. The
132 <code>files</code> dictionary should include the main dynamic program and its dynamic
133 libraries. There should be one file entry that corresponds to each a dynamic
134 library. Each file entry is a dictionary of supported architectures and the
135 URLs where the appropriate Native Client shared object (<code>.so</code>) for that
136 architecture may be found.</p>
137 <p>Since <code>program</code> is used to refer to the dynamic linker that comes
138 with the NaCl port of glibc, the main program is specified in the
139 <code>files</code> dictionary. The main program is specified under the
140 <code>&quot;main.nexe&quot;</code> field of the <code>files</code> dictionary.</p>
141 <pre class="prettyprint">
143 &quot;program&quot;: {
144 &quot;x86-64&quot;: {&quot;url&quot;: &quot;lib64/runnable-ld.so&quot;},
145 &quot;x86-32&quot;: {&quot;url&quot;: &quot;lib32/runnable-ld.so&quot;}
147 &quot;files&quot;: {
148 &quot;main.nexe&quot; : {
149 &quot;x86-64&quot;: {&quot;url&quot;: &quot;pi_generator_x86_64.nexe&quot;},
150 &quot;x86-32&quot;: {&quot;url&quot;: &quot;pi_generator_x86_32.nexe&quot;}
152 &quot;libpthread.so.5055067a&quot; : {
153 &quot;x86-64&quot;: {&quot;url&quot;: &quot;lib64/libpthread.so.5055067a&quot;},
154 &quot;x86-32&quot;: {&quot;url&quot;: &quot;lib32/libpthread.so.5055067a&quot;}
156 &quot;libppapi_cpp.so&quot; : {
157 &quot;x86-64&quot;: {&quot;url&quot;: &quot;lib64/libppapi_cpp.so&quot;},
158 &quot;x86-32&quot;: {&quot;url&quot;: &quot;lib32/libppapi_cpp.so&quot;}
160 &quot;libstdc++.so.6&quot; : {
161 &quot;x86-64&quot;: {&quot;url&quot;: &quot;lib64/libstdc++.so.6&quot;},
162 &quot;x86-32&quot;: {&quot;url&quot;: &quot;lib32/libstdc++.so.6&quot;}
164 &quot;libm.so.5055067a&quot; : {
165 &quot;x86-64&quot;: {&quot;url&quot;: &quot;lib64/libm.so.5055067a&quot;},
166 &quot;x86-32&quot;: {&quot;url&quot;: &quot;lib32/libm.so.5055067a&quot;}
168 &quot;libgcc_s.so.1&quot; : {
169 &quot;x86-64&quot;: {&quot;url&quot;: &quot;lib64/libgcc_s.so.1&quot;},
170 &quot;x86-32&quot;: {&quot;url&quot;: &quot;lib32/libgcc_s.so.1&quot;}
172 &quot;libc.so.5055067a&quot; : {
173 &quot;x86-64&quot;: {&quot;url&quot;: &quot;lib64/libc.so.5055067a&quot;},
174 &quot;x86-32&quot;: {&quot;url&quot;: &quot;lib32/libc.so.5055067a&quot;}
178 </pre>
179 <p>Dynamic libraries that the dynamic program depends upon and links in at program
180 startup must be listed in the <code>files</code> dictionary. Library files that are
181 loaded after startup using <code>dlopen()</code> should either be listed in the <code>files</code>
182 dictionary, or should be made accessible by the <code>nacl_io</code> library. The
183 <code>nacl_io</code> library provides various file system <em>mounts</em> such as HTTP-based
184 file systems and memory-based file systems. The Native Client SDK includes
185 helpful tools for determining library dependencies and generating NaCl manifest
186 files for programs that that use dynamic linking. See
187 <a class="reference internal" href="/native-client/devguide/devcycle/dynamic-loading.html#dynamic-loading-manifest"><em>Generating a Native Client manifest file for a dynamically linked application</em></a>.</p>
188 <h2 id="semantics">Semantics</h2>
189 <h3 id="schema-validation">Schema validation</h3>
190 <p>Manifests are validated before the program files are downloaded.
191 Schema validation checks the following properties:</p>
192 <ul class="small-gap">
193 <li>The schema must be valid JSON.</li>
194 <li>The schema must conform to the grammar given above.</li>
195 <li>If the program is not a PNaCl program, then the manifest
196 must contain at least one applicable match for the current ISA
197 in &#8220;program&#8221; and in every entry within &#8220;files&#8221;.</li>
198 </ul>
199 <p>If the manifest contains a field that is not in the official
200 set of supported fields, it is ignored. This allows the grammar to be
201 extended without breaking compatibility with older browsers.</p>
202 <h3 id="nexe-matching">Nexe matching</h3>
203 <p>For Portable Native Client, there are no architecture variations, so
204 matching is simple.</p>
205 <p>For Native Client, the main nexe for the application is determined by
206 looking up the browser&#8217;s current architecture in the <code>&quot;program&quot;</code>
207 dictionary. Failure to provide an entry for the browser&#8217;s architecture
208 will result in a load error.</p>
209 <h3 id="file-matching">File matching</h3>
210 <p>All files (shared objects and other assets, typically) are looked up
211 by a UTF8 string that is the file name. To load a library with a certain
212 file name, the browser searches the <code>&quot;files&quot;</code> dictionary for an entry
213 corresponding to that file name. Failure to find that name in the
214 <code>&quot;files&quot;</code> dictionary is a run-time error. The architecture matching
215 rule for all files is from most to least specific. That is, if there
216 is an exact match for the current architecture (e.g., &#8220;x86-32&#8221;) it is
217 used in preference to more general &#8220;portable&#8221;. This is useful for
218 non-architecture-specific asset files. Note that <code>&quot;files&quot;</code> is only
219 useful for files that must be loaded early in application startup
220 (before PPAPI interfaces are initialized to provide the standard
221 file loading mechanisms).</p>
222 <h3 id="url-of-the-nmf-file-from-embed-src-and-data-uri">URL of the nmf file, from <code>&lt;embed&gt;</code> src, and data URI</h3>
223 <p>The URL for the manifest file should be specified by the <code>src</code> attribute
224 of the <code>&lt;embed&gt;</code> tag for a Native Client module instance. The URL for
225 a manifest file can refer to an actual file, or it can be a
226 <a class="reference external" href="http://en.wikipedia.org/wiki/Data_URI_scheme">data URI</a>
227 representing the contents of the file. Specifying the <code>nmf</code> contents
228 inline with a data URI can help reduce the amount of network traffic
229 required to load the Native Client application.</p>
230 <h3 id="url-resolution"><span id="nmf-url-resolution"></span>URL resolution</h3>
231 <p>All URLs contained in a manifest are resolved relative to the URL of
232 the manifest. If the manifest was specified as a data URI, the URLs must
233 all be absolute.</p>
234 </section>
236 {{/partials.standard_nacl_article}}