Bug 1882714 [wpt PR 44850] - Update wpt metadata, a=testonly
[gecko.git] / build / vs / generate_yaml.py
blob042780480697d3c607af43960c0c3a20b954661e
1 #!/usr/bin/env python3
2 # This Source Code Form is subject to the terms of the Mozilla Public
3 # License, v. 2.0. If a copy of the MPL was not distributed with this
4 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
6 import sys
8 import yaml
9 from mozbuild.shellutil import quote as shellquote
10 from vsdownload import (
11 getArgsParser,
12 getManifest,
13 getPackages,
14 getSelectedPackages,
15 lowercaseIgnores,
16 setPackageSelection,
19 if __name__ == "__main__":
20 parser = getArgsParser()
21 parser.add_argument("-o", dest="output", required=True, help="Output file")
22 parser.add_argument(
23 "--exclude", default=[], nargs="+", help="Patterns of file names to exclude"
25 args = parser.parse_args()
26 lowercaseIgnores(args)
28 packages = getPackages(getManifest(args))
29 setPackageSelection(args, packages)
30 selected = getSelectedPackages(packages, args)
31 reduced = []
32 # Filter-out data we won't be using.
33 for s in selected:
34 type = s["type"]
35 if type == "Component" or type == "Workload" or type == "Group":
36 continue
37 if type == "Vsix" or s["id"].startswith(("Win10SDK", "Win11SDK")):
38 filtered = {k: v for k, v in s.items() if k in ("type", "id", "version")}
39 filtered["payloads"] = [
41 k: v
42 for k, v in payload.items()
43 if k in ("fileName", "sha256", "size", "url")
45 for payload in s["payloads"]
46 if payload["fileName"].endswith((".cab", ".msi", ".vsix"))
47 and not any(e in payload["fileName"] for e in args.exclude)
49 reduced.append(filtered)
50 with open(args.output, "w") as out:
51 print("# Generated with:", file=out)
52 print(
53 "# ./mach python --virtualenv build build/vs/generate_yaml.py \\", file=out
55 for i, arg_ in enumerate(sys.argv[1:]):
56 arg = shellquote(arg_)
57 if i < len(sys.argv) - 2:
58 print("# ", arg, "\\", file=out)
59 else:
60 print("# ", arg, file=out)
61 print(yaml.dump(reduced), file=out)