def parse_args()

in antlir/compiler/compiler.py [0:0]


def parse_args(args) -> argparse.Namespace:
    parser = argparse.ArgumentParser(
        description=__doc__, formatter_class=argparse.RawTextHelpFormatter
    )
    parser.add_argument(
        "--subvolumes-dir",
        required=True,
        type=Path.from_argparse,
        help="A directory on a btrfs volume to store the compiled subvolume "
        "representing the new layer",
    )
    # We separate this from `--subvolumes-dir` in order to help keep our
    # JSON output ignorant of the absolute path of the repo.
    parser.add_argument(
        "--subvolume-rel-path",
        required=True,
        type=Path.from_argparse,
        help="Path underneath --subvolumes-dir where we should create "
        "the subvolume. Note that all path components but the basename "
        "should already exist.",
    )
    parser.add_argument(
        "--flavor-config",
        type=flavor_config_t.parse_raw,
        help="The serialized config for the flavor. This contains "
        "information about the build appliance and rpm installer.",
    )
    parser.add_argument(
        "--artifacts-may-require-repo",
        action="store_true",
        help='Buck @mode/dev produces "in-place" build artifacts that are '
        "not truly standalone. It is important to be able to execute "
        "code from images built in this mode to support rapid "
        'development and debugging, even though it is not a "true" '
        "self-contained image. To allow execution of in-place binaries, "
        "antlir runtimes will automatically mount the repo into any "
        "`--artifacts-may-require-repo` image at runtime (e.g. when "
        "running image unit-tests, when using `=container` or `=systemd` "
        "targets, when using the image as a build appliance).",
    )
    parser.add_argument(
        "--child-layer-target",
        required=True,
        help="The name of the Buck target describing the layer being built",
    )
    parser.add_argument(
        "--child-feature-json",
        action="append",
        default=[],
        help="The path of the JSON output of any `feature`s that are"
        "directly included by the layer being built",
    )
    parser.add_argument("--debug", action="store_true", help="Log more")
    parser.add_argument(
        "--allowed-host-mount-target",
        action="append",
        default=[],
        help="Target name that is allowed to contain host mounts used as "
        "build_sources.  Can be specified more than once.",
    )
    parser.add_argument(
        "--version-set-override",
        help="Path to a file containing TAB-separated ENVRAs, one per line."
        "Also refer to `build_opts.bzl`.",
    )
    parser.add_argument(
        "--parent-layer",
        type=normalize_buck_path,
        help="The directory of the buck image output of the parent layer. "
        "We will read the flavor from the parent layer to deduce the flavor "
        "of the child layer",
    )
    parser.add_argument(
        "--profile",
        default=os.environ.get("ANTLIR_PROFILE"),
        dest="profile_dir",
        type=normalize_buck_path,
        help="Profile this image build and write pstats files into the given directory.",
    )
    parser.add_argument(
        "--compiler-binary",
        required=True,
        type=normalize_buck_path,
        help="The path to the compiler binary being invoked currently. "
        "It is used to re-invoke the compiler inside the BA container as root.",
    )
    parser.add_argument(
        "--is-nested",
        action="store_true",
        help="Indicates whether the compiler binary is being run nested inside "
        "a BA container.",
    )
    parser.add_argument(
        "--internal-only-is-genrule-layer",
        action="store_true",
        help="Indicates whether the layer being compiled is a genrule layer. "
        "This is a temporary crutch to avoid running the compiler inside a BA "
        "container when building genrule layers. This should be removed in "
        "the future.",
    )
    add_targets_and_outputs_arg(parser)
    return Path.parse_args(parser, args)