History

build: fix dynamic generation of mpv.desktop file protocols

Running cross-compiled binaries may be possible, but the runtime environment must be configured correctly. In some configurations, an exe_wrapper needs to be used, and in all cases, the library path must be set correctly for the given binary. Fortunately, Meson handles all of this if cross-compilation is configured correctly. Fix this by having Meson run the mpv binary directly, instead of as a subprocess of a Python script. This ensures that the environment is properly set for running host binaries, if possible.

Kacper Michajłow committed 2 years ago

Commit baabc291 parent 86e8cae2 files · +14 −12Browse files

Unified · Split

2 files
  1. TOOLS/gen-mpv-desktop.py +7 −10
  2. meson.build +7 −2
TOOLS/gen-mpv-desktop.py+7−10
@@ -21,7 +21,6 @@ · 20 unmodified lines
2121 #
2222
2323 import sys
24−from subprocess import check_output
2524
2625 if __name__ == "__main__":
2726 with open(sys.argv[1], encoding="UTF-8") as f:
@@ -31,15 +30,13 @@ if __name__ == "__main__": · 3 unmodified lines
3130 if not mpv_desktop["X-KDE-Protocols"]:
3231 raise ValueError("Missing X-KDE-Protocols entry in mpv.desktop file")
3332
34− mpv_protocols = check_output(
35− [sys.argv[2], "--no-config", "--list-protocols"],
36− encoding="UTF-8",
37− )
38− mpv_protocols = {
39− line.strip(" :/")
40− for line in mpv_protocols.splitlines()
41− if "://" in line
42− }
33+ with open(sys.argv[2], encoding="UTF-8") as mpv_protocols:
34+ mpv_protocols = {
35+ line.strip(" :/")
36+ for line in mpv_protocols.read().splitlines()
37+ if "://" in line
38+ }
39+
4340 if len(mpv_protocols) == 0:
4441 raise ValueError("Unable to parse any protocols from mpv '--list-protocols'")
4542
meson.build+7−2
@@ -1815,11 +1815,16 @@ if get_option('cplayer') · 1814 unmodified lines
18151815
18161816 if not win32 and not darwin
18171817 if meson.can_run_host_binaries()
1818+ mpv_protocols = custom_target('mpv_protocols',
1819+ output: 'mpv_protocols',
1820+ command: [mpv, '--no-config','--list-protocols'],
1821+ capture: true,
1822+ )
18181823 mpv_desktop_path = join_paths(source_root, 'etc', 'mpv.desktop')
18191824 custom_target('mpv.desktop',
1820− depends: mpv,
1825+ input: mpv_protocols,
18211826 output: 'mpv.desktop',
1822− command: [mpv_desktop, mpv_desktop_path, mpv.full_path(), '@OUTPUT@'],
1827+ command: [mpv_desktop, mpv_desktop_path, '@INPUT@', '@OUTPUT@'],
18231828 install: true,
18241829 install_dir: join_paths(datadir, 'applications'),
18251830 )

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t