rroonga 0.9.2-x86-mingw32

Sign up to get free protection for your applications and to get access to all the features.
Files changed (199) hide show
  1. data/AUTHORS +5 -0
  2. data/NEWS.ja.rdoc +114 -0
  3. data/NEWS.rdoc +116 -0
  4. data/README.ja.rdoc +65 -0
  5. data/README.rdoc +66 -0
  6. data/Rakefile +206 -0
  7. data/benchmark/common.rb +49 -0
  8. data/benchmark/read-write-many-small-items.rb +144 -0
  9. data/benchmark/write-many-small-items.rb +135 -0
  10. data/example/bookmark.rb +161 -0
  11. data/example/index-html.rb +89 -0
  12. data/example/search/config.ru +230 -0
  13. data/example/search/public/css/groonga.css +122 -0
  14. data/ext/.gitignore +2 -0
  15. data/ext/groonga/extconf.rb +93 -0
  16. data/ext/groonga/rb-grn-accessor.c +52 -0
  17. data/ext/groonga/rb-grn-array-cursor.c +36 -0
  18. data/ext/groonga/rb-grn-array.c +210 -0
  19. data/ext/groonga/rb-grn-column.c +573 -0
  20. data/ext/groonga/rb-grn-context.c +662 -0
  21. data/ext/groonga/rb-grn-database.c +472 -0
  22. data/ext/groonga/rb-grn-encoding-support.c +64 -0
  23. data/ext/groonga/rb-grn-encoding.c +257 -0
  24. data/ext/groonga/rb-grn-exception.c +1110 -0
  25. data/ext/groonga/rb-grn-expression-builder.c +75 -0
  26. data/ext/groonga/rb-grn-expression.c +731 -0
  27. data/ext/groonga/rb-grn-fix-size-column.c +166 -0
  28. data/ext/groonga/rb-grn-hash-cursor.c +38 -0
  29. data/ext/groonga/rb-grn-hash.c +294 -0
  30. data/ext/groonga/rb-grn-index-column.c +488 -0
  31. data/ext/groonga/rb-grn-logger.c +504 -0
  32. data/ext/groonga/rb-grn-object.c +1369 -0
  33. data/ext/groonga/rb-grn-operation.c +198 -0
  34. data/ext/groonga/rb-grn-patricia-trie-cursor.c +39 -0
  35. data/ext/groonga/rb-grn-patricia-trie.c +488 -0
  36. data/ext/groonga/rb-grn-procedure.c +52 -0
  37. data/ext/groonga/rb-grn-query.c +260 -0
  38. data/ext/groonga/rb-grn-record.c +40 -0
  39. data/ext/groonga/rb-grn-snippet.c +334 -0
  40. data/ext/groonga/rb-grn-table-cursor-key-support.c +69 -0
  41. data/ext/groonga/rb-grn-table-cursor.c +247 -0
  42. data/ext/groonga/rb-grn-table-key-support.c +714 -0
  43. data/ext/groonga/rb-grn-table.c +1977 -0
  44. data/ext/groonga/rb-grn-type.c +181 -0
  45. data/ext/groonga/rb-grn-utils.c +769 -0
  46. data/ext/groonga/rb-grn-variable-size-column.c +36 -0
  47. data/ext/groonga/rb-grn-variable.c +108 -0
  48. data/ext/groonga/rb-grn-view-accessor.c +53 -0
  49. data/ext/groonga/rb-grn-view-cursor.c +35 -0
  50. data/ext/groonga/rb-grn-view-record.c +41 -0
  51. data/ext/groonga/rb-grn-view.c +421 -0
  52. data/ext/groonga/rb-grn.h +698 -0
  53. data/ext/groonga/rb-groonga.c +107 -0
  54. data/extconf.rb +130 -0
  55. data/html/bar.svg +153 -0
  56. data/html/developer.html +117 -0
  57. data/html/developer.svg +469 -0
  58. data/html/download.svg +253 -0
  59. data/html/favicon.ico +0 -0
  60. data/html/favicon.xcf +0 -0
  61. data/html/footer.html.erb +28 -0
  62. data/html/head.html.erb +4 -0
  63. data/html/header.html.erb +17 -0
  64. data/html/index.html +147 -0
  65. data/html/install.svg +636 -0
  66. data/html/logo.xcf +0 -0
  67. data/html/ranguba.css +250 -0
  68. data/html/tutorial.svg +559 -0
  69. data/lib/1.8/groonga.so +0 -0
  70. data/lib/1.9/groonga.so +0 -0
  71. data/lib/groonga.rb +90 -0
  72. data/lib/groonga/context.rb +184 -0
  73. data/lib/groonga/expression-builder.rb +324 -0
  74. data/lib/groonga/patricia-trie.rb +85 -0
  75. data/lib/groonga/record.rb +311 -0
  76. data/lib/groonga/schema.rb +1191 -0
  77. data/lib/groonga/view-record.rb +56 -0
  78. data/license/GPL +340 -0
  79. data/license/LGPL +504 -0
  80. data/license/RUBY +59 -0
  81. data/misc/grnop2ruby.rb +49 -0
  82. data/pkg-config.rb +333 -0
  83. data/rroonga-build.rb +57 -0
  84. data/test-unit/Rakefile +40 -0
  85. data/test-unit/TODO +5 -0
  86. data/test-unit/bin/testrb +5 -0
  87. data/test-unit/html/classic.html +15 -0
  88. data/test-unit/html/index.html +25 -0
  89. data/test-unit/html/index.html.ja +27 -0
  90. data/test-unit/lib/test/unit.rb +323 -0
  91. data/test-unit/lib/test/unit/assertionfailederror.rb +25 -0
  92. data/test-unit/lib/test/unit/assertions.rb +1230 -0
  93. data/test-unit/lib/test/unit/attribute.rb +125 -0
  94. data/test-unit/lib/test/unit/autorunner.rb +360 -0
  95. data/test-unit/lib/test/unit/collector.rb +36 -0
  96. data/test-unit/lib/test/unit/collector/descendant.rb +23 -0
  97. data/test-unit/lib/test/unit/collector/dir.rb +108 -0
  98. data/test-unit/lib/test/unit/collector/load.rb +144 -0
  99. data/test-unit/lib/test/unit/collector/objectspace.rb +34 -0
  100. data/test-unit/lib/test/unit/color-scheme.rb +102 -0
  101. data/test-unit/lib/test/unit/color.rb +96 -0
  102. data/test-unit/lib/test/unit/diff.rb +724 -0
  103. data/test-unit/lib/test/unit/error.rb +130 -0
  104. data/test-unit/lib/test/unit/exceptionhandler.rb +39 -0
  105. data/test-unit/lib/test/unit/failure.rb +136 -0
  106. data/test-unit/lib/test/unit/fixture.rb +176 -0
  107. data/test-unit/lib/test/unit/notification.rb +129 -0
  108. data/test-unit/lib/test/unit/omission.rb +191 -0
  109. data/test-unit/lib/test/unit/pending.rb +150 -0
  110. data/test-unit/lib/test/unit/priority.rb +180 -0
  111. data/test-unit/lib/test/unit/runner/console.rb +52 -0
  112. data/test-unit/lib/test/unit/runner/emacs.rb +8 -0
  113. data/test-unit/lib/test/unit/runner/tap.rb +8 -0
  114. data/test-unit/lib/test/unit/testcase.rb +476 -0
  115. data/test-unit/lib/test/unit/testresult.rb +89 -0
  116. data/test-unit/lib/test/unit/testsuite.rb +110 -0
  117. data/test-unit/lib/test/unit/ui/console/outputlevel.rb +14 -0
  118. data/test-unit/lib/test/unit/ui/console/testrunner.rb +466 -0
  119. data/test-unit/lib/test/unit/ui/emacs/testrunner.rb +63 -0
  120. data/test-unit/lib/test/unit/ui/tap/testrunner.rb +92 -0
  121. data/test-unit/lib/test/unit/ui/testrunner.rb +28 -0
  122. data/test-unit/lib/test/unit/ui/testrunnermediator.rb +77 -0
  123. data/test-unit/lib/test/unit/ui/testrunnerutilities.rb +41 -0
  124. data/test-unit/lib/test/unit/util/backtracefilter.rb +41 -0
  125. data/test-unit/lib/test/unit/util/method-owner-finder.rb +28 -0
  126. data/test-unit/lib/test/unit/util/observable.rb +90 -0
  127. data/test-unit/lib/test/unit/util/procwrapper.rb +48 -0
  128. data/test-unit/lib/test/unit/version.rb +7 -0
  129. data/test-unit/sample/adder.rb +13 -0
  130. data/test-unit/sample/subtracter.rb +12 -0
  131. data/test-unit/sample/test_adder.rb +20 -0
  132. data/test-unit/sample/test_subtracter.rb +20 -0
  133. data/test-unit/sample/test_user.rb +23 -0
  134. data/test-unit/test/collector/test-descendant.rb +133 -0
  135. data/test-unit/test/collector/test-load.rb +442 -0
  136. data/test-unit/test/collector/test_dir.rb +406 -0
  137. data/test-unit/test/collector/test_objectspace.rb +100 -0
  138. data/test-unit/test/run-test.rb +15 -0
  139. data/test-unit/test/test-attribute.rb +86 -0
  140. data/test-unit/test/test-color-scheme.rb +67 -0
  141. data/test-unit/test/test-color.rb +47 -0
  142. data/test-unit/test/test-diff.rb +518 -0
  143. data/test-unit/test/test-emacs-runner.rb +60 -0
  144. data/test-unit/test/test-fixture.rb +287 -0
  145. data/test-unit/test/test-notification.rb +33 -0
  146. data/test-unit/test/test-omission.rb +81 -0
  147. data/test-unit/test/test-pending.rb +70 -0
  148. data/test-unit/test/test-priority.rb +119 -0
  149. data/test-unit/test/test-testcase.rb +544 -0
  150. data/test-unit/test/test_assertions.rb +1151 -0
  151. data/test-unit/test/test_error.rb +26 -0
  152. data/test-unit/test/test_failure.rb +33 -0
  153. data/test-unit/test/test_testresult.rb +113 -0
  154. data/test-unit/test/test_testsuite.rb +129 -0
  155. data/test-unit/test/testunit-test-util.rb +14 -0
  156. data/test-unit/test/ui/test_testrunmediator.rb +20 -0
  157. data/test-unit/test/util/test-method-owner-finder.rb +38 -0
  158. data/test-unit/test/util/test_backtracefilter.rb +41 -0
  159. data/test-unit/test/util/test_observable.rb +102 -0
  160. data/test-unit/test/util/test_procwrapper.rb +36 -0
  161. data/test/.gitignore +1 -0
  162. data/test/groonga-test-utils.rb +134 -0
  163. data/test/run-test.rb +58 -0
  164. data/test/test-array.rb +90 -0
  165. data/test/test-column.rb +316 -0
  166. data/test/test-context-select.rb +93 -0
  167. data/test/test-context.rb +73 -0
  168. data/test/test-database.rb +113 -0
  169. data/test/test-encoding.rb +33 -0
  170. data/test/test-exception.rb +93 -0
  171. data/test/test-expression-builder.rb +217 -0
  172. data/test/test-expression.rb +134 -0
  173. data/test/test-fix-size-column.rb +65 -0
  174. data/test/test-gqtp.rb +72 -0
  175. data/test/test-hash.rb +305 -0
  176. data/test/test-index-column.rb +81 -0
  177. data/test/test-logger.rb +37 -0
  178. data/test/test-patricia-trie.rb +205 -0
  179. data/test/test-procedure.rb +37 -0
  180. data/test/test-query.rb +22 -0
  181. data/test/test-record.rb +243 -0
  182. data/test/test-remote.rb +54 -0
  183. data/test/test-schema-view.rb +90 -0
  184. data/test/test-schema.rb +459 -0
  185. data/test/test-snippet.rb +130 -0
  186. data/test/test-table-cursor.rb +153 -0
  187. data/test/test-table-offset-and-limit.rb +102 -0
  188. data/test/test-table-select-normalize.rb +53 -0
  189. data/test/test-table-select.rb +150 -0
  190. data/test/test-table.rb +594 -0
  191. data/test/test-type.rb +71 -0
  192. data/test/test-variable-size-column.rb +98 -0
  193. data/test/test-variable.rb +28 -0
  194. data/test/test-vector-column.rb +76 -0
  195. data/test/test-version.rb +31 -0
  196. data/test/test-view.rb +72 -0
  197. data/text/TUTORIAL.ja.rdoc +392 -0
  198. data/text/expression.rdoc +284 -0
  199. metadata +276 -0
