forked from le0pard/webp-ffi
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Rakefile
67 lines (60 loc) · 1.89 KB
/
Rakefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
require 'rubygems'
require 'bundler/setup'
require 'rake'
require 'rake/clean'
require 'bundler/gem_tasks'
require 'rspec/core/rake_task'
require 'ffi-compiler/compile_task'
require 'mini_portile2'
require 'gemfury'
require 'gemfury/command'
# Override rubygem_push to push to gemfury instead when doing `rake release`
module Bundler
class GemHelper
def rubygem_push(path)
::Gemfury::Command::App.start(['push', path, '--as=livelink'])
end
def version_tag
"#{name}-#{version}"
end
end
end
WEBP = MiniPortile.new('libwebp', '1.2.4')
WEBP.files = ['https://storage.googleapis.com/downloads.webmproject.org/releases/webp/libwebp-1.2.4.tar.gz']
WEBP.configure_options << '--disable-gl' << '--disable-sdl'
desc "compiler tasks"
namespace "ffi-compiler" do
task :libs do
old_cflags = ENV['CFLAGS']
ENV['CFLAGS'] = (ENV['CFLAGS'].to_s + ' -fPIC').strip
WEBP.cook
ENV['CFLAGS'] = old_cflags
WEBP.activate
end
FFI::Compiler::CompileTask.new('ext/webp_ffi/webp_ffi') do |c|
c.have_header?('stdio.h', '/usr/local/include')
c.have_func?('puts')
c.have_library?('z')
c.ldflags << '-L' + File.join(WEBP.path, 'lib')
c.cflags << '-I' + File.join(WEBP.path, 'include')
c.have_header?('decode.h', '/usr/local/include')
c.have_header?('encode.h', '/usr/local/include')
c.have_func?('WebPDecoderConfig')
c.have_func?('WebPGetInfo')
c.have_library?('webp')
c.have_library?('png')
c.have_library?('jpeg')
c.have_library?('tiff')
c.ldflags << ENV['LD_FLAGS'] if ENV['LD_FLAGS']
c.cflags << ENV['C_FLAGS'] if ENV['C_FLAGS']
end
end
task :compile => ["ffi-compiler:libs", "ffi-compiler:default"]
desc "run specs"
task :spec do
RSpec::Core::RakeTask.new
end
task :default => [:clean, :compile, :spec]
CLEAN.include('ext/**/*{.o,.log,.so,.bundle}')
CLEAN.include('lib/**/*{.o,.log,.so,.bundle}')
CLEAN.include('ext/**/Makefile')