Skip to content

Commit 433e09c

Browse files
authored
[bazel] Add filegroups for MLIR bindings sources (#98396)
This can be useful if downstream projects configure their pybind differently, similar to how local_config_python isn't defined here.
1 parent c675a9b commit 433e09c

File tree

1 file changed

+25
-19
lines changed

1 file changed

+25
-19
lines changed

utils/bazel/llvm-project-overlay/mlir/BUILD.bazel

Lines changed: 25 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -931,11 +931,14 @@ exports_files(
931931
# Some out-of-tree projects alias @python_runtime//:headers to
932932
# @local_config_python//:python_headers.
933933

934-
MLIR_BINDINGS_PYTHON_HEADERS = [
935-
"lib/Bindings/Python/*.h",
936-
"include/mlir-c/Bindings/Python/*.h",
937-
"include/mlir/Bindings/Python/*.h",
938-
]
934+
filegroup(
935+
name = "MLIRBindingsPythonHeaderFiles",
936+
srcs = glob([
937+
"lib/Bindings/Python/*.h",
938+
"include/mlir-c/Bindings/Python/*.h",
939+
"include/mlir/Bindings/Python/*.h",
940+
]),
941+
)
939942

940943
cc_library(
941944
name = "MLIRBindingsPythonHeaders",
@@ -947,7 +950,7 @@ cc_library(
947950
"manual", # External dependency
948951
"nobuildkite", # TODO(gcmn): Add support for this target
949952
],
950-
textual_hdrs = glob(MLIR_BINDINGS_PYTHON_HEADERS),
953+
textual_hdrs = [":MLIRBindingsPythonHeaderFiles"],
951954
deps = [
952955
":CAPIIRHeaders",
953956
":CAPITransformsHeaders",
@@ -966,7 +969,7 @@ cc_library(
966969
"manual", # External dependency
967970
"nobuildkite", # TODO(gcmn): Add support for this target
968971
],
969-
textual_hdrs = glob(MLIR_BINDINGS_PYTHON_HEADERS),
972+
textual_hdrs = [":MLIRBindingsPythonHeaderFiles"],
970973
deps = [
971974
":CAPIIR",
972975
":CAPITransforms",
@@ -986,20 +989,23 @@ PYBIND11_FEATURES = [
986989
"-use_header_modules",
987990
]
988991

989-
MLIR_PYTHON_BINDINGS_SOURCES = [
990-
"lib/Bindings/Python/IRAffine.cpp",
991-
"lib/Bindings/Python/IRAttributes.cpp",
992-
"lib/Bindings/Python/IRCore.cpp",
993-
"lib/Bindings/Python/IRInterfaces.cpp",
994-
"lib/Bindings/Python/IRModule.cpp",
995-
"lib/Bindings/Python/IRTypes.cpp",
996-
"lib/Bindings/Python/Pass.cpp",
997-
"lib/Bindings/Python/Rewrite.cpp",
998-
]
992+
filegroup(
993+
name = "MLIRBindingsPythonSourceFiles",
994+
srcs = [
995+
"lib/Bindings/Python/IRAffine.cpp",
996+
"lib/Bindings/Python/IRAttributes.cpp",
997+
"lib/Bindings/Python/IRCore.cpp",
998+
"lib/Bindings/Python/IRInterfaces.cpp",
999+
"lib/Bindings/Python/IRModule.cpp",
1000+
"lib/Bindings/Python/IRTypes.cpp",
1001+
"lib/Bindings/Python/Pass.cpp",
1002+
"lib/Bindings/Python/Rewrite.cpp",
1003+
],
1004+
)
9991005

10001006
cc_library(
10011007
name = "MLIRBindingsPythonCore",
1002-
srcs = MLIR_PYTHON_BINDINGS_SOURCES,
1008+
srcs = [":MLIRBindingsPythonSourceFiles"],
10031009
copts = PYBIND11_COPTS,
10041010
features = PYBIND11_FEATURES,
10051011
tags = [
@@ -1022,7 +1028,7 @@ cc_library(
10221028

10231029
cc_library(
10241030
name = "MLIRBindingsPythonCoreNoCAPI",
1025-
srcs = MLIR_PYTHON_BINDINGS_SOURCES,
1031+
srcs = [":MLIRBindingsPythonSourceFiles"],
10261032
copts = PYBIND11_COPTS,
10271033
features = PYBIND11_FEATURES,
10281034
tags = [

0 commit comments

Comments
 (0)