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)
return ret
def get_libname(self, projects) -> str:
vals = self.get_project_refs(
projects,
['build'],
'libname',
scope = Scope.One,
add_self = False,
names_only = True,
)
if not vals:
return ' '.join(projects)
if 'none' in vals:
vals.remove('none')
return ' '.join(reversed(vals))
def get_libname(self, spec: str) -> str | None:
project_name = self.strip_module_from_spec(spec)
ret = self.get_value(project_name, 'build', 'libname')
if ret == 'none':
return None
if ret is None:
return project_name
return ret
def is_excluded_from_build(self, project: str) -> str | None:
log(DEBUG, 'checking if project ' + project + ' is excluded from build')

View file

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