MesonPackage: make "default_library" a multi-valued variant (#23540)

Currently if one package does `depends_on('pkg default_library=shared')`
and another does `depends_on('pkg default_library=both')`, you'd get a
concretization error.

With this PR one package can do `depends_on('pkg default_library=shared')` 
and another depends_on('default_library=static'), and it would concretize to 
`pkg default_library=shared,static`

Co-authored-by: Massimiliano Culpo <massimiliano.culpo@gmail.com>
This commit is contained in:
Harmen Stoppels 2021-05-25 12:07:00 +02:00 committed by GitHub
parent 6d29f0d61f
commit 56e7e2a406
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 11 additions and 12 deletions

View file

@ -55,9 +55,8 @@ class MesonPackage(PackageBase):
variant('buildtype', default='debugoptimized',
description='Meson build type',
values=('plain', 'debug', 'debugoptimized', 'release', 'minsize'))
variant('default_library', default='shared',
description=' Default library type',
values=('shared', 'static', 'both'))
variant('default_library', default='shared', values=('shared', 'static'),
multi=True, description='Build shared libs, static libs or both')
variant('strip', default=False, description='Strip targets on install')
depends_on('meson', type='build')
@ -102,9 +101,11 @@ def _std_args(pkg):
strip = 'true' if '+strip' in pkg.spec else 'false'
try:
default_library = pkg.spec.variants['default_library'].value
except KeyError:
if 'libs=static,shared' in pkg.spec:
default_library = 'both'
elif 'libs=static' in pkg.spec:
default_library = 'static'
else:
default_library = 'shared'
args = [

View file

@ -68,12 +68,10 @@ def meson(self, spec, prefix):
"INIT_D_PATH={0}".format(self.prefix.etc),
]
if 'default_library=shared' in self.spec:
args.extend(['--enable-shared', '--disable-static'])
elif 'default_library=static' in self.spec:
args.extend(['--disable-shared', '--enable-static'])
else:
args.extend(['--enable-shared', '--enable-static'])
args.append('--enable-static' if 'libs=static' in self.spec
else '--disable-static')
args.append('--enable-shared' if 'libs=shared' in self.spec
else '--disable-shared')
configure(*args)