Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add bazel tools to generate tao build version info #5

Open
wants to merge 1 commit into
base: features/aicompiler_rebase_20220216
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions tensorflow/workspace2.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
# Import third party config rules.
load("//tensorflow:version_check.bzl", "check_bazel_version_at_least")
load("//third_party/gpus:cuda_configure.bzl", "cuda_configure")
load("//third_party/blade_helper:blade_helper_configure.bzl", "blade_helper_configure")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

blade->baldedisc?

load("//third_party/gpus:rocm_configure.bzl", "rocm_configure")
load("//third_party/tensorrt:tensorrt_configure.bzl", "tensorrt_configure")
load("//third_party/nccl:nccl_configure.bzl", "nccl_configure")
Expand Down Expand Up @@ -94,6 +95,7 @@ def _tf_toolchains():
clang6_configure(name = "local_config_clang6")
cc_download_clang_toolchain(name = "local_config_download_clang")
cuda_configure(name = "local_config_cuda")
blade_helper_configure(name = "local_config_blade_helper")
tensorrt_configure(name = "local_config_tensorrt")
nccl_configure(name = "local_config_nccl")
git_configure(name = "local_config_git")
Expand Down
Empty file added third_party/blade_helper/BUILD
Empty file.
Empty file.
34 changes: 34 additions & 0 deletions third_party/blade_helper/blade_helper_configure.bzl
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
load("//third_party/remote_config:common.bzl", "get_host_environ")

_TAO_BUILD_VERSION = "TAO_BUILD_VERSION"
_TAO_BUILD_GIT_BRANCH = "TAO_BUILD_GIT_BRANCH"
_TAO_BUILD_GIT_HEAD = "TAO_BUILD_GIT_HEAD"
_TAO_BUILD_HOST = "TAO_BUILD_HOST"
_TAO_BUILD_IP = "TAO_BUILD_IP"
_TAO_BUILD_TIME = "TAO_BUILD_TIME"


def _blade_helper_impl(repository_ctx):
repository_ctx.template("build_defs.bzl", Label("//bazel/blade_helper:build_defs.bzl.tpl"), {
"%{TAO_BUILD_VERSION}": get_host_environ(repository_ctx, _TAO_BUILD_VERSION),
"%{TAO_BUILD_GIT_BRANCH}": get_host_environ(repository_ctx, _TAO_BUILD_GIT_BRANCH),
"%{TAO_BUILD_GIT_HEAD}": get_host_environ(repository_ctx, _TAO_BUILD_GIT_HEAD),
"%{TAO_BUILD_HOST}": get_host_environ(repository_ctx, _TAO_BUILD_HOST),
"%{TAO_BUILD_IP}": get_host_environ(repository_ctx, _TAO_BUILD_IP),
"%{TAO_BUILD_TIME}": get_host_environ(repository_ctx, _TAO_BUILD_TIME),
})

repository_ctx.template("BUILD", Label("//bazel/blade_helper:BUILD.tpl"), {
})

blade_helper_configure = repository_rule(
implementation = _blade_helper_impl,
environ = [
_TAO_BUILD_VERSION,
_TAO_BUILD_GIT_BRANCH,
_TAO_BUILD_GIT_HEAD,
_TAO_BUILD_HOST,
_TAO_BUILD_IP,
_TAO_BUILD_TIME
],
)
17 changes: 17 additions & 0 deletions third_party/blade_helper/build_defs.bzl.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
def tao_build_version():
return "%{TAO_BUILD_VERSION}"

def tao_build_git_branch():
return "%{TAO_BUILD_GIT_BRANCH}"

def tao_build_git_head():
return "%{TAO_BUILD_GIT_HEAD}"

def tao_build_host():
return "%{TAO_BUILD_HOST}"

def tao_build_ip():
return "%{TAO_BUILD_IP}"

def tao_build_time():
return "%{TAO_BUILD_TIME}"