Skip to content

Commit 0a606d9

Browse files
al3xtjamesAkemi
authored andcommitted
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 ffd47de commit 0a606d9

File tree

2 files changed

+10
-7
lines changed

2 files changed

+10
-7
lines changed

TOOLS/osxbundle.py

Lines changed: 8 additions & 6 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,12 +49,12 @@ 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):
5253
version = "UNKNOWN"
53-
version_path = os.path.join(src_path, "MPV_VERSION")
54-
if os.path.exists(version_path):
55-
x = open(version_path)
56-
version = x.read()
54+
version_h_path = os.path.join(build_path, "common", "version.h")
55+
if os.path.exists(version_h_path):
56+
x = open(version_h_path)
57+
version = re.findall(r"#define\s+VERSION\s+\"v(.+)\"", x.read())[0]
5758
x.close()
5859
return version
5960

@@ -70,9 +71,10 @@ def main():
7071
parser.error("incorrect number of arguments")
7172
else:
7273
binary_name = args[0]
74+
build_path = os.path.dirname(binary_name)
7375
src_path = args[1] if len(args) > 1 else "."
7476

75-
version = bundle_version(src_path).rstrip()
77+
version = bundle_version(build_path).rstrip()
7678

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

meson.build

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1843,7 +1843,8 @@ if get_option('cplayer')
18431843
osxbundle = find_program(join_paths(tools_directory, 'osxbundle.py'), required: true)
18441844
custom_target('macos-bundle',
18451845
output: 'mpv.app',
1846-
command: [osxbundle, mpv.full_path(), '@SOURCE_ROOT@'],
1846+
depends: version_h,
1847+
command: [osxbundle, mpv, '@SOURCE_ROOT@'],
18471848
)
18481849
endif
18491850

0 commit comments

Comments
 (0)