2013-05-19 07:19:29 +00:00
|
|
|
#!/usr/bin/ruby
|
|
|
|
|
|
|
|
class TravisDepsBuilder
|
|
|
|
def self.make(name)
|
2014-08-01 05:49:28 +00:00
|
|
|
instance = klass.new(name)
|
|
|
|
instance.fill_data
|
2013-05-19 07:19:29 +00:00
|
|
|
instance.deps
|
|
|
|
instance.build
|
|
|
|
end
|
|
|
|
|
2014-08-01 05:49:28 +00:00
|
|
|
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
|
2013-05-19 07:19:29 +00:00
|
|
|
|
2014-08-01 05:49:28 +00:00
|
|
|
def fill_data
|
|
|
|
data = build_map.fetch(name)
|
|
|
|
@url, @action = data[:url], data[:action]
|
2013-05-19 07:19:29 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
def build
|
2014-08-01 05:49:28 +00:00
|
|
|
send(action)
|
2013-05-19 07:19:29 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
def deps; end
|
|
|
|
|
|
|
|
private
|
2014-08-01 05:49:28 +00:00
|
|
|
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
|
|
|
|
|
2013-05-19 07:19:29 +00:00
|
|
|
def git
|
|
|
|
sh "git clone --depth=1 #{url} #{name}"
|
|
|
|
compile name
|
|
|
|
end
|
|
|
|
|
|
|
|
def stable
|
|
|
|
filename = File.basename(url)
|
|
|
|
sh "wget #{url}"
|
|
|
|
sh "tar -xzvf #{filename}"
|
|
|
|
dirname = File.basename(url, ".tar.gz" )
|
|
|
|
compile dirname
|
|
|
|
end
|
|
|
|
|
2014-08-01 05:49:28 +00:00
|
|
|
def package
|
|
|
|
package_install(url)
|
|
|
|
end
|
|
|
|
|
2013-05-19 07:19:29 +00:00
|
|
|
def compile(dirname)
|
2013-09-01 16:46:38 +00:00
|
|
|
sh "cd #{dirname} && #{configure} && make && sudo make install"
|
2013-05-19 07:19:29 +00:00
|
|
|
sh "cd $TRAVIS_BUILD_DIR"
|
|
|
|
end
|
|
|
|
|
2013-09-01 16:46:38 +00:00
|
|
|
def configure
|
|
|
|
"./configure"
|
|
|
|
end
|
|
|
|
|
2013-05-19 07:19:29 +00:00
|
|
|
def sh(command)
|
|
|
|
`#{command}`
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
class Libav < TravisDepsBuilder
|
2014-08-01 05:49:28 +00:00
|
|
|
def build_map
|
2013-05-19 07:19:29 +00:00
|
|
|
{
|
|
|
|
"libav-stable" => {
|
|
|
|
:action => :stable,
|
2016-12-07 17:17:41 +00:00
|
|
|
:url => 'http://libav.org/releases/libav-12.tar.gz'
|
2013-05-19 07:19:29 +00:00
|
|
|
},
|
|
|
|
"libav-git" => {
|
|
|
|
:action => :git,
|
|
|
|
:url => "git://git.libav.org/libav.git"
|
|
|
|
},
|
|
|
|
"ffmpeg-stable" => {
|
|
|
|
:action => :stable,
|
2016-12-07 17:17:41 +00:00
|
|
|
:url => 'http://www.ffmpeg.org/releases/ffmpeg-3.2.2.tar.gz'
|
2013-05-19 07:19:29 +00:00
|
|
|
},
|
|
|
|
"ffmpeg-git" => {
|
|
|
|
:action => :git,
|
|
|
|
:url => "git://github.com/FFmpeg/FFmpeg.git"
|
|
|
|
}
|
|
|
|
}
|
|
|
|
end
|
2013-09-01 16:46:38 +00:00
|
|
|
|
|
|
|
def configure
|
2016-11-17 14:07:54 +00:00
|
|
|
[super, "--cc=#{ENV['CC']} --disable-asm"].join(" ")
|
2013-09-01 16:46:38 +00:00
|
|
|
end
|
2013-05-19 07:19:29 +00:00
|
|
|
end
|
|
|
|
|
2014-08-01 05:49:28 +00:00
|
|
|
class LibavOsx < Libav
|
|
|
|
def build_map
|
|
|
|
{
|
|
|
|
"ffmpeg-stable" => { :action => :package, :url => 'ffmpeg' },
|
|
|
|
}
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2013-05-19 07:19:29 +00:00
|
|
|
class Libass < TravisDepsBuilder
|
2014-08-01 05:49:28 +00:00
|
|
|
def build_map
|
2013-05-19 07:19:29 +00:00
|
|
|
{
|
|
|
|
"libass-stable" => {
|
|
|
|
:action => :stable,
|
2015-02-18 20:37:55 +00:00
|
|
|
:url => 'https://github.com/libass/libass/releases/download/0.12.1/libass-0.12.1.tar.gz'
|
2013-05-19 07:19:29 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
class Dependencies < TravisDepsBuilder
|
|
|
|
def deps
|
2014-08-01 05:49:28 +00:00
|
|
|
packages = {
|
|
|
|
'linux' => 'pkg-config fontconfig libfribidi-dev yasm',
|
|
|
|
'osx' => 'pkg-config fontconfig freetype fribidi yasm'
|
|
|
|
}
|
|
|
|
package_manager_update
|
|
|
|
package_install(packages.fetch(os))
|
2013-05-19 07:19:29 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
Dependencies.new(:deps).deps
|
|
|
|
|
|
|
|
Libass.make(ARGV[0])
|
|
|
|
Libav.make(ARGV[1])
|