App.get_libname(): Don't use get_proj_refs() #7

Merged
Jan Lindemann merged 2 commits from jan/feature/20260608-app-get-libname-don-t-use-get-proj-refs into master 2026-06-08 20:49:04 +02:00 AGit
2 changed files with 14 additions and 19 deletions
Showing only changes of commit 3f47abb29a - Show all commits

App.get_libname(): Don't use get_proj_refs()
All checks were successful
CI / Packaging - Kali Linux (pull_request) Successful in 3m16s
CI / Packaging - OpenSUSE Tumbleweed (pull_request) Successful in 3m12s
CI / Packaging test (pull_request) Successful in 0s
CI / Packaging - Kali Linux (push) Successful in 3m17s
CI / Packaging - OpenSUSE Tumbleweed (push) Successful in 3m18s
CI / Packaging test (push) Successful in 0s

App.get_projects_refs() is a versatile tool, but what it does isn't obvious. Use the simpler method .get_value() instead for get_libname(), and return None if a project doesn't provide a linkable library.

This is similar to fix aadcdfb5f.

Signed-off-by: Jan Lindemann <jan@janware.com>
Jan Lindemann 2026-06-06 14:51:40 +02:00
Signed by: Jan Lindemann
GPG key ID: 3750640C9E25DD61

View file

@ -639,20 +639,14 @@ class App(Base):
ret.append(m) ret.append(m)
return ret return ret
def get_libname(self, projects) -> str: def get_libname(self, spec: str) -> str | None:
vals = self.get_project_refs( project_name = self.strip_module_from_spec(spec)
projects, ret = self.get_value(project_name, 'build', 'libname')
['build'], if ret == 'none':
'libname', return None
scope = Scope.One, if ret is None:
add_self = False, return project_name
names_only = True, return ret
)
if not vals:
return ' '.join(projects)
if 'none' in vals:
vals.remove('none')
return ' '.join(reversed(vals))
def is_excluded_from_build(self, project: str) -> str | None: def is_excluded_from_build(self, project: str) -> str | None:
log(DEBUG, 'checking if project ' + project + ' is excluded from build') log(DEBUG, 'checking if project ' + project + ' is excluded from build')

View file

@ -45,8 +45,8 @@ class CmdLdflags(Cmd): # export
for m in deps: for m in deps:
if m in exclude: if m in exclude:
continue continue
libname = self.app.get_libname([m]) libname = self.app.get_libname(m)
if not len(libname): if libname is None:
continue continue
path = self.app.find_dir(m, ['/lib']) path = self.app.find_dir(m, ['/lib'])
if not path: if not path:
@ -69,8 +69,9 @@ class CmdLdflags(Cmd): # export
for m in reversed(deps): for m in reversed(deps):
if m in args.exclude: if m in args.exclude:
continue continue
libname = self.app.get_libname([m]) libname = self.app.get_libname(m)
if len(libname): if libname is None:
continue
out.append('-l' + libname) out.append('-l' + libname)
if not out: if not out:
return return