Skip to content

Commit

Permalink
[bazel] Add filegroups for MLIR bindings sources (#98396)
Browse files Browse the repository at this point in the history
This can be useful if downstream projects configure their pybind
differently, similar to how local_config_python isn't defined here.
  • Loading branch information
keith authored Jul 18, 2024
1 parent c675a9b commit 433e09c
Showing 1 changed file with 25 additions and 19 deletions.
44 changes: 25 additions & 19 deletions utils/bazel/llvm-project-overlay/mlir/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -931,11 +931,14 @@ exports_files(
# Some out-of-tree projects alias @python_runtime//:headers to
# @local_config_python//:python_headers.

MLIR_BINDINGS_PYTHON_HEADERS = [
"lib/Bindings/Python/*.h",
"include/mlir-c/Bindings/Python/*.h",
"include/mlir/Bindings/Python/*.h",
]
filegroup(
name = "MLIRBindingsPythonHeaderFiles",
srcs = glob([
"lib/Bindings/Python/*.h",
"include/mlir-c/Bindings/Python/*.h",
"include/mlir/Bindings/Python/*.h",
]),
)

cc_library(
name = "MLIRBindingsPythonHeaders",
Expand All @@ -947,7 +950,7 @@ cc_library(
"manual", # External dependency
"nobuildkite", # TODO(gcmn): Add support for this target
],
textual_hdrs = glob(MLIR_BINDINGS_PYTHON_HEADERS),
textual_hdrs = [":MLIRBindingsPythonHeaderFiles"],
deps = [
":CAPIIRHeaders",
":CAPITransformsHeaders",
Expand All @@ -966,7 +969,7 @@ cc_library(
"manual", # External dependency
"nobuildkite", # TODO(gcmn): Add support for this target
],
textual_hdrs = glob(MLIR_BINDINGS_PYTHON_HEADERS),
textual_hdrs = [":MLIRBindingsPythonHeaderFiles"],
deps = [
":CAPIIR",
":CAPITransforms",
Expand All @@ -986,20 +989,23 @@ PYBIND11_FEATURES = [
"-use_header_modules",
]

MLIR_PYTHON_BINDINGS_SOURCES = [
"lib/Bindings/Python/IRAffine.cpp",
"lib/Bindings/Python/IRAttributes.cpp",
"lib/Bindings/Python/IRCore.cpp",
"lib/Bindings/Python/IRInterfaces.cpp",
"lib/Bindings/Python/IRModule.cpp",
"lib/Bindings/Python/IRTypes.cpp",
"lib/Bindings/Python/Pass.cpp",
"lib/Bindings/Python/Rewrite.cpp",
]
filegroup(
name = "MLIRBindingsPythonSourceFiles",
srcs = [
"lib/Bindings/Python/IRAffine.cpp",
"lib/Bindings/Python/IRAttributes.cpp",
"lib/Bindings/Python/IRCore.cpp",
"lib/Bindings/Python/IRInterfaces.cpp",
"lib/Bindings/Python/IRModule.cpp",
"lib/Bindings/Python/IRTypes.cpp",
"lib/Bindings/Python/Pass.cpp",
"lib/Bindings/Python/Rewrite.cpp",
],
)

cc_library(
name = "MLIRBindingsPythonCore",
srcs = MLIR_PYTHON_BINDINGS_SOURCES,
srcs = [":MLIRBindingsPythonSourceFiles"],
copts = PYBIND11_COPTS,
features = PYBIND11_FEATURES,
tags = [
Expand All @@ -1022,7 +1028,7 @@ cc_library(

cc_library(
name = "MLIRBindingsPythonCoreNoCAPI",
srcs = MLIR_PYTHON_BINDINGS_SOURCES,
srcs = [":MLIRBindingsPythonSourceFiles"],
copts = PYBIND11_COPTS,
features = PYBIND11_FEATURES,
tags = [
Expand Down

0 comments on commit 433e09c

Please sign in to comment.