pixbufutils 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/README.md +4 -0
- data/Rakefile +48 -0
- data/ext/pixbufutils/extconf.rb +109 -0
- data/ext/pixbufutils/pixbufutils.c +2031 -0
- data/ext/pixbufutils/pixbufutils.cr +1561 -0
- data/ext/pixbufutils/pixbufutils.rd +76 -0
- metadata +102 -0
data/README.md
ADDED
data/Rakefile
ADDED
@@ -0,0 +1,48 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
gem 'rake-compiler'
|
3
|
+
require 'rake/extensiontask'
|
4
|
+
BASE_DIR = Dir.pwd
|
5
|
+
require 'rubygems/package_task'
|
6
|
+
require 'rake/testtask'
|
7
|
+
|
8
|
+
exts = []
|
9
|
+
|
10
|
+
namespace :prepare do
|
11
|
+
FileList["ext/*/*.cr"].each do |cr|
|
12
|
+
dir = File.dirname(cr)
|
13
|
+
name = File.basename(dir)
|
14
|
+
desc "Generate source for #{name}"
|
15
|
+
task(name.intern) do
|
16
|
+
sh 'rubber-generate', '--build-dir', dir, cr
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
spec = Gem::Specification.new do |s|
|
22
|
+
s.name = "pixbufutils"
|
23
|
+
s.author = "Geoff Youngs"
|
24
|
+
s.email = "git@intersect-uk.co.uk"
|
25
|
+
s.version = "0.0.1"
|
26
|
+
s.homepage = "http://github.com/geoffyoungs/pixbufutils"
|
27
|
+
s.summary = "Additional utils for Gdk::Pixbuf"
|
28
|
+
s.add_dependency("rubber-generate", ">= 0.0.17")
|
29
|
+
s.add_dependency("glib2", ">= 1.1.6")
|
30
|
+
s.add_dependency("gdk_pixbuf2", ">= 1.1.6")
|
31
|
+
s.platform = Gem::Platform::RUBY
|
32
|
+
s.extensions = FileList["ext/*/extconf.rb"]
|
33
|
+
s.files = FileList['ext/*/*.{c,h,cr,rd}'] + ['Rakefile', 'README.md']
|
34
|
+
s.description = <<-EOF
|
35
|
+
Misc functions for alpha channel extraction, gamma, tinting, masking, blur etc.
|
36
|
+
EOF
|
37
|
+
end
|
38
|
+
Gem::PackageTask.new(spec) do |pkg|
|
39
|
+
pkg.need_tar = true
|
40
|
+
end
|
41
|
+
Rake::ExtensionTask.new("pixbufutils", spec)
|
42
|
+
|
43
|
+
Rake::TestTask.new do |t|
|
44
|
+
t.test_files = FileList['test/*_test.rb']
|
45
|
+
end
|
46
|
+
|
47
|
+
task :default, :compile
|
48
|
+
|
@@ -0,0 +1,109 @@
|
|
1
|
+
require 'mkmf'
|
2
|
+
use_gems = false
|
3
|
+
begin
|
4
|
+
require 'mkmf-gnome2'
|
5
|
+
rescue LoadError
|
6
|
+
use_gems = true
|
7
|
+
end
|
8
|
+
|
9
|
+
if use_gems or Object.const_defined?('Gem')
|
10
|
+
require 'rubygems'
|
11
|
+
gem 'glib2'
|
12
|
+
require 'mkmf-gnome2'
|
13
|
+
%w[rbglib.h rbgtk.h rbpango.h rbatk.h].each do |header|
|
14
|
+
Gem.find_files(header).each do |f|
|
15
|
+
$CFLAGS += " '-I#{File.dirname(f)}'"
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
# Look for headers in {gem_root}/ext/{package}
|
20
|
+
if use_gems
|
21
|
+
%w[
|
22
|
+
glib2 ].each do |package|
|
23
|
+
require package
|
24
|
+
$CFLAGS += " -I"+Gem.loaded_specs[package].full_gem_path+"/ext/"+package
|
25
|
+
end
|
26
|
+
end
|
27
|
+
if RbConfig::CONFIG.has_key?('rubyhdrdir')
|
28
|
+
$CFLAGS += " -I" + RbConfig::CONFIG['rubyhdrdir']+'/ruby'
|
29
|
+
end
|
30
|
+
|
31
|
+
$CFLAGS += " -I."
|
32
|
+
have_func("rb_errinfo")
|
33
|
+
PKGConfig.have_package("gdk-pixbuf-2.0") or exit(-1)
|
34
|
+
PKGConfig.have_package("gdk-2.0") or exit(-1)
|
35
|
+
have_header("gdk-pixbuf/gdk-pixbuf.h") or exit(-1)
|
36
|
+
have_header("rbglib.h") or exit(-1)
|
37
|
+
have_header("rbgobject.h") or exit(-1)
|
38
|
+
have_header("tiffio.h") or exit(-1)
|
39
|
+
have_header("gdk/gdk.h") or exit(-1)
|
40
|
+
have_library("tiff") or exit(-1)
|
41
|
+
$LIBS += " -ltiff"
|
42
|
+
|
43
|
+
STDOUT.print("checking for new allocation framework... ") # for ruby-1.7
|
44
|
+
if Object.respond_to? :allocate
|
45
|
+
STDOUT.print "yes
|
46
|
+
"
|
47
|
+
$defs << "-DHAVE_OBJECT_ALLOCATE"
|
48
|
+
else
|
49
|
+
STDOUT.print "no
|
50
|
+
"
|
51
|
+
end
|
52
|
+
|
53
|
+
top = File.expand_path(File.dirname(__FILE__) + '/..') # XXX
|
54
|
+
$CFLAGS += " " + ['glib/src'].map{|d|
|
55
|
+
"-I" + File.join(top, d)
|
56
|
+
}.join(" ")
|
57
|
+
|
58
|
+
have_func("rb_define_alloc_func") # for ruby-1.8
|
59
|
+
|
60
|
+
#set_output_lib('libruby-pixbufutils.a')
|
61
|
+
if /cygwin|mingw/ =~ RUBY_PLATFORM
|
62
|
+
top = "../.."
|
63
|
+
[
|
64
|
+
["glib/src", "ruby-glib2"],
|
65
|
+
].each{|d,l|
|
66
|
+
$LDFLAGS << sprintf(" -L%s/%s", top, d)
|
67
|
+
$libs << sprintf(" -l%s", l)
|
68
|
+
}
|
69
|
+
end
|
70
|
+
begin
|
71
|
+
srcdir = File.expand_path(File.dirname($0))
|
72
|
+
|
73
|
+
begin
|
74
|
+
|
75
|
+
obj_ext = "."+$OBJEXT
|
76
|
+
|
77
|
+
$libs = $libs.split(/ /).uniq.join(' ')
|
78
|
+
$source_files = Dir.glob(sprintf("%s/*.c", srcdir)).map{|fname|
|
79
|
+
fname[0, srcdir.length+1] = ''
|
80
|
+
fname
|
81
|
+
}
|
82
|
+
$objs = $source_files.collect do |item|
|
83
|
+
item.gsub(/.c$/, obj_ext)
|
84
|
+
end
|
85
|
+
|
86
|
+
#
|
87
|
+
# create Makefile
|
88
|
+
#
|
89
|
+
$defs << "-DRUBY_PIXBUFUTILS_COMPILATION"
|
90
|
+
# $CFLAGS << $defs.join(' ')
|
91
|
+
create_makefile("pixbufutils", srcdir)
|
92
|
+
raise Interrupt if not FileTest.exist? "Makefile"
|
93
|
+
|
94
|
+
File.open("Makefile", "a") do |mfile|
|
95
|
+
$source_files.each do |e|
|
96
|
+
mfile.print sprintf("%s: %s
|
97
|
+
", e.gsub(/.c$/, obj_ext), e)
|
98
|
+
end
|
99
|
+
end
|
100
|
+
ensure
|
101
|
+
#Dir.chdir ".."
|
102
|
+
end
|
103
|
+
|
104
|
+
#create_top_makefile()
|
105
|
+
rescue Interrupt
|
106
|
+
print " [error] " + $!.to_s + "
|
107
|
+
"
|
108
|
+
end
|
109
|
+
|