-
Notifications
You must be signed in to change notification settings - Fork 2.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
add defines at configure time for wayland protocol interface versions #13993
Closed
Dudemanguy
wants to merge
2
commits into
mpv-player:master
from
Dudemanguy:wayland-interface-parsing
Closed
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
#!/usr/bin/env python3 | ||
""" | ||
Simple script to parse out interface names and version in wayland protocols | ||
for meson. | ||
""" | ||
|
||
# | ||
# This file is part of mpv. | ||
# | ||
# mpv is free software; you can redistribute it and/or | ||
# modify it under the terms of the GNU Lesser General Public | ||
# License as published by the Free Software Foundation; either | ||
# version 2.1 of the License, or (at your option) any later version. | ||
# | ||
# mpv is distributed in the hope that it will be useful, | ||
# but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
# GNU Lesser General Public License for more details. | ||
# | ||
# You should have received a copy of the GNU Lesser General Public | ||
# License along with mpv. If not, see <http://www.gnu.org/licenses/>. | ||
# | ||
|
||
import re | ||
import sys | ||
|
||
def parse_interface(line): | ||
line = re.sub('[<">\n]', '', line.strip()) | ||
line = line.replace("interface name", "interface_name") | ||
split = line.split() | ||
interface = "" | ||
for entry in split: | ||
key, value = entry.split("=") | ||
if key == "interface_name": | ||
interface += value.upper() + "_VERSION " | ||
if key == "version": | ||
interface += value | ||
return interface | ||
|
||
if __name__ == "__main__": | ||
if len(sys.argv) < 2: | ||
print(f"Usage: {sys.argv[0]} <file>") | ||
sys.exit(1) | ||
|
||
interfaces = [] | ||
with open(sys.argv[1], 'r') as f: | ||
for line in f: | ||
if "interface name=" in line: | ||
interfaces.append(parse_interface(line)) | ||
sys.stdout.write(','.join(interfaces)) | ||
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -27,6 +27,14 @@ endif | |
|
||
foreach p: protocols | ||
xml = join_paths(p) | ||
|
||
wayland_interface_parse = find_program(join_paths(tools_directory, 'wayland-interface-parse.py')) | ||
interfaces = run_command(wayland_interface_parse, xml, check: true).stdout().split(',') | ||
foreach interface: interfaces | ||
split = interface.split() | ||
conf_data.set(split[0], split[1].to_int()) | ||
endforeach | ||
|
||
wl_protocols_source += custom_target(xml.underscorify() + '_c', | ||
input: xml, | ||
output: '@[email protected]', | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nitpick, but there is mix of
"
and'
usage, make it use one of them.