glib2 1.2.6 → 2.0.0
Sign up to get free protection for your applications and to get access to all the features.
- data/Rakefile +59 -24
- data/ext/glib2/extconf.rb +1 -1
- data/ext/glib2/glib2.def +1 -0
- data/ext/glib2/rbglib.h +3 -3
- data/lib/glib2.rb +11 -10
- data/lib/gnome2-raketask.rb +4 -226
- data/lib/gnome2/rake/external-package.rb +198 -0
- data/lib/gnome2/rake/native-binary-build-task.rb +108 -0
- data/lib/gnome2/rake/package-task.rb +244 -0
- data/lib/gnome2/rake/package.rb +122 -0
- data/lib/gnome2/rake/source-download-task.rb +81 -0
- data/lib/gnome2/rake/win32-binary-build-task.rb +223 -0
- data/lib/{gnome2-win32-binary-download-task.rb → gnome2/rake/win32-binary-download-task.rb} +7 -7
- data/lib/mkmf-gnome2.rb +3 -2
- metadata +9 -4
- data/lib/gnome2-win32-binary-build-task.rb +0 -250
@@ -0,0 +1,198 @@
|
|
1
|
+
# -*- ruby -*-
|
2
|
+
#
|
3
|
+
# Copyright (C) 2013 Ruby-GNOME2 Project Team
|
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 as published by the Free Software Foundation; either
|
8
|
+
# version 2.1 of the License, or (at your option) any later version.
|
9
|
+
#
|
10
|
+
# This library is distributed in the hope that it will be useful,
|
11
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
12
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
13
|
+
# Lesser General Public License for more details.
|
14
|
+
#
|
15
|
+
# You should have received a copy of the GNU Lesser General Public
|
16
|
+
# License along with this library; if not, write to the Free Software
|
17
|
+
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
18
|
+
|
19
|
+
module GNOME2
|
20
|
+
module Rake
|
21
|
+
class ExternalPackage < Struct.new(:name,
|
22
|
+
:label,
|
23
|
+
:version,
|
24
|
+
:download_site,
|
25
|
+
:download_base_url,
|
26
|
+
:compression_method,
|
27
|
+
:windows,
|
28
|
+
:native,
|
29
|
+
:patches,
|
30
|
+
:need_autogen,
|
31
|
+
:need_autoreconf,
|
32
|
+
:build_concurrently,
|
33
|
+
:bundled_packages)
|
34
|
+
def initialize(properties)
|
35
|
+
super()
|
36
|
+
properties.each do |key, value|
|
37
|
+
send("#{key}=", value)
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
def compression_method
|
42
|
+
super || "gz"
|
43
|
+
end
|
44
|
+
|
45
|
+
def base_name
|
46
|
+
"#{name}-#{version}"
|
47
|
+
end
|
48
|
+
|
49
|
+
def archive_base_name
|
50
|
+
"#{base_name}.tar.#{compression_method}"
|
51
|
+
end
|
52
|
+
|
53
|
+
def archive_url
|
54
|
+
"#{download_base_url}/#{archive_base_name}"
|
55
|
+
end
|
56
|
+
|
57
|
+
def download_base_url
|
58
|
+
super || download_site_base_url
|
59
|
+
end
|
60
|
+
|
61
|
+
def patches
|
62
|
+
super || []
|
63
|
+
end
|
64
|
+
|
65
|
+
def need_autogen?
|
66
|
+
need_autogen
|
67
|
+
end
|
68
|
+
|
69
|
+
def need_autoreconf?
|
70
|
+
need_autoreconf
|
71
|
+
end
|
72
|
+
|
73
|
+
def windows
|
74
|
+
super || WindowsConfiguration.new({})
|
75
|
+
end
|
76
|
+
|
77
|
+
def windows=(properties)
|
78
|
+
super(WindowsConfiguration.new(properties))
|
79
|
+
end
|
80
|
+
|
81
|
+
def native
|
82
|
+
super || NativeConfiguration.new({})
|
83
|
+
end
|
84
|
+
|
85
|
+
def native=(properties)
|
86
|
+
super(NativeConfiguration.new(properties))
|
87
|
+
end
|
88
|
+
|
89
|
+
def bundled_packages
|
90
|
+
super || []
|
91
|
+
end
|
92
|
+
|
93
|
+
private
|
94
|
+
def download_site_base_url
|
95
|
+
case download_site
|
96
|
+
when :gnome
|
97
|
+
base_url = "http://ftp.gnome.org/pub/gnome/sources"
|
98
|
+
release_series = version.gsub(/\A(\d+\.\d+).+\z/, '\1')
|
99
|
+
base_url << "/#{name}/#{release_series}"
|
100
|
+
else
|
101
|
+
base_url = nil
|
102
|
+
end
|
103
|
+
base_url
|
104
|
+
end
|
105
|
+
|
106
|
+
class WindowsConfiguration < Struct.new(:build,
|
107
|
+
:include_paths,
|
108
|
+
:library_paths,
|
109
|
+
:configure_args,
|
110
|
+
:patches,
|
111
|
+
:need_autogen,
|
112
|
+
:need_autoreconf,
|
113
|
+
:build_concurrently,
|
114
|
+
:use_cc_environment_variable)
|
115
|
+
def initialize(properties)
|
116
|
+
super()
|
117
|
+
properties.each do |key, value|
|
118
|
+
send("#{key}=", value)
|
119
|
+
end
|
120
|
+
end
|
121
|
+
|
122
|
+
def build?
|
123
|
+
build.nil? ? true : build
|
124
|
+
end
|
125
|
+
|
126
|
+
def include_paths
|
127
|
+
super || []
|
128
|
+
end
|
129
|
+
|
130
|
+
def library_paths
|
131
|
+
super || []
|
132
|
+
end
|
133
|
+
|
134
|
+
def configure_args
|
135
|
+
super || []
|
136
|
+
end
|
137
|
+
|
138
|
+
def patches
|
139
|
+
super || []
|
140
|
+
end
|
141
|
+
|
142
|
+
def need_autogen?
|
143
|
+
need_autogen.nil? ? false : need_autogen
|
144
|
+
end
|
145
|
+
|
146
|
+
def need_autoreconf?
|
147
|
+
need_autoreconf.nil? ? false : need_autoreconf
|
148
|
+
end
|
149
|
+
|
150
|
+
def build_concurrently?
|
151
|
+
build_concurrently.nil? ? true : build_concurrently
|
152
|
+
end
|
153
|
+
|
154
|
+
def use_cc_environment_variable?
|
155
|
+
use_cc_environment_variable.nil? ? true : use_cc_environment_variable
|
156
|
+
end
|
157
|
+
end
|
158
|
+
|
159
|
+
class NativeConfiguration < Struct.new(:build,
|
160
|
+
:configure_args,
|
161
|
+
:patches,
|
162
|
+
:need_autogen,
|
163
|
+
:need_autoreconf,
|
164
|
+
:build_concurrently)
|
165
|
+
def initialize(properties)
|
166
|
+
super()
|
167
|
+
properties.each do |key, value|
|
168
|
+
send("#{key}=", value)
|
169
|
+
end
|
170
|
+
end
|
171
|
+
|
172
|
+
def build?
|
173
|
+
build.nil? ? false : build
|
174
|
+
end
|
175
|
+
|
176
|
+
def configure_args
|
177
|
+
super || []
|
178
|
+
end
|
179
|
+
|
180
|
+
def patches
|
181
|
+
super || []
|
182
|
+
end
|
183
|
+
|
184
|
+
def need_autogen?
|
185
|
+
need_autogen.nil? ? false : need_autogen
|
186
|
+
end
|
187
|
+
|
188
|
+
def need_autoreconf?
|
189
|
+
need_autoreconf.nil? ? false : need_autoreconf
|
190
|
+
end
|
191
|
+
|
192
|
+
def build_concurrently?
|
193
|
+
build_concurrently.nil? ? true : build_concurrently
|
194
|
+
end
|
195
|
+
end
|
196
|
+
end
|
197
|
+
end
|
198
|
+
end
|
@@ -0,0 +1,108 @@
|
|
1
|
+
# -*- ruby -*-
|
2
|
+
#
|
3
|
+
# Copyright (C) 2013 Ruby-GNOME2 Project Team
|
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 as published by the Free Software Foundation; either
|
8
|
+
# version 2.1 of the License, or (at your option) any later version.
|
9
|
+
#
|
10
|
+
# This library is distributed in the hope that it will be useful,
|
11
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
12
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
13
|
+
# Lesser General Public License for more details.
|
14
|
+
#
|
15
|
+
# You should have received a copy of the GNU Lesser General Public
|
16
|
+
# License along with this library; if not, write to the Free Software
|
17
|
+
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
18
|
+
|
19
|
+
require "rake"
|
20
|
+
|
21
|
+
module GNOME2
|
22
|
+
module Rake
|
23
|
+
class NativeBinaryBuildTask
|
24
|
+
include ::Rake::DSL
|
25
|
+
|
26
|
+
def initialize(package)
|
27
|
+
@package = package
|
28
|
+
end
|
29
|
+
|
30
|
+
def define
|
31
|
+
namespace :native do
|
32
|
+
namespace :builder do
|
33
|
+
task :before
|
34
|
+
define_build_tasks
|
35
|
+
build_tasks = build_packages.collect do |package|
|
36
|
+
"native:builder:build:#{package.name}"
|
37
|
+
end
|
38
|
+
task :build => build_tasks
|
39
|
+
task :after
|
40
|
+
end
|
41
|
+
|
42
|
+
desc "Build binaries for build environment"
|
43
|
+
task :build => [
|
44
|
+
"native:builder:before",
|
45
|
+
"native:builder:build",
|
46
|
+
"native:builder:after",
|
47
|
+
]
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
private
|
52
|
+
def define_build_tasks
|
53
|
+
namespace :build do
|
54
|
+
build_packages.each do |package|
|
55
|
+
download_task = "source:downloader:download:#{package.name}"
|
56
|
+
desc "Build #{package.label} and install it into #{dist_dir}."
|
57
|
+
task package.name => [download_task] do
|
58
|
+
package_tmp_dir = @package.tmp_dir + package.name
|
59
|
+
rm_rf(package_tmp_dir)
|
60
|
+
mkdir_p(package_tmp_dir)
|
61
|
+
|
62
|
+
tar_full_path = @package.download_dir + package.archive_base_name
|
63
|
+
Dir.chdir(package_tmp_dir.to_s) do
|
64
|
+
sh("tar", "xf", tar_full_path.to_s) or exit(false)
|
65
|
+
end
|
66
|
+
|
67
|
+
Dir.chdir((package_tmp_dir + package.base_name).to_s) do
|
68
|
+
package.native.patches.each do |patch|
|
69
|
+
sh("patch -p1 < #{@package.patches_dir}/#{patch}")
|
70
|
+
end
|
71
|
+
sh("./autogen.sh") if package.native.need_autogen?
|
72
|
+
sh("autoreconf --install") if package.native.need_autoreconf?
|
73
|
+
sh("./configure",
|
74
|
+
"PKG_CONFIG_PATH=#{pkg_config_path}",
|
75
|
+
"--prefix=#{dist_dir}",
|
76
|
+
*package.native.configure_args) or exit(false)
|
77
|
+
common_make_args = []
|
78
|
+
common_make_args << "GLIB_COMPILE_SCHEMAS=glib-compile-schemas"
|
79
|
+
build_make_args = common_make_args.dup
|
80
|
+
install_make_args = common_make_args.dup
|
81
|
+
if package.native.build_concurrently?
|
82
|
+
make_n_jobs = ENV["MAKE_N_JOBS"]
|
83
|
+
build_make_args << "-j#{make_n_jobs}" if make_n_jobs
|
84
|
+
end
|
85
|
+
sh("nice", "make", *build_make_args) or exit(false)
|
86
|
+
sh("make", "install", *install_make_args) or exit(false)
|
87
|
+
end
|
88
|
+
end
|
89
|
+
end
|
90
|
+
end
|
91
|
+
end
|
92
|
+
|
93
|
+
def build_packages
|
94
|
+
@package.external_packages.select do |package|
|
95
|
+
package.native.build?
|
96
|
+
end
|
97
|
+
end
|
98
|
+
|
99
|
+
def dist_dir
|
100
|
+
@package.native.absolute_binary_dir
|
101
|
+
end
|
102
|
+
|
103
|
+
def pkg_config_path
|
104
|
+
dist_dir + "lib/pkgconfig"
|
105
|
+
end
|
106
|
+
end
|
107
|
+
end
|
108
|
+
end
|
@@ -0,0 +1,244 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
|
3
|
+
# Copyright(C) 2011 Ruby-GNOME2 Project.
|
4
|
+
#
|
5
|
+
# This program is licenced under the same license of Ruby-GNOME2.
|
6
|
+
|
7
|
+
require "find"
|
8
|
+
require "pathname"
|
9
|
+
|
10
|
+
require "rubygems"
|
11
|
+
require "rubygems/package_task"
|
12
|
+
require "rake/extensiontask"
|
13
|
+
require "gnome2/rake/package"
|
14
|
+
require "gnome2/rake/external-package"
|
15
|
+
require "gnome2/rake/source-download-task"
|
16
|
+
require "gnome2/rake/native-binary-build-task"
|
17
|
+
require "gnome2/rake/win32-binary-download-task"
|
18
|
+
require "gnome2/rake/win32-binary-build-task"
|
19
|
+
|
20
|
+
module GNOME2
|
21
|
+
module Rake
|
22
|
+
class PackageTask
|
23
|
+
include ::Rake::DSL
|
24
|
+
|
25
|
+
attr_accessor :name, :summary, :description, :author, :email, :homepage, :required_ruby_version, :post_install_message
|
26
|
+
attr_reader :root_dir
|
27
|
+
def initialize
|
28
|
+
initialize_variables
|
29
|
+
initialize_configurations
|
30
|
+
file, line, method = caller[1].scan(/^(.*):(\d+)(?::.*`(.*)')?\Z/).first
|
31
|
+
@package = Package.new(File.dirname(file))
|
32
|
+
@packages = FileList["#{@package.root_dir.parent}/*"].map{|f| File.directory?(f) ? File.basename(f) : nil}.compact
|
33
|
+
@name = @package.name
|
34
|
+
@cross_compiling_hooks = []
|
35
|
+
yield(self) if block_given?
|
36
|
+
end
|
37
|
+
|
38
|
+
def cross_compiling(&block)
|
39
|
+
@cross_compiling_hooks << block
|
40
|
+
end
|
41
|
+
|
42
|
+
def define
|
43
|
+
task :default => :build
|
44
|
+
define_spec
|
45
|
+
define_source_tasks
|
46
|
+
define_native_tasks
|
47
|
+
define_win32_tasks
|
48
|
+
define_package_tasks
|
49
|
+
end
|
50
|
+
|
51
|
+
# Deprecated. Use #define instead.
|
52
|
+
def define_tasks
|
53
|
+
define
|
54
|
+
end
|
55
|
+
|
56
|
+
def ruby_gnome2_package?(name)
|
57
|
+
@packages.include?(name)
|
58
|
+
end
|
59
|
+
|
60
|
+
def dependency
|
61
|
+
@dependency_configuration
|
62
|
+
end
|
63
|
+
|
64
|
+
def windows
|
65
|
+
@package.windows
|
66
|
+
end
|
67
|
+
|
68
|
+
# For backward compatibility
|
69
|
+
def win32
|
70
|
+
windows
|
71
|
+
end
|
72
|
+
|
73
|
+
def native
|
74
|
+
@package.native
|
75
|
+
end
|
76
|
+
|
77
|
+
def version
|
78
|
+
ENV["VERSION"] || guess_version
|
79
|
+
end
|
80
|
+
|
81
|
+
def guess_version
|
82
|
+
versions = {}
|
83
|
+
File.open("#{@package.glib2_root_dir}/ext/glib2/rbglib.h") do |rbglib_h|
|
84
|
+
rbglib_h.each_line do |line|
|
85
|
+
if /#define\s+RBGLIB_([A-Z]+)_VERSION\s+(\d+)/ =~ line
|
86
|
+
versions[$1.downcase] = $2.to_i
|
87
|
+
end
|
88
|
+
end
|
89
|
+
end
|
90
|
+
["major", "minor", "micro"].collect {|type| versions[type]}.compact.join(".")
|
91
|
+
end
|
92
|
+
|
93
|
+
def external_packages=(packages)
|
94
|
+
@package.external_packages = packages
|
95
|
+
end
|
96
|
+
|
97
|
+
private
|
98
|
+
def initialize_variables
|
99
|
+
@summary = ""
|
100
|
+
@description = ""
|
101
|
+
@author = "The Ruby-GNOME2 Project Team"
|
102
|
+
@email = "ruby-gnome2-devel-en@lists.sourceforge.net"
|
103
|
+
@homepage = "http://ruby-gnome2.sourceforge.jp/"
|
104
|
+
@external_packages = []
|
105
|
+
end
|
106
|
+
|
107
|
+
def initialize_configurations
|
108
|
+
@dependency_configuration = DependencyConfiguration.new(self)
|
109
|
+
end
|
110
|
+
|
111
|
+
def define_spec
|
112
|
+
@spec = Gem::Specification.new do |s|
|
113
|
+
s.name = @name
|
114
|
+
s.summary = @summary
|
115
|
+
s.description = @description
|
116
|
+
s.author = @author
|
117
|
+
s.email = @email
|
118
|
+
s.homepage = @homepage
|
119
|
+
s.version = version
|
120
|
+
extensions = FileList["ext/#{@name}/extconf.rb"]
|
121
|
+
extensions.existing!
|
122
|
+
s.extensions = extensions
|
123
|
+
s.require_paths = ["lib"]
|
124
|
+
files = FileList["ChangeLog", "README",
|
125
|
+
"Rakefile", "extconf.rb",
|
126
|
+
"lib/**/*.rb",
|
127
|
+
"{ext,sample,test,test-unit}/**/*"]
|
128
|
+
files.existing!
|
129
|
+
s.files = files
|
130
|
+
s.required_ruby_version = @required_ruby_version || ">= 1.8.5"
|
131
|
+
s.post_install_message = @post_install_message
|
132
|
+
@dependency_configuration.apply(s)
|
133
|
+
end
|
134
|
+
end
|
135
|
+
|
136
|
+
def define_source_tasks
|
137
|
+
define_source_download_tasks
|
138
|
+
end
|
139
|
+
|
140
|
+
def define_source_download_tasks
|
141
|
+
task = SourceDownloadTask.new(@package)
|
142
|
+
task.define
|
143
|
+
end
|
144
|
+
|
145
|
+
def define_native_tasks
|
146
|
+
define_native_build_tasks
|
147
|
+
end
|
148
|
+
|
149
|
+
def define_native_build_tasks
|
150
|
+
task = NativeBinaryBuildTask.new(@package)
|
151
|
+
task.define
|
152
|
+
end
|
153
|
+
|
154
|
+
def define_win32_tasks
|
155
|
+
define_win32_extension_task
|
156
|
+
define_win32_download_task
|
157
|
+
define_win32_build_task
|
158
|
+
end
|
159
|
+
|
160
|
+
def so_base_name
|
161
|
+
@name.gsub(/-/, "_")
|
162
|
+
end
|
163
|
+
|
164
|
+
def define_win32_extension_task
|
165
|
+
::Rake::ExtensionTask.new(so_base_name, @spec) do |ext|
|
166
|
+
ext.ext_dir = "ext/#{@name}"
|
167
|
+
ext.cross_compile = true
|
168
|
+
ext.cross_compiling do |spec|
|
169
|
+
if /mingw|mswin/ =~ spec.platform.to_s
|
170
|
+
win32_binary_dir = @package.windows.relative_binary_dir
|
171
|
+
win32_files = []
|
172
|
+
if win32_binary_dir.exist?
|
173
|
+
Find.find(win32_binary_dir.to_s) do |file|
|
174
|
+
next if /\.zip\z/ =~ file
|
175
|
+
win32_files << file
|
176
|
+
end
|
177
|
+
end
|
178
|
+
spec.files += win32_files
|
179
|
+
end
|
180
|
+
@cross_compiling_hooks.each do |hook|
|
181
|
+
hook.call(spec)
|
182
|
+
end
|
183
|
+
end
|
184
|
+
end
|
185
|
+
|
186
|
+
def define_win32_download_task
|
187
|
+
GNOME2Win32BinaryDownloadTask.new(@package)
|
188
|
+
end
|
189
|
+
|
190
|
+
def define_win32_build_task
|
191
|
+
GNOME2Win32BinaryBuildTask.new(@package)
|
192
|
+
end
|
193
|
+
end
|
194
|
+
|
195
|
+
def define_package_tasks
|
196
|
+
Gem::PackageTask.new(@spec) do |pkg|
|
197
|
+
end
|
198
|
+
end
|
199
|
+
|
200
|
+
class DependencyConfiguration
|
201
|
+
attr_accessor :platform, :ruby
|
202
|
+
def initialize(package)
|
203
|
+
@package = package
|
204
|
+
@platform = Gem::Platform::RUBY
|
205
|
+
@gem_configuration = GemConfiguration.new(@package)
|
206
|
+
end
|
207
|
+
|
208
|
+
def gem
|
209
|
+
@gem_configuration
|
210
|
+
end
|
211
|
+
|
212
|
+
def apply(spec)
|
213
|
+
spec.platform = @platform
|
214
|
+
@gem_configuration.apply(spec)
|
215
|
+
end
|
216
|
+
|
217
|
+
class GemConfiguration
|
218
|
+
attr_accessor :runtime, :development
|
219
|
+
def initialize(package)
|
220
|
+
@package = package
|
221
|
+
@runtime = []
|
222
|
+
@development = []
|
223
|
+
end
|
224
|
+
|
225
|
+
def apply(spec)
|
226
|
+
@runtime.each do |dependency|
|
227
|
+
spec.add_runtime_dependency(*append_version(dependency))
|
228
|
+
end
|
229
|
+
|
230
|
+
@development.each do |dependency|
|
231
|
+
spec.add_development_dependency(*append_version(dependency))
|
232
|
+
end
|
233
|
+
end
|
234
|
+
|
235
|
+
def append_version(dependency)
|
236
|
+
name, *ver = dependency.is_a?(Array) ? dependency : [dependency]
|
237
|
+
ver << ">= #{@package.version}" if @package.ruby_gnome2_package?(name)
|
238
|
+
[name, *ver]
|
239
|
+
end
|
240
|
+
end
|
241
|
+
end
|
242
|
+
end
|
243
|
+
end
|
244
|
+
end
|