def _maybe_parse_as_library_copts(srcs):
    """Returns a list of compiler flags depending on whether a `main.swift` file is present.

    Builds on Apple platforms typically don't use `swift_binary`; they use different linking logic
    (https://github.com/bazelbuild/rules_apple) to produce fat binaries and bundles. This means
    that all such application code will typically be in a `swift_library` target, and that
    includes a possible custom main entry point. For this reason, we need to support the creation
    of `swift_library` targets containing a `main.swift` file, which should *not* pass the
    `-parse-as-library` flag to the compiler.

    Args:
        srcs: A list of source files to check for the presence of `main.swift`.

    Returns:
        An empty list if `main.swift` was present in `srcs`, or a list containing a single
        element `"-parse-as-library"` if `main.swift` was not present.
    """
    use_parse_as_library = True
    for src in srcs:
        if src.basename == "main.swift":
            use_parse_as_library = False
            break
    return ["-parse-as-library"] if use_parse_as_library else []