Skip to content

Commit 0af04ab

Browse files
comiusrules_java Copybara
authored andcommitted
Replace asserts on library_identifier with static_library
library_identifier is private and will be removed. Works towards starlarkifying LibraryToLink structure. PiperOrigin-RevId: 763431970 Change-Id: I5536fc0c5502674967b8b4c64278d991aa6fbf3a
1 parent b07c319 commit 0af04ab

File tree

4 files changed

+20
-20
lines changed

4 files changed

+20
-20
lines changed

java/testutil.bzl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,10 @@
77
def _cc_info_transitive_native_libraries(cc_info):
88
return cc_info.transitive_native_libraries()
99

10-
def _cc_library_to_link_identifier(library_to_link):
11-
return library_to_link.library_identifier()
10+
def _cc_library_to_link_static_library(library_to_link):
11+
return library_to_link.static_library or library_to_link.pic_static_library
1212

1313
testutil = struct(
1414
cc_info_transitive_native_libraries = _cc_info_transitive_native_libraries,
15-
cc_library_to_link_identifier = _cc_library_to_link_identifier,
15+
cc_library_to_link_static_library = _cc_library_to_link_static_library,
1616
)

test/java/common/java_info_tests.bzl

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,7 @@ def _with_native_libraries_test(name):
175175
def _with_native_libraries_test_impl(env, target):
176176
assert_native_libs = java_info_subject.from_target(env, target).transitive_native_libraries()
177177

178-
assert_native_libs.identifiers().contains_exactly_predicates([matching.str_endswith("my_cc_lib_direct")])
178+
assert_native_libs.static_libraries().contains_exactly_predicates([matching.str_matches("*my_cc_lib_direct*")])
179179

180180
def _with_deps_and_neverlink_test(name):
181181
target_name = name + "/my_starlark_rule"
@@ -1136,10 +1136,10 @@ def _transitive_native_libraries_test(name):
11361136

11371137
def _transitive_native_libraries_test_impl(env, target):
11381138
assert_transitive_native_libraries = java_info_subject.from_target(env, target).transitive_native_libraries()
1139-
assert_transitive_native_libraries.identifiers().contains_exactly_predicates([
1140-
matching.str_endswith("my_cc_lib_a.so"),
1141-
matching.str_endswith("my_cc_lib_b.so"),
1142-
matching.str_endswith("my_cc_lib_c.so"),
1139+
assert_transitive_native_libraries.static_libraries().contains_exactly_predicates([
1140+
matching.str_matches("*my_cc_lib_a.so*"),
1141+
matching.str_matches("*my_cc_lib_b.so*"),
1142+
matching.str_matches("*my_cc_lib_c.so*"),
11431143
])
11441144

11451145
def _native_libraries_propagation_test(name):
@@ -1197,10 +1197,10 @@ def _native_libraries_propagation_test(name):
11971197

11981198
def _native_libraries_propagation_test_impl(env, target):
11991199
assert_transitive_native_libraries = java_info_subject.from_target(env, target).transitive_native_libraries()
1200-
assert_transitive_native_libraries.identifiers().contains_exactly_predicates([
1201-
matching.str_endswith("native_rdeps1.so"),
1202-
matching.str_endswith("native_exports1.so"),
1203-
matching.str_endswith("native_deps1.so"),
1200+
assert_transitive_native_libraries.static_libraries().contains_exactly_predicates([
1201+
matching.str_matches("*native_rdeps1.so*"),
1202+
matching.str_matches("*native_exports1.so*"),
1203+
matching.str_matches("*native_deps1.so*"),
12041204
]).in_order()
12051205

12061206
def _annotation_processing_test(name):

test/java/common/rules/java_library_tests.bzl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -273,9 +273,9 @@ def _test_propagates_direct_native_libraries(name):
273273

274274
def _test_propagates_direct_native_libraries_impl(env, target):
275275
assert_transitive_native_libraries = java_info_subject.from_target(env, target).transitive_native_libraries()
276-
assert_transitive_native_libraries.identifiers().contains_exactly_predicates([
277-
matching.str_endswith("native"),
278-
matching.str_endswith("ccl"),
276+
assert_transitive_native_libraries.static_libraries().contains_exactly_predicates([
277+
matching.str_matches("*native*"),
278+
matching.str_matches("*ccl*"),
279279
]).in_order()
280280

281281
def _test_exposes_native_library_info(name):

test/java/testutil/cc_info_subject.bzl

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ def _new_cc_info_libraries_to_link_subject(libraries_to_link, meta):
6060
meta = meta,
6161
)
6262
public = struct(
63-
identifiers = lambda: _new_library_to_link_identifiers_subject(self.actual, self.meta),
63+
static_libraries = lambda: _new_library_to_link_static_libraries_subject(self.actual, self.meta),
6464
singleton = lambda: _new_library_to_link_subject(_get_singleton(self.actual), self.meta.derive("[0]")),
6565
)
6666
return public
@@ -71,11 +71,11 @@ def _new_library_to_link_subject(library_to_link, meta):
7171
)
7272
return public
7373

74-
def _new_library_to_link_identifiers_subject(libraries_to_link, meta):
74+
def _new_library_to_link_static_libraries_subject(libraries_to_link, meta):
7575
self = subjects.collection(
76-
[testutil.cc_library_to_link_identifier(lib) for lib in libraries_to_link],
77-
meta = meta.derive("library_identifier()"),
78-
)
76+
[testutil.cc_library_to_link_static_library(lib) for lib in libraries_to_link],
77+
meta = meta.derive("static_library()"),
78+
).transform(desc = "basename", map_each = lambda file: file.basename)
7979
public = struct(
8080
contains_exactly = lambda expected: self.contains_exactly([meta.format_str(e) for e in expected]),
8181
contains_exactly_predicates = lambda expected: self.contains_exactly_predicates(expected),

0 commit comments

Comments
 (0)