Skip to content

Commit 2135b60

Browse files
committed
osxbundle: read version from version.h
osxbundle.py currently reads the version number from MPV_VERSION, while Meson first tries git describe before falling back to MPV_VERSION. Update osxbundle.py to try reading the version number from version.h before falling back to MPV_VERSION. This ensures that the version number in the bundle matches the output of mpv --version.
1 parent ad59ff1 commit 2135b60

File tree

2 files changed

+11
-4
lines changed

2 files changed

+11
-4
lines changed

TOOLS/osxbundle.py

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
#!/usr/bin/env python3
22
import fileinput
33
import os
4+
import re
45
import shutil
56
import subprocess
67
from optparse import OptionParser
@@ -48,10 +49,15 @@ def sign_bundle(binary_name):
4849
subprocess.run(["codesign", "--force", "-s", "-", path])
4950
subprocess.run(["codesign", "--force", "-s", "-", bundle_path(binary_name)])
5051

51-
def bundle_version(src_path):
52+
def bundle_version(build_path, src_path):
5253
version = "UNKNOWN"
54+
version_h_path = os.path.join(build_path, "common", "version.h")
5355
version_path = os.path.join(src_path, "MPV_VERSION")
54-
if os.path.exists(version_path):
56+
if os.path.exists(version_h_path):
57+
x = open(version_h_path)
58+
version = re.findall(r"#define\s+VERSION\s+\"v(.+)\"", x.read())[0]
59+
x.close()
60+
elif os.path.exists(version_path):
5561
x = open(version_path)
5662
version = x.read()
5763
x.close()
@@ -70,9 +76,10 @@ def main():
7076
parser.error("incorrect number of arguments")
7177
else:
7278
binary_name = args[0]
79+
build_path = os.path.dirname(binary_name)
7380
src_path = args[1] if len(args) > 1 else "."
7481

75-
version = bundle_version(src_path).rstrip()
82+
version = bundle_version(build_path, src_path).rstrip()
7683

7784
print(f"Creating macOS application bundle (version: {version})...")
7885
print("> copying bundle skeleton")

meson.build

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1830,7 +1830,7 @@ if get_option('cplayer')
18301830
osxbundle = find_program(join_paths(tools_directory, 'osxbundle.py'), required: true)
18311831
custom_target('macos-bundle',
18321832
output: 'mpv.app',
1833-
command: [osxbundle, mpv.full_path(), '@SOURCE_ROOT@'],
1833+
command: [osxbundle, mpv, '@SOURCE_ROOT@'],
18341834
)
18351835
endif
18361836

0 commit comments

Comments
 (0)