ncurses: add query parameters to select wide/nowide; readline: use wide only (#30144)

* ncurses: add wide, nowide headers, libs query parameter options

* readline: only link with libncursesw

Needed for python to detect proper ncurses library #27369
This commit is contained in:
Dylan Simon 2022-04-20 03:44:34 -04:00 committed by GitHub
parent 2d94624d0a
commit 7aa1fef506
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 39 additions and 3 deletions

View File

@ -156,11 +156,47 @@ def install(self, spec, prefix):
h = os.path.basename(header) h = os.path.basename(header)
os.symlink(os.path.join('ncursesw', h), os.path.join(prefix.include, h)) os.symlink(os.path.join('ncursesw', h), os.path.join(prefix.include, h))
def query_parameter_options(self):
"""Use query parameters passed to spec (e.g., "spec[ncurses:wide]")
to select wide, non-wide, or default/both."""
query_parameters = self.spec.last_query.extra_parameters
return 'nowide' in query_parameters, 'wide' in query_parameters
@property
def headers(self):
nowide, wide = self.query_parameter_options()
include = self.prefix.include
hdirs = []
if not (nowide or wide):
# default (top-level, wide)
hdirs.append(include)
if nowide:
hdirs.append(include.ncurses)
if wide:
hdirs.append(include.ncursesw)
headers = HeaderList([])
for hdir in hdirs:
headers = headers + find_headers('*', root=hdir, recursive=False).headers
headers.directories = hdirs
return headers
@property @property
def libs(self): def libs(self):
libraries = ['libncurses', 'libncursesw'] nowide, wide = self.query_parameter_options()
if not (nowide or wide):
# default (both)
nowide = True
wide = True
libs = ['libncurses']
if '+termlib' in self.spec: if '+termlib' in self.spec:
libraries += ['libtinfo', 'libtinfow'] libs.append('libtinfo')
wlibs = [lib + 'w' for lib in libs]
libraries = []
if nowide:
libraries.extend(libs)
if wide:
libraries.extend(wlibs)
return find_libraries(libraries, root=self.prefix, recursive=True) return find_libraries(libraries, root=self.prefix, recursive=True)

View File

@ -29,7 +29,7 @@ class Readline(AutotoolsPackage, GNUMirrorPackage):
patch('readline-6.3-upstream_fixes-1.patch', when='@6.3') patch('readline-6.3-upstream_fixes-1.patch', when='@6.3')
def build(self, spec, prefix): def build(self, spec, prefix):
make('SHLIB_LIBS=' + spec['ncurses'].libs.ld_flags) make('SHLIB_LIBS=' + spec['ncurses:wide'].libs.ld_flags)
def patch(self): def patch(self):
# Remove flags not recognized by the NVIDIA compiler # Remove flags not recognized by the NVIDIA compiler