2019-11-14 10:03:04 +00:00
|
|
|
"""This is an experimental implementation of cc_shared_library.
|
|
|
|
|
|
|
|
We may change the implementation at any moment or even delete this file. Do not
|
|
|
|
rely on this. It requires bazel >1.2 and passing the flag
|
2019-11-12 13:06:26 +00:00
|
|
|
--experimental_cc_shared_library
|
|
|
|
"""
|
|
|
|
|
2020-02-26 15:07:17 +00:00
|
|
|
# Add this as a tag to any target that can be linked by more than one
|
|
|
|
# cc_shared_library because it doesn't have static initializers or anything
|
|
|
|
# else that may cause issues when being linked more than once. This should be
|
|
|
|
# used sparingly after making sure it's safe to use.
|
|
|
|
LINKABLE_MORE_THAN_ONCE = "LINKABLE_MORE_THAN_ONCE"
|
|
|
|
|
2021-10-06 19:12:05 +00:00
|
|
|
def cc_shared_library_permissions(**kwargs):
|
|
|
|
native.cc_shared_library_permissions(**kwargs)
|
2020-04-21 15:37:54 +00:00
|
|
|
|
2021-10-06 19:12:05 +00:00
|
|
|
def cc_shared_library(**kwargs):
|
|
|
|
native.cc_shared_library(**kwargs)
|
2019-11-15 13:36:25 +00:00
|
|
|
|
2021-10-06 19:12:05 +00:00
|
|
|
# TODO(bazel-team): Everything below this line can be deleted when tests have
|
|
|
|
# been moved under bazel repo
|
2020-03-03 15:11:22 +00:00
|
|
|
def _check_if_target_under_path(value, pattern):
|
|
|
|
if pattern.workspace_name != value.workspace_name:
|
2020-02-12 16:01:29 +00:00
|
|
|
return False
|
2020-03-03 15:11:22 +00:00
|
|
|
if pattern.name == "__pkg__":
|
|
|
|
return pattern.package == value.package
|
|
|
|
if pattern.name == "__subpackages__":
|
|
|
|
return _same_package_or_above(pattern, value)
|
2020-02-12 16:01:29 +00:00
|
|
|
|
2020-03-03 15:11:22 +00:00
|
|
|
return pattern.package == value.package and pattern.name == value.name
|
2020-02-12 16:01:29 +00:00
|
|
|
|
|
|
|
def _same_package_or_above(label_a, label_b):
|
|
|
|
if label_a.workspace_name != label_b.workspace_name:
|
|
|
|
return False
|
|
|
|
package_a_tokenized = label_a.package.split("/")
|
|
|
|
package_b_tokenized = label_b.package.split("/")
|
|
|
|
if len(package_b_tokenized) < len(package_a_tokenized):
|
|
|
|
return False
|
2020-04-22 14:05:26 +00:00
|
|
|
|
|
|
|
if package_a_tokenized[0] != "":
|
|
|
|
for i in range(len(package_a_tokenized)):
|
|
|
|
if package_a_tokenized[i] != package_b_tokenized[i]:
|
|
|
|
return False
|
|
|
|
|
2020-02-12 16:01:29 +00:00
|
|
|
return True
|
|
|
|
|
2020-03-03 15:11:22 +00:00
|
|
|
for_testing_dont_use_check_if_target_under_path = _check_if_target_under_path
|