Skip to content
Draft
Show file tree
Hide file tree
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
15 changes: 11 additions & 4 deletions pyodide_build/pywasmcross.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,11 +83,18 @@ def is_link_cmd(line: list[str]) -> bool:
"""
Check if the command is a linker invocation.
"""
import re

SHAREDLIB_REGEX = re.compile(r"\.so(.\d+)*$")
for arg in line:
if not arg.startswith("-") and SHAREDLIB_REGEX.search(arg):
parts = arg.split(".")
idx = len(parts) - 1

# response file
if parts[-1] == "rsp":
idx -= 1

while idx > 0 and parts[idx].isdigit():
idx -= 1

if idx > 0 and parts[idx] == "so":
return True

return False
Expand Down
4 changes: 4 additions & 0 deletions pyodide_build/tests/test_pywasmcross.py
Original file line number Diff line number Diff line change
Expand Up @@ -266,4 +266,8 @@ def test_handle_command_cmake(build_args):
def test_is_link_cmd():
assert is_link_cmd(["test.so"])
assert is_link_cmd(["test.so.1.2.3"])
assert is_link_cmd(["test.so.rsp"])
assert is_link_cmd(["test.1.2.3.so.rsp"])
assert not is_link_cmd(["test.1.2.3.rsp"])
assert is_link_cmd(["emcc.py", "test.so"])
assert not is_link_cmd(["test", "test.a", "test.o", "test.c", "test.cpp", "test.h"])
Loading