glib2 3.3.8 → 3.3.9
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.
- checksums.yaml +4 -4
- data/ext/glib2/extconf.rb +22 -6
- data/ext/glib2/glib2.def +7 -2
- data/ext/glib2/rbglib-bytes.c +9 -1
- data/ext/glib2/rbglib-gc.c +1 -3
- data/ext/glib2/rbglib.c +83 -26
- data/ext/glib2/rbglib.h +14 -14
- data/ext/glib2/rbglib2conversions.h +2 -2
- data/ext/glib2/rbglib_iochannel.c +15 -12
- data/ext/glib2/rbglib_maincontext.c +5 -5
- data/ext/glib2/rbglib_messages.c +6 -2
- data/ext/glib2/rbglib_pollfd.c +7 -7
- data/ext/glib2/rbglib_source.c +2 -2
- data/ext/glib2/rbgobj_boxed.c +1 -3
- data/ext/glib2/rbgobj_enums.c +0 -2
- data/ext/glib2/rbgobj_flags.c +4 -5
- data/ext/glib2/rbgobj_object.c +19 -7
- data/ext/glib2/rbgobj_param.c +66 -24
- data/ext/glib2/rbgobj_signal.c +10 -9
- data/ext/glib2/rbgobj_type.c +24 -0
- data/ext/glib2/rbgobj_value.c +10 -4
- data/ext/glib2/rbgobj_valuearray.c +3 -3
- data/ext/glib2/rbgobject.h +8 -4
- data/ext/glib2/rbgprivate.h +1 -2
- data/ext/glib2/rbgutil_callback.c +4 -4
- data/lib/glib-mkenums.rb +2 -0
- data/lib/glib2/deprecated.rb +7 -1
- data/lib/mkmf-gnome.rb +478 -0
- data/lib/mkmf-gnome2.rb +14 -466
- metadata +5 -3
data/ext/glib2/rbgobj_type.c
CHANGED
@@ -429,6 +429,30 @@ rbgobj_gtype_to_ruby_class(GType gtype)
|
|
429
429
|
return cinfo ? cinfo->klass : Qnil;
|
430
430
|
}
|
431
431
|
|
432
|
+
GType
|
433
|
+
rbgobj_gtype_from_ruby(VALUE rb_gtype)
|
434
|
+
{
|
435
|
+
ID id_gtype;
|
436
|
+
|
437
|
+
if (RB_TYPE_P(rb_gtype, RUBY_T_STRING)) {
|
438
|
+
GType gtype;
|
439
|
+
gtype = g_type_from_name(RVAL2CSTR(rb_gtype));
|
440
|
+
if (gtype == G_TYPE_INVALID) {
|
441
|
+
rb_raise(rb_eArgError,
|
442
|
+
"unknown GType name: <%s>",
|
443
|
+
RVAL2CSTR(rb_gtype));
|
444
|
+
}
|
445
|
+
return gtype;
|
446
|
+
}
|
447
|
+
|
448
|
+
CONST_ID(id_gtype, "gtype");
|
449
|
+
if (rb_respond_to(rb_gtype, id_gtype)) {
|
450
|
+
rb_gtype = rb_funcall(rb_gtype, id_gtype, 0);
|
451
|
+
}
|
452
|
+
|
453
|
+
return NUM2ULONG(rb_gtype);
|
454
|
+
}
|
455
|
+
|
432
456
|
VALUE
|
433
457
|
rbgobj_define_class(GType gtype, const gchar *name, VALUE module,
|
434
458
|
RGMarkFunc mark, RGFreeFunc free, VALUE parent)
|
data/ext/glib2/rbgobj_value.c
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */
|
2
2
|
/*
|
3
|
-
* Copyright (C) 2011 Ruby-
|
3
|
+
* Copyright (C) 2011-2019 Ruby-GNOME Project Team
|
4
4
|
* Copyright (C) 2002,2003 Masahiro Sakai
|
5
5
|
*
|
6
6
|
* This library is free software; you can redistribute it and/or
|
@@ -22,13 +22,21 @@
|
|
22
22
|
#include "rbgprivate.h"
|
23
23
|
|
24
24
|
/**********************************************************************/
|
25
|
-
|
25
|
+
static VALUE rb_cGLibValue;
|
26
|
+
|
27
|
+
#define RG_TARGET_NAMESPACE rb_cGLibValue
|
26
28
|
#define _SELF(self) RVAL2GVALUE(self)
|
27
29
|
|
28
30
|
static ID id_to_s;
|
29
31
|
static GQuark qRValueToGValueFunc;
|
30
32
|
static GQuark qGValueToRValueFunc;
|
31
33
|
|
34
|
+
gboolean
|
35
|
+
rbg_is_value(VALUE object)
|
36
|
+
{
|
37
|
+
return RVAL2CBOOL(rb_obj_is_kind_of(object, RG_TARGET_NAMESPACE));
|
38
|
+
}
|
39
|
+
|
32
40
|
void
|
33
41
|
rbgobj_register_r2g_func(GType gtype, RValueToGValueFunc func)
|
34
42
|
{
|
@@ -395,8 +403,6 @@ rg_to_s(VALUE self)
|
|
395
403
|
void
|
396
404
|
Init_gobject_gvalue(void)
|
397
405
|
{
|
398
|
-
VALUE RG_TARGET_NAMESPACE;
|
399
|
-
|
400
406
|
id_to_s = rb_intern("to_s");
|
401
407
|
qRValueToGValueFunc = g_quark_from_static_string("__ruby_r2g_func__");
|
402
408
|
qGValueToRValueFunc = g_quark_from_static_string("__ruby_g2r_func__");
|
@@ -1,6 +1,6 @@
|
|
1
1
|
/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */
|
2
2
|
/*
|
3
|
-
* Copyright (C) 2011-2019 Ruby-
|
3
|
+
* Copyright (C) 2011-2019 Ruby-GNOME Project Team
|
4
4
|
* Copyright (C) 2006 Sjoerd Simons
|
5
5
|
*
|
6
6
|
* This library is free software; you can redistribute it and/or
|
@@ -63,11 +63,11 @@ value_array_from_ruby_body(VALUE value)
|
|
63
63
|
}
|
64
64
|
|
65
65
|
static G_GNUC_NORETURN VALUE
|
66
|
-
value_array_from_ruby_rescue(VALUE value)
|
66
|
+
value_array_from_ruby_rescue(VALUE value, VALUE error)
|
67
67
|
{
|
68
68
|
g_value_array_free(((struct value_array_from_ruby_args *)value)->result);
|
69
69
|
|
70
|
-
rb_exc_raise(
|
70
|
+
rb_exc_raise(error);
|
71
71
|
}
|
72
72
|
|
73
73
|
static void
|
data/ext/glib2/rbgobject.h
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */
|
2
2
|
/*
|
3
|
-
* Copyright (C) 2011-
|
4
|
-
* Copyright (C) 2003,2006 Ruby-
|
3
|
+
* Copyright (C) 2011-2019 Ruby-GNOME Project Team
|
4
|
+
* Copyright (C) 2003,2006 Ruby-GNOME Project Team
|
5
5
|
* Copyright (C) 2002,2003 Masahiro Sakai
|
6
6
|
*
|
7
7
|
* This library is free software; you can redistribute it and/or
|
@@ -192,6 +192,7 @@ extern const RGObjClassInfo *rbgobj_lookup_class_by_gtype_full(GType gtype,
|
|
192
192
|
VALUE parent,
|
193
193
|
gboolean create_object);
|
194
194
|
extern VALUE rbgobj_gtype_to_ruby_class(GType gtype);
|
195
|
+
extern GType rbgobj_gtype_from_ruby(VALUE rb_gtype);
|
195
196
|
extern VALUE rbgobj_define_class(GType gtype, const gchar* name, VALUE module,
|
196
197
|
RGMarkFunc mark, RGFreeFunc free, VALUE parent);
|
197
198
|
extern VALUE rbgobj_define_class_dynamic(const gchar* gtype_name,
|
@@ -305,8 +306,10 @@ extern VALUE rbgobj_flags_alloc_func(VALUE klass);
|
|
305
306
|
extern GType g_source_get_type(void);
|
306
307
|
#endif
|
307
308
|
|
308
|
-
#
|
309
|
-
|
309
|
+
#if !GLIB_CHECK_VERSION(2, 36, 0)
|
310
|
+
#define G_TYPE_POLLFD (g_pollfd_get_type())
|
311
|
+
extern GType g_pollfd_get_type(void);
|
312
|
+
#endif
|
310
313
|
|
311
314
|
/* rbglib_keyfile.c */
|
312
315
|
#if !GLIB_CHECK_VERSION(2,31,2)
|
@@ -332,6 +335,7 @@ typedef struct {
|
|
332
335
|
|
333
336
|
extern void rbgobj_convert_define(const RGConvertTable *table);
|
334
337
|
|
338
|
+
|
335
339
|
G_END_DECLS
|
336
340
|
|
337
341
|
#include "rbgcompat.h"
|
data/ext/glib2/rbgprivate.h
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */
|
2
2
|
/*
|
3
|
-
* Copyright (C) 2007-2019 Ruby-
|
3
|
+
* Copyright (C) 2007-2019 Ruby-GNOME Project Team
|
4
4
|
*
|
5
5
|
* This library is free software; you can redistribute it and/or
|
6
6
|
* modify it under the terms of the GNU Lesser General Public
|
@@ -23,7 +23,6 @@
|
|
23
23
|
/*
|
24
24
|
* CentOS 6: GLib 2.28
|
25
25
|
* CentOS 7: GLib 2.50
|
26
|
-
* Ubuntu 14.04: GLib 2.40
|
27
26
|
* Ubuntu 16.04: GLib 2.48
|
28
27
|
* Ubuntu 18.04: GLib 2.54
|
29
28
|
*/
|
@@ -1,7 +1,6 @@
|
|
1
1
|
/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */
|
2
2
|
/*
|
3
|
-
* Copyright (C)
|
4
|
-
* Copyright (C) 2007 Ruby-GNOME2 Project
|
3
|
+
* Copyright (C) 2007-2019 Ruby-GNOME2 Project Team
|
5
4
|
*
|
6
5
|
* This library is free software; you can redistribute it and/or
|
7
6
|
* modify it under the terms of the GNU Lesser General Public
|
@@ -82,8 +81,9 @@ exec_callback(VALUE data)
|
|
82
81
|
}
|
83
82
|
|
84
83
|
static VALUE
|
85
|
-
process_request(
|
84
|
+
process_request(void *user_data)
|
86
85
|
{
|
86
|
+
CallbackRequest *request = user_data;
|
87
87
|
g_mutex_lock(request->done_mutex);
|
88
88
|
request->result = rbgutil_protect(exec_callback, (VALUE)request);
|
89
89
|
g_cond_signal(request->done_cond);
|
@@ -93,7 +93,7 @@ process_request(CallbackRequest *request)
|
|
93
93
|
}
|
94
94
|
|
95
95
|
static VALUE
|
96
|
-
mainloop(void)
|
96
|
+
mainloop(G_GNUC_UNUSED void *user_data)
|
97
97
|
{
|
98
98
|
for (;;) {
|
99
99
|
CallbackRequest *request;
|
data/lib/glib-mkenums.rb
CHANGED
@@ -168,6 +168,7 @@ GType #{@enum_name}_get_type (void);
|
|
168
168
|
end
|
169
169
|
@targets << [path, EnumDefinition.parse(data, g_type_prefix, options)]
|
170
170
|
end
|
171
|
+
@preamble = options[:preamble]
|
171
172
|
end
|
172
173
|
|
173
174
|
def create_enums(meth) # :nodoc:
|
@@ -186,6 +187,7 @@ GType #{@enum_name}_get_type (void);
|
|
186
187
|
# Create a C source as a String.
|
187
188
|
def create_c
|
188
189
|
ret = "\n/* Generated by glib-mkenums.rb ($Id$) */ \n\n"
|
190
|
+
ret << "#{@preamble}\n" if @preamble
|
189
191
|
ret << %Q[#include "#{@target_filename}.h"\n]
|
190
192
|
@include_files.each do |file|
|
191
193
|
ret << "#include <#{file}>\n"
|
data/lib/glib2/deprecated.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
# Copyright (C) 2018 Ruby-
|
1
|
+
# Copyright (C) 2018-2019 Ruby-GNOME Project Team
|
2
2
|
#
|
3
3
|
# This library is free software; you can redistribute it and/or
|
4
4
|
# modify it under the terms of the GNU Lesser General Public
|
@@ -20,4 +20,10 @@ module GLib
|
|
20
20
|
define_deprecated_singleton_method :remove,
|
21
21
|
warn: "Use 'GLib::Source.remove(id)'."
|
22
22
|
end
|
23
|
+
|
24
|
+
class Param
|
25
|
+
extend GLib::Deprecatable
|
26
|
+
define_deprecated_const(:PRIVATE, :STATIC_NAME)
|
27
|
+
define_deprecated_method(:private?, :static_name?)
|
28
|
+
end
|
23
29
|
end
|
data/lib/mkmf-gnome.rb
ADDED
@@ -0,0 +1,478 @@
|
|
1
|
+
# Copyright (C) 2003-2019 Ruby-GNOME Project Team
|
2
|
+
#
|
3
|
+
# This library is free software; you can redistribute it and/or
|
4
|
+
# modify it under the terms of the GNU Lesser General Public
|
5
|
+
# License as published by the Free Software Foundation; either
|
6
|
+
# version 2.1 of the License, or (at your option) any later version.
|
7
|
+
#
|
8
|
+
# This library is distributed in the hope that it will be useful,
|
9
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
10
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
11
|
+
# Lesser General Public License for more details.
|
12
|
+
#
|
13
|
+
# You should have received a copy of the GNU Lesser General Public
|
14
|
+
# License along with this library; if not, write to the Free Software
|
15
|
+
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
16
|
+
|
17
|
+
require 'English'
|
18
|
+
require 'mkmf'
|
19
|
+
require 'pkg-config'
|
20
|
+
require 'glib-mkenums'
|
21
|
+
require "native-package-installer"
|
22
|
+
|
23
|
+
$CFLAGS += " #{ENV['CFLAGS']}" if ENV['CFLAGS']
|
24
|
+
|
25
|
+
def gcc?
|
26
|
+
CONFIG["GCC"] == "yes"
|
27
|
+
end
|
28
|
+
|
29
|
+
def disable_optimization_build_flag(flags)
|
30
|
+
if gcc?
|
31
|
+
RbConfig.expand(flags.dup).gsub(/(^|\s)?-O\d(\s|$)?/, '\\1-O0\\2')
|
32
|
+
else
|
33
|
+
flags
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
def enable_debug_build_flag(flags)
|
38
|
+
if gcc?
|
39
|
+
expanded_flags = RbConfig.expand(flags.dup)
|
40
|
+
debug_option_pattern = /(^|\s)-g\d?(\s|$)/
|
41
|
+
if debug_option_pattern =~ expanded_flags
|
42
|
+
expanded_flags.gsub(debug_option_pattern, '\\1-g3\\2')
|
43
|
+
else
|
44
|
+
flags + " -g3"
|
45
|
+
end
|
46
|
+
else
|
47
|
+
flags
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
checking_for(checking_message("--enable-debug-build option")) do
|
52
|
+
enable_debug_build = enable_config("debug-build", false)
|
53
|
+
if enable_debug_build
|
54
|
+
$CFLAGS = disable_optimization_build_flag($CFLAGS)
|
55
|
+
$CFLAGS = enable_debug_build_flag($CFLAGS)
|
56
|
+
|
57
|
+
$CXXFLAGS = disable_optimization_build_flag($CXXFLAGS)
|
58
|
+
$CXXFLAGS = enable_debug_build_flag($CXXFLAGS)
|
59
|
+
end
|
60
|
+
enable_debug_build
|
61
|
+
end
|
62
|
+
|
63
|
+
def try_compiler_option(opt, &block)
|
64
|
+
checking_for "#{opt} option to compiler" do
|
65
|
+
if try_compile '', opt + " -Werror", &block
|
66
|
+
$CFLAGS += " #{opt}"
|
67
|
+
true
|
68
|
+
else
|
69
|
+
false
|
70
|
+
end
|
71
|
+
end
|
72
|
+
end
|
73
|
+
|
74
|
+
try_compiler_option '-Wall'
|
75
|
+
try_compiler_option '-Waggregate-return'
|
76
|
+
try_compiler_option '-Wcast-align'
|
77
|
+
# NOTE: Generates way too many false positives.
|
78
|
+
# try_compiler_option '-Wconversion'
|
79
|
+
try_compiler_option '-Wextra'
|
80
|
+
try_compiler_option '-Wformat=2'
|
81
|
+
try_compiler_option '-Winit-self'
|
82
|
+
# NOTE: This generates warnings for functions defined in ruby.h.
|
83
|
+
# try_compiler_option '-Winline'
|
84
|
+
try_compiler_option '-Wlarger-than-65500'
|
85
|
+
try_compiler_option '-Wmissing-declarations'
|
86
|
+
try_compiler_option '-Wmissing-format-attribute'
|
87
|
+
try_compiler_option '-Wmissing-include-dirs'
|
88
|
+
try_compiler_option '-Wmissing-noreturn'
|
89
|
+
try_compiler_option '-Wmissing-prototypes'
|
90
|
+
try_compiler_option '-Wnested-externs'
|
91
|
+
try_compiler_option '-Wold-style-definition'
|
92
|
+
try_compiler_option '-Wpacked'
|
93
|
+
try_compiler_option '-Wp,-D_FORTIFY_SOURCE=2'
|
94
|
+
try_compiler_option '-Wpointer-arith'
|
95
|
+
# NOTE: ruby.h and intern.h have too many of these.
|
96
|
+
# try_compiler_option '-Wredundant-decls'
|
97
|
+
# NOTE: Complains about index, for example.
|
98
|
+
# try_compiler_option '-Wshadow'
|
99
|
+
try_compiler_option '-Wundef'
|
100
|
+
# NOTE: Incredible amounts of false positives.
|
101
|
+
#try_compiler_option '-Wunreachable-code'
|
102
|
+
try_compiler_option '-Wout-of-line-declaration'
|
103
|
+
try_compiler_option '-Wunsafe-loop-optimizations'
|
104
|
+
try_compiler_option '-Wwrite-strings'
|
105
|
+
|
106
|
+
if /-Wl,--no-undefined/ =~ $LDFLAGS.to_s
|
107
|
+
$LDFLAGS.gsub!(/-Wl,--no-undefined/, '')
|
108
|
+
end
|
109
|
+
|
110
|
+
include_path = nil
|
111
|
+
if ENV['GTK_BASEPATH'] and /cygwin/ !~ RUBY_PLATFORM
|
112
|
+
include_path = (ENV['GTK_BASEPATH'] + "\\INCLUDE").gsub("\\", "/")
|
113
|
+
# $hdrdir += " -I#{include_path} "
|
114
|
+
$INCFLAGS += " -I#{include_path} "
|
115
|
+
end
|
116
|
+
|
117
|
+
def windows_platform?
|
118
|
+
/cygwin|mingw|mswin/ === RUBY_PLATFORM
|
119
|
+
end
|
120
|
+
|
121
|
+
# For backward compatibility
|
122
|
+
def setup_windows(target_name, base_dir=nil)
|
123
|
+
checking_for(checking_message("Windows")) do
|
124
|
+
windows_platform?
|
125
|
+
end
|
126
|
+
end
|
127
|
+
# For backward compatibility
|
128
|
+
def setup_win32(*args, &block)
|
129
|
+
setup_windows(*args, &block)
|
130
|
+
end
|
131
|
+
|
132
|
+
def find_gem_spec(package)
|
133
|
+
begin
|
134
|
+
Gem::Specification.find_by_name(package)
|
135
|
+
rescue LoadError
|
136
|
+
nil
|
137
|
+
end
|
138
|
+
end
|
139
|
+
|
140
|
+
def setup_homebrew
|
141
|
+
checking_for(checking_message("Homebrew")) do
|
142
|
+
platform = NativePackageInstaller::Platform.detect
|
143
|
+
if platform.is_a?(NativePackageInstaller::Platform::Homebrew)
|
144
|
+
libffi_prefix = `brew --prefix libffi`.chomp
|
145
|
+
PKGConfig.add_path("#{libffi_prefix}/lib/pkgconfig")
|
146
|
+
true
|
147
|
+
else
|
148
|
+
false
|
149
|
+
end
|
150
|
+
end
|
151
|
+
end
|
152
|
+
|
153
|
+
setup_homebrew
|
154
|
+
|
155
|
+
#add_depend_package("glib2", "ext/glib2", "/...../ruby-gnome2")
|
156
|
+
def add_depend_package(target_name, target_srcdir, top_srcdir, options={})
|
157
|
+
gem_spec = find_gem_spec(target_name)
|
158
|
+
if gem_spec
|
159
|
+
target_source_dir = File.join(gem_spec.full_gem_path, "ext/#{target_name}")
|
160
|
+
target_build_dir = target_source_dir
|
161
|
+
add_depend_package_path(target_name,
|
162
|
+
target_source_dir,
|
163
|
+
target_build_dir)
|
164
|
+
end
|
165
|
+
|
166
|
+
[top_srcdir,
|
167
|
+
File.join(top_srcdir, target_name),
|
168
|
+
$configure_args['--topdir'],
|
169
|
+
File.join($configure_args['--topdir'], target_name)].each do |topdir|
|
170
|
+
topdir = File.expand_path(topdir)
|
171
|
+
target_source_dir_full_path = File.join(topdir, target_srcdir)
|
172
|
+
|
173
|
+
top_build_dir = options[:top_build_dir] || topdir
|
174
|
+
target_build_dir = options[:target_build_dir] || target_srcdir
|
175
|
+
target_build_dir_full_path = File.join(top_build_dir, target_build_dir)
|
176
|
+
unless File.exist?(target_build_dir_full_path)
|
177
|
+
target_build_dir_full_path = File.join(top_build_dir, target_srcdir)
|
178
|
+
end
|
179
|
+
unless File.exist?(target_build_dir_full_path)
|
180
|
+
target_build_dir_full_path = File.join(topdir, target_build_dir)
|
181
|
+
end
|
182
|
+
unless File.exist?(target_build_dir_full_path)
|
183
|
+
target_build_dir_full_path = File.join(topdir, target_srcdir)
|
184
|
+
end
|
185
|
+
add_depend_package_path(target_name,
|
186
|
+
target_source_dir_full_path,
|
187
|
+
target_build_dir_full_path)
|
188
|
+
end
|
189
|
+
end
|
190
|
+
|
191
|
+
def add_depend_package_path(target_name, target_source_dir, target_build_dir)
|
192
|
+
if File.exist?(target_source_dir)
|
193
|
+
$INCFLAGS = "-I#{target_source_dir} #{$INCFLAGS}"
|
194
|
+
end
|
195
|
+
|
196
|
+
return unless File.exist?(target_build_dir)
|
197
|
+
if target_source_dir != target_build_dir
|
198
|
+
$INCFLAGS = "-I#{target_build_dir} #{$INCFLAGS}"
|
199
|
+
end
|
200
|
+
|
201
|
+
library_base_name = target_name.gsub(/-/, "_")
|
202
|
+
case RUBY_PLATFORM
|
203
|
+
when /cygwin|mingw/
|
204
|
+
$libs << " " << File.join(target_build_dir, "#{library_base_name}.so")
|
205
|
+
when /mswin/
|
206
|
+
$DLDFLAGS << " /libpath:#{target_build_dir}"
|
207
|
+
$libs << " #{library_base_name}-$(arch).lib"
|
208
|
+
end
|
209
|
+
end
|
210
|
+
|
211
|
+
def add_distcleanfile(file)
|
212
|
+
$distcleanfiles ||= []
|
213
|
+
$distcleanfiles << file
|
214
|
+
end
|
215
|
+
|
216
|
+
def create_pkg_config_file(package_name, c_package,
|
217
|
+
version=nil, pc_file_name=nil)
|
218
|
+
pc_file_name ||= "#{package_name.downcase.sub(/\//, '-')}.pc"
|
219
|
+
version ||= ruby_gnome_version || PKGConfig.modversion(c_package)
|
220
|
+
|
221
|
+
puts "creating #{pc_file_name}"
|
222
|
+
|
223
|
+
File.open(pc_file_name, 'w') do |pc_file|
|
224
|
+
if package_name.nil?
|
225
|
+
c_module_name = PKGConfig.name(c_package)
|
226
|
+
package_name = "Ruby/#{c_module_name}" if c_module_name
|
227
|
+
end
|
228
|
+
pc_file.puts("Name: #{package_name}") if package_name
|
229
|
+
|
230
|
+
description = PKGConfig.description(c_package)
|
231
|
+
pc_file.puts("Description: Ruby bindings for #{description}") if description
|
232
|
+
pc_file.printf("Version: #{version}")
|
233
|
+
end
|
234
|
+
|
235
|
+
add_distcleanfile(pc_file_name)
|
236
|
+
end
|
237
|
+
|
238
|
+
def ruby_gnome_version(glib_source_directory=nil)
|
239
|
+
glib_source_directory ||= File.join(File.dirname(__FILE__), "..",
|
240
|
+
"ext", "glib2")
|
241
|
+
rbglib_h = File.join(glib_source_directory, "rbglib.h")
|
242
|
+
return nil unless File.exist?(rbglib_h)
|
243
|
+
|
244
|
+
version = nil
|
245
|
+
File.open(rbglib_h) do |h_file|
|
246
|
+
version_info = {}
|
247
|
+
h_file.each_line do |line|
|
248
|
+
case line
|
249
|
+
when /\A#define RBGLIB_(MAJOR|MINOR|MICRO)_VERSION\s+(\d+)/
|
250
|
+
version_info[$1] = $2
|
251
|
+
end
|
252
|
+
end
|
253
|
+
version_info = [version_info["MAJOR"],
|
254
|
+
version_info["MINOR"],
|
255
|
+
version_info["MICRO"]].compact
|
256
|
+
version = version_info.join(".") if version_info.size == 3
|
257
|
+
end
|
258
|
+
|
259
|
+
version
|
260
|
+
end
|
261
|
+
|
262
|
+
def ruby_gnome2_version(*args)
|
263
|
+
warn("ruby_gnome2_version is deprecated. Use ruby_gnome_version instead.")
|
264
|
+
ruby_gnome_version(*args)
|
265
|
+
end
|
266
|
+
|
267
|
+
def ensure_objs
|
268
|
+
return unless $objs.nil?
|
269
|
+
|
270
|
+
source_dir = '$(srcdir)'
|
271
|
+
RbConfig.expand(source_dir)
|
272
|
+
|
273
|
+
pattern = "*.{#{SRC_EXT.join(',')}}"
|
274
|
+
srcs = Dir[File.join(source_dir, pattern)]
|
275
|
+
srcs |= Dir[File.join(".", pattern)]
|
276
|
+
$objs = srcs.collect do |f|
|
277
|
+
File.basename(f, ".*") + ".o"
|
278
|
+
end.uniq
|
279
|
+
end
|
280
|
+
|
281
|
+
def create_makefile_at_srcdir(pkg_name, srcdir, defs = nil)
|
282
|
+
base_dir = File.basename(Dir.pwd)
|
283
|
+
last_common_index = srcdir.rindex(base_dir)
|
284
|
+
if last_common_index
|
285
|
+
builddir = srcdir[(last_common_index + base_dir.size + 1)..-1]
|
286
|
+
end
|
287
|
+
builddir ||= "."
|
288
|
+
FileUtils.mkdir_p(builddir)
|
289
|
+
|
290
|
+
Dir.chdir(builddir) do
|
291
|
+
yield if block_given?
|
292
|
+
|
293
|
+
$defs << defs if defs
|
294
|
+
ensure_objs
|
295
|
+
create_makefile(pkg_name, srcdir)
|
296
|
+
end
|
297
|
+
end
|
298
|
+
|
299
|
+
def run_make_in_sub_dirs_command(command, sub_dirs)
|
300
|
+
if /mswin/ =~ RUBY_PLATFORM
|
301
|
+
sub_dirs.collect do |dir|
|
302
|
+
<<-EOM.chmop
|
303
|
+
@cd #{dir}
|
304
|
+
@nmake -nologo DESTDIR=$(DESTDIR) #{command}
|
305
|
+
@cd ..
|
306
|
+
EOM
|
307
|
+
end.join("\n")
|
308
|
+
else
|
309
|
+
sub_dirs.collect do |dir|
|
310
|
+
"\t@cd #{dir}; $(MAKE) #{command}"
|
311
|
+
end.join("\n")
|
312
|
+
end
|
313
|
+
end
|
314
|
+
|
315
|
+
def create_top_makefile(sub_dirs=["src"])
|
316
|
+
File.open("Makefile", "w") do |makefile|
|
317
|
+
makefile.print(<<-EOM)
|
318
|
+
all:
|
319
|
+
#{run_make_in_sub_dirs_command("all", sub_dirs)}
|
320
|
+
|
321
|
+
install:
|
322
|
+
#{run_make_in_sub_dirs_command("install", sub_dirs)}
|
323
|
+
|
324
|
+
site-install:
|
325
|
+
#{run_make_in_sub_dirs_command("site-install", sub_dirs)}
|
326
|
+
|
327
|
+
clean:
|
328
|
+
#{run_make_in_sub_dirs_command("clean", sub_dirs)}
|
329
|
+
EOM
|
330
|
+
|
331
|
+
if /mswin/ =~ RUBY_PLATFORM
|
332
|
+
makefile.print(<<-EOM)
|
333
|
+
@if exist extconf.h del extconf.h
|
334
|
+
@if exist conftest.* del conftest.*
|
335
|
+
@if exist *.lib del *.lib
|
336
|
+
@if exist *~ del *~
|
337
|
+
@if exist mkmf.log del mkmf.log
|
338
|
+
EOM
|
339
|
+
else
|
340
|
+
makefile.print(<<-EOM)
|
341
|
+
|
342
|
+
distclean: clean
|
343
|
+
#{run_make_in_sub_dirs_command("distclean", sub_dirs)}
|
344
|
+
@rm -f Makefile extconf.h conftest.*
|
345
|
+
@rm -f core *~ mkmf.log
|
346
|
+
EOM
|
347
|
+
end
|
348
|
+
end
|
349
|
+
end
|
350
|
+
|
351
|
+
# This is used for the library which doesn't support version info.
|
352
|
+
def make_version_header(app_name, pkgname, dir = "src")
|
353
|
+
version = PKGConfig.modversion(pkgname).split(/\./)
|
354
|
+
(0..2).each do |v|
|
355
|
+
version[v] = "0" unless version[v]
|
356
|
+
if /\A(\d+)/ =~ version[v]
|
357
|
+
number = $1
|
358
|
+
tag = $POSTMATCH
|
359
|
+
unless tag.empty?
|
360
|
+
version[v] = number
|
361
|
+
version[3] = tag
|
362
|
+
end
|
363
|
+
end
|
364
|
+
end
|
365
|
+
filename = "rb#{app_name.downcase}version.h"
|
366
|
+
|
367
|
+
puts "creating #{filename}"
|
368
|
+
|
369
|
+
add_distcleanfile(filename)
|
370
|
+
|
371
|
+
FileUtils.mkdir_p(dir)
|
372
|
+
out = File.open(File.join(dir, filename), "w")
|
373
|
+
|
374
|
+
version_definitions = []
|
375
|
+
["MAJOR", "MINOR", "MICRO", "TAG"].each_with_index do |type, i|
|
376
|
+
_version = version[i]
|
377
|
+
next if _version.nil?
|
378
|
+
version_definitions << "#define #{app_name}_#{type}_VERSION (#{_version})"
|
379
|
+
end
|
380
|
+
out.print %Q[/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */
|
381
|
+
/************************************************
|
382
|
+
|
383
|
+
#{filename} -
|
384
|
+
|
385
|
+
This file was generated by mkmf-gnome.rb.
|
386
|
+
|
387
|
+
************************************************/
|
388
|
+
|
389
|
+
#ifndef __RB#{app_name}_VERSION_H__
|
390
|
+
#define __RB#{app_name}_VERSION_H__
|
391
|
+
|
392
|
+
#{version_definitions.join("\n")}
|
393
|
+
|
394
|
+
#define #{app_name}_CHECK_VERSION(major,minor,micro) \\
|
395
|
+
(#{app_name}_MAJOR_VERSION > (major) || \\
|
396
|
+
(#{app_name}_MAJOR_VERSION == (major) && #{app_name}_MINOR_VERSION > (minor)) || \\
|
397
|
+
(#{app_name}_MAJOR_VERSION == (major) && #{app_name}_MINOR_VERSION == (minor) && \\
|
398
|
+
#{app_name}_MICRO_VERSION >= (micro)))
|
399
|
+
|
400
|
+
|
401
|
+
#endif /* __RB#{app_name}_VERSION_H__ */
|
402
|
+
]
|
403
|
+
out.close
|
404
|
+
end
|
405
|
+
|
406
|
+
def add_obj(name)
|
407
|
+
ensure_objs
|
408
|
+
$objs << name unless $objs.index(name)
|
409
|
+
end
|
410
|
+
|
411
|
+
def glib_mkenums(prefix, files, g_type_prefix, include_files, options={})
|
412
|
+
add_distcleanfile(prefix + ".h")
|
413
|
+
add_distcleanfile(prefix + ".c")
|
414
|
+
GLib::MkEnums.create(prefix, files, g_type_prefix, include_files, options)
|
415
|
+
add_obj("#{prefix}.o")
|
416
|
+
end
|
417
|
+
|
418
|
+
def check_cairo(options={})
|
419
|
+
rcairo_source_dir = options[:rcairo_source_dir]
|
420
|
+
if rcairo_source_dir.nil?
|
421
|
+
rcairo_source_base_dir = "rcairo"
|
422
|
+
top_dir = options[:top_dir]
|
423
|
+
if top_dir
|
424
|
+
rcairo_source_dir = File.join(top_dir, "..", rcairo_source_base_dir)
|
425
|
+
end
|
426
|
+
end
|
427
|
+
|
428
|
+
if rcairo_source_dir and !File.exist?(rcairo_source_dir)
|
429
|
+
rcairo_source_dir = nil
|
430
|
+
end
|
431
|
+
if rcairo_source_dir.nil?
|
432
|
+
cairo_gem_spec = find_gem_spec("cairo")
|
433
|
+
rcairo_source_dir = cairo_gem_spec.full_gem_path if cairo_gem_spec
|
434
|
+
end
|
435
|
+
|
436
|
+
unless rcairo_source_dir.nil?
|
437
|
+
options = {}
|
438
|
+
build_dir = "tmp/#{RUBY_PLATFORM}/cairo/#{RUBY_VERSION}"
|
439
|
+
if File.exist?(File.join(rcairo_source_dir, build_dir))
|
440
|
+
options[:target_build_dir] = build_dir
|
441
|
+
end
|
442
|
+
add_depend_package("cairo", "ext/cairo", rcairo_source_dir, options)
|
443
|
+
end
|
444
|
+
|
445
|
+
PKGConfig.have_package("cairo") and have_header("rb_cairo.h")
|
446
|
+
end
|
447
|
+
|
448
|
+
def install_missing_native_package(native_package_info)
|
449
|
+
NativePackageInstaller.install(native_package_info)
|
450
|
+
end
|
451
|
+
|
452
|
+
def required_pkg_config_package(package_info, native_package_info=nil)
|
453
|
+
if package_info.is_a?(Array)
|
454
|
+
required_package_info = package_info
|
455
|
+
else
|
456
|
+
required_package_info = [package_info]
|
457
|
+
end
|
458
|
+
return true if PKGConfig.have_package(*required_package_info)
|
459
|
+
|
460
|
+
native_package_info ||= {}
|
461
|
+
return false unless install_missing_native_package(native_package_info)
|
462
|
+
|
463
|
+
PKGConfig.have_package(*required_package_info)
|
464
|
+
end
|
465
|
+
|
466
|
+
add_include_path = Proc.new do |dir_variable|
|
467
|
+
value = RbConfig::CONFIG[dir_variable]
|
468
|
+
if value and File.exist?(value)
|
469
|
+
$INCFLAGS << " -I$(#{dir_variable}) "
|
470
|
+
end
|
471
|
+
end
|
472
|
+
|
473
|
+
add_include_path.call("sitearchdir")
|
474
|
+
add_include_path.call("vendorarchdir")
|
475
|
+
|
476
|
+
if /mingw/ =~ RUBY_PLATFORM
|
477
|
+
$ruby.gsub!('\\', '/')
|
478
|
+
end
|