blob: 4315a84f2d6cde2cf8515a1f8c7796ff4dea7689 [file] [log] [blame]
# Copyright lowRISC contributors.
# Licensed under the Apache License, Version 2.0, see LICENSE for details.
# SPDX-License-Identifier: Apache-2.0
def _exclude_files_impl(ctx):
out = []
for src in ctx.files.srcs:
include = True
for suffix in ctx.attr.exclude_suffix:
if src.path.endswith(suffix):
include = False
break
if include:
out.append(src)
return [DefaultInfo(files = depset(out))]
exclude_files = rule(
implementation = _exclude_files_impl,
attrs = {
"srcs": attr.label_list(
allow_files = True,
mandatory = True,
doc = "Targets producing file outputs",
),
"exclude_suffix": attr.string_list(
doc = "File suffixes to exclude from the result",
),
},
)