data/license/RUBY ADDED
@@ -0,0 +1,59 @@
1
+ Rcairo is copyrighted free software by the persons listed in AUTHORS
2
+ distributed under the same conditions as ruby; which follow:
3
+
4
+ Ruby is copyrighted free software by Yukihiro Matsumoto <matz@netlab.jp>.
5
+ You can redistribute it and/or modify it under either the terms of the GPL
6
+ (see the file GPL), or the conditions below:
7
+
8
+ 1. You may make and give away verbatim copies of the source form of the
9
+ software without restriction, provided that you duplicate all of the
10
+ original copyright notices and associated disclaimers.
11
+
12
+ 2. You may modify your copy of the software in any way, provided that
13
+ you do at least ONE of the following:
14
+
15
+ a) place your modifications in the Public Domain or otherwise
16
+ make them Freely Available, such as by posting said
17
+ modifications to Usenet or an equivalent medium, or by allowing
18
+ the author to include your modifications in the software.
19
+
20
+ b) use the modified software only within your corporation or
21
+ organization.
22
+
23
+ c) give non-standard binaries non-standard names, with
24
+ instructions on where to get the original software distribution.
25
+
26
+ d) make other distribution arrangements with the author.
27
+
28
+ 3. You may distribute the software in object code or binary form,
29
+ provided that you do at least ONE of the following:
30
+
31
+ a) distribute the binaries and library files of the software,
32
+ together with instructions (in the manual page or equivalent)
33
+ on where to get the original distribution.
34
+
35
+ b) accompany the distribution with the machine-readable source of
36
+ the software.
37
+
38
+ c) give non-standard binaries non-standard names, with
39
+ instructions on where to get the original software distribution.
40
+
41
+ d) make other distribution arrangements with the author.
42
+
43
+ 4. You may modify and include the part of the software into any other
44
+ software (possibly commercial). But some files in the distribution
45
+ are not written by the author, so that they are not under these terms.
46
+
47
+ For the list of those files and their copying conditions, see the
48
+ file LEGAL.
49
+
50
+ 5. The scripts and library files supplied as input to or produced as
51
+ output from the software do not automatically fall under the
52
+ copyright of the software, but belong to whomever generated them,
53
+ and may be sold commercially, and may be aggregated with this
54
+ software.
55
+
56
+ 6. THIS SOFTWARE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR
57
+ IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
58
+ WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
59
+ PURPOSE.
@@ -0,0 +1,49 @@
1
+ # -*- coding: utf-8 -*-
2
+ #
3
+ # Copyright (C) 2009 Yuto Hayamizu <y.hayamizu@gmail.com>
4
+ #
5
+ # This library is free software; you can redistribute it and/or
6
+ # modify it under the terms of the GNU Lesser General Public
7
+ # License version 2.1 as published by the Free Software Foundation.
8
+ #
9
+ # This library is distributed in the hope that it will be useful,
10
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
11
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12
+ # Lesser General Public License for more details.
13
+ #
14
+ # You should have received a copy of the GNU Lesser General Public
15
+ # License along with this library; if not, write to the Free Software
16
+ # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17
+
18
+ #
19
+ # This script expects "groonga.h" as a first argument, extracts the
20
+ # 'grn_operator', and write 'rb_define_const's of 'grn_operator' to
21
+ # standard outout.
22
+ #
23
+ # Usage:
24
+ # ruby grnop2ruby.rb /path/to/groonga.h
25
+ #
26
+
27
+ replace_dictionary = {
28
+ "VAR" => "VARIABLE",
29
+ "EXPR" => "EXPRESSION",
30
+ "NOP" => "NO_OPERATION",
31
+ "REF" => "REFERENCE",
32
+ "OBJ" => "OBJECT",
33
+ "INCR" => "INCREMENT",
34
+ "DECR" => "DECREMENT",
35
+ "MOD" => "MODULO",
36
+ "LCP" => "LONGEST_COMMON_PREFIX",
37
+ }
38
+
39
+ ARGF.each_line do |line|
40
+ case line
41
+ when /\A\s+(GRN_OP_\w+)/
42
+ operator = $1
43
+ rb_operator = operator.gsub(/\AGRN_OP_/, "").split("_").map{ |word|
44
+ replace_dictionary[word] || word
45
+ }.join("_")
46
+ puts " rb_define_const(rb_mGrnOperation, \"%s\",
47
+ UINT2NUM(%s));" % [rb_operator, operator]
48
+ end
49
+ end
data/pkg-config.rb ADDED
@@ -0,0 +1,333 @@
1
+ # Copyright 2008-2009 Kouhei Sutou <kou@cozmixng.org>
2
+ # This file is made available under the same terms as Ruby.
3
+
4
+ require "rbconfig"
5
+
6
+ require 'mkmf'
7
+ require 'shellwords'
8
+ require 'English'
9
+ require 'pathname'
10
+
11
+ class PackageConfig
12
+ @@default_prepend_paths = []
13
+ @@default_append_paths = []
14
+
15
+ class << self
16
+ def prepend_default_path(path)
17
+ @@default_prepend_paths.unshift(path)
18
+ end
19
+
20
+ def append_default_path(path)
21
+ @@default_append_paths << path
22
+ end
23
+ end
24
+
25
+ attr_accessor :msvc_syntax
26
+ def initialize(name, path=nil, msvc_syntax=false)
27
+ @name = name
28
+ @path = path || ENV["PKG_CONFIG_PATH"]
29
+ @path = [@path, guess_default_path].compact.join(separator)
30
+ @msvc_syntax = msvc_syntax
31
+ @variables = @declarations = nil
32
+ override_variables = with_config("override-variables", "")
33
+ @override_variables = parse_override_variables(override_variables)
34
+ end
35
+
36
+ def exist?
37
+ not pc.nil?
38
+ end
39
+
40
+ def requires
41
+ parse_requires(declaration("Requires"))
42
+ end
43
+
44
+ def requires_private
45
+ parse_requires(declaration("Requires.private"))
46
+ end
47
+
48
+ def cflags
49
+ path_flags, other_flags = collect_cflags
50
+ (other_flags + path_flags).join(" ")
51
+ end
52
+
53
+ def cflags_only_I
54
+ collect_cflags[0].join(" ")
55
+ end
56
+
57
+ def libs
58
+ path_flags, other_flags = collect_libs
59
+ (other_flags + path_flags).join(" ")
60
+ end
61
+
62
+ def libs_only_l
63
+ collect_libs[1].find_all do |arg|
64
+ if @msvc_syntax
65
+ /\.lib\z/ =~ arg
66
+ else
67
+ /\A-l/ =~ arg
68
+ end
69
+ end.join(" ")
70
+ end
71
+
72
+ def version
73
+ declaration("Version")
74
+ end
75
+
76
+ def variable(name)
77
+ parse_pc if @variables.nil?
78
+ expand_value(@override_variables[name] || @variables[name])
79
+ end
80
+
81
+ def declaration(name)
82
+ parse_pc if @declarations.nil?
83
+ expand_value(@declarations[name])
84
+ end
85
+
86
+ private
87
+ def paths
88
+ paths = @@default_prepend_paths
89
+ paths += @path.split(separator)
90
+ paths += @@default_append_paths
91
+ paths
92
+ end
93
+
94
+ def pc
95
+ paths.each do |path|
96
+ pc_name = File.join(path, "#{@name}.pc")
97
+ return pc_name if File.exist?(pc_name)
98
+ end
99
+ return nil
100
+ end
101
+
102
+ def separator
103
+ File.expand_path(".").index(":") ? ";" : ":"
104
+ end
105
+
106
+ def collect_cflags
107
+ all_cflags = (requires_private + requires.reverse).collect do |package|
108
+ self.class.new(package, @path, @msvc_syntax).cflags
109
+ end
110
+ all_cflags = [declaration("Cflags")] + all_cflags
111
+ all_cflags = all_cflags.join(" ").gsub(/-I /, '-I').split.uniq
112
+ path_flags, other_flags = all_cflags.partition {|flag| /\A-I/ =~ flag}
113
+ path_flags = path_flags.reject do |flag|
114
+ flag == "-I/usr/include"
115
+ end
116
+ if @msvc_syntax
117
+ path_flags = path_flags.collect do |flag|
118
+ flag.gsub(/\A-I/, "/I")
119
+ end
120
+ end
121
+ [path_flags, other_flags]
122
+ end
123
+
124
+ def collect_libs
125
+ all_libs = requires.collect do |package|
126
+ self.class.new(package, @path, @msvc_syntax).libs
127
+ end
128
+ all_libs = [declaration("Libs")] + all_libs
129
+ all_libs = all_libs.join(" ").gsub(/-([Ll]) /, '\1').split.uniq
130
+ path_flags, other_flags = all_libs.partition {|flag| /\A-L/ =~ flag}
131
+ path_flags = path_flags.reject do |flag|
132
+ /\A-L\/usr\/lib(?:64)?\z/ =~ flag
133
+ end
134
+ if @msvc_syntax
135
+ path_flags = path_flags.collect do |flag|
136
+ flag.gsub(/\A-L/, "/libpath:")
137
+ end
138
+ other_flags = other_flags.collect do |flag|
139
+ if /\A-l/ =~ flag
140
+ "#{$POSTMATCH}.lib"
141
+ else
142
+ flag
143
+ end
144
+ end
145
+ end
146
+ [path_flags, other_flags]
147
+ end
148
+
149
+ IDENTIFIER_RE = /[\w.]+/
150
+ def parse_pc
151
+ raise ".pc for #{@name} doesn't exist." unless exist?
152
+ @variables = {}
153
+ @declarations = {}
154
+ File.open(pc) do |input|
155
+ input.each_line do |line|
156
+ line = line.gsub(/#.*/, '').strip
157
+ next if line.empty?
158
+ case line
159
+ when /^(#{IDENTIFIER_RE})=/
160
+ @variables[$1] = $POSTMATCH.strip
161
+ when /^(#{IDENTIFIER_RE}):/
162
+ @declarations[$1] = $POSTMATCH.strip
163
+ end
164
+ end
165
+ end
166
+ end
167
+
168
+ def parse_requires(requires)
169
+ return [] if requires.nil?
170
+ requires_without_version = requires.gsub(/[<>]?=\s*[\d.]+\s*/, '')
171
+ requires_without_version.split(/[,\s]+/)
172
+ end
173
+
174
+ def parse_override_variables(override_variables)
175
+ variables = {}
176
+ override_variables.split(",").each do |variable|
177
+ name, value = variable.split("=", 2)
178
+ variables[name] = value
179
+ end
180
+ variables
181
+ end
182
+
183
+ def expand_value(value)
184
+ return nil if value.nil?
185
+ value.gsub(/\$\{(#{IDENTIFIER_RE})\}/) do
186
+ variable($1)
187
+ end
188
+ end
189
+
190
+ def search_pkg_config_from_path(pkg_config)
191
+ (ENV["PATH"] || "").split(separator).each do |path|
192
+ try_pkg_config = Pathname(path) + pkg_config
193
+ return try_pkg_config if try_pkg_config.exist?
194
+ end
195
+ nil
196
+ end
197
+
198
+ def search_pkg_config_by_dln_find_exe(pkg_config)
199
+ begin
200
+ require "dl/import"
201
+ rescue LoadError
202
+ return nil
203
+ end
204
+ dln = Module.new
205
+ dln.module_eval do
206
+ if DL.const_defined?(:Importer)
207
+ extend DL::Importer
208
+ else
209
+ extend DL::Importable
210
+ end
211
+ begin
212
+ dlload RbConfig::CONFIG["LIBRUBY"]
213
+ rescue RuntimeError
214
+ return nil if $!.message == "unknown error"
215
+ return nil if /: image not found\z/ =~ $!.message
216
+ raise
217
+ rescue DL::DLError
218
+ return nil
219
+ end
220
+ extern "const char *dln_find_exe(const char *, const char *)"
221
+ end
222
+ path = dln.dln_find_exe(pkg_config.to_s, nil)
223
+ if path.size.zero?
224
+ nil
225
+ else
226
+ Pathname(path.to_s)
227
+ end
228
+ end
229
+
230
+ def guess_default_path
231
+ default_path = ["/usr/local/lib64/pkgconfig",
232
+ "/usr/local/lib/pkgconfig",
233
+ "/usr/local/libdata/pkgconfig",
234
+ "/opt/local/lib/pkgconfig",
235
+ "/usr/lib64/pkgconfig",
236
+ "/usr/lib/pkgconfig",
237
+ "/usr/X11/lib/pkgconfig/",
238
+ "/usr/share/pkgconfig"].join(separator)
239
+ libdir = ENV["PKG_CONFIG_LIBDIR"]
240
+ default_path = [libdir, default_path].join(separator) if libdir
241
+
242
+ pkg_config = with_config("pkg-config", ENV["PKG_CONFIG"] || "pkg-config")
243
+ pkg_config = Pathname.new(pkg_config)
244
+ unless pkg_config.absolute?
245
+ found_pkg_config = search_pkg_config_from_path(pkg_config)
246
+ pkg_config = found_pkg_config if found_pkg_config
247
+ end
248
+ unless pkg_config.absolute?
249
+ found_pkg_config = search_pkg_config_by_dln_find_exe(pkg_config)
250
+ pkg_config = found_pkg_config if found_pkg_config
251
+ end
252
+
253
+ return default_path unless pkg_config.absolute?
254
+ [(pkg_config.parent.parent + "lib" + "pkgconfig").to_s,
255
+ (pkg_config.parent.parent + "libdata" + "pkgconfig").to_s,
256
+ default_path].join(separator)
257
+ end
258
+ end
259
+
260
+ module PKGConfig
261
+ module_function
262
+ def msvc?
263
+ /mswin32/.match(RUBY_PLATFORM) and /^cl\b/.match(Config::CONFIG['CC'])
264
+ end
265
+
266
+ def package_config(package)
267
+ PackageConfig.new(package, nil, msvc?)
268
+ end
269
+
270
+ def exist?(pkg)
271
+ package_config(pkg).exist?
272
+ end
273
+
274
+ def libs(pkg)
275
+ package_config(pkg).libs
276
+ end
277
+
278
+ def libs_only_l(pkg)
279
+ package_config(pkg).libs_only_l
280
+ end
281
+
282
+ def cflags(pkg)
283
+ package_config(pkg).cflags
284
+ end
285
+
286
+ def cflags_only_I(pkg)
287
+ package_config(pkg).cflags_only_I
288
+ end
289
+
290
+ def modversion(pkg)
291
+ package_config(pkg).version
292
+ end
293
+
294
+ def check_version?(pkg, major = 0, minor = 0, micro = 0)
295
+ return false unless exist?(pkg)
296
+ ver = modversion(pkg).split(".").collect{|item| item.to_i}
297
+ (0..2).each {|i| ver[i] = 0 unless ver[i]}
298
+
299
+ (ver[0] > major ||
300
+ (ver[0] == major && ver[1] > minor) ||
301
+ (ver[0] == major && ver[1] == minor &&
302
+ ver[2] >= micro))
303
+ end
304
+
305
+ def have_package(pkg, major = nil, minor = 0, micro = 0)
306
+ if major.nil?
307
+ STDOUT.print("checking for #{pkg}... ")
308
+ else
309
+ STDOUT.print("checking for #{pkg} version (>= #{major}.#{minor}.#{micro})... ")
310
+ end
311
+ major ||= 0
312
+ STDOUT.flush
313
+ if check_version?(pkg, major, minor, micro)
314
+ STDOUT.print "yes\n"
315
+ libraries = libs_only_l(pkg)
316
+ dldflags = libs(pkg)
317
+ dldflags = (Shellwords.shellwords(dldflags) -
318
+ Shellwords.shellwords(libraries))
319
+ dldflags = dldflags.map {|s| /\s/ =~ s ? "\"#{s}\"" : s }.join(' ')
320
+ $libs += ' ' + libraries
321
+ if /mswin32/ =~ RUBY_PLATFORM
322
+ $DLDFLAGS += ' ' + dldflags
323
+ else
324
+ $LDFLAGS += ' ' + dldflags
325
+ end
326
+ $CFLAGS += ' ' + cflags(pkg)
327
+ true
328
+ else
329
+ STDOUT.print "no\n"
330
+ false
331
+ end
332
+ end
333
+ end
data/rroonga-build.rb ADDED
@@ -0,0 +1,57 @@
1
+ #!/usr/bin/env ruby
2
+ #
3
+ # Copyright (C) 2009-2010 Kouhei Sutou <kou@clear-code.com>
4
+ #
5
+ # This library is free software; you can redistribute it and/or
6
+ # modify it under the terms of the GNU Lesser General Public
7
+ # License version 2.1 as published by the Free Software Foundation.
8
+ #
9
+ # This library is distributed in the hope that it will be useful,
10
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
11
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12
+ # Lesser General Public License for more details.
13
+ #
14
+ # You should have received a copy of the GNU Lesser General Public
15
+ # License along with this library; if not, write to the Free Software
16
+ # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17
+
18
+ module RroongaBuild
19
+ module RequiredGroongaVersion
20
+ MAJOR = 0
21
+ MINOR = 1
22
+ MICRO = 9
23
+ VERSION = [MAJOR, MINOR, MICRO]
24
+ end
25
+
26
+ module_function
27
+ def local_groonga_base_dir
28
+ File.join(File.dirname(__FILE__), "vendor")
29
+ end
30
+
31
+ def local_groonga_install_dir
32
+ File.expand_path(File.join(local_groonga_base_dir, "local"))
33
+ end
34
+
35
+ def have_local_groonga?(package_name, major, minor, micro)
36
+ return false unless File.exist?(File.join(local_groonga_install_dir, "lib"))
37
+
38
+ prepend_pkg_config_path_for_local_groonga
39
+ PKGConfig.have_package(package_name, major, minor, micro)
40
+ end
41
+
42
+ def prepend_pkg_config_path_for_local_groonga
43
+ pkg_config_dir = File.join(local_groonga_install_dir, "lib", "pkgconfig")
44
+ PackageConfig.prepend_default_path(pkg_config_dir)
45
+ end
46
+
47
+ def add_rpath_for_local_groonga
48
+ lib_dir = File.join(local_groonga_install_dir, "lib")
49
+ original_LDFLAGS = $LDFLAGS
50
+ checking_for(checking_message("-Wl,-rpath is available")) do
51
+ $LDFLAGS += " -Wl,-rpath,#{Shellwords.escape(lib_dir)}"
52
+ available = try_compile("int main() {return 0;}")
53
+ $LDFLAGS = original_LDFLAGS unless available
54
+ available
55
+ end
56
+ end
57
+ end