def get_protoc_out_dir(ctx):
    """compute protoc output directory

    Args:
        ctx: rule context
    Returns:
        output directory for protoc (string)
    """
    out_path_parts = [ctx.bin_dir.path]

    # handle workspace_root like 'external/[repo]'
    if ctx.label.workspace_root:
        out_path_parts.append(ctx.label.workspace_root)
    out_path_parts.append(ctx.label.package)
    return "/".join(out_path_parts)