hornetseye-frame 0.5.0 → 0.5.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. data/Rakefile +43 -4
  2. data/ext/colourspace.cc +7 -0
  3. metadata +3 -3
data/Rakefile CHANGED
@@ -5,9 +5,10 @@ require 'rake/testtask'
5
5
  require 'rake/packagetask'
6
6
  require 'rake/loaders/makefile'
7
7
  require 'rbconfig'
8
+ require 'tempfile'
8
9
 
9
10
  PKG_NAME = 'hornetseye-frame'
10
- PKG_VERSION = '0.5.0'
11
+ PKG_VERSION = '0.5.1'
11
12
  CXX = ENV[ 'CXX' ] || 'g++'
12
13
  STRIP = ENV[ 'STRIP' ] || 'strip'
13
14
  RB_FILES = FileList[ 'lib/**/*.rb' ]
@@ -28,7 +29,7 @@ HOMEPAGE = %q{http://wedesoft.github.com/hornetseye-frame/}
28
29
 
29
30
  OBJ = CC_FILES.ext 'o'
30
31
  $CXXFLAGS = ENV[ 'CXXFLAGS' ] || ''
31
- $CXXFLAGS = "#{$CXXFLAGS} -fPIC -DNDEBUG"
32
+ $CXXFLAGS = "#{$CXXFLAGS} -fPIC -DNDEBUG -DHAVE_CONFIG_H"
32
33
  if RbConfig::CONFIG[ 'rubyhdrdir' ]
33
34
  $CXXFLAGS = "#{$CXXFLAGS} -I#{RbConfig::CONFIG[ 'rubyhdrdir' ]} " +
34
35
  "-I#{RbConfig::CONFIG[ 'rubyhdrdir' ]}/#{RbConfig::CONFIG[ 'arch' ]}"
@@ -73,6 +74,44 @@ task :uninstall do
73
74
  end
74
75
  end
75
76
 
77
+ desc 'Create config.h'
78
+ task :config_h => 'ext/config.h'
79
+
80
+ def check_program
81
+ f_base_name = 'rakeconf'
82
+ begin
83
+ File.open( "#{f_base_name}.cc", 'w' ) { |f| yield f }
84
+ `#{CXX} -S #{$CXXFLAGS} -c -o #{f_base_name}.o #{f_base_name}.cc 2>&1 >> rake.log`
85
+ $?.exitstatus == 0
86
+ ensure
87
+ File.delete *Dir.glob( "#{f_base_name}.*" )
88
+ end
89
+ end
90
+
91
+ def check_c_header( name )
92
+ check_program do |c|
93
+ c.puts <<EOS
94
+ extern "C" {
95
+ #include <#{name}>
96
+ }
97
+ int main(void) { return 0; }
98
+ EOS
99
+ end
100
+ end
101
+
102
+ file 'ext/config.h' do |t|
103
+ s = "/* config.h. Generated from Rakefile by rake. */\n"
104
+ if check_c_header 'libswscale/swscale.h'
105
+ s << "#define HAVE_LIBSWSCALE_INCDIR 1\n"
106
+ else
107
+ unless check_c_header 'ffmpeg/swscale.h'
108
+ raise 'Cannot find swscale.h header file'
109
+ end
110
+ s << "#undef HAVE_LIBSWSCALE_INCDIR\n"
111
+ end
112
+ File.open( t.name, 'w' ) { |f| f.puts s }
113
+ end
114
+
76
115
  Rake::TestTask.new do |t|
77
116
  t.libs << 'ext'
78
117
  t.test_files = TC_FILES
@@ -168,7 +207,7 @@ rule '.o' => '.cc' do |t|
168
207
  sh "#{CXX} #{$CXXFLAGS} -c -o #{t.name} #{t.source}"
169
208
  end
170
209
 
171
- file ".depends.mf" do |t|
210
+ file ".depends.mf" => :config_h do |t|
172
211
  sh "g++ -MM #{$CXXFLAGS} #{CC_FILES.join ' '} | " +
173
212
  "sed -e :a -e N -e 's/\\n/\\$/g' -e ta | " +
174
213
  "sed -e 's/ *\\\\\\$ */ /g' -e 's/\\$/\\n/g' | sed -e 's/^/ext\\//' > #{t.name}"
@@ -179,5 +218,5 @@ end
179
218
  import ".depends.mf"
180
219
 
181
220
  CLEAN.include 'ext/*.o'
182
- CLOBBER.include SO_FILE, 'doc', '.yardoc', '.depends.mf'
221
+ CLOBBER.include SO_FILE, 'doc', '.yardoc', '.depends.mf', 'ext/config.h'
183
222
 
data/ext/colourspace.cc CHANGED
@@ -13,8 +13,15 @@
13
13
 
14
14
  You should have received a copy of the GNU General Public License
15
15
  along with this program. If not, see <http://www.gnu.org/licenses/>. */
16
+ #ifdef HAVE_CONFIG_H
17
+ #include "config.h"
18
+ #endif
16
19
  extern "C" {
20
+ #ifndef HAVE_LIBSWSCALE_INCDIR
21
+ #include <ffmpeg/swscale.h>
22
+ #else
17
23
  #include <libswscale/swscale.h>
24
+ #endif
18
25
  }
19
26
  #undef RSHIFT
20
27
  #include "colourspace.hh"
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 5
8
- - 0
9
- version: 0.5.0
8
+ - 1
9
+ version: 0.5.1
10
10
  platform: ruby
11
11
  authors:
12
12
  - Jan Wedekind
@@ -14,7 +14,7 @@ autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
16
 
17
- date: 2010-10-07 00:00:00 +01:00
17
+ date: 2010-10-08 00:00:00 +01:00
18
18
  default_executable:
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency