Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
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: 1 addition & 1 deletion cc/private/cc_common.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -732,7 +732,7 @@ cc_common = struct(
# Ideally we would like to get rid of this Java symbol and replace it with Starlark one.
# And also deprecate this public API.
CcToolchainInfo = CcToolchainInfo,
do_not_use_tools_cpp_compiler_present = _cc_common_internal.do_not_use_tools_cpp_compiler_present,
do_not_use_tools_cpp_compiler_present = None,
configure_features = configure_features,
get_tool_for_action = _get_tool_for_action,
get_execution_requirements = _get_execution_requirements,
Expand Down
18 changes: 18 additions & 0 deletions tests/cc/common/cc_common_test.bzl

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Don't think we need to test for this.

Also; it appears we have a few (<5) files still checking this; should clean them up first.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Are these internal usages? I didn't see them in this repo. (I did see https://github.com/protocolbuffers/protobuf/blob/b790ca9a4b222070d1d7cdf93c980ddeae8a55aa/build_defs/compiler_config_setting.bzl#L5-L25 and things like that but I think they will continue to work as they did, even with the None-valued attr?)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Good point, it's void type on the Java side already and most of the checks are hasattr (a few test environments mock it out as True for some reason and were came up before the usages in my searches, I didn't look closely enough).

Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,27 @@ load("@rules_testing//lib:truth.bzl", "matching")
load("@rules_testing//lib:util.bzl", "TestingAspectInfo", "util")
load("//cc:cc_binary.bzl", "cc_binary")
load("//cc:cc_library.bzl", "cc_library")
load("//cc/common:cc_common.bzl", "cc_common")
load("//cc/common:cc_info.bzl", "CcInfo")
load("//tests/cc/testutil:cc_analysis_test.bzl", "cc_analysis_test")
load("//tests/cc/testutil:cc_info_subject.bzl", "cc_info_subject")

def _test_compiler_presence_marker(name):
util.helper_target(
cc_library,
name = name + "/lib",
)

cc_analysis_test(
name = name,
impl = _test_compiler_presence_marker_impl,
target = name + "/lib",
)

def _test_compiler_presence_marker_impl(env, _target):
env.expect.that_bool(hasattr(cc_common, "do_not_use_tools_cpp_compiler_present")).equals(True)
env.expect.that_bool(cc_common.do_not_use_tools_cpp_compiler_present == None).equals(True)

def _test_same_cc_file_twice(name):
util.helper_target(
native.filegroup,
Expand Down Expand Up @@ -661,6 +678,7 @@ def _test_alwayslink_yields_lo_impl(env, target):

def cc_common_tests(name):
tests = [
_test_compiler_presence_marker,
_test_same_cc_file_twice,
_test_same_header_file_twice,
_test_isolated_includes,
Expand Down