| # Copyright 2023 The IREE Authors | |
| # | |
| # Licensed under the Apache License v2.0 with LLVM Exceptions. | |
| # See https://llvm.org/LICENSE.txt for license information. | |
| # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | |
| load("@rules_cc//cc:defs.bzl", "cc_library") | |
| load("//build_tools/bazel:build_defs.oss.bzl", "iree_cmake_extra_content", "iree_compiler_register_plugin") | |
| load("//build_tools/bazel:renamed_link.bzl", "iree_compiler_register_experimental_dynamic_plugin") | |
| package( | |
| default_visibility = ["//visibility:public"], | |
| features = ["layering_check"], | |
| licenses = ["notice"], # Apache 2.0 | |
| ) | |
| cc_library( | |
| name = "defs", | |
| includes = ["src"], | |
| ) | |
| cc_library( | |
| name = "registration", | |
| srcs = [ | |
| "src/PluginRegistration.cpp", | |
| ], | |
| deps = [ | |
| ":defs", | |
| "//compiler/src/iree/compiler/PluginAPI", | |
| "//compiler/src/iree/compiler/PluginAPI:PluginEntryPoint", | |
| "@llvm-project//mlir:IR", | |
| ], | |
| ) | |
| iree_compiler_register_plugin( | |
| plugin_id = "example", | |
| target = ":registration", | |
| ) | |
| # The same source as a loadable module, so both link modes are tested. The id | |
| # must differ; see src/PluginRegistration.cpp. CMake builds it only with dynamic | |
| # plugins on, hence the guard. | |
| iree_cmake_extra_content( | |
| content = """ | |
| if(IREE_EXPERIMENTAL_COMPILER_DYNAMIC_PLUGINS) | |
| """, | |
| inline = True, | |
| ) | |
| cc_library( | |
| name = "registration_dyn", | |
| srcs = [ | |
| "src/PluginRegistration.cpp", | |
| ], | |
| defines = [ | |
| "IREE_EXAMPLE_PLUGIN_ID=example_dyn", | |
| ], | |
| deps = [ | |
| ":defs", | |
| "//compiler/src/iree/compiler/PluginAPI", | |
| "//compiler/src/iree/compiler/PluginAPI:PluginEntryPoint", | |
| "@llvm-project//mlir:IR", | |
| ], | |
| ) | |
| iree_compiler_register_experimental_dynamic_plugin( | |
| compiler = "//lib:IREECompilerShared", | |
| plugin_id = "example_dyn", | |
| target = ":registration_dyn", | |
| ) | |
| iree_cmake_extra_content( | |
| content = """ | |
| endif() | |
| """, | |
| inline = True, | |
| ) |