glib2 3.3.2 → 3.3.3

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,6 +1,4 @@
1
- # -*- ruby -*-
2
- #
3
- # Copyright (C) 2013-2015 Ruby-GNOME2 Project Team
1
+ # Copyright (C) 2013-2019 Ruby-GNOME2 Project Team
4
2
  #
5
3
  # This library is free software; you can redistribute it and/or
6
4
  # modify it under the terms of the GNU Lesser General Public
@@ -16,86 +14,14 @@
16
14
  # License along with this library; if not, write to the Free Software
17
15
  # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
18
16
 
19
- require "open-uri"
20
- require "pathname"
21
-
22
- require "rake"
23
-
24
17
  module GNOME2
25
18
  module Rake
26
19
  class SourceDownloadTask
27
- include ::Rake::DSL
28
-
29
20
  def initialize(package)
30
21
  @package = package
31
22
  end
32
23
 
33
24
  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
- private
55
- def define_download_tasks
56
- namespace :download do
57
- @package.external_packages.each do |package|
58
- download_dir = @package.download_dir
59
- tar_full_path = download_dir + package.archive_base_name
60
-
61
- task :before
62
- task :after
63
- desc "Download #{package.label} into #{download_dir}."
64
- # task package[:name] => [:before, tar_full_path.to_s, :after]
65
- task package[:name] => tar_full_path.to_s
66
-
67
- directory_path = tar_full_path.dirname
68
- directory directory_path.to_s
69
- file tar_full_path.to_s => directory_path.to_s do
70
- archive_url = package.archive_url
71
- rake_output_message "Downloading... #{archive_url}"
72
- download(archive_url, tar_full_path)
73
- end
74
- end
75
- end
76
- end
77
-
78
- def download(url, output_path)
79
- OpenURI.singleton_class.class_eval do
80
- alias_method :redirectable_original?, :redirectable?
81
- def redirectable?(uri1, uri2)
82
- redirectable_original?(uri1, uri2) or
83
- (uri1.scheme.downcase == "http" and
84
- uri2.scheme.downcase == "https")
85
- end
86
- end
87
- begin
88
- open(url) do |input|
89
- output_path.open("wb") do |output_file|
90
- output_file.print(input.read)
91
- end
92
- end
93
- ensure
94
- OpenURI.singleton_class.class_eval do
95
- alias_method :redirectable?, :redirectable_original?
96
- remove_method :redirectable_original?
97
- end
98
- end
99
25
  end
100
26
  end
101
27
  end
@@ -1,37 +1,15 @@
1
- # Copyright(C) 2012-2015 Ruby-GNOME2 Project.
1
+ # Copyright(C) 2012-2019 Ruby-GNOME2 Project.
2
2
  #
3
3
  # This program is licenced under the same license of Ruby-GNOME2.
4
4
 
5
- require "open-uri"
6
- require "pathname"
7
- require "tempfile"
8
- require "tmpdir"
9
-
10
5
  module GNOME2
11
6
  module Rake
12
7
  class WindowsBinaryBuildTask
13
- include ::Rake::DSL
14
-
15
8
  def initialize(package)
16
9
  @package = package
17
10
  end
18
11
 
19
12
  def define
20
- namespace :windows do
21
- namespace :builder do
22
- task :before
23
- define_build_tasks
24
- build_tasks = build_packages.collect do |package|
25
- "windows:builder:build:#{package.name}"
26
- end
27
- task :build => build_tasks
28
- task :after
29
- end
30
- desc "Build Windows binaries"
31
- task :build => ["windows:builder:before",
32
- "windows:builder:build",
33
- "windows:builder:after"]
34
- end
35
13
  end
36
14
 
37
15
  def rcairo_binary_base_dir
@@ -47,417 +25,9 @@ module GNOME2
47
25
  end
48
26
 
49
27
  private
