Skip to content

Commit

Permalink
Supporting versioned dylib in has_versioned_shared_lib_extension (#2947)
Browse files Browse the repository at this point in the history
* Supporting versioned dylib in has_versioned_shared_lib_extension

* buidifier
  • Loading branch information
linzhp authored Sep 24, 2021
1 parent 9f77676 commit f93f505
Showing 1 changed file with 10 additions and 19 deletions.
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

0 comments on commit f93f505

Please sign in to comment.