Stella Laurenzo | 6f24a2f | 2023-03-27 17:08:20 -0700 | [diff] [blame] | 1 | # Copyright 2020 The IREE Authors |
| 2 | # |
| 3 | # Licensed under the Apache License v2.0 with LLVM Exceptions. |
| 4 | # See https://llvm.org/LICENSE.txt for license information. |
| 5 | # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception |
| 6 | |
| 7 | import bazel_to_cmake_converter |
| 8 | import bazel_to_cmake_targets |
| 9 | |
| 10 | DEFAULT_ROOT_DIRS = ["compiler", "runtime", "samples", "tests", "tools"] |
| 11 | |
| 12 | REPO_MAP = { |
| 13 | # Since this is the @iree_core repo, map to empty since all internal |
| 14 | # targets are of the form "//compiler", not "@iree_core//compiler". |
| 15 | "@iree_core": "", |
| 16 | } |
| 17 | |
| 18 | |
| 19 | class CustomBuildFileFunctions(bazel_to_cmake_converter.BuildFileFunctions): |
| 20 | |
| 21 | def iree_compiler_cc_library(self, deps=[], **kwargs): |
| 22 | self.cc_library(deps=deps + ["//compiler/src:defs"], **kwargs) |
| 23 | |
| 24 | def iree_runtime_cc_library(self, deps=[], **kwargs): |
| 25 | self.cc_library(deps=deps + ["//runtime/src:runtime_defines"], **kwargs) |
| 26 | |
| 27 | def iree_runtime_cc_test(self, deps=[], **kwargs): |
| 28 | self.cc_test(deps=deps + ["//runtime/src:runtime_defines"], **kwargs) |
| 29 | |
| 30 | def iree_compiler_cc_test(self, deps=[], **kwargs): |
| 31 | self.cc_test(deps=deps + ["//compiler/src:defs"], **kwargs) |
| 32 | |
| 33 | def iree_runtime_cc_binary(self, deps=[], **kwargs): |
| 34 | self.cc_binary(deps=deps + ["//runtime/src:runtime_defines"], **kwargs) |
| 35 | |
| 36 | def iree_compiler_cc_binary(self, deps=[], **kwargs): |
| 37 | self.cc_binary(deps=deps + ["//compiler/src:defs"], **kwargs) |
| 38 | |
| 39 | |
| 40 | class CustomTargetConverter(bazel_to_cmake_targets.TargetConverter): |
| 41 | |
| 42 | def _initialize(self): |
| 43 | self._update_target_mappings({ |
| 44 | "//compiler/src:defs": [], |
| 45 | "//runtime/src:runtime_defines": [], |
| 46 | }) |
| 47 | |
| 48 | def _convert_unmatched_target(self, target: str) -> str: |
| 49 | """Converts unmatched targets in a repo specific way.""" |
| 50 | # Default rewrite: prefix with "iree::", without pruning the path. |
| 51 | return ["iree::" + self._convert_to_cmake_path(target)] |