Revert D33141010: allow Bazel to build without glog and gflags

Test Plan: revert-hammer

Differential Revision:
D33141010 (8c41f258f4)

Original commit changeset: d951e5616459

Original Phabricator Diff: D33141010 (8c41f258f4)

fbshipit-source-id: d52ca20ddf4c5a91cb09a32fecb30a00227fc4ae
This commit is contained in:
Michael Suo
2021-12-22 17:45:28 -08:00
committed by Facebook GitHub Bot
parent 682fab19d4
commit f126501d37
3 changed files with 10 additions and 46 deletions

View File

@ -459,10 +459,6 @@ test_bazel() {
get_bazel
# Test //c10/... without Google flags and logging libraries.
tools/bazel test --test_timeout=480 --test_output=all --test_tag_filters=-gpu-required --test_filter=-*CUDA \
--no//c10:use_gflags --no//c10:use_glog //c10/...
# Test //c10/... in the default mode.
tools/bazel test --test_timeout=480 --test_output=all --test_tag_filters=-gpu-required --test_filter=-*CUDA //c10/...

View File

@ -1,32 +1,7 @@
load("@bazel_skylib//rules:common_settings.bzl", "bool_flag")
load("@rules_cc//cc:defs.bzl", "cc_library", "cc_test")
load("//third_party:substitution.bzl", "header_template_rule")
load("//tools/config:defs.bzl", "if_cuda")
# The bool_flag targets allow configuring the build from the
# command-line, e.g. --//c10:use_gflags or --no//c10:use_gflags to
# disable.
bool_flag(
name = "use_gflags",
build_setting_default = True,
)
bool_flag(
name = "use_glog",
build_setting_default = True,
)
config_setting(
name = "using_gflags",
flag_values = {":use_gflags": "true"},
)
config_setting(
name = "using_glog",
flag_values = {":use_glog": "true"},
)
header_template_rule(
name = "cuda_cmake_macros_h",
src = "cuda/impl/cuda_cmake_macros.h.in",
@ -48,15 +23,11 @@ cc_library(
"util/*.hpp",
]),
deps = [
"@com_github_gflags_gflags//:gflags",
"@com_github_glog//:glog",
":cuda_cmake_macros_h",
"//c10/macros",
] + select({
":using_gflags": ["@com_github_gflags_gflags//:gflags"],
"//conditions:default": [],
}) + select({
":using_glog": ["@com_github_glog//:glog"],
"//conditions:default": [],
}),
],
visibility = ["//:__pkg__"],
)

View File

@ -1,5 +1,5 @@
load("@rules_cc//cc:defs.bzl", "cc_library")
load(":cmake_configure_file.bzl", "cmake_configure_file")
load("//third_party:substitution.bzl", "header_template_rule")
cc_library(
name = "macros",
@ -10,19 +10,16 @@ cc_library(
# public header in this file.
"Export.h",
],
srcs = [":cmake_macros"],
srcs = [":cmake_macros_h"],
visibility = ["//visibility:public"],
)
cmake_configure_file(
name = "cmake_macros",
header_template_rule(
name = "cmake_macros_h",
src = "cmake_macros.h.in",
out = "cmake_macros.h",
definitions = {
"C10_BUILD_SHARED_LIBS": True,
"C10_USE_GFLAGS": "config_setting://c10:using_gflags",
"C10_USE_GLOG": "config_setting://c10:using_glog",
"C10_USE_MSVC_STATIC_RUNTIME": True,
"C10_USE_NUMA": False,
substitutions = {
"cmakedefine": "define",
"#define C10_USE_NUMA": "/* #undef C10_USE_NUMA */",
},
)