Skip to content
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

bundle macOS App and upload it as artifact #13529

Merged
merged 12 commits into from
Feb 24, 2024
Merged
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
27 changes: 26 additions & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,15 @@ jobs:
os:
- "macos-12"
- "macos-13"
- "macos-14"
include:
- os: "macos-12"
arch: "intel"
- os: "macos-13"
arch: "intel"
- os: "macos-14"
arch: "arm"
xcode: "Xcode_15.2"
steps:
- uses: actions/checkout@v4

Expand All @@ -105,10 +114,16 @@ jobs:
find /usr/local/bin -lname '*/Library/Frameworks/Python.framework/*' -delete -print
brew unlink python && brew link --overwrite python

- name: Change Xcode version
if: ${{ matrix.xcode != '' }}
run: |
sudo xcode-select -s /Applications/${{ matrix.xcode }}.app

- name: Install dependencies
run: |
brew update
brew install autoconf automake pkg-config libtool python freetype fribidi little-cms2 luajit libass ffmpeg meson libplacebo
brew install autoconf automake pkg-config libtool python freetype fribidi little-cms2 \
luajit libass ffmpeg meson uchardet mujs libplacebo molten-vk vulkan-loader vulkan-headers

- name: Build with meson
id: build
Expand All @@ -119,6 +134,11 @@ jobs:
CXX: "${{ matrix.cxx }}"
TRAVIS_OS_NAME: "${{ matrix.os }}"

- name: Create App Bundle
run: |
meson compile -C build macos-bundle
tar -czvf mpv.tar.gz -C build mpv.app

- name: Print meson log
if: ${{ failure() && steps.build.outcome == 'failure' }}
run: |
Expand All @@ -134,6 +154,11 @@ jobs:
run: |
cat ./build/meson-logs/testlog.txt

- uses: actions/upload-artifact@v4
with:
name: mpv-${{ matrix.os }}-${{ matrix.arch }}
path: mpv.tar.gz

linux:
runs-on: "ubuntu-22.04"
container:
Expand Down
7 changes: 7 additions & 0 deletions .github/workflows/comment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,13 @@ jobs:
body += `\n* [${art.name}](${art_link})`;
}
}
body += `\n</details>\n\n<details><summary>macOS</summary>\n`;
for (const art of artifacts) {
const art_link = `https://nightly.link/${owner}/${repo}/actions/artifacts/${art.id}.zip`;
if (art.name.includes('macos')) {
body += `\n* [${art.name}](${art_link})`;
}
}
body += `\n</details>`;

const { data: comments } = await github.rest.issues.listComments({ repo, owner, issue_number });
Expand Down
24 changes: 16 additions & 8 deletions TOOLS/dylib-unhell.py → TOOLS/dylib_unhell.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
import shutil
import subprocess
import json
from distutils.dir_util import copy_tree
from functools import partial

sys_re = re.compile("^/System")
Expand Down Expand Up @@ -43,22 +42,27 @@ def otool(objfile, rapths):
def get_rapths(objfile):
rpaths = []
command = "otool -l '%s' | grep -A2 LC_RPATH | grep path" % objfile
pathRe = re.compile("^\s*path (.*) \(offset \d*\)$")
pathRe = re.compile(r"^\s*path (.*) \(offset \d*\)$")

try:
result = subprocess.check_output(command, shell = True, universal_newlines=True)
except:
return rpaths

for line in result.splitlines():
rpaths.append(pathRe.search(line).group(1).strip())
line_clean = pathRe.search(line).group(1).strip()
# resolve @loader_path
if line_clean.startswith('@loader_path/'):
line_clean = line_clean[len('@loader_path/'):]
line_clean = os.path.normpath(os.path.join(os.path.dirname(objfile), line_clean))
rpaths.append(line_clean)

return rpaths

def get_rpaths_dev_tools(binary):
command = "otool -l '%s' | grep -A2 LC_RPATH | grep path | grep \"Xcode\|CommandLineTools\"" % binary
command = "otool -l '%s' | grep -A2 LC_RPATH | grep path | grep \"Xcode\\|CommandLineTools\"" % binary
result = subprocess.check_output(command, shell = True, universal_newlines=True)
pathRe = re.compile("^\s*path (.*) \(offset \d*\)$")
pathRe = re.compile(r"^\s*path (.*) \(offset \d*\)$")
output = []

for line in result.splitlines():
Expand Down Expand Up @@ -91,6 +95,9 @@ def check_vulkan_max_version(version):
except:
return False

def get_homebrew_prefix():
return subprocess.check_output("brew --prefix", universal_newlines=True, shell=True).strip()

def install_name_tool_change(old, new, objfile):
subprocess.call(["install_name_tool", "-change", old, new, objfile], stderr=subprocess.DEVNULL)

