glib2 0.20.0 → 0.90.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (175) hide show
  1. data/ChangeLog +92 -0
  2. data/README +22 -10
  3. data/Rakefile +54 -72
  4. data/ext/glib2/depend +10 -0
  5. data/ext/glib2/extconf.rb +61 -0
  6. data/ext/glib2/glib2.def +89 -0
  7. data/{src → ext/glib2}/rbgcompat.h +0 -0
  8. data/{src → ext/glib2}/rbglib.c +17 -7
  9. data/{src → ext/glib2}/rbglib.h +2 -2
  10. data/{src → ext/glib2}/rbglib_bookmarkfile.c +0 -0
  11. data/{src → ext/glib2}/rbglib_completion.c +0 -0
  12. data/{src → ext/glib2}/rbglib_convert.c +0 -0
  13. data/{src → ext/glib2}/rbglib_error.c +0 -0
  14. data/{src → ext/glib2}/rbglib_fileutils.c +0 -0
  15. data/{src → ext/glib2}/rbglib_i18n.c +0 -0
  16. data/{src → ext/glib2}/rbglib_int64.c +0 -0
  17. data/{src → ext/glib2}/rbglib_iochannel.c +0 -0
  18. data/{src → ext/glib2}/rbglib_keyfile.c +0 -0
  19. data/{src → ext/glib2}/rbglib_maincontext.c +1 -3
  20. data/{src → ext/glib2}/rbglib_mainloop.c +0 -0
  21. data/{src → ext/glib2}/rbglib_messages.c +0 -0
  22. data/{src → ext/glib2}/rbglib_pollfd.c +0 -0
  23. data/{src → ext/glib2}/rbglib_shell.c +0 -0
  24. data/{src → ext/glib2}/rbglib_source.c +0 -0
  25. data/{src → ext/glib2}/rbglib_spawn.c +0 -0
  26. data/{src → ext/glib2}/rbglib_threads.c +0 -0
  27. data/{src → ext/glib2}/rbglib_timer.c +0 -0
  28. data/{src → ext/glib2}/rbglib_unicode.c +0 -0
  29. data/{src → ext/glib2}/rbglib_utils.c +0 -0
  30. data/{src → ext/glib2}/rbglib_win32.c +0 -0
  31. data/{src → ext/glib2}/rbgobj_boxed.c +0 -0
  32. data/{src → ext/glib2}/rbgobj_closure.c +0 -0
  33. data/{src → ext/glib2}/rbgobj_convert.c +0 -0
  34. data/{src → ext/glib2}/rbgobj_enums.c +0 -0
  35. data/{src → ext/glib2}/rbgobj_fundamental.c +0 -0
  36. data/{src → ext/glib2}/rbgobj_object.c +0 -0
  37. data/{src → ext/glib2}/rbgobj_param.c +0 -0
  38. data/{src → ext/glib2}/rbgobj_paramspecs.c +0 -0
  39. data/{src → ext/glib2}/rbgobj_signal.c +0 -0
  40. data/{src → ext/glib2}/rbgobj_strv.c +0 -0
  41. data/{src → ext/glib2}/rbgobj_type.c +0 -0
  42. data/{src → ext/glib2}/rbgobj_typeinstance.c +0 -0
  43. data/{src → ext/glib2}/rbgobj_typeinterface.c +0 -0
  44. data/{src → ext/glib2}/rbgobj_typemodule.c +0 -0
  45. data/{src → ext/glib2}/rbgobj_typeplugin.c +0 -0
  46. data/{src → ext/glib2}/rbgobj_value.c +0 -0
  47. data/{src → ext/glib2}/rbgobj_valuearray.c +0 -0
  48. data/{src → ext/glib2}/rbgobj_valuetypes.c +0 -0
  49. data/{src → ext/glib2}/rbgobject.c +0 -0
  50. data/{src → ext/glib2}/rbgobject.h +0 -0
  51. data/{src → ext/glib2}/rbgprivate.h +0 -0
  52. data/ext/glib2/rbgutil.c +316 -0
  53. data/{src → ext/glib2}/rbgutil.h +9 -9
  54. data/{src → ext/glib2}/rbgutil_callback.c +0 -0
  55. data/extconf.rb +48 -60
  56. data/{src/lib → lib}/glib-mkenums.rb +2 -2
  57. data/{src/lib → lib}/glib2.rb +28 -9
  58. data/lib/gnome2-win32-binary-downloader.rb +92 -0
  59. data/{src/lib → lib}/mkmf-gnome2.rb +76 -89
  60. data/test-unit/COPYING +56 -0
  61. data/test-unit/GPL +340 -0
  62. data/test-unit/History.txt +232 -0
  63. data/test-unit/Manifest.txt +110 -0
  64. data/test-unit/PSFL +271 -0
  65. data/test-unit/README.txt +75 -0
  66. data/test-unit/Rakefile +53 -0
  67. data/test-unit/TODO +5 -0
  68. data/test-unit/bin/testrb +5 -0
  69. data/test-unit/html/bar.png +0 -0
  70. data/test-unit/html/bar.svg +153 -0
  71. data/test-unit/html/developer.png +0 -0
  72. data/test-unit/html/developer.svg +469 -0
  73. data/test-unit/html/famfamfam-logo.png +0 -0
  74. data/test-unit/html/favicon.ico +0 -0
  75. data/test-unit/html/favicon.png +0 -0
  76. data/test-unit/html/favicon.svg +82 -0
  77. data/test-unit/html/heading-mark.png +0 -0
  78. data/test-unit/html/heading-mark.svg +393 -0
  79. data/test-unit/html/index.html +247 -0
  80. data/test-unit/html/index.html.ja +270 -0
  81. data/test-unit/html/install.png +0 -0
  82. data/test-unit/html/install.svg +636 -0
  83. data/test-unit/html/jp.png +0 -0
  84. data/test-unit/html/kinotan-failure.png +0 -0
  85. data/test-unit/html/kinotan-pass.png +0 -0
  86. data/test-unit/html/logo.png +0 -0
  87. data/test-unit/html/logo.svg +483 -0
  88. data/test-unit/html/reference.png +0 -0
  89. data/test-unit/html/rubyforge.png +0 -0
  90. data/test-unit/html/tango-logo.png +0 -0
  91. data/test-unit/html/test-unit.css +339 -0
  92. data/test-unit/html/tutorial.png +0 -0
  93. data/test-unit/html/tutorial.svg +559 -0
  94. data/test-unit/html/us.png +0 -0
  95. data/test-unit/images/color-diff.png +0 -0
  96. data/test-unit/lib/test/unit.rb +328 -0
  97. data/test-unit/lib/test/unit/assertionfailederror.rb +25 -0
  98. data/test-unit/lib/test/unit/assertions.rb +1334 -0
  99. data/test-unit/lib/test/unit/attribute.rb +125 -0
  100. data/test-unit/lib/test/unit/autorunner.rb +363 -0
  101. data/test-unit/lib/test/unit/collector.rb +36 -0
  102. data/test-unit/lib/test/unit/collector/descendant.rb +23 -0
  103. data/test-unit/lib/test/unit/collector/dir.rb +108 -0
  104. data/test-unit/lib/test/unit/collector/load.rb +144 -0
  105. data/test-unit/lib/test/unit/collector/objectspace.rb +34 -0
  106. data/test-unit/lib/test/unit/color-scheme.rb +106 -0
  107. data/test-unit/lib/test/unit/color.rb +96 -0
  108. data/test-unit/lib/test/unit/diff.rb +740 -0
  109. data/test-unit/lib/test/unit/error.rb +130 -0
  110. data/test-unit/lib/test/unit/exceptionhandler.rb +39 -0
  111. data/test-unit/lib/test/unit/failure.rb +136 -0
  112. data/test-unit/lib/test/unit/fixture.rb +176 -0
  113. data/test-unit/lib/test/unit/notification.rb +129 -0
  114. data/test-unit/lib/test/unit/omission.rb +191 -0
  115. data/test-unit/lib/test/unit/pending.rb +150 -0
  116. data/test-unit/lib/test/unit/priority.rb +180 -0
  117. data/test-unit/lib/test/unit/runner/console.rb +52 -0
  118. data/test-unit/lib/test/unit/runner/emacs.rb +8 -0
  119. data/test-unit/lib/test/unit/runner/tap.rb +8 -0
  120. data/test-unit/lib/test/unit/testcase.rb +483 -0
  121. data/test-unit/lib/test/unit/testresult.rb +121 -0
  122. data/test-unit/lib/test/unit/testsuite.rb +110 -0
  123. data/test-unit/lib/test/unit/ui/console/outputlevel.rb +14 -0
  124. data/test-unit/lib/test/unit/ui/console/testrunner.rb +430 -0
  125. data/test-unit/lib/test/unit/ui/emacs/testrunner.rb +63 -0
  126. data/test-unit/lib/test/unit/ui/tap/testrunner.rb +82 -0
  127. data/test-unit/lib/test/unit/ui/testrunner.rb +53 -0
  128. data/test-unit/lib/test/unit/ui/testrunnermediator.rb +77 -0
  129. data/test-unit/lib/test/unit/ui/testrunnerutilities.rb +41 -0
  130. data/test-unit/lib/test/unit/util/backtracefilter.rb +42 -0
  131. data/test-unit/lib/test/unit/util/method-owner-finder.rb +28 -0
  132. data/test-unit/lib/test/unit/util/observable.rb +90 -0
  133. data/test-unit/lib/test/unit/util/output.rb +31 -0
  134. data/test-unit/lib/test/unit/util/procwrapper.rb +48 -0
  135. data/test-unit/lib/test/unit/version.rb +7 -0
  136. data/test-unit/sample/adder.rb +13 -0
  137. data/test-unit/sample/subtracter.rb +12 -0
  138. data/test-unit/sample/test_adder.rb +20 -0
  139. data/test-unit/sample/test_subtracter.rb +20 -0
  140. data/test-unit/sample/test_user.rb +23 -0
  141. data/test-unit/test/collector/test-descendant.rb +133 -0
  142. data/test-unit/test/collector/test-load.rb +442 -0
  143. data/test-unit/test/collector/test_dir.rb +406 -0
  144. data/test-unit/test/collector/test_objectspace.rb +100 -0
  145. data/test-unit/test/run-test.rb +15 -0
  146. data/test-unit/test/test-attribute.rb +86 -0
  147. data/test-unit/test/test-color-scheme.rb +69 -0
  148. data/test-unit/test/test-color.rb +47 -0
  149. data/test-unit/test/test-diff.rb +518 -0
  150. data/test-unit/test/test-emacs-runner.rb +60 -0
  151. data/test-unit/test/test-fixture.rb +287 -0
  152. data/test-unit/test/test-notification.rb +33 -0
  153. data/test-unit/test/test-omission.rb +81 -0
  154. data/test-unit/test/test-pending.rb +70 -0
  155. data/test-unit/test/test-priority.rb +119 -0
  156. data/test-unit/test/test-testcase.rb +544 -0
  157. data/test-unit/test/test_assertions.rb +1197 -0
  158. data/test-unit/test/test_error.rb +26 -0
  159. data/test-unit/test/test_failure.rb +33 -0
  160. data/test-unit/test/test_testresult.rb +113 -0
  161. data/test-unit/test/test_testsuite.rb +129 -0
  162. data/test-unit/test/testunit-test-util.rb +14 -0
  163. data/test-unit/test/ui/test_tap.rb +33 -0
  164. data/test-unit/test/ui/test_testrunmediator.rb +20 -0
  165. data/test-unit/test/util/test-method-owner-finder.rb +38 -0
  166. data/test-unit/test/util/test-output.rb +11 -0
  167. data/test-unit/test/util/test_backtracefilter.rb +41 -0
  168. data/test-unit/test/util/test_observable.rb +102 -0
  169. data/test-unit/test/util/test_procwrapper.rb +36 -0
  170. data/test/run-test.rb +2 -6
  171. metadata +197 -100
  172. data/src/glib-enum-types.c +0 -1032
  173. data/src/glib-enum-types.h +0 -140
  174. data/src/lib/pkg-config.rb +0 -137
  175. data/src/rbgutil.c +0 -222
