2022-04-12 22:52:53 +00:00
|
|
|
#!/usr/bin/env python3
|
|
|
|
# This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
# License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
|
|
|
|
2022-11-24 17:23:47 +00:00
|
|
|
import sys
|
|
|
|
|
|
|
|
import yaml
|
2023-04-19 09:31:54 +00:00
|
|
|
from mozbuild.shellutil import quote as shellquote
|
2022-04-12 22:52:53 +00:00
|
|
|
from vsdownload import (
|
|
|
|
getArgsParser,
|
|
|
|
getManifest,
|
|
|
|
getPackages,
|
|
|
|
getSelectedPackages,
|
|
|
|
lowercaseIgnores,
|
2022-11-24 17:23:47 +00:00
|
|
|
setPackageSelection,
|
2022-04-12 22:52:53 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
if __name__ == "__main__":
|
|
|
|
parser = getArgsParser()
|
|
|
|
parser.add_argument("-o", dest="output", required=True, help="Output file")
|
2023-04-19 09:31:54 +00:00
|
|
|
parser.add_argument(
|
|
|
|
"--exclude", default=[], nargs="+", help="Patterns of file names to exclude"
|
|
|
|
)
|
2022-04-12 22:52:53 +00:00
|
|
|
args = parser.parse_args()
|
|
|
|
lowercaseIgnores(args)
|
|
|
|
|
|
|
|
packages = getPackages(getManifest(args))
|
|
|
|
setPackageSelection(args, packages)
|
|
|
|
selected = getSelectedPackages(packages, args)
|
|
|
|
reduced = []
|
|
|
|
# Filter-out data we won't be using.
|
|
|
|
for s in selected:
|
|
|
|
type = s["type"]
|
|
|
|
if type == "Component" or type == "Workload" or type == "Group":
|
|
|
|
continue
|
|
|
|
if type == "Vsix" or s["id"].startswith(("Win10SDK", "Win11SDK")):
|
|
|
|
filtered = {k: v for k, v in s.items() if k in ("type", "id", "version")}
|
|
|
|
filtered["payloads"] = [
|
|
|
|
{
|
|
|
|
k: v
|
|
|
|
for k, v in payload.items()
|
|
|
|
if k in ("fileName", "sha256", "size", "url")
|
|
|
|
}
|
|
|
|
for payload in s["payloads"]
|
|
|
|
if payload["fileName"].endswith((".cab", ".msi", ".vsix"))
|
2023-04-19 09:31:54 +00:00
|
|
|
and not any(e in payload["fileName"] for e in args.exclude)
|
2022-04-12 22:52:53 +00:00
|
|
|
]
|
|
|
|
reduced.append(filtered)
|
2024-08-27 08:59:57 +00:00
|
|
|
with open(args.output, "w", newline="\n") as out:
|
2022-04-12 22:52:53 +00:00
|
|
|
print("# Generated with:", file=out)
|
|
|
|
print(
|
|
|
|
"# ./mach python --virtualenv build build/vs/generate_yaml.py \\", file=out
|
|
|
|
)
|
2023-04-19 09:31:54 +00:00
|
|
|
for i, arg_ in enumerate(sys.argv[1:]):
|
|
|
|
arg = shellquote(arg_)
|
2022-04-12 22:52:53 +00:00
|
|
|
if i < len(sys.argv) - 2:
|
|
|
|
print("# ", arg, "\\", file=out)
|
|
|
|
else:
|
|
|
|
print("# ", arg, file=out)
|
|
|
|
print(yaml.dump(reduced), file=out)
|