Expand Down Expand Up @@ -180,6 +187,7 @@ def process_vulkan_loader(binary, loaderName, loaderRelativeFolder, libraryNode)
os.path.join(os.path.expanduser("~"), ".local/share", loaderRelativeFolder),
os.path.join("/usr/local/share", loaderRelativeFolder),
os.path.join("/usr/share/vulkan", loaderRelativeFolder),
os.path.join(get_homebrew_prefix(), 'share', loaderRelativeFolder),
]

loaderSystemFolder = ""
Expand Down Expand Up @@ -228,8 +236,8 @@ def remove_dev_tools_rapths(binary):
for path in get_rpaths_dev_tools(binary):
install_name_tool_delete_rpath(path, binary)

def main():
binary = os.path.abspath(sys.argv[1])
def process(binary):
binary = os.path.abspath(binary)
if not os.path.exists(lib_path(binary)):
os.makedirs(lib_path(binary))
print(">> gathering all linked libraries")
Expand All @@ -250,4 +258,4 @@ def main():
process_vulkan_loader(binary, "VkLayer_khronos_synchronization2.json", "vulkan/explicit_layer.d", "layer")

if __name__ == "__main__":
main()
process(sys.argv[1])
3 changes: 2 additions & 1 deletion TOOLS/osxbundle.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import shutil
import sys
import fileinput
import dylib_unhell
from optparse import OptionParser

def sh(command):
Expand Down Expand Up @@ -77,7 +78,7 @@ def main():

if options.deps:
print("> bundling dependencies")
print(sh(" ".join([os.path.join(src_path, "TOOLS/dylib-unhell.py"), target_binary(binary_name)])))
dylib_unhell.process(target_binary(binary_name))

print("> signing bundle with ad-hoc pseudo identity")
sign_bundle(binary_name)
Expand Down
3 changes: 2 additions & 1 deletion ci/build-macos.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ meson setup build \
-D{c_args,objc_args}="-Wno-error=deprecated -Wno-error=deprecated-declarations" \
-D{libmpv,tests}=true \
-D{gl,iconv,lcms2,lua,jpeg,plain-gl,zlib}=enabled \
-D{cocoa,coreaudio,gl-cocoa,macos-cocoa-cb,macos-touchbar,videotoolbox-gl}=enabled
-D{cocoa,coreaudio,gl-cocoa,videotoolbox-gl,videotoolbox-pl}=enabled \
-D{swift-build,macos-cocoa-cb,macos-media-player,macos-touchbar,vulkan}=enabled

meson compile -C build -j4
meson install -C build
Expand Down
8 changes: 8 additions & 0 deletions meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -1754,6 +1754,14 @@ if get_option('cplayer')
executable('mpv', wrapper_sources, c_args: '-municode', link_args: '-municode',
name_suffix: 'com', install: true)
endif

if darwin
osxbundle = find_program(join_paths(tools_directory, 'osxbundle.py'), required: true)
custom_target('macos-bundle',
output: 'mpv.app',
command: [osxbundle, mpv.full_path(), '@SOURCE_ROOT@'],
)
endif
endif

if get_option('tests')
Expand Down
4 changes: 0 additions & 4 deletions osdep/macos/swift_extensions.swift
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ extension NSDeviceDescriptionKey {
}

extension NSScreen {

public var displayID: CGDirectDisplayID {
get {
return deviceDescription[.screenNumber] as? CGDirectDisplayID ?? 0
Expand All @@ -31,7 +30,6 @@ extension NSScreen {
}

extension NSColor {

convenience init(hex: String) {
let int = Int(hex.dropFirst(), radix: 16) ?? 0
let alpha = CGFloat((int >> 24) & 0x000000FF)/255
Expand All @@ -44,14 +42,12 @@ extension NSColor {
}

extension Bool {

init(_ int32: Int32) {
self.init(int32 != 0)
}
}

extension Int32 {

init(_ bool: Bool) {
self.init(bool ? 1 : 0)
}
Expand Down
4 changes: 2 additions & 2 deletions test/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ endif

img_utils_objects = libmpv.extract_objects(img_utils_files)
img_utils = static_library('img-utils', 'img_utils.c', include_directories: incdir,
dependencies: [libavcodec], objects: img_utils_objects)
dependencies: [libavcodec, libplacebo], objects: img_utils_objects)

# The actual tests.
chmap_files = [
Expand All @@ -92,7 +92,7 @@ test('chmap', chmap)
gl_video_objects = libmpv.extract_objects('video/out/gpu/ra.c',
'video/out/gpu/utils.c')
gl_video = executable('gl-video', 'gl_video.c', objects: gl_video_objects,
dependencies: [libavutil], include_directories: incdir,
dependencies: [libavutil, libplacebo], include_directories: incdir,
link_with: [img_utils, test_utils])
test('gl-video', gl_video)

Expand Down
Loading