-
Notifications
You must be signed in to change notification settings - Fork 35
Expand file tree
/
Copy pathRakefile
More file actions
51 lines (40 loc) · 1.28 KB
/
Rakefile
File metadata and controls
51 lines (40 loc) · 1.28 KB
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
require_relative 'lib/filemagic/version'
begin
require 'hen'
file mgc = 'lib/filemagic/magic.mgc' do
dir = ENV['WITH_CROSS_MAGIC']
dir && File.exist?(src = File.join(dir, 'magic', File.basename(mgc))) ?
cp(src, mgc) : File.binwrite(mgc, "\x1C\x04\x1E\xF1\x0C".ljust(248, "\0"))
end
Hen.lay! {{
gem: {
name: %q{ruby-filemagic},
version: FileMagic::VERSION,
summary: 'Ruby bindings to the magic(4) library',
authors: ['Travis Whitton', 'Jens Wille'],
email: 'jens.wille@gmail.com',
license: %q{Ruby},
homepage: :blackwinter,
local_files: [mgc],
extension: {
with_cross_gnurx: lambda { |dir| [dir] },
with_cross_magic: lambda { |dir| [src =
File.join(dir, 'src'), File.join(src, '.libs')] }
},
required_ruby_version: '>= 1.9.3'
}
}}
rescue LoadError => err
warn "Please install the `hen' gem. (#{err})"
end
namespace :docker do
name = "ruby-filemagic-gem-native:#{FileMagic::VERSION}"
task :build do
sh *%W[docker build -t #{name} .]
end
task :run do
sh *%W[docker run -it --rm -v #{Dir.pwd}/pkg:/ruby-filemagic/pkg #{name}]
end
desc "Build native gems using docker image #{name}"
task 'gem:native' => %w[build run]
end