50
- def define_build_tasks
51
- namespace :build do
52
- task :prepare
53
-
54
- build_packages.each do |package|
55
- namespace package.name do
56
- task :before
57
- download_task = "source:downloader:download:#{package.name}"
58
- built_file = package.windows.built_file
59
- if built_file
60
- built_file = dist_dir + built_file
61
- file built_file.to_s do
62
- ::Rake::Task["windows:builder:build:prepare"].invoke
63
- ::Rake::Task[download_task].invoke
64
- build_package_task_body(package)
65
- end
66
- task :build => built_file.to_s
67
- else
68
- task :build => [:prepare, download_task] do
69
- build_package_task_body(package)
70
- end
71
- end
72
- task :after
73
- end
74
-
75
- prefix = "windows:builder:build:#{package.name}"
76
- desc "Build #{package.label} and install it into #{dist_dir}."
77
- task package.name => [
78
- "#{prefix}:before",
79
- "#{prefix}:build",
80
- "#{prefix}:after",
81
- ]
82
- end
83
- end
84
- end
85
-
86
- def build_package_task_body(package)
87
- package_tmp_dir = @package.tmp_dir + "windows" + package.name
88
- rm_rf(package_tmp_dir)
89
- mkdir_p(package_tmp_dir)
90
-
91
- tar_full_path = @package.download_dir + package.archive_base_name
92
- Dir.chdir(package_tmp_dir.to_s) do
93
- sh("tar", "xf", tar_full_path.to_s)
94
- end
95
-
96
- env = build_env
97
- package_dir_path =
98
- package_tmp_dir + package.base_name + package.base_dir_in_package
99
- Dir.chdir(package_dir_path.to_s) do
100
- package.windows.patches.each do |patch|
101
- sh("patch -p1 < #{@package.patches_dir}/#{patch}")
102
- end
103
- common_make_args = []
104
- common_make_args << "MAKE=make"
105
- common_make_args << "GLIB_COMPILE_SCHEMAS=glib-compile-schemas"
106
- if package.windows.use_cc_environment_variable?
107
- common_make_args << cc_env(package)
108
- end
109
- add_gobject_introspection_make_args(package, common_make_args)
110
- common_make_args.concat(package.windows.make_args)
111
- build_make_args = common_make_args.dup
112
- install_make_args = common_make_args.dup
113
- if package.windows.build_concurrently?
114
- make_n_jobs = ENV["MAKE_N_JOBS"]
115
- build_make_args << "-j#{make_n_jobs}" if make_n_jobs
116
- end
117
- # build_make_args << "--debug"
118
- # build_make_args << "V=1"
119
- # build_make_args << "VERBOSE=1"
120
- # env["GI_SCANNER_DEBUG"] = "save-temps"
121
- if File.exist?("meson.build")
122
- source_dir = Dir.pwd
123
- build_dir = "build"
124
- mkdir_p(build_dir)
125
- Dir.chdir(build_dir) do
126
- meson(env, package, source_dir)
127
- sh(env.merge(make_args_to_env(build_make_args)),
128
- "nice", "ninja") or exit(false)
129
- sh(env.merge(make_args_to_env(install_make_args)),
130
- "ninja", "install") or exit(false)
131
- end
132
- else
133
- if File.exist?("Makefile.am") or File.exist?("Makefile.in")
134
- configure(env, package)
135
- else
136
- cmake(env, package)
137
- end
138
- sh(env, "nice", "make", *build_make_args) or exit(false)
139
- sh(env, "make", "install", *install_make_args) or exit(false)
140
- end
141
-
142
- package_license_dir = license_dir + package.name
143
- mkdir_p(package_license_dir)
144
- package_license_files = ["AUTHORS", "COPYING", "COPYING.LIB"]
145
- package_license_files = package_license_files.reject do |file|
146
- not File.exist?(file)
147
- end
148
- cp(package_license_files, package_license_dir)
149
- bundled_packages = package.bundled_packages
150
- bundled_packages.each do |bundled_package|
151
- bundled_package_license_dir = license_dir + bundled_package[:name]
152
- mkdir_p(bundled_package_license_dir)
153
- license_files = bundled_package[:license_files].collect do |file|
154
- File.join(bundled_package[:path], file)
155
- end
156
- cp(license_files, bundled_package_license_dir)
157
- end
158
- end
159
- end
160
-
161
- def build_env
162
- path = "#{g_ir_scanner_bin_dir}:#{ENV["PATH"]}"
163
- env = {
164
- "GI_HOST_OS" => "nt",
165
- "MSYSTEM" => "MINGW64",
166
- "GREP_OPTIONS" => "--text",
167
- "PATH" => path,
168
- "PKG_CONFIG" => pkg_config,
169
- }
170
- depended_packages = @package.windows.build_dependencies
171
- use_packages = [@package.name] + depended_packages
172
- pkg_config_path = [rcairo_pkgconfig_path]
173
- use_packages.each do |package|
174
- path = "../#{package}/#{@package.windows.relative_binary_dir}/lib/pkgconfig"
175
- pkg_config_path << path
176
- end
177
- env["PKG_CONFIG_PATH"] = pkg_config_path.collect do |path|
178
- File.expand_path(path)
179
- end.join(":")
180
- env
181
- end
182
-
183
- def configure(env, package)
184
- sh(env, "./autogen.sh") if package.windows.need_autogen?
185
- if package.windows.need_autoreconf?
186
- sh(env, "autoreconf", "--install", "--force")
187
- end
188
- sh(env, "env")
189
- sh(env,
190
- "./configure",
191
- cc_env(package),
192
- dlltool_env,
193
- "CPPFLAGS=#{cppflags(package)}",
194
- "LDFLAGS=#{ldflags(package)}",
195
- "--prefix=#{dist_dir}",
196
- "--host=#{@package.windows.build_host}",
197
- # "--target=#{@package.windows.build_host}",
198
- # "--build=x86_64-pc-linux-gnu",
199
- *package.windows.configure_args) or exit(false)
200
- if package.windows.force_to_disable_deplibs_check?
201
- sh(env,
202
- "sed",
203
- "-i",
204
- "-e", "s/valid_a_lib=false/valid_a_lib=:/g",
205
- "libtool")
206
- end
207
- end
208
-
209
- def meson(env, package, source_dir)
210
- cross_file = Tempfile.new("meson-cross-file")
211
- cross_file.puts(<<-CROSS_FILE)
212
- [host_machine]
213
- system = 'windows'
214
- cpu_family = '#{meson_cpu_family}'
215
- cpu = '#{meson_cpu}'
216
- endian = 'littel'
217
-
218
- [binaries]
219
- c = '/usr/bin/#{cc(package)}'
220
- cpp = '/usr/bin/#{cxx(package)}'
221
- ar = '/usr/bin/#{ar}'
222
- strip = '/usr/bin/#{strip}'
223
- dlltool = '/usr/bin/#{dlltool}'
224
- pkgconfig = '/usr/bin/#{pkg_config}'
225
- windres = '/usr/bin/#{windres}'
226
- exe_wrapper = 'wine'
227
-
228
- [properties]
229
- root = '/usr/#{@package.windows.build_host}'
230
- CROSS_FILE
231
- cross_file.close
232
- sh(env.merge({
233
- "CPPFLAGS" => cppflags(package),
234
- "LDFLAGS" => ldflags(package),
235
- }),
236
- "meson",
237
- source_dir,
238
- ".",
239
- "--prefix=#{dist_dir}",
240
- "--libdir=lib",
241
- "--cross-file=#{cross_file.path}",
242
- *package.windows.meson_args) or exit(false)
243
- end
244
-
245
- def meson_cpu_family
246
- case @package.windows.build_architecture
247
- when "x86"
248
- "x86"
249
- when "x86_64"
250
- "x86_64"
251
- end
252
- end
253
-
254
- def meson_cpu
255
- case @package.windows.build_architecture
256
- when "x86"
257
- "i686"
258
- when "x86_64"
259
- "x86_64"
260
- end
261
- end
262
-
263
- def cmake(env, package)
264
- sh(env,
265
- "cmake",
266
- ".",
267
- "-DCMAKE_INSTALL_PREFIX=#{dist_dir}",
268
- "-DCMAKE_SYSTEM_NAME=Windows",
269
- "-DCMAKE_SYSTEM_PROCESSOR=#{@package.windows.build_architecture}",
270
- "-DCMAKE_C_COMPILER=#{cc(package)}",
271
- "-DCMAKE_CXX_COMPILER=#{cxx(package)}",
272
- *package.windows.cmake_args) or exit(false)
273
- end
274
-
275
- def cc_env(package)
276
- "CC=#{cc(package)}"
277
- end
278
-
279
- def dlltool_env
280
- "DLLTOOL=#{dlltool}"
281
- end
282
-
283
- def build_packages
284
- packages = @package.external_packages.select do |package|
285
- package.windows.build?
286
- end
287
- # For backward compatibility
288
- packages + @package.windows.build_packages
289
- end
290
-
291
- def dist_dir
292
- @package.windows.absolute_binary_dir
293
- end
294
-
295
- def license_dir
296
- dist_dir + "share" + "license"
297
- end
298
-
299
- def glib2_include_path
300
- "#{glib2_binary_base_dir}/include"
301
- end
302
-
303
- def glib2_lib_path
304
- "#{glib2_binary_base_dir}/lib"
305
- end
306
-
307
28
  def rcairo_dir
