cairo 1.5.1 → 1.6.0
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of cairo might be problematic. Click here for more details.
- data/ChangeLog +153 -0
- data/NEWS +16 -2
- data/README +2 -0
- data/Rakefile +21 -7
- data/doc/doc.css +69 -0
- data/doc/en/cairo-antialias.html +27 -0
- data/doc/en/cairo-clip-not-representable-error.html +36 -0
- data/doc/en/cairo-color-base.html +58 -0
- data/doc/en/cairo-color-cmyk.html +146 -0
- data/doc/en/cairo-color-hsv.html +126 -0
- data/doc/en/cairo-color-rgb.html +131 -0
- data/doc/en/cairo-color-x11.html +162 -0
- data/doc/en/cairo-color.html +227 -0
- data/doc/en/cairo-content.html +26 -0
- data/doc/en/cairo-context-blur.html +28 -0
- data/doc/en/cairo-context-circle.html +28 -0
- data/doc/en/cairo-context-color.html +28 -0
- data/doc/en/cairo-context-path.html +33 -0
- data/doc/en/cairo-context-rectangle.html +28 -0
- data/doc/en/cairo-context-triangle.html +28 -0
- data/doc/en/cairo-context.html +622 -0
- data/doc/en/cairo-error.html +33 -0
- data/doc/en/cairo-extend.html +27 -0
- data/doc/en/cairo-file-not-found.html +36 -0
- data/doc/en/cairo-fill-rule.html +25 -0
- data/doc/en/cairo-filter.html +29 -0
- data/doc/en/cairo-font-extents.html +60 -0
- data/doc/en/cairo-font-face.html +27 -0
- data/doc/en/cairo-font-options.html +128 -0
- data/doc/en/cairo-font-slant.html +26 -0
- data/doc/en/cairo-font-weight.html +25 -0
- data/doc/en/cairo-format.html +35 -0
- data/doc/en/cairo-glyph.html +88 -0
- data/doc/en/cairo-gradient-pattern.html +63 -0
- data/doc/en/cairo-hint-metrics.html +26 -0
- data/doc/en/cairo-hint-style.html +28 -0
- data/doc/en/cairo-image-surface.html +71 -0
- data/doc/en/cairo-invalid-content-error.html +36 -0
- data/doc/en/cairo-invalid-dash-error.html +36 -0
- data/doc/en/cairo-invalid-dsc-comment-error.html +36 -0
- data/doc/en/cairo-invalid-format-error.html +36 -0
- data/doc/en/cairo-invalid-index-error.html +36 -0
- data/doc/en/cairo-invalid-matrix-error.html +36 -0
- data/doc/en/cairo-invalid-path-data-error.html +36 -0
- data/doc/en/cairo-invalid-pop-group-error.html +36 -0
- data/doc/en/cairo-invalid-restore-error.html +36 -0
- data/doc/en/cairo-invalid-status-error.html +36 -0
- data/doc/en/cairo-invalid-stride-error.html +36 -0
- data/doc/en/cairo-invalid-string-error.html +36 -0
- data/doc/en/cairo-invalid-visual-error.html +36 -0
- data/doc/en/cairo-line-cap.html +26 -0
- data/doc/en/cairo-line-join.html +26 -0
- data/doc/en/cairo-linear-pattern.html +49 -0
- data/doc/en/cairo-matrix.html +243 -0
- data/doc/en/cairo-no-current-point-error.html +36 -0
- data/doc/en/cairo-null-pointer-error.html +36 -0
- data/doc/en/cairo-operator.html +37 -0
- data/doc/en/cairo-paper-parse-error.html +36 -0
- data/doc/en/cairo-paper-unknown-paper-name.html +55 -0
- data/doc/en/cairo-paper-unknown-unit.html +55 -0
- data/doc/en/cairo-paper-unrecognized-paper-description.html +55 -0
- data/doc/en/cairo-paper.html +173 -0
- data/doc/en/cairo-path-close-path.html +38 -0
- data/doc/en/cairo-path-curve-to.html +38 -0
- data/doc/en/cairo-path-data-type.html +27 -0
- data/doc/en/cairo-path-data.html +87 -0
- data/doc/en/cairo-path-line-to.html +38 -0
- data/doc/en/cairo-path-move-to.html +38 -0
- data/doc/en/cairo-path.html +144 -0
- data/doc/en/cairo-pattern-type-mismatch-error.html +36 -0
- data/doc/en/cairo-pattern.html +88 -0
- data/doc/en/cairo-pdf-surface.html +46 -0
- data/doc/en/cairo-point.html +63 -0
- data/doc/en/cairo-ps-level.html +38 -0
- data/doc/en/cairo-ps-surface.html +81 -0
- data/doc/en/cairo-quartz-surface.html +38 -0
- data/doc/en/cairo-radial-pattern.html +49 -0
- data/doc/en/cairo-read-error.html +36 -0
- data/doc/en/cairo-rectangle.html +78 -0
- data/doc/en/cairo-scaled-font.html +73 -0
- data/doc/en/cairo-solid-pattern.html +51 -0
- data/doc/en/cairo-subpixel-order.html +28 -0
- data/doc/en/cairo-surface-finished-error.html +36 -0
- data/doc/en/cairo-surface-pattern.html +46 -0
- data/doc/en/cairo-surface-type-mismatch-error.html +36 -0
- data/doc/en/cairo-surface.html +100 -0
- data/doc/en/cairo-svg-surface.html +66 -0
- data/doc/en/cairo-svg-version.html +38 -0
- data/doc/en/cairo-temp-file-error.html +36 -0
- data/doc/en/cairo-text-extents.html +65 -0
- data/doc/en/cairo-win32-surface.html +43 -0
- data/doc/en/cairo-write-error.html +36 -0
- data/doc/en/cairo.html +109 -0
- data/doc/en/index.html +1058 -0
- data/doc/index.html +18 -0
- data/doc/ja/cairo-antialias.html +43 -0
- data/doc/ja/cairo-clip-not-representable-error.html +42 -0
- data/doc/ja/cairo-color-base.html +61 -0
- data/doc/ja/cairo-color-cmyk.html +138 -0
- data/doc/ja/cairo-color-hsv.html +121 -0
- data/doc/ja/cairo-color-rgb.html +131 -0
- data/doc/ja/cairo-color-x11.html +169 -0
- data/doc/ja/cairo-color.html +303 -0
- data/doc/ja/cairo-content.html +37 -0
- data/doc/ja/cairo-context-blur.html +39 -0
- data/doc/ja/cairo-context-circle.html +40 -0
- data/doc/ja/cairo-context-color.html +38 -0
- data/doc/ja/cairo-context-path.html +63 -0
- data/doc/ja/cairo-context-rectangle.html +46 -0
- data/doc/ja/cairo-context-triangle.html +33 -0
- data/doc/ja/cairo-context.html +1435 -0
- data/doc/ja/cairo-error.html +42 -0
- data/doc/ja/cairo-extend.html +42 -0
- data/doc/ja/cairo-file-not-found.html +37 -0
- data/doc/ja/cairo-fill-rule.html +44 -0
- data/doc/ja/cairo-filter.html +29 -0
- data/doc/ja/cairo-font-extents.html +96 -0
- data/doc/ja/cairo-font-face.html +41 -0
- data/doc/ja/cairo-font-options.html +172 -0
- data/doc/ja/cairo-font-slant.html +36 -0
- data/doc/ja/cairo-font-weight.html +33 -0
- data/doc/ja/cairo-format.html +67 -0
- data/doc/ja/cairo-glyph.html +101 -0
- data/doc/ja/cairo-gradient-pattern.html +105 -0
- data/doc/ja/cairo-hint-metrics.html +43 -0
- data/doc/ja/cairo-hint-style.html +50 -0
- data/doc/ja/cairo-image-surface.html +117 -0
- data/doc/ja/cairo-invalid-content-error.html +40 -0
- data/doc/ja/cairo-invalid-dash-error.html +40 -0
- data/doc/ja/cairo-invalid-dsc-comment-error.html +40 -0
- data/doc/ja/cairo-invalid-format-error.html +40 -0
- data/doc/ja/cairo-invalid-index-error.html +40 -0
- data/doc/ja/cairo-invalid-matrix-error.html +40 -0
- data/doc/ja/cairo-invalid-path-data-error.html +40 -0
- data/doc/ja/cairo-invalid-pop-group-error.html +40 -0
- data/doc/ja/cairo-invalid-restore-error.html +41 -0
- data/doc/ja/cairo-invalid-status-error.html +41 -0
- data/doc/ja/cairo-invalid-stride-error.html +41 -0
- data/doc/ja/cairo-invalid-string-error.html +40 -0
- data/doc/ja/cairo-invalid-visual-error.html +43 -0
- data/doc/ja/cairo-line-cap.html +36 -0
- data/doc/ja/cairo-line-join.html +39 -0
- data/doc/ja/cairo-linear-pattern.html +73 -0
- data/doc/ja/cairo-matrix.html +329 -0
- data/doc/ja/cairo-no-current-point-error.html +40 -0
- data/doc/ja/cairo-null-pointer-error.html +40 -0
- data/doc/ja/cairo-operator.html +37 -0
- data/doc/ja/cairo-paper-parse-error.html +41 -0
- data/doc/ja/cairo-paper-unknown-paper-name.html +62 -0
- data/doc/ja/cairo-paper-unknown-unit.html +61 -0
- data/doc/ja/cairo-paper-unrecognized-paper-description.html +62 -0
- data/doc/ja/cairo-paper.html +343 -0
- data/doc/ja/cairo-path-close-path.html +43 -0
- data/doc/ja/cairo-path-curve-to.html +56 -0
- data/doc/ja/cairo-path-data-type.html +39 -0
- data/doc/ja/cairo-path-data.html +113 -0
- data/doc/ja/cairo-path-line-to.html +48 -0
- data/doc/ja/cairo-path-move-to.html +48 -0
- data/doc/ja/cairo-path.html +130 -0
- data/doc/ja/cairo-pattern-type-mismatch-error.html +42 -0
- data/doc/ja/cairo-pattern.html +114 -0
- data/doc/ja/cairo-pdf-surface.html +72 -0
- data/doc/ja/cairo-point.html +76 -0
- data/doc/ja/cairo-ps-level.html +48 -0
- data/doc/ja/cairo-ps-surface.html +200 -0
- data/doc/ja/cairo-quartz-surface.html +78 -0
- data/doc/ja/cairo-radial-pattern.html +79 -0
- data/doc/ja/cairo-read-error.html +41 -0
- data/doc/ja/cairo-rectangle.html +95 -0
- data/doc/ja/cairo-scaled-font.html +130 -0
- data/doc/ja/cairo-solid-pattern.html +73 -0
- data/doc/ja/cairo-subpixel-order.html +43 -0
- data/doc/ja/cairo-surface-finished-error.html +40 -0
- data/doc/ja/cairo-surface-pattern.html +54 -0
- data/doc/ja/cairo-surface-type-mismatch-error.html +42 -0
- data/doc/ja/cairo-surface.html +177 -0
- data/doc/ja/cairo-svg-surface.html +100 -0
- data/doc/ja/cairo-svg-version.html +52 -0
- data/doc/ja/cairo-temp-file-error.html +36 -0
- data/doc/ja/cairo-text-extents.html +87 -0
- data/doc/ja/cairo-win32-surface.html +86 -0
- data/doc/ja/cairo-write-error.html +41 -0
- data/doc/ja/cairo.html +134 -0
- data/doc/ja/index.html +1059 -0
- data/extconf.rb +53 -17
- data/pkg-config.rb +197 -52
- data/samples/pac.rb +8 -9
- data/samples/pac2.rb +6 -6
- data/samples/png.rb +1 -2
- data/samples/text2.rb +9 -3
- data/src/cairo.def +6 -0
- data/src/lib/cairo.rb +35 -5
- data/src/lib/cairo/paper.rb +183 -0
- data/src/lib/cairo/papers.rb +41 -0
- data/src/rb_cairo.c +4 -3
- data/src/rb_cairo.h +18 -1
- data/src/rb_cairo_constants.c +124 -2
- data/src/rb_cairo_context.c +35 -5
- data/src/rb_cairo_exception.c +23 -1
- data/src/rb_cairo_font_options.c +1 -1
- data/src/rb_cairo_path.c +1 -14
- data/src/rb_cairo_surface.c +301 -82
- data/test/run-test.rb +15 -0
- data/test/test_paper.rb +81 -0
- data/test/test_pkg_config.rb +121 -0
- metadata +187 -3
- data/samples/.#blur.rb.1.1 +0 -36
data/extconf.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
# vim: filetype=ruby:expandtab:shiftwidth=2:tabstop=8:softtabstop=2 :
|
3
3
|
|
4
|
-
$LOAD_PATH.unshift(
|
4
|
+
$LOAD_PATH.unshift(File.dirname(__FILE__))
|
5
5
|
|
6
6
|
require 'English'
|
7
7
|
require 'mkmf'
|
@@ -37,27 +37,36 @@ def check_win32
|
|
37
37
|
end
|
38
38
|
end
|
39
39
|
|
40
|
-
def set_output_lib(target_name)
|
40
|
+
def set_output_lib(target_name, directory=nil)
|
41
41
|
case RUBY_PLATFORM
|
42
42
|
when /cygwin|mingw/
|
43
|
-
filename = "libruby-#{target_name}.a"
|
43
|
+
filename = File.join(*([directory, "libruby-#{target_name}.a"].compact))
|
44
44
|
if RUBY_VERSION > "1.8.0"
|
45
|
-
$DLDFLAGS << ",--out-implib=#{filename}"
|
45
|
+
$DLDFLAGS << ",--out-implib=#{filename}"
|
46
46
|
elsif RUBY_VERSION > "1.8"
|
47
47
|
$DLDFLAGS.gsub!(/ -Wl,--out-implib=[^ ]+/, '')
|
48
|
-
$DLDFLAGS << " -Wl,--out-implib=#{filename}"
|
48
|
+
$DLDFLAGS << " -Wl,--out-implib=#{filename}"
|
49
49
|
else
|
50
50
|
$DLDFLAGS.gsub!(/ --output-lib\s+[^ ]+/, '')
|
51
|
-
$DLDFLAGS << " --output-lib #{filename}"
|
51
|
+
$DLDFLAGS << " --output-lib #{filename}"
|
52
52
|
end
|
53
|
+
$cleanfiles << filename
|
53
54
|
when /mswin32/
|
54
|
-
filename = "libruby-#{target_name}.lib"
|
55
55
|
$DLDFLAGS.gsub!(/ --output-lib\s+[^ ]+/, '')
|
56
56
|
$DLDFLAGS.gsub!(/ \/IMPLIB:[^ ]+/, '')
|
57
|
-
$DLDFLAGS << " /IMPLIB
|
57
|
+
$DLDFLAGS << " /IMPLIB:$(IMPLIB)"
|
58
58
|
when /darwin/
|
59
59
|
if have_macro("CAIRO_HAS_QUARTZ_SURFACE", ["cairo.h"])
|
60
|
-
|
60
|
+
checking_for("RubyCocoa") do
|
61
|
+
begin
|
62
|
+
require 'osx/cocoa'
|
63
|
+
$defs << "-DHAVE_RUBY_COCOA"
|
64
|
+
$DLDFLAGS << " -Wl,-framework,RubyCocoa"
|
65
|
+
true
|
66
|
+
rescue LoadError
|
67
|
+
false
|
68
|
+
end
|
69
|
+
end
|
61
70
|
end
|
62
71
|
end
|
63
72
|
end
|
@@ -74,18 +83,29 @@ PKGConfig.have_package(pkg, major, minor, micro) or exit 1
|
|
74
83
|
have_func("rb_errinfo")
|
75
84
|
|
76
85
|
check_win32
|
77
|
-
|
78
|
-
|
86
|
+
target_name = File.basename(modname)
|
87
|
+
set_output_lib(target_name, ext_dir_name)
|
88
|
+
$defs << "-DRB_CAIRO_COMPILATION"
|
79
89
|
create_makefile(modname, srcdir)
|
80
90
|
|
91
|
+
wine = with_config("wine", false)
|
92
|
+
|
81
93
|
makefile = File.read("Makefile")
|
82
94
|
File.open("Makefile", "w") do |f|
|
83
95
|
objs = []
|
84
96
|
co = nil
|
85
97
|
makefile.each_line do |line|
|
98
|
+
if wine
|
99
|
+
line.gsub!(/\bgcc\b/, "i586-mingw32msvc-gcc")
|
100
|
+
line.gsub!(/C:/, "$(HOME)/.wine/drive_c")
|
101
|
+
line.gsub!(/Z:/, "")
|
102
|
+
end
|
103
|
+
|
86
104
|
case line
|
87
|
-
when /^
|
88
|
-
|
105
|
+
when /^DLLIB\s*=\s*/
|
106
|
+
dllib = $POSTMATCH
|
107
|
+
f.puts("DLLIB = #{ext_dir_name}/#{dllib}")
|
108
|
+
f.puts("IMPLIB = #{ext_dir_name}/libruby-#{dllib.gsub(/\..+?$/, '.lib')}")
|
89
109
|
when /^(SRCS)\s*=\s*/
|
90
110
|
name = $1
|
91
111
|
vars = $POSTMATCH.split.collect {|var| "$(srcdir)/#{var}"}.join(" ")
|
@@ -96,20 +116,36 @@ File.open("Makefile", "w") do |f|
|
|
96
116
|
objs = vars if name == "OBJS"
|
97
117
|
vars = vars.join(" ")
|
98
118
|
f.puts("#{name} = #{vars}")
|
119
|
+
when /^LDSHARED\s*=/
|
120
|
+
def_file = "#{ext_dir_name}/#{target_name}.def"
|
121
|
+
line.gsub!(/\b-shared\b/, "-shared #{def_file}") if wine
|
122
|
+
f.puts(line)
|
99
123
|
when /^\t\$\(CC\)/
|
100
|
-
|
124
|
+
if PKGConfig.msvc?
|
125
|
+
output_option = "-Fo"
|
126
|
+
else
|
127
|
+
output_option = "-o"
|
128
|
+
end
|
129
|
+
unless /#{Regexp.escape(output_option)}/ =~ line
|
130
|
+
line = "#{line.chomp} #{output_option}$@"
|
131
|
+
end
|
101
132
|
co = line
|
102
133
|
f.puts(line)
|
103
134
|
else
|
104
|
-
f.
|
135
|
+
f.puts(line)
|
105
136
|
end
|
106
137
|
end
|
107
138
|
|
108
139
|
if co and !objs.empty?
|
109
140
|
f.puts
|
110
|
-
|
111
|
-
f.puts "
|
141
|
+
if PKGConfig.msvc?
|
142
|
+
f.puts "{$(srcdir)}.c{#{ext_dir_name}}.obj:"
|
112
143
|
f.puts co
|
144
|
+
else
|
145
|
+
objs.each do |obj|
|
146
|
+
f.puts "#{obj}: $(srcdir)/#{File.basename(obj).sub(/\..+?$/, '.c')}"
|
147
|
+
f.puts co
|
148
|
+
end
|
113
149
|
end
|
114
150
|
end
|
115
151
|
end
|
data/pkg-config.rb
CHANGED
@@ -1,89 +1,232 @@
|
|
1
|
-
|
2
|
-
# pkg-config.rb
|
3
|
-
#
|
4
|
-
# Wrapper of pkg-config tool.
|
5
|
-
#
|
6
|
-
# Copyright(C) 2003-2005 Ruby-GNOME2 Project.
|
7
|
-
#
|
8
|
-
# This program is licenced under the same
|
9
|
-
# license of Ruby-GNOME2.
|
10
|
-
#
|
1
|
+
require "rbconfig"
|
11
2
|
|
12
3
|
require 'mkmf'
|
13
4
|
require 'shellwords'
|
5
|
+
require 'English'
|
6
|
+
require 'pathname'
|
14
7
|
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
8
|
+
class PackageConfig
|
9
|
+
attr_accessor :msvc_syntax
|
10
|
+
def initialize(name, path=nil, msvc_syntax=false)
|
11
|
+
@name = name
|
12
|
+
@path = path || ENV["PKG_CONFIG_PATH"]
|
13
|
+
@path = [@path, guess_default_path].compact.join(separator)
|
14
|
+
@msvc_syntax = msvc_syntax
|
15
|
+
@variables = @declarations = nil
|
16
|
+
override_variables = with_config("override-variables", "")
|
17
|
+
@override_variables = parse_override_variables(override_variables)
|
19
18
|
end
|
20
19
|
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
@@list[pkg] = [name, desc]
|
25
|
-
}
|
20
|
+
def exist?
|
21
|
+
not pc.nil?
|
22
|
+
end
|
26
23
|
|
27
|
-
|
28
|
-
|
29
|
-
system("#{@@cmd} --exists #{pkg}")
|
24
|
+
def requires
|
25
|
+
parse_requires(declaration("Requires"))
|
30
26
|
end
|
31
27
|
|
32
|
-
def
|
33
|
-
|
28
|
+
def requires_private
|
29
|
+
parse_requires(declaration("Requires.private"))
|
34
30
|
end
|
35
31
|
|
36
|
-
def
|
37
|
-
|
32
|
+
def cflags
|
33
|
+
path_flags, other_flags = collect_cflags
|
34
|
+
(other_flags + path_flags).join(" ")
|
38
35
|
end
|
39
36
|
|
40
|
-
def
|
41
|
-
|
37
|
+
def cflags_only_I
|
38
|
+
collect_cflags[0].join(" ")
|
42
39
|
end
|
43
40
|
|
44
|
-
def
|
45
|
-
|
41
|
+
def libs
|
42
|
+
path_flags, other_flags = collect_libs
|
43
|
+
(other_flags + path_flags).join(" ")
|
46
44
|
end
|
47
45
|
|
48
|
-
def
|
49
|
-
|
46
|
+
def libs_only_l
|
47
|
+
collect_libs[1].find_all do |arg|
|
48
|
+
if @msvc_syntax
|
49
|
+
/\.lib\z/ =~ arg
|
50
|
+
else
|
51
|
+
/\A-l/ =~ arg
|
52
|
+
end
|
53
|
+
end.join(" ")
|
50
54
|
end
|
51
55
|
|
52
|
-
def
|
53
|
-
|
56
|
+
def version
|
57
|
+
declaration("Version")
|
54
58
|
end
|
55
59
|
|
56
|
-
def variable(
|
57
|
-
|
60
|
+
def variable(name)
|
61
|
+
parse_pc if @variables.nil?
|
62
|
+
expand_value(@override_variables[name] || @variables[name])
|
58
63
|
end
|
59
64
|
|
60
|
-
def
|
61
|
-
|
65
|
+
def declaration(name)
|
66
|
+
parse_pc if @declarations.nil?
|
67
|
+
expand_value(@declarations[name])
|
62
68
|
end
|
63
69
|
|
64
|
-
|
65
|
-
|
70
|
+
private
|
71
|
+
def pc
|
72
|
+
@path.split(separator).each do |path|
|
73
|
+
pc_name = File.join(path, "#{@name}.pc")
|
74
|
+
return pc_name if File.exist?(pc_name)
|
75
|
+
end
|
76
|
+
return nil
|
77
|
+
end
|
78
|
+
|
79
|
+
def separator
|
80
|
+
File.expand_path(".").index(":") ? ";" : ":"
|
81
|
+
end
|
82
|
+
|
83
|
+
def collect_cflags
|
84
|
+
all_cflags = (requires_private + requires.reverse).collect do |package|
|
85
|
+
self.class.new(package, @path, @msvc_syntax).cflags
|
86
|
+
end
|
87
|
+
all_cflags = [declaration("Cflags")] + all_cflags
|
88
|
+
all_cflags = all_cflags.join(" ").gsub(/-I /, '-I').split.uniq
|
89
|
+
path_flags, other_flags = all_cflags.partition {|flag| /\A-I/ =~ flag}
|
90
|
+
path_flags = path_flags.reject do |flag|
|
91
|
+
flag == "-I/usr/include"
|
92
|
+
end
|
93
|
+
if @msvc_syntax
|
94
|
+
path_flags = path_flags.collect do |flag|
|
95
|
+
flag.gsub(/\A-I/, "/I")
|
96
|
+
end
|
97
|
+
end
|
98
|
+
[path_flags, other_flags]
|
99
|
+
end
|
100
|
+
|
101
|
+
def collect_libs
|
102
|
+
all_libs = requires.collect do |package|
|
103
|
+
self.class.new(package, @path, @msvc_syntax).libs
|
104
|
+
end
|
105
|
+
all_libs = [declaration("Libs")] + all_libs
|
106
|
+
all_libs = all_libs.join(" ").gsub(/-([Ll]) /, '\1').split.uniq
|
107
|
+
path_flags, other_flags = all_libs.partition {|flag| /\A-L/ =~ flag}
|
108
|
+
path_flags = path_flags.reject do |flag|
|
109
|
+
/\A-L\/usr\/lib(?:64)?\z/ =~ flag
|
110
|
+
end
|
111
|
+
if @msvc_syntax
|
112
|
+
path_flags = path_flags.collect do |flag|
|
113
|
+
flag.gsub(/\A-L/, "/libpath:")
|
114
|
+
end
|
115
|
+
other_flags = other_flags.collect do |flag|
|
116
|
+
if /\A-l/ =~ flag
|
117
|
+
"#{$POSTMATCH}.lib"
|
118
|
+
else
|
119
|
+
flag
|
120
|
+
end
|
121
|
+
end
|
122
|
+
end
|
123
|
+
[path_flags, other_flags]
|
124
|
+
end
|
125
|
+
|
126
|
+
IDENTIFIER_RE = /[\w\d_.]+/
|
127
|
+
def parse_pc
|
128
|
+
raise ".pc for #{@name} doesn't exist." unless exist?
|
129
|
+
@variables = {}
|
130
|
+
@declarations = {}
|
131
|
+
File.open(pc) do |input|
|
132
|
+
input.each_line do |line|
|
133
|
+
line = line.gsub(/#.*/, '').strip
|
134
|
+
next if line.empty?
|
135
|
+
case line
|
136
|
+
when /^(#{IDENTIFIER_RE})=/
|
137
|
+
@variables[$1] = $POSTMATCH.strip
|
138
|
+
when /^(#{IDENTIFIER_RE}):/
|
139
|
+
@declarations[$1] = $POSTMATCH.strip
|
140
|
+
end
|
141
|
+
end
|
142
|
+
end
|
143
|
+
end
|
144
|
+
|
145
|
+
def parse_requires(requires)
|
146
|
+
return [] if requires.nil?
|
147
|
+
requires_without_version = requires.gsub(/[<>]?=\s*[\d.]+\s*/, '')
|
148
|
+
requires_without_version.split(/[,\s]+/)
|
149
|
+
end
|
150
|
+
|
151
|
+
def parse_override_variables(override_variables)
|
152
|
+
variables = {}
|
153
|
+
override_variables.split(",").each do |variable|
|
154
|
+
name, value = variable.split("=", 2)
|
155
|
+
variables[name] = value
|
156
|
+
end
|
157
|
+
variables
|
158
|
+
end
|
159
|
+
|
160
|
+
def expand_value(value)
|
161
|
+
return nil if value.nil?
|
162
|
+
value.gsub(/\$\{(#{IDENTIFIER_RE})\}/) do
|
163
|
+
variable($1)
|
164
|
+
end
|
165
|
+
end
|
166
|
+
|
167
|
+
def guess_default_path
|
168
|
+
default_path = "/usr/local/lib/pkgconfig:/usr/lib/pkgconfig"
|
169
|
+
pkg_config = with_config("pkg-config", ENV["PKG_CONFIG"] || "pkg-config")
|
170
|
+
pkg_config = Pathname.new(pkg_config)
|
171
|
+
unless pkg_config.absolute?
|
172
|
+
require "dl/import"
|
173
|
+
dln = Module.new
|
174
|
+
dln.module_eval do
|
175
|
+
if DL.const_defined?(:Importer)
|
176
|
+
extend DL::Importer
|
177
|
+
else
|
178
|
+
extend DL::Importable
|
179
|
+
end
|
180
|
+
begin
|
181
|
+
dlload RbConfig::CONFIG["LIBRUBY"]
|
182
|
+
rescue RuntimeError
|
183
|
+
return default_path if $!.message == "unknown error"
|
184
|
+
raise
|
185
|
+
rescue DL::DLError
|
186
|
+
return default_path
|
187
|
+
end
|
188
|
+
extern "const char *dln_find_exe(const char *, const char *)"
|
189
|
+
end
|
190
|
+
pkg_config = dln.dln_find_exe(pkg_config.to_s, nil)
|
191
|
+
return default_path if pkg_config.nil?
|
192
|
+
pkg_config = Pathname.new(pkg_config)
|
193
|
+
end
|
194
|
+
(pkg_config.parent.parent + "lib" + "pkgconfig").to_s
|
195
|
+
end
|
196
|
+
end
|
197
|
+
|
198
|
+
module PKGConfig
|
199
|
+
module_function
|
200
|
+
def msvc?
|
201
|
+
/mswin32/.match(RUBY_PLATFORM) and /^cl\b/.match(Config::CONFIG['CC'])
|
66
202
|
end
|
67
203
|
|
68
|
-
def
|
69
|
-
|
70
|
-
@@list.keys.collect{|key| [key] + @@list[key]}.sort
|
204
|
+
def package_config(package)
|
205
|
+
PackageConfig.new(package, nil, msvc?)
|
71
206
|
end
|
72
207
|
|
73
|
-
def
|
74
|
-
|
208
|
+
def exist?(pkg)
|
209
|
+
package_config(pkg).exist?
|
75
210
|
end
|
76
211
|
|
77
|
-
def
|
78
|
-
|
212
|
+
def libs(pkg)
|
213
|
+
package_config(pkg).libs
|
79
214
|
end
|
80
215
|
|
81
|
-
def
|
82
|
-
|
216
|
+
def libs_only_l(pkg)
|
217
|
+
package_config(pkg).libs_only_l
|
83
218
|
end
|
84
219
|
|
85
|
-
def
|
86
|
-
|
220
|
+
def cflags(pkg)
|
221
|
+
package_config(pkg).cflags
|
222
|
+
end
|
223
|
+
|
224
|
+
def cflags_only_I(pkg)
|
225
|
+
package_config(pkg).cflags_only_I
|
226
|
+
end
|
227
|
+
|
228
|
+
def modversion(pkg)
|
229
|
+
package_config(pkg).version
|
87
230
|
end
|
88
231
|
|
89
232
|
def check_version?(pkg, major = 0, minor = 0, micro = 0)
|
@@ -109,7 +252,9 @@ module PKGConfig
|
|
109
252
|
STDOUT.print "yes\n"
|
110
253
|
libraries = libs_only_l(pkg)
|
111
254
|
dldflags = libs(pkg)
|
112
|
-
dldflags = (Shellwords.shellwords(dldflags) -
|
255
|
+
dldflags = (Shellwords.shellwords(dldflags) -
|
256
|
+
Shellwords.shellwords(libraries))
|
257
|
+
dldflags = dldflags.map {|s| /\s/ =~ s ? "\"#{s}\"" : s }.join(' ')
|
113
258
|
$libs += ' ' + libraries
|
114
259
|
if /mswin32/ =~ RUBY_PLATFORM
|
115
260
|
$DLDFLAGS += ' ' + dldflags
|
data/samples/pac.rb
CHANGED
@@ -11,14 +11,13 @@ $LOAD_PATH.unshift File.join(src, "lib")
|
|
11
11
|
|
12
12
|
require "cairo"
|
13
13
|
|
14
|
-
|
15
|
-
HEIGHT = 595.275590551181
|
14
|
+
paper = Cairo::Paper::A4_LANDSCAPE
|
16
15
|
|
17
16
|
def pac(surface)
|
18
17
|
cr = Cairo::Context.new(surface)
|
19
18
|
|
20
19
|
cr.set_source_color(:black)
|
21
|
-
cr.
|
20
|
+
cr.paint
|
22
21
|
|
23
22
|
# Wall
|
24
23
|
cr.set_source_color(:magenta)
|
@@ -79,15 +78,15 @@ def pac(surface)
|
|
79
78
|
cr.show_page
|
80
79
|
end
|
81
80
|
|
82
|
-
Cairo::ImageSurface.new(
|
81
|
+
Cairo::ImageSurface.new(*paper.size("pt")) do |surface|
|
83
82
|
cr = pac(surface)
|
84
83
|
cr.target.write_to_png("pac.png")
|
85
84
|
end
|
86
85
|
|
87
|
-
def scalable_surface_output(surface_class_name, suffix)
|
86
|
+
def scalable_surface_output(surface_class_name, paper, suffix)
|
88
87
|
if Cairo.const_defined?(surface_class_name)
|
89
88
|
surface_class = Cairo.const_get(surface_class_name)
|
90
|
-
surface_class.new("pac.#{suffix}",
|
89
|
+
surface_class.new("pac.#{suffix}", paper) do |surface|
|
91
90
|
pac(surface)
|
92
91
|
end
|
93
92
|
else
|
@@ -95,6 +94,6 @@ def scalable_surface_output(surface_class_name, suffix)
|
|
95
94
|
end
|
96
95
|
end
|
97
96
|
|
98
|
-
scalable_surface_output("PSSurface", "ps")
|
99
|
-
scalable_surface_output("PDFSurface", "pdf")
|
100
|
-
scalable_surface_output("SVGSurface", "svg")
|
97
|
+
scalable_surface_output("PSSurface", paper, "ps")
|
98
|
+
scalable_surface_output("PDFSurface", paper, "pdf")
|
99
|
+
scalable_surface_output("SVGSurface", paper, "svg")
|