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

Supporting versioned dylib in has_versioned_shared_lib_extension #2947

Merged
merged 2 commits into from
Sep 24, 2021
Merged
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
29 changes: 10 additions & 19 deletions go/private/common.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -184,29 +184,20 @@ def has_simple_shared_lib_extension(path):
return False

def has_versioned_shared_lib_extension(path):
"""Returns whether the path appears to be an .so file."""
if not path[-1].isdigit():
"""Returns whether the path appears to be an versioned .so or .dylib file."""
parts = path.split("/")[-1].split(".")
if not parts[-1].isdigit():
return False
for i in range(len(parts) - 1, 0, -1):
if not parts[i].isdigit():
if parts[i] == "dylib" or parts[i] == "so":
return True

so_location = path.rfind(".so")

# Version extensions are only allowed for .so files
if so_location == -1:
return False
last_dot = so_location
for i in range(so_location + 3, len(path)):
if path[i] == ".":
if i - last_dot > 1:
last_dot = i
else:
return False
elif not path[i].isdigit():
# somehting like foo.bar.1.2
return False

if last_dot == len(path):
return False

return True
# something like 1.2.3, or so.1.2, or dylib.1.2, or foo.1.2
return False

MINIMUM_BAZEL_VERSION = "4.0.0"

Expand Down