From 33137606e9fba8677f1cb1f5424aff2067075147 Mon Sep 17 00:00:00 2001 From: Stefano Pigozzi Date: Fri, 1 Aug 2014 07:49:28 +0200 Subject: 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. --- travis-deps | 76 ++++++++++++++++++++++++++++++++++++++++++++++--------------- 1 file changed, 58 insertions(+), 18 deletions(-) (limited to 'travis-deps') diff --git a/travis-deps b/travis-deps index adf7fadefa..8df9147f69 100755 --- a/travis-deps +++ b/travis-deps @@ -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 self.os + ENV['TRAVIS_OS_NAME'] + end + + attr_reader :name, :url, :action, :os + + def initialize(name) + @name, @os = name, self.class.os + end - def initialize(name, url=nil, action=nil) - @name, @url, @action = name, url, action + 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 -- cgit v1.2.3