def _extract_common_p4c_args(ctx):
    """Extract common arguments for p4c build rules."""
    p4file = ctx.file.src
    p4deps = ctx.files._p4include + ctx.files.deps
    args = [
        p4file.path,
        "--std",
        ctx.attr.std,
        "--arch",
        ctx.attr.arch,
    ]

    include_dirs = {d.dirname: 0 for d in p4deps}  # Use dict to express set.
    include_dirs["."] = 0  # Enable include paths relative to workspace root.
    args += [("-I" + dir) for dir in include_dirs.keys()]

    return args