jar-manifests.rst 4.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. .. _jar_manifests:
  2. =============
  3. JAR Manifests
  4. =============
  5. JAR Manifests are plaintext files in the tree that are used to package chrome
  6. files into the correct JARs, and create
  7. `Chrome Registration <https://developer.mozilla.org/en-US/docs/Chrome_Registration>`_
  8. manifests. JAR Manifests are commonly named ``jar.mn``. They are
  9. declared in ``moz.build`` files using the ``JAR_MANIFESTS`` variable.
  10. ``jar.mn`` files are automatically processed by the build system when building a
  11. source directory that contains one. The ``jar``.mn is run through the
  12. :ref:`preprocessor` before being passed to the manifest processor. In order to
  13. have ``@variables@`` expanded (such as ``@AB_CD@``) throughout the file, add
  14. the line ``#filter substitution`` at the top of your ``jar.mn`` file.
  15. The format of a jar.mn is fairly simple; it consists of a heading specifying
  16. which JAR file is being packaged, followed by indented lines listing files and
  17. chrome registration instructions.
  18. To see a simple ``jar.mn`` file at work, see ``toolkit/profile/jar.mn``. A much
  19. more complex ``jar.mn`` is at ``toolkit/locales/jar.mn``.
  20. Shipping Chrome Files
  21. =====================
  22. To ship chrome files in a JAR, an indented line indicates a file to be packaged::
  23. <jarfile>.jar:
  24. path/in/jar/file_name.xul (source/tree/location/file_name.xul)
  25. The JAR location may be preceded with a base path between square brackets::
  26. [base/path] <jarfile>.jar:
  27. path/in/jar/file_name.xul (source/tree/location/file_name.xul)
  28. In this case, the jar will be directly located under the given ``base/bath``,
  29. while without a base path, it will be under a ``chrome`` directory.
  30. If the JAR manifest and packaged file live in the same directory, the path and
  31. parenthesis can be omitted. In other words, the following two lines are
  32. equivalent::
  33. path/in/jar/same_place.xhtml (same_place.xhtml)
  34. path/in/jar/same_place.xhtml
  35. The source tree location may also be an *absolute* path (taken from the
  36. top of the source tree::
  37. path/in/jar/file_name.xul (/path/in/sourcetree/file_name.xul)
  38. An asterisk marker (``*``) at the beginning of the line indicates that the
  39. file should be processed by the :ref:`preprocessor` before being packaged::
  40. * path/in/jar/preprocessed.xul (source/tree/location/file_name.xul)
  41. Preprocessed files always replace existing files, to ensure that changes in
  42. ``#expand`` or ``#include`` directives are picked up.
  43. There is a special source-directory format for localized files (note the
  44. percent sign in the source file location): this format reads ``localized.dtd``
  45. from the ``en-US`` directory if building an English version, and reads the
  46. file from the alternate localization source tree
  47. ``/l10n/<locale>/path/localized.dtd`` if building a localized version::
  48. locale/path/localized.dtd (%localized/path/localized.dtd)
  49. The source tree location can also use wildcards, in which case the path in
  50. jar is expected to be a base directory. Paths before the wildcard are not
  51. made part of the destination path::
  52. path/in/jar/ (source/tree/location/*.xul)
  53. The above will install all xul files under ``source/tree/location`` as
  54. ``path/in/jar/*.xul``.
  55. Register Chrome
  56. ===============
  57. `Chrome Registration <https://developer.mozilla.org/en-US/docs/Chrome_Registration>`_
  58. instructions are marked with a percent sign (``%``) at the beginning of the
  59. line, and must be part of the definition of a JAR file. Any additional percents
  60. signs are replaced with an appropriate relative URL of the JAR file being
  61. packaged::
  62. % content global %path/in/jar/
  63. % overlay chrome://blah/content/blah.xul chrome://foo/content/overlay.xul
  64. There are two possible locations for a manifest file. If the chrome is being
  65. built into a standalone application, the ``jar.mn`` processor creates a
  66. ``<jarfilename>.manifest`` next to the JAR file itself. This is the default
  67. behavior.
  68. If the build specifies ``USE_EXTENSION_MANIFEST = 1``, the ``jar.mn`` processor
  69. creates a single ``chrome.manifest`` file suitable for registering chrome as
  70. an extension.