1
0
mirror of https://github.com/mpv-player/mpv synced 2024-12-22 06:42:03 +00:00

travis: use homebrew to build ffmpeg on OS X

This allows us to use a newer version of ffmpeg and to test the build of our
VDA code.
This commit is contained in:
Stefano Pigozzi 2014-08-01 07:49:28 +02:00
parent 33f465d9a7
commit 33137606e9

View File

@ -2,26 +2,57 @@
class TravisDepsBuilder
def self.make(name)
info = build_map[name]
raise "unrecognized dependency identifier '#{name}'" unless info
instance = new(name, info[:url], info[:action])
instance = klass.new(name)
instance.fill_data
instance.deps
instance.build
end
attr_reader :name, :url, :action
def self.klass
Module.const_get([self.name, self.os.capitalize].join)
rescue NameError
self
end
def initialize(name, url=nil, action=nil)
@name, @url, @action = name, url, action
def self.os
ENV['TRAVIS_OS_NAME']
end
attr_reader :name, :url, :action, :os
def initialize(name)
@name, @os = name, self.class.os
end
def fill_data
data = build_map.fetch(name)
@url, @action = data[:url], data[:action]
end
def build
send(@action)
send(action)
end
def deps; end
private
def package_manager_update
# yes class variable, you wanna update only once across all instances
@@updated ||= false
return if @@updated
sh({'linux' => 'sudo apt-get update -y', 'osx' => 'brew update'}[os])
@@updated = true
end
def package_install(*packages)
cmd = {
'linux' => 'sudo apt-get install %s -y',
'osx' => 'brew install %s'
}[os] % [packages.join(" ")]
sh cmd
end
def git
sh "git clone --depth=1 #{url} #{name}"
compile name
@ -35,6 +66,10 @@ class TravisDepsBuilder
compile dirname
end
def package
package_install(url)
end
def compile(dirname)
sh "cd #{dirname} && #{configure} && make && sudo make install"
sh "cd $TRAVIS_BUILD_DIR"
@ -50,7 +85,7 @@ class TravisDepsBuilder
end
class Libav < TravisDepsBuilder
def self.build_map
def build_map
{
"libav-stable" => {
:action => :stable,
@ -76,8 +111,16 @@ class Libav < TravisDepsBuilder
end
end
class LibavOsx < Libav
def build_map
{
"ffmpeg-stable" => { :action => :package, :url => 'ffmpeg' },
}
end
end
class Libass < TravisDepsBuilder
def self.build_map
def build_map
{
"libass-stable" => {
:action => :stable,
@ -89,15 +132,12 @@ end
class Dependencies < TravisDepsBuilder
def deps
case ENV['TRAVIS_OS_NAME']
when 'linux' then
sh "sudo apt-get update -y"
sh "sudo apt-get install pkg-config fontconfig libfribidi-dev yasm -y"
when 'osx' then
sh 'brew install pkg-config fontconfig freetype fribidi yasm'
else
abort "Unrecognized OS"
end
packages = {
'linux' => 'pkg-config fontconfig libfribidi-dev yasm',
'osx' => 'pkg-config fontconfig freetype fribidi yasm'
}
package_manager_update
package_install(packages.fetch(os))
end
end