1 # This Source Code Form is subject to the terms of the Mozilla Public
2 # License, v. 2.0. If a copy of the MPL was not distributed with this
3 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
11 import mozpack
.path
as mozpath
13 from mozpack
.copier
import FileRegistry
14 from mozpack
.manifests
import InstallManifest
17 # A list of build manifests, and their relative base paths, from which to
18 # extract lists of install files. These vary depending on which backend we're
19 # using, so nonexistent manifests are ignored.
21 ("", "_build_manifests/install/dist_bin"),
22 ("", "faster/install_dist_bin"),
23 ("browser", "faster/install_dist_bin_browser"),
27 def get_registry(paths
):
30 registry
= FileRegistry()
31 for base
, path
in paths
:
32 full_path
= mozpath
.join(buildconfig
.topobjdir
, path
)
33 if not os
.path
.exists(full_path
):
36 used_paths
.add(full_path
)
39 InstallManifest(full_path
).populate_registry(reg
)
42 path
= mozpath
.join(base
, p
)
48 return registry
, used_paths
51 def get_child(base
, path
):
52 """Returns the nearest parent of `path` which is an immediate child of
55 dirname
= mozpath
.dirname(path
)
56 while dirname
!= base
:
58 dirname
= mozpath
.dirname(path
)
62 def main(output
, *args
):
63 parser
= argparse
.ArgumentParser(
64 description
="Produces a JSON manifest of built-in add-ons"
71 help=("The distribution sub-directory " "containing feature add-ons"),
73 args
= parser
.parse_args(args
)
75 registry
, inputs
= get_registry(manifest_paths
)
78 for path
in registry
.match("dictionaries/*.dic"):
79 base
, ext
= os
.path
.splitext(mozpath
.basename(path
))
83 "dictionaries": dicts
,
88 for p
in registry
.match("%s/*" % args
.featuresdir
):
89 features
.add(mozpath
.basename(get_child(args
.featuresdir
, p
)))
91 listing
["system"] = sorted(features
)
93 json
.dump(listing
, output
, sort_keys
=True)
98 if __name__
== "__main__":
99 main(sys
.stdout
, *sys
.argv
[1:])