-
Notifications
You must be signed in to change notification settings - Fork 872
Expand file tree
/
Copy path.bazel_to_cmake.cfg.py
More file actions
62 lines (49 loc) · 2.32 KB
/
.bazel_to_cmake.cfg.py
File metadata and controls
62 lines (49 loc) · 2.32 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
# Copyright 2020 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
import bazel_to_cmake_converter
import bazel_to_cmake_targets
DEFAULT_ROOT_DIRS = ["compiler", "runtime", "samples", "tests", "tools"]
REPO_MAP = {
# Since this is the @iree_core repo, map to empty since all internal
# targets are of the form "//compiler", not "@iree_core//compiler".
"@iree_core": "",
}
class CustomBuildFileFunctions(bazel_to_cmake_converter.BuildFileFunctions):
def iree_compiler_cc_library(self, deps=[], **kwargs):
self.cc_library(deps=deps + ["//compiler/src:defs"], **kwargs)
def iree_runtime_cc_library(self, deps=[], **kwargs):
self.cc_library(deps=deps + ["//runtime/src:runtime_defines"], **kwargs)
def iree_runtime_cc_test(self, deps=[], resource_group=None, **kwargs):
# Extract resource_group from tags if provided via the .bzl macro.
tags = kwargs.get("tags", [])
if not resource_group and tags:
for tag in tags:
if tag.startswith("resource_group:"):
resource_group = tag[len("resource_group:") :]
break
self.cc_test(
deps=deps + ["//runtime/src:runtime_defines"],
resource_group=resource_group,
**kwargs,
)
def iree_compiler_cc_test(self, deps=[], **kwargs):
self.cc_test(deps=deps + ["//compiler/src:defs"], **kwargs)
def iree_runtime_cc_binary(self, deps=[], **kwargs):
self.cc_binary(deps=deps + ["//runtime/src:runtime_defines"], **kwargs)
def iree_compiler_cc_binary(self, deps=[], **kwargs):
self.cc_binary(deps=deps + ["//compiler/src:defs"], **kwargs)
class CustomTargetConverter(bazel_to_cmake_targets.TargetConverter):
def _initialize(self):
self._update_target_mappings(
{
"//compiler/src:defs": [],
"//runtime/src:runtime_defines": [],
}
)
def _convert_unmatched_target(self, target: str) -> str:
"""Converts unmatched targets in a repo specific way."""
# Default rewrite: prefix with "iree::", without pruning the path.
return ["iree::" + self._convert_to_cmake_path(target)]