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

pkgconfig: Handle malformatted string dependencies #13951

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
17 changes: 13 additions & 4 deletions mesonbuild/modules/pkgconfig.py
Original file line number Diff line number Diff line change
Expand Up @@ -286,11 +286,20 @@ def add_version_reqs(self, name: str, version_reqs: T.Optional[T.List[str]]) ->
self.version_reqs[name].update(version_reqs)

def split_version_req(self, s: str) -> T.Tuple[str, T.Optional[str]]:
stripped_str = s.strip()
if not stripped_str:
raise mesonlib.MesonException(f'required dependency must not be empty, "{s}" was provided.')
for op in ['>=', '<=', '!=', '==', '=', '>', '<']:
pos = s.find(op)
if pos > 0:
return s[0:pos].strip(), s[pos:].strip()
return s, None
pos = stripped_str.find(op)
if pos < 0:
continue
if pos == 0:
raise mesonlib.MesonException(f'required versioned dependency "{s}" is missing the dependency\'s name.')
stripped_str, version = stripped_str[0:pos].strip(), stripped_str[pos:].strip()
if not stripped_str:
raise mesonlib.MesonException(f'required versioned dependency "{s}" is missing the dependency\'s name.')
return stripped_str, version
return stripped_str, None

def format_vreq(self, vreq: str) -> str:
# vreq are '>=1.0' and pkgconfig wants '>= 1.0'
Expand Down
Loading