Skip to content

Commit

Permalink
wayland: Stable protocols can have a version
Browse files Browse the repository at this point in the history
  • Loading branch information
xclaesse committed Mar 14, 2024
1 parent 675b47b commit 9d70a9c
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 8 deletions.
13 changes: 13 additions & 0 deletions docs/markdown/snippets/wayland_stable_prot_version.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
## Wayland stable protocols can be versioned

The wayland module now accepts a version number for stable protocols.

```meson
wl_mod = import('unstable-wayland')
wl_mod.find_protocol(
'linux-dmabuf',
state: 'stable'
version: 1
)
```
16 changes: 8 additions & 8 deletions mesonbuild/modules/wayland.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
from . import ExtensionModule, ModuleReturnValue, ModuleInfo
from ..build import CustomTarget
from ..interpreter.type_checking import NoneType, in_set_validator
from ..interpreterbase import typed_pos_args, typed_kwargs, KwargInfo
from ..interpreterbase import typed_pos_args, typed_kwargs, KwargInfo, FeatureNew
from ..mesonlib import File, MesonException

if T.TYPE_CHECKING:
Expand Down Expand Up @@ -122,20 +122,20 @@ def find_protocol(self, state: ModuleState, args: T.Tuple[str], kwargs: FindProt
raise MesonException(f'{xml_state} protocols require a version number.')

if xml_state == 'stable' and version is not None:
raise MesonException('stable protocols do not require a version number.')
FeatureNew.single_use('Version number in stable wayland protocol', '1.5.0', state.subproject, location=state.current_node)

if self.protocols_dep is None:
self.protocols_dep = state.dependency('wayland-protocols')

if self.pkgdatadir is None:
self.pkgdatadir = self.protocols_dep.get_variable(pkgconfig='pkgdatadir', internal='pkgdatadir')

if xml_state == 'stable':
xml_name = f'{base_name}.xml'
elif xml_state == 'staging':
xml_name = f'{base_name}-v{version}.xml'
else:
xml_name = f'{base_name}-unstable-v{version}.xml'
xml_name = base_name
if xml_state == 'unstable':
xml_name += '-unstable'
if version is not None:
xml_name += f'-v{version}'
xml_name += '.xml'

path = os.path.join(self.pkgdatadir, xml_state, base_name, xml_name)

Expand Down

0 comments on commit 9d70a9c

Please sign in to comment.