308
29
  @package.project_root_dir.parent + "rcairo"
309
30
  end
310
-
311
- def rcairo_pkgconfig_path
312
- "#{rcairo_binary_base_dir}/lib/pkgconfig"
313
- end
314
-
315
- def rcairo_include_path
316
- "#{rcairo_binary_base_dir}/include"
317
- end
318
-
319
- def rcairo_lib_path
320
- "#{rcairo_binary_base_dir}/lib"
321
- end
322
-
323
- def cc(package)
324
- cc_command_line = [
325
- "#{@package.windows.build_host}-gcc",
326
- *package.windows.cc_args,
327
- ]
328
- cc_command_line.compact.join(" ")
329
- end
330
-
331
- def cxx(package)
332
- cxx_command_line = [
333
- "#{@package.windows.build_host}-g++",
334
- ]
335
- cxx_command_line.compact.join(" ")
336
- end
337
-
338
- def ar
339
- "#{@package.windows.build_host}-ar"
340
- end
341
-
342
- def strip
343
- "#{@package.windows.build_host}-strip"
344
- end
345
-
346
- def dlltool
347
- "#{@package.windows.build_host}-dlltool"
348
- end
349
-
350
- def pkg_config
351
- "#{@package.windows.build_host}-pkg-config"
352
- end
353
-
354
- def windres
355
- "#{@package.windows.build_host}-windres"
356
- end
357
-
358
- def g_ir_scanner_bin_dir
359
- "#{@package.project_root_dir}/gobject-introspection/" +
360
- "#{@package.native.relative_binary_dir}/bin"
361
- end
362
-
363
- def g_ir_scanner
364
- "#{g_ir_scanner_bin_dir}/g-ir-scanner"
365
- end
366
-
367
- def cppflags(package)
368
- include_paths = package.windows.include_paths
369
- if @package.windows.build_dependencies.include?("glib2")
370
- include_paths += [glib2_include_path]
371
- end
372
- include_paths += [
373
- rcairo_include_path,
374
- dist_dir + 'include',
375
- ]
376
- cppflags = include_paths.collect do |path|
377
- "-I#{path}"
378
- end
379
- cppflags.join(" ")
380
- end
381
-
382
- def ldflags(package)
383
- library_paths = package.windows.library_paths
384
- if @package.windows.build_dependencies.include?("glib2")
385
- library_paths += [glib2_lib_path]
386
- end
387
- library_paths += [
388
- rcairo_lib_path,
389
- dist_dir + 'lib',
390
- ]
391
- ldflags = library_paths.collect do |path|
392
- "-L#{path}"
393
- end
394
- ldflags.join(" ")
395
- end
396
-
397
- def cmake_root_paths
398
- paths = [
399
- "/usr/#{@package.windows.build_host}",
400
- rcairo_binary_base_dir.to_path,
401
- ]
402
- @package.windows.build_dependencies.each do |package|
403
- paths << binary_base_dir(package).to_path
404
- end
405
- paths
406
- end
407
-
408
- def make_args_to_env(make_args)
409
- env = {}
410
- make_args.each do |arg|
411
- key, value = arg.split("=", 2)
412
- env[key] = value
413
- end
414
- env
415
- end
416
-
417
- def add_gobject_introspection_make_args(package, common_make_args)
418
- return unless use_gobject_introspection?(package)
419
-
420
- introspection_scanner = "INTROSPECTION_SCANNER=#{g_ir_scanner}"
421
- common_make_args << introspection_scanner
422
-
423
-
424
- dependencies = [
425
- "gobject-introspection",
426
- @package.name,
427
- ]
428
- dependencies += @package.windows.gobject_introspection_dependencies
429
-
430
- gi_base_dir = binary_base_dir("gobject-introspection")
431
- introspection_compiler = "INTROSPECTION_COMPILER="
432
- introspection_compiler << "#{gi_base_dir}/bin/g-ir-compiler.exe"
433
- introspection_compiler_args = ""
434
- dependencies.each do |dependent_package|
435
- gir_dir = "#{binary_base_dir(dependent_package)}/share/gir-1.0"
436
- introspection_compiler_args << " --includedir=#{gir_dir}"
437
- end
438
- if package.windows.gobject_introspection_compiler_split_args?
439
- common_make_args << introspection_compiler
440
- common_make_args <<
441
- "INTROSPECTION_COMPILER_ARGS=#{introspection_compiler_args}"
442
- common_make_args <<
443
- "INTROSPECTION_COMPILER_OPTS=#{introspection_compiler_args}"
444
- else
445
- introspection_compiler << " #{introspection_compiler_args}"
446
- common_make_args << introspection_compiler
447
- end
448
-
449
- common_make_args << dlltool_env
450
-
451
- data_dirs = dependencies.collect do |dependent_package|
452
- "#{binary_base_dir(dependent_package)}/share"
453
- end
454
- common_make_args << "XDG_DATA_DIRS=#{data_dirs.join(File::PATH_SEPARATOR)}"
455
- end
456
-
457
- def use_gobject_introspection?(package)
458
- return false unless package.windows.use_gobject_introspection?
459
- @package.windows.build_dependencies.include?("gobject-introspection")
460
- end
461
31
  end
462
32
  end
463
33
  end