Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ trim_trailing_whitespace = true
[.git/COMMIT*]
max_line_length = 72

[{osdep/dirent-win.h,TOOLS/osxbundle/mpv.app/Contents/PkgInfo}]
[{osdep/dirent-win.h,TOOLS/osxbundle/mpv.app/Contents/PkgInfo,TOOLS/osxbundle/icon.icon/icon.json}]
charset = unset
insert_final_newline = unset
indent_style = unset
Expand Down
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ repos:
exclude: ^TOOLS/mpv-osd-symbols.sfdir/font.props$
- id: check-yaml
- id: end-of-file-fixer
exclude: ^TOOLS/osxbundle/mpv.app/Contents/PkgInfo$
exclude: ^(TOOLS/osxbundle/mpv.app/Contents/PkgInfo|TOOLS/osxbundle/icon.icon/icon.json)$
- id: fix-byte-order-marker
- id: mixed-line-ending
- id: trailing-whitespace
Expand Down
12 changes: 12 additions & 0 deletions TOOLS/osxbundle.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,12 @@ def target_binary(binary_name):
return os.path.join(target_directory(binary_name),
os.path.basename(binary_name))

def target_asset(binary_name, asset_name):
return os.path.join(bundle_path(binary_name), "Contents", "Resources", asset_name)

def source_asset(build_path, asset_name):
return os.path.join(build_path, "TOOLS", "osxbundle", asset_name)

def copy_bundle(binary_name, src_path):
if os.path.isdir(bundle_path(binary_name)):
shutil.rmtree(bundle_path(binary_name))
Expand All @@ -35,6 +41,10 @@ def copy_bundle(binary_name, src_path):
def copy_binary(binary_name):
shutil.copy(binary_name, target_binary(binary_name))

def copy_icons(binary_name, build_path):
shutil.copy(source_asset(build_path, "Assets.car"), target_asset(binary_name, "Assets.car"))
shutil.copy(source_asset(build_path, "icon.icns"), target_asset(binary_name, "icon.icns"))

def apply_plist_template(plist_file, version, category):
print(">> setting bundle category to " + category)
for line in fileinput.input(plist_file, inplace=True):
Expand Down Expand Up @@ -83,6 +93,8 @@ def main():
print(f"Creating macOS application bundle (version: {version})...")
print("> copying bundle skeleton")
copy_bundle(binary_name, src_path)
print("> copying icons")
copy_icons(binary_name, build_path)
print("> copying binary")
copy_binary(binary_name)
print("> generating Info.plist")
Expand Down

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why this icon is in oxsbundle and not with other icons in repository?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if you mean that specific png, then it's because it's within the Icon Composer project folder (icon.icon). we have to keep that folder structure.

if you mean the whole Icon Composer project folder (icon.icon), i just kept it besides the bundle close to where the old icon was. so not much of a reason. if you prefer i can move the whole folder to /etc, since we move the generated icon files into the bundle anyway?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I mean, we already have icons in etc/ directory.

Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
68 changes: 68 additions & 0 deletions TOOLS/osxbundle/icon.icon/icon.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
{
"fill-specializations" : [
{
"value" : {
"linear-gradient" : [
"display-p3:0.39488,0.24356,0.44742,1.00000",
"display-p3:0.24515,0.11286,0.28708,1.00000"
]
}
},
{
"appearance" : "dark",
"value" : {
"linear-gradient" : [
"display-p3:0.27475,0.12647,0.31624,1.00000",
"display-p3:0.17670,0.06822,0.20669,1.00000"
]
}
}
],
"groups" : [
{
"blend-mode" : "normal",
"blur-material" : null,
"hidden" : false,
"layers" : [
{
"blend-mode" : "normal",
"fill" : "none",
"glass" : false,
"image-name" : "icon_1024x1024.png",
"name" : "icon_1024x1024",
"opacity" : 1,
"position" : {
"scale" : 0.91,
"translation-in-points" : [
0,
0
]
}
}
],
"lighting" : "combined",
"name" : "Group",
"position" : {
"scale" : 1,
"translation-in-points" : [
0,
0
]
},
"shadow" : {
"kind" : "neutral",
"opacity" : 0.5
},
"specular" : false,
"translucency" : {
"enabled" : false,
"value" : 0.5
}
}
],
"supported-platforms" : {
"squares" : [
"macOS"
]
}
}
23 changes: 19 additions & 4 deletions TOOLS/osxbundle/meson.build
Original file line number Diff line number Diff line change
@@ -1,6 +1,21 @@
osxbundle = custom_target('osxbundle',
input: join_paths('mpv.app', 'Contents', 'Resources', 'icon.icns'),
if xcrun.found()
actool = find_program(run_command(xcrun, '-find', 'actool', check: true).stdout().strip())
icon_directory = join_paths(tools_directory, 'osxbundle', 'icon.icon')

mac_icon = custom_target('mac_icon',
output: ['icon.icns', 'Assets.car'],
command: [actool, icon_directory, '--compile', '@BUILD_ROOT@/TOOLS/osxbundle/',
'--app-icon', 'icon', '--enable-on-demand-resources', 'NO',
'--development-region', 'en', '--target-device', 'mac', '--platform', 'macosx',
'--include-all-app-icons', '--minimum-deployment-target', '10.15',
'--output-partial-info-plist', '/dev/null', '--standalone-icon-behavior', 'all'],
)
sources += mac_icon
endif

mac_bundle_icon = custom_target('mac_bundle_icon',
input: mac_icon,
output: 'icon.icns.inc',
command: [file2string, '@INPUT@', '@OUTPUT@', '@SOURCE_ROOT@'],
command: [file2string, '@INPUT0@', '@OUTPUT@', '@SOURCE_ROOT@'],
)
sources += osxbundle
sources += mac_bundle_icon
2 changes: 2 additions & 0 deletions TOOLS/osxbundle/mpv.app/Contents/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,8 @@
<string>mpv</string>
<key>CFBundleIconFile</key>
<string>icon</string>
<key>CFBundleIconName</key>
<string>icon</string>
<key>CFBundleIdentifier</key>
<string>io.mpv</string>
<key>CFBundleInfoDictionaryVersion</key>
Expand Down
Binary file not shown.
4 changes: 2 additions & 2 deletions meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -605,6 +605,7 @@ subdir('player/javascript')
subdir('player/lua')
subdir('sub')

xcrun = find_program('xcrun', required: darwin)
if darwin
subdir(join_paths('TOOLS', 'osxbundle'))
endif
Expand Down Expand Up @@ -1553,7 +1554,6 @@ swift = get_option('swift-build').require(
darwin and features['cocoa'],
error_message: 'cocoa was not found',
)
xcrun = find_program('xcrun', required: swift)
swift_ver = '0.0'
if xcrun.found()
swift_prog = find_program(run_command(xcrun, '-find', 'swiftc', check: true).stdout().strip())
Expand Down Expand Up @@ -1856,7 +1856,7 @@ if get_option('cplayer')
osxbundle = find_program(join_paths(tools_directory, 'osxbundle.py'), required: true)
custom_target('macos-bundle',
output: 'mpv.app',
depends: version_h,
depends: [version_h, mac_icon, mac_bundle_icon],
command: [osxbundle, mpv, '@SOURCE_ROOT@', '-c', get_option('macos-bundle-category')],
)
endif
Expand Down