-
Notifications
You must be signed in to change notification settings - Fork 608
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Make bazel_to_cmake configurable. (#12765)
This reworks bazel_to_cmake so that it searches for a .bazel_to_cmake.cfg.py file and uses its location as the root of the repository. This file is also evaluated and provides repository-specific configuration for the tool. There may still be some work to fully generalize but this should get us pretty close to being able to use bazel_to_cmake in related OpenXLA projects. Progress on #12520 for letting us use bazel_to_cmake in out of tree plugin repositories.
- Loading branch information
Stella Laurenzo
authored
Mar 28, 2023
1 parent
9b74ec0
commit 6f24a2f
Showing
4 changed files
with
879 additions
and
756 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
# 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=[], **kwargs): | ||
self.cc_test(deps=deps + ["//runtime/src:runtime_defines"], **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)] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.