glib2 1.2.6 → 2.0.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,122 @@
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 "pathname"
20
+
21
+ module GNOME2
22
+ module Rake
23
+ class Package
24
+ attr_reader :name
25
+ attr_reader :root_dir
26
+ attr_reader :windows
27
+ attr_reader :native
28
+ attr_writer :external_packages
29
+ def initialize(root_dir)
30
+ @root_dir = Pathname.new(root_dir).expand_path
31
+ @name = @root_dir.basename.to_s
32
+ @windows = WindowsConfiguration.new
33
+ @native = NativeConfiguration.new
34
+ @external_packages = []
35
+ end
36
+
37
+ def project_root_dir
38
+ @root_dir.parent
39
+ end
40
+
41
+ def glib2_root_dir
42
+ project_root_dir + "glib2"
43
+ end
44
+
45
+ def tmp_dir
46
+ @root_dir + "tmp"
47
+ end
48
+
49
+ def download_dir
50
+ tmp_dir + "download"
51
+ end
52
+
53
+ def patches_dir
54
+ @root_dir + "patches"
55
+ end
56
+
57
+ def external_packages
58
+ @external_packages.collect do |package|
59
+ ExternalPackage.new(package)
60
+ end
61
+ end
62
+
63
+ class WindowsConfiguration < Struct.new(:packages,
64
+ :dependencies,
65
+ :build_dependencies,
66
+ :gobject_introspection_dependencies,
67
+ :build_packages,
68
+ :build_host)
69
+
70
+ attr_reader :relative_binary_dir, :absolute_binary_dir
71
+ def initialize
72
+ super
73
+ @relative_binary_dir = Pathname.new("vendor/local")
74
+ @absolute_binary_dir = @relative_binary_dir.expand_path
75
+ end
76
+
77
+ def packages
78
+ super || []
79
+ end
80
+
81
+ def dependencies
82
+ super || []
83
+ end
84
+
85
+ def build_dependencies
86
+ super || []
87
+ end
88
+
89
+ def gobject_introspection_dependencies
90
+ super || []
91
+ end
92
+
93
+ def build_packages
94
+ (super || []).collect do |package|
95
+ package = package.dup
96
+ package[:windows] = {
97
+ :include_paths => package.delete(:include_paths),
98
+ :library_paths => package.delete(:library_paths),
99
+ :configure_args => package.delete(:configure_args),
100
+ :patches => package.delete(:patches),
101
+ :need_autogen => package.delete(:need_autogen),
102
+ :need_autoreconf => package.delete(:need_autoreconf),
103
+ }
104
+ ExternalPackage.new(package)
105
+ end
106
+ end
107
+
108
+ def build_host
109
+ super || "i686-w64-mingw32"
110
+ end
111
+ end
112
+
113
+ class NativeConfiguration
114
+ attr_reader :relative_binary_dir, :absolute_binary_dir
115
+ def initialize
116
+ @relative_binary_dir = Pathname.new("tmp/native/local")
117
+ @absolute_binary_dir = @relative_binary_dir.expand_path
118
+ end
119
+ end
120
+ end
121
+ end
122
+ end
@@ -0,0 +1,81 @@
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 "open-uri"
20
+ require "pathname"
21
+
22
+ require "rake"
23
+
24
+ module GNOME2
25
+ module Rake
26
+ class SourceDownloadTask
27
+ include ::Rake::DSL
28
+
29
+ def initialize(package)
30
+ @package = package
31
+ end
32
+
33
+ def define
34
+ namespace :source do
35
+ namespace :downloader do
36
+ task :before
37
+ define_download_tasks
38
+ download_tasks = @package.external_packages.collect do |package|
39
+ "source:downloader:download:#{package.name}"
40
+ end
41
+ task :download => download_tasks
42
+ task :after
43
+ end
44
+
45
+ desc "Dowanload sources"
46
+ task :download => [
47
+ "source:downloader:before",
48
+ "source:downloader:download",
49
+ "source:downloader:after",
50
+ ]
51
+ end
52
+ end
53
+
54
+ def define_download_tasks
55
+ namespace :download do
56
+ @package.external_packages.each do |package|
57
+ download_dir = @package.download_dir
58
+ tar_full_path = download_dir + package.archive_base_name
59
+
60
+ task :before
61
+ task :after
62
+ desc "Download #{package.label} into #{download_dir}."
63
+ task package[:name] => [:before, tar_full_path.to_s, :after]
64
+
65
+ directory_path = tar_full_path.dirname
66
+ directory directory_path.to_s
67
+ file tar_full_path.to_s => directory_path.to_s do
68
+ archive_url = package.archive_url
69
+ rake_output_message "Downloading... #{archive_url}"
70
+ open(archive_url) do |downloaded_tar|
71
+ tar_full_path.open("wb") do |tar_file|
72
+ tar_file.print(downloaded_tar.read)
73
+ end
74
+ end
75
+ end
76
+ end
77
+ end
78
+ end
79
+ end
80
+ end
81
+ end
@@ -0,0 +1,223 @@
1
+ # Copyright(C) 2012 Ruby-GNOME2 Project.
2
+ #
3
+ # This program is licenced under the same license of Ruby-GNOME2.
4
+
5
+ require "open-uri"
6
+ require "pathname"
7
+
8
+ class GNOME2Win32BinaryBuildTask
9
+ include Rake::DSL
10
+
11
+ def initialize(package)
12
+ @package = package
13
+ define
14
+ end
15
+
16
+ private
17
+ def define
18
+ namespace :win32 do
19
+ namespace :builder do
20
+ task :before
21
+ define_build_tasks
22
+ build_tasks = build_packages.collect do |package|
23
+ "win32:builder:build:#{package.name}"
24
+ end
25
+ task :build => build_tasks
26
+ task :after
27
+ end
28
+ desc "Build Windows binaries"
29
+ task :build => ["win32:builder:before",
30
+ "win32:builder:build",
31
+ "win32:builder:after"]
32
+ end
33
+ end
34
+
35
+ def define_build_tasks
36
+ namespace :build do
37
+ prepare_task_names = []
38
+ namespace :prepare do
39
+ prepare_task_names << "pkg_config"
40
+ task :pkg_config do
41
+ depended_packages = @package.windows.build_dependencies
42
+ use_packages = [@package.name] + depended_packages
43
+ pkg_config_path = use_packages.collect do |package|
44
+ "../#{package}/#{@package.windows.relative_binary_dir}/lib/pkgconfig"
45
+ end
46
+ ENV["PKG_CONFIG_PATH"] = pkg_config_path.collect do |path|
47
+ File.expand_path(path)
48
+ end.join(":")
49
+ ENV["PKG_CONFIG_LIBDIR"] = rcairo_win32_pkgconfig_path
50
+ end
51
+ end
52
+
53
+ full_prepare_task_names = prepare_task_names.collect do |name|
54
+ "win32:builder:build:prepare:#{name}"
55
+ end
56
+ task :prepare => full_prepare_task_names
57
+
58
+ build_packages.each do |package|
59
+ namespace package.name do
60
+ task :before
61
+ download_task = "source:downloader:download:#{package.name}"
62
+ task :build => [:prepare, download_task] do
63
+ build_package_task_body(package)
64
+ end
65
+ task :after
66
+ end
67
+
68
+ prefix = "win32:builder:build:#{package.name}"
69
+ desc "Build #{package.label} and install it into #{dist_dir}."
70
+ task package.name => [
71
+ "#{prefix}:before",
72
+ "#{prefix}:build",
73
+ "#{prefix}:after",
74
+ ]
75
+ end
76
+ end
77
+ end
78
+
79
+ def build_package_task_body(package)
80
+ package_tmp_dir = @package.tmp_dir + package.name
81
+ rm_rf(package_tmp_dir)
82
+ mkdir_p(package_tmp_dir)
83
+
84
+ tar_full_path = @package.download_dir + package.archive_base_name
85
+ Dir.chdir(package_tmp_dir.to_s) do
86
+ sh("tar", "xf", tar_full_path.to_s)
87
+ end
88
+
89
+ Dir.chdir((package_tmp_dir + package.base_name).to_s) do
90
+ package.windows.patches.each do |patch|
91
+ sh("patch -p1 < #{@package.patches_dir}/#{patch}")
92
+ end
93
+ sh("./autogen.sh") if package.windows.need_autogen?
94
+ sh("autoreconf --install") if package.windows.need_autoreconf?
95
+ cc_env = "CC=#{@package.windows.build_host}-gcc"
96
+ sh("./configure",
97
+ cc_env,
98
+ "CPPFLAGS=#{cppflags(package)}",
99
+ "LDFLAGS=#{ldflags(package)}",
100
+ "--prefix=#{dist_dir}",
101
+ "--host=#{@package.windows.build_host}",
102
+ *package.windows.configure_args) or exit(false)
103
+ common_make_args = []
104
+ common_make_args << "GLIB_COMPILE_SCHEMAS=glib-compile-schemas"
105
+ if package.windows.use_cc_environment_variable?
106
+ common_make_args << cc_env
107
+ end
108
+ add_gobject_introspection_make_args(common_make_args)
109
+ build_make_args = common_make_args.dup
110
+ install_make_args = common_make_args.dup
111
+ if package.windows.build_concurrently?
112
+ make_n_jobs = ENV["MAKE_N_JOBS"]
113
+ build_make_args << "-j#{make_n_jobs}" if make_n_jobs
114
+ end
115
+ ENV["GREP_OPTIONS"] = "--text"
116
+ sh("nice", "make", *build_make_args) or exit(false)
117
+ sh("make", "install", *install_make_args) or exit(false)
118
+
119
+ package_license_dir = license_dir + package.name
120
+ mkdir_p(package_license_dir)
121
+ package_license_files = ["AUTHORS", "COPYING", "COPYING.LIB"]
122
+ package_license_files = package_license_files.reject do |file|
123
+ not File.exist?(file)
124
+ end
125
+ cp(package_license_files, package_license_dir)
126
+ bundled_packages = package.bundled_packages
127
+ bundled_packages.each do |bundled_package|
128
+ bundled_package_license_dir = license_dir + bundled_package[:name]
129
+ mkdir_p(bundled_package_license_dir)
130
+ license_files = bundled_package[:license_files].collect do |file|
131
+ File.join(bundled_package[:path], file)
132
+ end
133
+ cp(license_files, bundled_package_license_dir)
134
+ end
135
+ end
136
+ end
137
+
138
+ def build_packages
139
+ packages = @package.external_packages.select do |package|
140
+ package.windows.build?
141
+ end
142
+ # For backward compatibility
143
+ packages + @package.windows.build_packages
144
+ end
145
+
146
+ def dist_dir
147
+ @package.windows.absolute_binary_dir
148
+ end
149
+
150
+ def license_dir
151
+ dist_dir + "share" + "license"
152
+ end
153
+
154
+ def glib2_include_path
155
+ "#{@package.glib2_root_dir}/vendor/local/include"
156
+ end
157
+
158
+ def glib2_lib_path
159
+ "#{@package.glib2_root_dir}/vendor/local/lib"
160
+ end
161
+
162
+ def rcairo_win32_dir
163
+ @package.project_root_dir.parent + "rcairo.win32"
164
+ end
165
+
166
+ def rcairo_win32_pkgconfig_path
167
+ "#{rcairo_win32_dir}/vendor/local/lib/pkgconfig"
168
+ end
169
+
170
+ def rcairo_win32_include_path
171
+ "#{rcairo_win32_dir}/vendor/local/include"
172
+ end
173
+
174
+ def rcairo_win32_lib_path
175
+ "#{rcairo_win32_dir}/vendor/local/lib"
176
+ end
177
+
178
+ def cppflags(package)
179
+ include_paths = package.windows.include_paths
180
+ if @package.windows.build_dependencies.include?("glib2")
181
+ include_paths += [glib2_include_path]
182
+ end
183
+ include_paths += [
184
+ rcairo_win32_include_path,
185
+ dist_dir + 'include',
186
+ ]
187
+ cppflags = include_paths.collect do |path|
188
+ "-I#{path}"
189
+ end
190
+ cppflags.join(" ")
191
+ end
192
+
193
+ def ldflags(package)
194
+ library_paths = package.windows.library_paths
195
+ if @package.windows.build_dependencies.include?("glib2")
196
+ library_paths += [glib2_lib_path]
197
+ end
198
+ library_paths += [
199
+ rcairo_win32_lib_path,
200
+ dist_dir + 'lib',
201
+ ]
202
+ ldflags = library_paths.collect do |path|
203
+ "-L#{path}"
204
+ end
205
+ ldflags.join(" ")
206
+ end
207
+
208
+ def add_gobject_introspection_make_args(common_make_args)
209
+ unless @package.windows.build_dependencies.include?("gobject-introspection")
210
+ return
211
+ end
212
+
213
+ dependencies = [
214
+ "gobject-introspection",
215
+ @package.name,
216
+ ]
217
+ dependencies += @package.windows.gobject_introspection_dependencies
218
+ data_dirs = dependencies.collect do |package|
219
+ "#{@package.project_root_dir}/#{package}/vendor/local/share"
220
+ end
221
+ common_make_args << "XDG_DATA_DIRS=#{data_dirs.join(File::PATH_SEPARATOR)}"
222
+ end
223
+ end
@@ -10,8 +10,8 @@ class GNOME2Win32BinaryDownloadTask
10
10
  include Rake::DSL
11
11
 
12
12
  URL_BASE = "http://ftp.gnome.org/pub/gnome/binaries/win32"
13
- def initialize(configuration)
14
- @configuration = configuration
13
+ def initialize(package)
14
+ @package = package
15
15
  define
16
16
  end
17
17
 
@@ -23,8 +23,8 @@ class GNOME2Win32BinaryDownloadTask
23
23
 
24
24
  download_tasks = []
25
25
  namespace :download do
26
- directory dist_dir
27
- task :prepare => [dist_dir]
26
+ directory dist_dir.to_s
27
+ task :prepare => [dist_dir.to_s]
28
28
 
29
29
  packages.each do |package|
30
30
  desc "download #{package}"
@@ -60,15 +60,15 @@ class GNOME2Win32BinaryDownloadTask
60
60
  end
61
61
 
62
62
  def dist_dir
63
- @configuration.absolute_binary_dir
63
+ @package.windows.absolute_binary_dir
64
64
  end
65
65
 
66
66
  def packages
67
- @configuration.packages
67
+ @package.windows.packages
68
68
  end
69
69
 
70
70
  def dependencies
71
- @configuration.dependencies
71
+ @package.windows.dependencies
72
72
  end
73
73
 
74
74
  def download_package(package)