blob: a9400482131c486feaca827626c4788aa474e51f [file] [log] [blame]
Stella Laurenzo6f24a2f2023-03-27 17:08:20 -07001# 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
7import bazel_to_cmake_converter
8import bazel_to_cmake_targets
9
10DEFAULT_ROOT_DIRS = ["compiler", "runtime", "samples", "tests", "tools"]
11
12REPO_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
19class 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
40class 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)]