Skip to content
Permalink
Browse files

Update library dependency scripts to be more general

Also update the README with instructions on how to use MacPorts to
install dependencies
  • Loading branch information...
saagarjha authored and lhc70000 committed Mar 30, 2019
1 parent 00d18c2 commit 2be46b3cd02bfac9d730fa3d6c2a6d01eb4034bf
Showing with 44 additions and 15 deletions.
  1. +18 −4 README.md
  2. +26 −11 other/change_lib_dependencies.rb
@@ -55,18 +55,32 @@ $ brew install cocoapods

### Building mpv manually

1. Install mpv:
1. Build your own copy of mpv. If you're using a package manager to manage dependencies, the steps below outline the process.

#### Homebrew

Use our tap, since passes the correct flags during configuration:

```console
$ brew tap iina/homebrew-mpv-iina
$ brew install mpv-iina
```

#### MacPorts

Pass in the flags when installing:

```console
$ brew install mpv
# port install mpv +uchardet -bundle -rubberband configure.args="--enable-libmpv-shared --enable-lua --enable-libarchive --enable-libbluray --disable-swift --disable-rubberband"
```

2. Copy latest [header files](https://github.com/mpv-player/mpv/tree/master/libmpv) into `libmpv/include/mpv/`.

3. Run `other/parse_doc.rb`. This script will fetch the latest mpv documentation and generate `MPVOption.swift`, `MPVCommand.swift` and `MPVProperty.swift`. This is only needed when updating libmpv. Note that if the API changes, the player source code may also need to be changed.

4. Run `other/change_lib_dependencies.rb`. This script will deploy the depended libraries into `libmpv/libs`.
Make sure you have a phase copying of all these dylibs in Xcode's build settings.
4. Run `other/change_lib_dependencies.rb`. This script will deploy the depended libraries into `libmpv/libs`. Once this is finished, go to Xcode and delete all of the dylibs from the Frameworks group in the sidebar and drag in your own from `libmpv/libs`; do the same in the "Embedded Binaries" section of the iina target.

5. Run a fresh build in Xcode.

## Contributing

@@ -54,8 +54,22 @@ def change_install_name!(old_name, new_name)
end
end

linked_files = Dir["#{`brew --prefix mpv`.chomp}/lib/*.dylib"]
linked_files += Dir["#{`brew --prefix ffmpeg`.chomp}/lib/*.dylib"]
if ARGV.length <= 1
abort <<~END
Usage: change_lib_dependencies.rb prefix libraries...
If you're using Homebrew, your invokation might look like this:
$ ./change_lib_dependencies.rb "$(brew --prefix)" "$(brew --prefix mpv)/lib/*.dylib"
If you're using MacPorts, your invokcation might look like this:
$ port contents mpv | grep '\.dylib$' | xargs ./change_lib_dependencies.rb /opt/local
END
end

prefix = ARGV.shift

linked_files = ARGV

proj_path = File.expand_path(File.join(File.dirname(__FILE__), '../'))
lib_folder = File.join(proj_path, "deps/lib/")

@@ -65,27 +79,28 @@ def change_install_name!(old_name, new_name)
mkdir lib_folder

linked_files.each do |file|
dest = File.join(lib_folder, File.basename(file))
# Grab the actual library on disk.
file = File.realpath(file)

# Keep the output filename the same as the library's install name
dylib = DylibFile.new file
dylib.parse_otool_L_output!
dest = File.join(lib_folder, File.basename(dylib.id))

puts "cp -p #{file} #{dest}"
copy_entry file, dest, preserve: true
libs << dest unless File.symlink?(dest)
libs << dest
end

fix_count = 0

libs.each do |file|
fix_count += 1
dylib = DylibFile.new file
dylib.change_id!
end

while !libs.empty?
file = libs.pop
puts "=== Fix dependencies for #{file} ==="
dylib = DylibFile.new file
dylib.change_id!
dylib.deps.each do |dep|
if dep.start_with?("/usr/local")
if dep.start_with?(prefix)
fix_count += 1
basename = File.basename(dep)
new_name = "@rpath/#{basename}"

0 comments on commit 2be46b3

Please sign in to comment.
You can’t perform that action at this time.