Top Level Namespace
Defined Under Namespace
Modules: GLib
Classes: GNOME2Win32BinaryDownloader
Instance Method Summary
collapse
-
#add_depend_package(target_name, target_srcdir, top_srcdir, options = {}) ⇒ Object
add_depend_package(“glib2”, “glib/src”, “/.…./ruby-gnome2”).
-
#add_distcleanfile(file) ⇒ Object
-
#add_obj(name) ⇒ Object
-
#check_cairo(options = {}) ⇒ Object
-
#check_ruby_func ⇒ Object
-
#create_makefile_at_srcdir(pkg_name, srcdir, defs = nil) ⇒ Object
-
#create_pkg_config_file(package_name, c_package, version = nil, pc_file_name = nil) ⇒ Object
-
#create_top_makefile(sub_dirs = ["src"]) ⇒ Object
-
#ensure_objs ⇒ Object
-
#glib_mkenums(prefix, files, g_type_prefix, include_files, options = {}) ⇒ Object
-
#macro_defined?(macro, src, opt = "") ⇒ Boolean
-
#make_version_header(app_name, pkgname, dir = "src") ⇒ Object
This is used for the library which doesn’t support version info.
-
#ruby_gnome2_version(glib_source_directory = nil) ⇒ Object
-
#run_make_in_sub_dirs_command(command, sub_dirs) ⇒ Object
-
#setup_win32(target_name, base_dir = nil) ⇒ Object
Instance Method Details
#add_depend_package(target_name, target_srcdir, top_srcdir, options = {}) ⇒ Object
add_depend_package(“glib2”, “glib/src”, “/.…./ruby-gnome2”)
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
|
# File 'lib/mkmf-gnome2.rb', line 73
def add_depend_package(target_name, target_srcdir, top_srcdir, options={})
[top_srcdir, $configure_args['--topdir']].each do |topdir|
topdir = File.expand_path(topdir)
target_source_dir_full_path = File.join(topdir, target_srcdir)
if File.exist?(target_source_dir_full_path)
$INCFLAGS = "-I#{target_source_dir_full_path} #{$INCFLAGS}"
end
top_build_dir = options[:top_build_dir] || topdir
target_build_dir = options[:target_build_dir] || target_srcdir
target_build_dir_full_path = File.join(top_build_dir, target_build_dir)
unless File.exist?(target_build_dir_full_path)
target_build_dir_full_path = File.join(top_build_dir, target_srcdir)
end
unless File.exist?(target_build_dir_full_path)
target_build_dir_full_path = File.join(topdir, target_build_dir)
end
unless File.exist?(target_build_dir_full_path)
target_build_dir_full_path = File.join(topdir, target_srcdir)
end
next unless File.exist?(target_build_dir_full_path)
$INCFLAGS = "-I#{target_build_dir_full_path} #{$INCFLAGS}"
if /cygwin|mingw/ =~ RUBY_PLATFORM
$libs << " -lruby-#{target_name}"
$LDFLAGS << " -L#{target_build_dir_full_path}"
elsif /mswin32/ =~ RUBY_PLATFORM
$DLDFLAGS << " /libpath:#{target_build_dir_full_path}"
$libs << " libruby-#{target_name}.lib"
end
end
end
|
#add_distcleanfile(file) ⇒ Object
106
107
108
109
|
# File 'lib/mkmf-gnome2.rb', line 106
def add_distcleanfile(file)
$distcleanfiles ||= []
$distcleanfiles << file
end
|
#add_obj(name) ⇒ Object
310
311
312
313
|
# File 'lib/mkmf-gnome2.rb', line 310
def add_obj(name)
ensure_objs
$objs << name unless $objs.index(name)
end
|
#check_cairo(options = {}) ⇒ Object
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
|
# File 'lib/mkmf-gnome2.rb', line 322
def check_cairo(options={})
return false unless PKGConfig.have_package('cairo')
rcairo_source_dir = options[:rcairo_source_dir]
if rcairo_source_dir and !File.exist?(rcairo_source_dir)
rcairo_source_dir = nil
end
$CFLAGS += " -I#{rcairo_source_dir}/ext/cairo" if rcairo_source_dir
have_rb_cairo_h = ('rb_cairo.h')
unless have_rb_cairo_h
begin
require 'rubygems'
gem 'cairo'
require 'cairo'
rcairo_src_gem_path_re =
/\A#{Regexp.escape(Gem.dir)}\/gems\/cairo-[\d.]+\/ext\/cairo\z/
$LOAD_PATH.each do |path|
if rcairo_src_gem_path_re =~ path
$CFLAGS += " -I#{path} "
have_rb_cairo_h = ('rb_cairo.h')
break
end
end
rescue LoadError
end
end
if have_rb_cairo_h
if /mingw|cygwin|mswin32/ =~ RUBY_PLATFORM
options = {}
build_dir = "tmp/#{RUBY_PLATFORM}/cairo/#{RUBY_VERSION}"
if File.exist?(File.join(rcairo_source_dir, build_dir))
options[:target_build_dir] = build_dir
end
add_depend_package("cairo", "ext/cairo", rcairo_source_dir, options)
$defs << "-DRUBY_CAIRO_PLATFORM_WIN32"
end
end
have_rb_cairo_h
end
|
#check_ruby_func ⇒ Object
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
|
# File 'lib/mkmf-gnome2.rb', line 282
def check_ruby_func
= "ruby.h"
have_func("rb_define_alloc_func", ) have_func("rb_block_proc", )
STDOUT.print("checking for new allocation framework... ") if Object.respond_to? :allocate
STDOUT.print "yes\n"
$defs << "-DHAVE_OBJECT_ALLOCATE"
else
STDOUT.print "no\n"
end
STDOUT.print("checking for attribute assignment... ") STDOUT.flush
if defined? try_compile and try_compile <<SRC
#include "ruby.h"
#include "node.h"
int node_attrasgn = (int)NODE_ATTRASGN;
SRC
STDOUT.print "yes\n"
$defs << "-DHAVE_NODE_ATTRASGN"
else
STDOUT.print "no\n"
end
end
|
#create_makefile_at_srcdir(pkg_name, srcdir, defs = nil) ⇒ Object
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
|
# File 'lib/mkmf-gnome2.rb', line 169
def create_makefile_at_srcdir(pkg_name, srcdir, defs = nil)
base_dir = File.basename(Dir.pwd)
last_common_index = srcdir.rindex(base_dir)
if last_common_index
builddir = srcdir[(last_common_index + base_dir.size + 1)..-1]
end
builddir ||= "."
FileUtils.mkdir_p(builddir)
Dir.chdir(builddir) do
yield if block_given?
$defs << defs if defs
ensure_objs
create_makefile(pkg_name, srcdir)
end
end
|
#create_pkg_config_file(package_name, c_package, version = nil, pc_file_name = nil) ⇒ Object
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
|
# File 'lib/mkmf-gnome2.rb', line 111
def create_pkg_config_file(package_name, c_package,
version=nil, pc_file_name=nil)
pc_file_name ||= "#{package_name.downcase.sub(/\//, '-')}.pc"
version ||= ruby_gnome2_version || PKGConfig.modversion(c_package)
puts "creating #{pc_file_name}"
File.open(pc_file_name, 'w') do |pc_file|
if package_name.nil?
c_module_name = PKGConfig.name(c_package)
package_name = "Ruby/#{c_module_name}" if c_module_name
end
pc_file.puts("Name: #{package_name}") if package_name
description = PKGConfig.description(c_package)
pc_file.puts("Description: Ruby bindings for #{description}") if description
pc_file.printf("Version: #{version}")
end
end
|
#create_top_makefile(sub_dirs = ["src"]) ⇒ Object
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
|
# File 'lib/mkmf-gnome2.rb', line 203
def create_top_makefile(sub_dirs=["src"])
File.open("Makefile", "w") do |makefile|
makefile.print(<<-EOM)
all:
#{run_make_in_sub_dirs_command("all", sub_dirs)}
install:
#{run_make_in_sub_dirs_command("install", sub_dirs)}
site-install:
#{run_make_in_sub_dirs_command("site-install", sub_dirs)}
clean:
#{run_make_in_sub_dirs_command("clean", sub_dirs)}
EOM
if /mswin32/ =~ RUBY_PLATFORM
makefile.print(<<-EOM)
@if exist extconf.h del extconf.h
@if exist conftest.* del conftest.*
@if exist *.lib del *.lib
@if exist *~ del *~
@if exist mkmf.log del mkmf.log
EOM
else
makefile.print(<<-EOM)
distclean: clean
#{run_make_in_sub_dirs_command("distclean", sub_dirs)}
@rm -f Makefile extconf.h conftest.*
@rm -f core *~ mkmf.log
EOM
end
end
end
|
#ensure_objs ⇒ Object
155
156
157
158
159
160
161
162
163
164
165
166
167
|
# File 'lib/mkmf-gnome2.rb', line 155
def ensure_objs
return unless $objs.nil?
source_dir = '$(srcdir)'
RbConfig.expand(source_dir)
pattern = "*.{#{SRC_EXT.join(',')}}"
srcs = Dir[File.join(source_dir, pattern)]
srcs |= Dir[File.join(".", pattern)]
$objs = srcs.collect do |f|
File.basename(f, ".*") + ".o"
end.uniq
end
|
#glib_mkenums(prefix, files, g_type_prefix, include_files, options = {}) ⇒ Object
315
316
317
318
319
320
|
# File 'lib/mkmf-gnome2.rb', line 315
def glib_mkenums(prefix, files, g_type_prefix, include_files, options={})
add_distcleanfile(prefix + ".h")
add_distcleanfile(prefix + ".c")
GLib::MkEnums.create(prefix, files, g_type_prefix, include_files, options)
add_obj("#{prefix}.o")
end
|
#macro_defined?(macro, src, opt = "") ⇒ Boolean
23
24
25
26
27
28
29
|
# File 'lib/mkmf-gnome2.rb', line 23
def macro_defined?(macro, src, opt="")
try_cpp(src + <<EOP, opt)
#ifndef #{macro}
# error
#endif
EOP
end
|
This is used for the library which doesn’t support version info.
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
|
# File 'lib/mkmf-gnome2.rb', line 240
def (app_name, pkgname, dir = "src")
version = PKGConfig.modversion(pkgname).split(/\./)
(0..2).each do |v|
version[v] = "0" unless version[v]
end
filename = "rb#{app_name.downcase}version.h"
puts "creating #{filename}"
add_distcleanfile(filename)
FileUtils.mkdir_p(dir)
out = File.open(File.join(dir, filename), "w")
out.print %Q[/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */
/************************************************
#{filename} -
This file was generated by mkmf-gnome2.rb.
************************************************/
#ifndef __RB#{app_name}_VERSION_H__
#define __RB#{app_name}_VERSION_H__
#define #{app_name}_MAJOR_VERSION (#{version[0]})
#define #{app_name}_MINOR_VERSION (#{version[1]})
#define #{app_name}_MICRO_VERSION (#{version[2]})
#define #{app_name}_CHECK_VERSION(major,minor,micro) \\
(#{app_name}_MAJOR_VERSION > (major) || \\
(#{app_name}_MAJOR_VERSION == (major) && #{app_name}_MINOR_VERSION > (minor)) || \\
(#{app_name}_MAJOR_VERSION == (major) && #{app_name}_MINOR_VERSION == (minor) && \\
#{app_name}_MICRO_VERSION >= (micro)))
#endif /* __RB#{app_name}_VERSION_H__ */
]
out.close
end
|
#ruby_gnome2_version(glib_source_directory = nil) ⇒ Object
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
|
# File 'lib/mkmf-gnome2.rb', line 131
def ruby_gnome2_version(glib_source_directory=nil)
glib_source_directory ||= File.join(File.dirname(__FILE__), "..",
"ext", "glib2")
rbglib_h = File.join(glib_source_directory, "rbglib.h")
return nil unless File.exist?(rbglib_h)
version = nil
File.open(rbglib_h) do |h_file|
version_info = {}
h_file.each_line do |line|
case line
when /\A#define RBGLIB_(MAJOR|MINOR|MICRO)_VERSION\s+(\d+)/
version_info[$1] = $2
end
end
version_info = [version_info["MAJOR"],
version_info["MINOR"],
version_info["MICRO"]].compact
version = version_info.join(".") if version_info.size == 3
end
version
end
|
#run_make_in_sub_dirs_command(command, sub_dirs) ⇒ Object
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
|
# File 'lib/mkmf-gnome2.rb', line 187
def run_make_in_sub_dirs_command(command, sub_dirs)
if /mswin32/ =~ RUBY_PLATFORM
sub_dirs.collect do |dir|
<<-EOM.chmop
@cd #{dir}
@nmake -nologo DESTDIR=$(DESTDIR) #{command}
@cd ..
EOM
end.join("\n")
else
sub_dirs.collect do |dir|
"\t@cd #{dir}; $(MAKE) #{command}"
end.join("\n")
end
end
|
#setup_win32(target_name, base_dir = nil) ⇒ Object
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
|
# File 'lib/mkmf-gnome2.rb', line 51
def setup_win32(target_name, base_dir=nil)
checking_for(checking_message("Win32 OS")) do
case RUBY_PLATFORM
when /cygwin|mingw|mswin32/
import_library_name = "libruby-#{target_name}.a"
$DLDFLAGS << " -Wl,--out-implib=#{import_library_name}"
$cleanfiles << import_library_name
base_dir ||= Pathname($0).dirname.parent.parent.expand_path
base_dir = Pathname(base_dir) if base_dir.is_a?(String)
binary_base_dir = base_dir + "vendor" + "local"
$CFLAGS += " -I#{binary_base_dir}/include"
pkg_config_dir = binary_base_dir + "lib" + "pkgconfig"
PKGConfig.add_path(pkg_config_dir.to_s)
PKGConfig.set_override_variable("prefix", binary_base_dir.to_s)
true
else
false
end
end
end
|