File without changes
data/extconf.rb CHANGED
@@ -1,61 +1,49 @@
1
- =begin
2
- extconf.rb for Ruby/GLib extention library
3
- =end
4
-
5
- TOPDIR = File.expand_path(File.dirname(__FILE__))
6
- MKMF_GNOME2_DIR = TOPDIR + '/src/lib'
7
- SRCDIR = TOPDIR + '/src'
8
-
9
- $LOAD_PATH.unshift MKMF_GNOME2_DIR
10
-
11
- PACKAGE_NAME = "glib2"
12
- PACKAGE_ID = "gobject-2.0"
13
-
14
- require 'mkmf-gnome2'
15
-
16
- PKGConfig.have_package(PACKAGE_ID) or exit 1
17
- PKGConfig.have_package('gthread-2.0')
18
-
19
- setup_win32(PACKAGE_NAME)
20
-
21
- have_header("unistd.h")
22
- have_header("io.h")
23
-
24
- glib_header = "glib.h"
25
- have_func("g_spawn_close_pid", glib_header)
26
- have_func("g_thread_init", glib_header)
27
- have_func("g_main_depth", glib_header)
28
- have_func("g_listenv", glib_header)
29
-
30
- ruby_header = "ruby.h"
31
- have_func("rb_check_array_type", ruby_header)
32
- have_func("rb_exec_recursive", ruby_header)
33
- have_func("rb_errinfo", ruby_header)
34
- have_func("rb_sourcefile", ruby_header)
35
- have_func("rb_sourceline", ruby_header)
36
- have_func("ruby_set_current_source", ruby_header)
37
- have_func("rb_thread_blocking_region", ruby_header)
38
- have_func("ruby_native_thread_p", ruby_header)
39
- have_func("rb_str_encode", ruby_header)
40
-
41
- have_var("curr_thread", [ruby_header, "node.h"])
42
- have_var("rb_curr_thread", [ruby_header, "node.h"])
43
-
44
- create_pkg_config_file("Ruby/GLib2", PACKAGE_ID)
45
-
46
- create_makefile_at_srcdir(PACKAGE_NAME, SRCDIR, "-DRUBY_GLIB2_COMPILATION") do
47
- enum_type_prefix = "glib-enum-types"
48
- include_paths = PKGConfig.cflags_only_I("glib-2.0")
49
- headers = include_paths.split.inject([]) do |result, path|
50
- result + Dir.glob(File.join(path.sub(/^-I/, ""), "glib", "*.h"))
51
- end.reject do |file|
52
- /g(iochannel|scanner)\.h/ =~ file
53
- end
54
- include_paths = PKGConfig.cflags_only_I("gobject-2.0")
55
- headers = include_paths.split.inject(headers) do |result, path|
56
- result + Dir.glob(File.join(path.sub(/^-I/, ""), "gobject", "gsignal.h"))
57
- end
58
- glib_mkenums(enum_type_prefix, headers, "G_TYPE_", ["glib-object.h"])
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'pathname'
4
+ require 'mkmf'
5
+ require 'rbconfig'
6
+ require 'fileutils'
7
+
8
+ package = "glib2"
9
+
10
+ base_dir = Pathname(__FILE__).dirname.expand_path
11
+ ext_dir = base_dir + "ext" + package
12
+ mkmf_gnome2_dir = base_dir + 'lib'
13
+
14
+ ruby = File.join(RbConfig::CONFIG['bindir'],
15
+ RbConfig::CONFIG['ruby_install_name'] +
16
+ RbConfig::CONFIG["EXEEXT"])
17
+
18
+ build_dir = Pathname("ext") + package
19
+ FileUtils.mkdir_p(build_dir.to_s) unless build_dir.exist?
20
+ extconf_rb_path = ext_dir + "extconf.rb"
21
+ system(ruby, "-C", build_dir.to_s, extconf_rb_path.to_s, *ARGV) || exit(false)
22
+
23
+ create_makefile(package)
24
+ FileUtils.mv("Makefile", "Makefile.lib")
25
+
26
+ File.open("Makefile", "w") do |makefile|
27
+ makefile.puts(<<-EOM)
28
+ all:
29
+ (cd ext/#{package} && $(MAKE))
30
+ $(MAKE) -f Makefile.lib
31
+
32
+ install:
33
+ (cd ext/#{package} && $(MAKE) install)
34
+ $(MAKE) -f Makefile.lib install
35
+
36
+ site-install:
37
+ (cd ext/#{package} && $(MAKE) site-install)
38
+ $(MAKE) -f Makefile.lib site-install
39
+
40
+ clean:
41
+ (cd ext/#{package} && $(MAKE) clean)
42
+ $(MAKE) -f Makefile.lib clean
43
+
44
+ distclean:
45
+ (cd ext/#{package} && $(MAKE) distclean)
46
+ $(MAKE) -f Makefile.lib distclean
47
+ @rm -f Makefile.lib
48
+ EOM
59
49
  end
60
-
61
- create_top_makefile
@@ -167,7 +167,7 @@ GType #{@enum_name}_get_type (void);
167
167
 
168
168
  # Create a C source as a String.
169
169
  def create_c
170
- ret = "\n/* Generated by glib-mkenums.rb ($Id$) */ \n\n"
170
+ ret = "\n/* Generated by glib-mkenums.rb ($Id: glib-mkenums.rb 3896 2010-09-25 07:49:34Z ktou $) */ \n\n"
171
171
  ret << %Q[#include "#{@target_filename}.h"\n]
172
172
  @include_files.each do |file|
173
173
  ret << "#include <#{file}>\n"
@@ -183,7 +183,7 @@ GType #{@enum_name}_get_type (void);
183
183
  header = "#{@target_filename}.h"
184
184
  const = "__#{File.basename(header).upcase.gsub(/-|\./, '_')}__"
185
185
 
186
- ret = "\n/* Generated by glib-mkenums.rb ($Id$) */ \n\n"
186
+ ret = "\n/* Generated by glib-mkenums.rb ($Id: glib-mkenums.rb 3896 2010-09-25 07:49:34Z ktou $) */ \n\n"
187
187
  ret << "#ifndef #{const}\n"
188
188
  ret << "#define #{const}\n\n"
189
189
  ret << "#include <glib-object.h>\n\n"
@@ -1,18 +1,12 @@
1
1
  #
2
2
  # glib2.rb
3
- # Copyright(C) 2005 Ruby-GNOME2 Project.
3
+ # Copyright(C) 2005-2010 Ruby-GNOME2 Project.
4
4
  #
5
5
  # This program is licenced under the same
6
6
  # license of Ruby-GNOME2.
7
7
  #
8
8
 
9
- require 'rbconfig'
10
- if /mingw|mswin|mswin32/ =~ RUBY_PLATFORM
11
- ENV['PATH'] = %w(bin lib).collect{|dir|
12
- "#{Config::CONFIG["prefix"]}\\lib\\GTK\\#{dir};"
13
- }.join('') + ENV['PATH']
14
- end
15
-
9
+ require 'pathname'
16
10
  require 'English'
17
11
  require 'thread'
18
12
 
@@ -66,9 +60,34 @@ module GLib
66
60
  end
67
61
  end
68
62
  end
63
+
64
+ def prepend_environment_path(path)
65
+ path = Pathname(path) unless path.is_a?(Pathname)
66
+ if path.exist?
67
+ environment_name = "PATH"
68
+ separator = File::PATH_SEPARATOR
69
+
70
+ paths = (ENV[environment_name] || '').split(/#{separator}/)
71
+ dir = path.to_s
72
+ dir = dir.gsub(/\//, File::ALT_SEPARATOR) if File::ALT_SEPARATOR
73
+ unless paths.include?(dir)
74
+ paths = [dir] + paths
75
+ ENV[environment_name] = paths.join(separator)
76
+ end
77
+ end
78
+ end
69
79
  end
70
80
 
71
- require 'glib2.so'
81
+
82
+ base_dir = Pathname.new(__FILE__).dirname.dirname.expand_path
83
+ vendor_dir = base_dir + "vendor" + "local"
84
+ GLib.prepend_environment_path(vendor_dir + "bin")
85
+ begin
86
+ major, minor, micro, = RUBY_VERSION.split(/\./)
87
+ require "#{major}.#{minor}/glib2.so"
88
+ rescue LoadError
89
+ require 'glib2.so'
90
+ end
72
91
 
73
92
  module GLib
74
93
 
@@ -0,0 +1,92 @@
1
+ # Copyright(C) 2010 Ruby-GNOME2 Project.
2
+ #
3
+ # This program is licenced under the same license of Ruby-GNOME2.
4
+
5
+ require 'open-uri'
6
+ require 'rubygems'
7
+ require 'mechanize'
8
+
9
+ class GNOME2Win32BinaryDownloader
10
+ class << self
11
+ def download(options)
12
+ downloader = new(options)
13
+ packages = options[:packages] || [options[:package]]
14
+ packages.compact.each do |package|
15
+ downloader.download_package(package)
16
+ end
17
+ dependencies = options[:dependencies] || [options[:dependency]]
18
+ dependencies.compact.each do |dependency|
19
+ downloader.download_dependency(dependency)
20
+ end
21
+ end
22
+ end
23
+
24
+ URL_BASE = "http://ftp.gnome.org/pub/gnome/binaries/win32"
25
+ def initialize(options={})
26
+ @output_dir = options[:output_dir] || File.join("vendor", "local")
27
+ end
28
+
29
+ def download_package(package)
30
+ version_page = agent.get("#{URL_BASE}/#{package}")
31
+ latest_version_link = version_page.links.sort_by do |link|
32
+ if /\A(\d+\.\d+)\/\z/ =~ link.href
33
+ $1.split(/\./).collect {|component| component.to_i}
34
+ else
35
+ [-1]
36
+ end
37
+ end.last
38
+
39
+ latest_version_page = latest_version_link.click
40
+ latest_version = latest_version_page.links.collect do |link|
41
+ if /_([\d\.\-]+)_win32\.zip\z/ =~ link.href
42
+ version = $1
43
+ [version.split(/[\.\-]/).collect {|component| component.to_i}, version]
44
+ else
45
+ [[-1], nil]
46
+ end
47
+ end.sort_by do |normalized_version, version|
48
+ normalized_version
49
+ end.last[1]
50
+
51
+ latest_version_page.links.each do |link|
52
+ if /_#{Regexp.escape(latest_version)}_win32\.zip\z/ =~ link.href
53
+ click_zip_link(link)
54
+ end
55
+ end
56
+ end
57
+
58
+ def download_dependency(dependency)
59
+ dependencies_page = agent.get("#{URL_BASE}/dependencies")
60
+ latest_version = dependencies_page.links.collect do |link|
61
+ if /\A#{Regexp.escape(dependency)}_([\d\.\-]+)_win32\.zip\z/ =~ link.href
62
+ version = $1
63
+ [version.split(/[\.\-]/).collect {|component| component.to_i}, version]
64
+ else
65
+ [[-1], nil]
66
+ end
67
+ end.sort_by do |normalized_version, version|
68
+ normalized_version
69
+ end.last[1]
70
+ dependencies_page.links.each do |link|
71
+ if /\A#{Regexp.escape(dependency)}(?:-dev)?_#{Regexp.escape(latest_version)}_win32.zip/ =~ link.href
72
+ click_zip_link(link)
73
+ end
74
+ end
75
+ end
76
+
77
+ private
78
+ def agent
79
+ @agent ||= Mechanize.new
80
+ end
81
+
82
+ def click_zip_link(link)
83
+ zip = link.click
84
+ FileUtils.mkdir_p(@output_dir)
85
+ Dir.chdir(@output_dir) do
86
+ open(zip.filename, "wb") do |file|
87
+ file.print(zip.body)
88
+ end
89
+ system("unzip '#{zip.filename}'")
90
+ end
91
+ end
92
+ end
@@ -10,7 +10,13 @@
10
10
  #
11
11
 
12
12
  require 'mkmf'
13
- require 'pkg-config'
13
+ begin
14
+ require 'pkg-config'
15
+ rescue LoadError
16
+ require 'rubygems'
17
+ gem 'pkg-config'
18
+ require 'pkg-config'
19
+ end
14
20
  require 'glib-mkenums'
15
21
 
16
22
  unless defined?(macro_defined?)
@@ -42,90 +48,55 @@ if ENV['GTK_BASEPATH'] and /cygwin/ !~ RUBY_PLATFORM
42
48
  $CFLAGS += " -I#{include_path} "
43
49
  end
44
50
 
45
- def check_win32()
46
- $G_PLATFORM_WIN32 = false
47
- $G_OS_WIN32 = false
48
- $G_WITH_CYGWIN = false
49
-
50
- STDOUT.print("checking for G_PLATFORM_WIN32... ")
51
- STDOUT.flush
52
- if macro_defined?('G_PLATFORM_WIN32', "#include <glibconfig.h>\n")
53
- STDOUT.print "yes\n"
54
- $G_PLATFORM_WIN32 = true
55
- else
56
- STDOUT.print "no\n"
57
- end
58
-
59
- if $G_PLATFORM_WIN32
60
- STDOUT.print("checking for G_OS_WIN32... ")
61
- STDOUT.flush
62
- if macro_defined?('G_OS_WIN32', "#include <glibconfig.h>\n")
63
- STDOUT.print "yes\n"
64
- $G_OS_WIN32 = true
65
- if $cc_is_gcc
66
- if /^2\./ =~ `#{Config::CONFIG['CC']} -dumpversion`.chomp
67
- $CFLAGS += ' -fnative-struct'
68
- else
69
- $CFLAGS += ' -mms-bitfields'
70
- end
71
- end
72
- else
73
- STDOUT.print "no\n"
74
- end
75
-
76
- # STDOUT.print("checking for G_WITH_CYGWIN... ")
77
- # STDOUT.flush
78
- # if macro_defined?('G_WITH_CYGWIN', "#include <glibconfig.h>\n")
79
- # STDOUT.print "yes\n"
80
- # $G_WITH_CYGWIN = true
81
- # else
82
- # STDOUT.print "no\n"
83
- # end
84
- end
85
-
86
- nil
87
- end
88
-
89
- def set_output_lib(target_name)
90
- if /cygwin|mingw/ =~ RUBY_PLATFORM
91
- filename = "libruby-#{target_name}.a"
92
- if RUBY_VERSION > "1.8.0"
93
- $DLDFLAGS << ",--out-implib=#{filename}" if filename
94
- elsif RUBY_VERSION > "1.8"
95
- $DLDFLAGS.gsub!(/ -Wl,--out-implib=[^ ]+/, '')
96
- $DLDFLAGS << " -Wl,--out-implib=#{filename}" if filename
51
+ def setup_win32(target_name, base_dir=nil)
52
+ checking_for(checking_message("Win32 OS")) do
53
+ case RUBY_PLATFORM
54
+ when /cygwin|mingw|mswin32/
55
+ import_library_name = "libruby-#{target_name}.a"
56
+ $DLDFLAGS << " -Wl,--out-implib=#{import_library_name}"
57
+ $cleanfiles << import_library_name
58
+ base_dir ||= Pathname($0).dirname.parent.parent.expand_path
59
+ base_dir = Pathname(base_dir) if base_dir.is_a?(String)
60
+ binary_base_dir = base_dir + "vendor" + "local"
61
+ $CFLAGS += " -I#{binary_base_dir}/include"
62
+ pkg_config_dir = binary_base_dir + "lib" + "pkgconfig"
63
+ PKGConfig.add_path(pkg_config_dir.to_s)
64
+ PKGConfig.set_override_variable("prefix", binary_base_dir.to_s)
65
+ true
97
66
  else
98
- $DLDFLAGS.gsub!(/ --output-lib\s+[^ ]+/, '')
99
- $DLDFLAGS << " --output-lib #{filename}" if filename
67
+ false
100
68
  end
101
- elsif /mswin32/ =~ RUBY_PLATFORM
102
- filename = "libruby-#{target_name}.lib"
103
- $DLDFLAGS.gsub!(/ --output-lib\s+[^ ]+/, '')
104
- $DLDFLAGS.gsub!(/ \/IMPLIB:[^ ]+/, '')
105
- $DLDFLAGS << " /IMPLIB:#{filename}" if filename
106
69
  end
107
70
  end
108
71
 
109
- def setup_win32(target_name)
110
- check_win32
111
- set_output_lib(target_name)
112
- end
113
-
114
72
  #add_depend_package("glib2", "glib/src", "/...../ruby-gnome2")
115
- def add_depend_package(target_name, target_srcdir, top_srcdir)
73
+ def add_depend_package(target_name, target_srcdir, top_srcdir, options={})
116
74
  [top_srcdir, $configure_args['--topdir']].each do |topdir|
117
75
  topdir = File.expand_path(topdir)
118
- if RUBY_VERSION < "1.8.5"
119
- $CFLAGS = "-I#{File.join(topdir, target_srcdir)} #{$CFLAGS}"
120
- else
121
- $INCFLAGS = "-I#{File.join(topdir, target_srcdir)} #{$INCFLAGS}"
76
+ target_source_dir_full_path = File.join(topdir, target_srcdir)
77
+ if File.exist?(target_source_dir_full_path)
78
+ $INCFLAGS = "-I#{target_source_dir_full_path} #{$INCFLAGS}"
79
+ end
80
+
81
+ top_build_dir = options[:top_build_dir] || topdir
82
+ target_build_dir = options[:target_build_dir] || target_srcdir
83
+ target_build_dir_full_path = File.join(top_build_dir, target_build_dir)
84
+ unless File.exist?(target_build_dir_full_path)
85
+ target_build_dir_full_path = File.join(top_build_dir, target_srcdir)
86
+ end
87
+ unless File.exist?(target_build_dir_full_path)
88
+ target_build_dir_full_path = File.join(topdir, target_build_dir)
89
+ end
90
+ unless File.exist?(target_build_dir_full_path)
91
+ target_build_dir_full_path = File.join(topdir, target_srcdir)
122
92
  end
93
+ $INCFLAGS = "-I#{target_build_dir_full_path} #{$INCFLAGS}"
123
94
 
124
95
  if /cygwin|mingw/ =~ RUBY_PLATFORM
125
96
  $libs << " -lruby-#{target_name}"
126
- $LDFLAGS << " -L#{topdir}/#{target_srcdir}"
97
+ $LDFLAGS << " -L#{target_build_dir_full_path}"
127
98
  elsif /mswin32/ =~ RUBY_PLATFORM
128
- $DLDFLAGS << " /libpath:#{topdir}/#{target_srcdir}"
99
+ $DLDFLAGS << " /libpath:#{target_build_dir_full_path}"
129
100
  $libs << " libruby-#{target_name}.lib"
130
101
  end
131
102
  end
@@ -157,7 +128,8 @@ def create_pkg_config_file(package_name, c_package,
157
128
  end
158
129
 
159
130
  def ruby_gnome2_version(glib_source_directory=nil)
160
- glib_source_directory ||= File.join(File.dirname(__FILE__), "..")
131
+ glib_source_directory ||= File.join(File.dirname(__FILE__), "..",
132
+ "ext", "glib2")
161
133
  rbglib_h = File.join(glib_source_directory, "rbglib.h")
162
134
  return nil unless File.exist?(rbglib_h)
163
135
 
@@ -179,6 +151,20 @@ def ruby_gnome2_version(glib_source_directory=nil)
179
151
  version
180
152
  end
181
153
 
154
+ def ensure_objs
155
+ return unless $objs.nil?
156
+
157
+ source_dir = '$(srcdir)'
158
+ RbConfig.expand(source_dir)
159
+
160
+ pattern = "*.{#{SRC_EXT.join(',')}}"
161
+ srcs = Dir[File.join(source_dir, pattern)]
162
+ srcs |= Dir[File.join(".", pattern)]
163
+ $objs = srcs.collect do |f|
164
+ File.basename(f, ".*") + ".o"
165
+ end.uniq
166
+ end
167
+
182
168
  def create_makefile_at_srcdir(pkg_name, srcdir, defs = nil)
183
169
  base_dir = File.basename(Dir.pwd)
184
170
  last_common_index = srcdir.rindex(base_dir)
@@ -192,14 +178,7 @@ def create_makefile_at_srcdir(pkg_name, srcdir, defs = nil)
192
178
  yield if block_given?
193
179
 
194
180
  $defs << defs if defs
195
-
196
- pattern = "*.{#{SRC_EXT.join(',')}}"
197
- srcs = Dir[File.join(srcdir, pattern)]
198
- srcs |= Dir[File.join(".", pattern)]
199
- $objs = srcs.collect do |src|
200
- File.basename(src, ".*") + ".o"
201
- end.flatten.uniq
202
-
181
+ ensure_objs
203
182
  create_makefile(pkg_name, srcdir)
204
183
  end
205
184
  end
@@ -328,6 +307,7 @@ SRC
328
307
  end
329
308
 
330
309
  def add_obj(name)
310
+ ensure_objs
331
311
  $objs << name unless $objs.index(name)
332
312
  end
333
313
 
@@ -335,11 +315,17 @@ def glib_mkenums(prefix, files, g_type_prefix, include_files, options={})
335
315
  add_distcleanfile(prefix + ".h")
336
316
  add_distcleanfile(prefix + ".c")
337
317
  GLib::MkEnums.create(prefix, files, g_type_prefix, include_files, options)
318
+ add_obj("#{prefix}.o")
338
319
  end
339
320
 
340
- def check_cairo
321
+ def check_cairo(options={})
341
322
  return false unless PKGConfig.have_package('cairo')
342
323
 
324
+ rcairo_source_dir = options[:rcairo_source_dir]
325
+ if rcairo_source_dir and !File.exist?(rcairo_source_dir)
326
+ rcairo_source_dir = nil
327
+ end
328
+ $CFLAGS += " -I#{rcairo_source_dir}/ext/cairo" if rcairo_source_dir
343
329
  have_rb_cairo_h = have_header('rb_cairo.h')
344
330
  unless have_rb_cairo_h
345
331
  begin
@@ -347,8 +333,8 @@ def check_cairo
347
333
  gem 'cairo'
348
334
  require 'cairo'
349
335
  rcairo_src_gem_path_re =
350
- /\A#{Regexp.escape(Gem.dir)}\/gems\/cairo-[\d.]+\/src\z/
351
- $:.each do |path|
336
+ /\A#{Regexp.escape(Gem.dir)}\/gems\/cairo-[\d.]+\/ext\/cairo\z/
337
+ $LOAD_PATH.each do |path|
352
338
  if rcairo_src_gem_path_re =~ path
353
339
  $CFLAGS += " -I#{path} "
354
340
  have_rb_cairo_h = have_header('rb_cairo.h')
@@ -361,11 +347,12 @@ def check_cairo
361
347
 
362
348
  if have_rb_cairo_h
363
349
  if /mingw|cygwin|mswin32/ =~ RUBY_PLATFORM
364
- unless ENV["CAIRO_PATH"]
365
- puts "Error! Set CAIRO_PATH."
366
- exit 1
350
+ options = {}
351
+ build_dir = "tmp/#{RUBY_PLATFORM}/cairo/#{RUBY_VERSION}"
352
+ if File.exist?(File.join(rcairo_source_dir, build_dir))
353
+ options[:target_build_dir] = build_dir
367
354
  end
368
- add_depend_package("cairo", "src", ENV["CAIRO_PATH"])
355
+ add_depend_package("cairo", "ext/cairo", rcairo_source_dir, options)
369
356
  $defs << "-DRUBY_CAIRO_PLATFORM_WIN32"
370
357
  end
371
358
  end
@@ -373,7 +360,7 @@ def check_cairo
373
360
  end
374
361
 
375
362
  add_include_path = Proc.new do |dir_variable|
376
- value = Config::CONFIG[dir_variable]
363
+ value = RbConfig::CONFIG[dir_variable]
377
364
  if value and File.exist?(value)
378
365
  $INCFLAGS << " -I$(#{dir_variable}) "
379
366
  end