| #!/usr/bin/env fuchsia-vendored-python |
| # Copyright 2022 The Fuchsia Authors. All rights reserved. |
| # Use of this source code is governed by a BSD-style license that can be |
| # found in the LICENSE file. |
| |
| import argparse |
| import json |
| import sys |
| from typing import List |
| |
| |
| def main() -> int: |
| parser = argparse.ArgumentParser( |
| description="Generate a hermetic inputs file for ffx_action by reading the sdk" |
| "manifest and generating a list of all the files that are mentioned" |
| ) |
| parser.add_argument( |
| "--sdk-manifest", |
| type=argparse.FileType("r"), |
| help="The path to the SDK manifest", |
| ) |
| parser.add_argument( |
| "--additional-hermetic-inputs", |
| type=argparse.FileType("r"), |
| help="The path to another hermetic inputs file to merge in", |
| ) |
| parser.add_argument( |
| "--output", |
| required=True, |
| help="The path to the hermetic inputs file to write", |
| ) |
| args = parser.parse_args() |
| |
| inputs = [] |
| if args.sdk_manifest: |
| sdk_manifest = json.load(args.sdk_manifest) |
| sdk_atoms = sdk_manifest.get("atoms", []) |
| for atom in sdk_atoms: |
| files = atom.get("files", []) |
| files = [entry["source"] for entry in files] |
| inputs.extend(files) |
| if args.additional_hermetic_inputs: |
| additional_inputs = args.additional_hermetic_inputs.readlines() |
| additional_inputs = [i.strip() for i in additional_inputs] |
| inputs.extend(additional_inputs) |
| with open(args.output, "w") as output: |
| for input in inputs: |
| output.write(input + "\n") |
| return 0 |
| |
| |
| if __name__ == "__main__": |
| sys.exit(main()) |