wxruby3 0.9.5 → 0.9.8

Sign up to get free protection for your applications and to get access to all the features.
Files changed (58) hide show
  1. checksums.yaml +4 -4
  2. data/INSTALL.md +440 -84
  3. data/README.md +40 -23
  4. data/ext/mkrf_conf_ext.rb +68 -0
  5. data/lib/wx/core/ext.rb +22 -3
  6. data/lib/wx/core/secret_store.rb +38 -0
  7. data/lib/wx/doc/extra/02_lifecycles.md +4 -4
  8. data/lib/wx/doc/extra/14_config.md +1 -1
  9. data/lib/wx/doc/secret_store.rb +55 -0
  10. data/lib/wx/version.rb +1 -1
  11. data/lib/wx/wxruby/base.rb +8 -8
  12. data/lib/wx/wxruby/cmd/check.rb +182 -0
  13. data/lib/wx/wxruby/cmd/sampler.rb +39 -29
  14. data/lib/wx/wxruby/cmd/setup.rb +125 -0
  15. data/lib/wx/wxruby/cmd/test.rb +56 -6
  16. data/rakelib/bin.rake +48 -0
  17. data/rakelib/bin.rb +62 -0
  18. data/rakelib/build.rb +11 -7
  19. data/rakelib/config.rake +3 -1
  20. data/rakelib/configure.rb +63 -35
  21. data/rakelib/doc.rake +3 -1
  22. data/rakelib/gem.rake +199 -0
  23. data/rakelib/gem.rb +334 -0
  24. data/rakelib/install.rb +5 -3
  25. data/rakelib/lib/config/{cygwin.rb → freebsd.rb} +1 -1
  26. data/rakelib/lib/config/linux.rb +26 -2
  27. data/rakelib/lib/config/macosx.rb +58 -11
  28. data/rakelib/lib/config/mingw.rb +134 -10
  29. data/rakelib/lib/config/pkgman/linux.rb +144 -0
  30. data/rakelib/lib/config/pkgman/macosx.rb +122 -0
  31. data/rakelib/lib/config/unixish.rb +47 -20
  32. data/rakelib/lib/config/{netbsd.rb → unknown.rb} +3 -2
  33. data/rakelib/lib/config.rb +301 -88
  34. data/rakelib/lib/core/package.rb +47 -49
  35. data/rakelib/lib/director/aui_manager.rb +1 -1
  36. data/rakelib/lib/director/dialog.rb +8 -0
  37. data/rakelib/lib/director/gdicommon.rb +1 -2
  38. data/rakelib/lib/director/grid_ctrl.rb +2 -2
  39. data/rakelib/lib/director/richtext_composite_object.rb +2 -4
  40. data/rakelib/lib/director/secret_store.rb +117 -0
  41. data/rakelib/lib/director/tree_event.rb +2 -2
  42. data/rakelib/lib/generate/doc/secret_store.yaml +55 -0
  43. data/rakelib/lib/generate/doc.rb +29 -14
  44. data/rakelib/lib/generate/interface.rb +4 -2
  45. data/rakelib/lib/specs/interfaces.rb +1 -0
  46. data/rakelib/lib/swig_runner.rb +11 -11
  47. data/rakelib/lib/typemap/common.rb +10 -0
  48. data/rakelib/prepost.rake +17 -5
  49. data/rakelib/yard/templates/default/fulldoc/html/css/wxruby3.css +18 -0
  50. data/rakelib/yard/templates/default/fulldoc/html/setup.rb +5 -5
  51. data/rakelib/yard/yard/relative_markdown_links.rb +7 -1
  52. data/samples/sampler/sample.rb +2 -0
  53. data/tests/lib/wxapp_runner.rb +1 -1
  54. data/tests/test_config.rb +7 -4
  55. data/tests/test_secret_store.rb +83 -0
  56. metadata +46 -23
  57. data/ext/mkrf_conf_srcgem.rb +0 -67
  58. data/rakelib/run.rake +0 -52
data/rakelib/gem.rake ADDED
@@ -0,0 +1,199 @@
1
+ # Copyright (c) 2023 M.J.N. Corino, The Netherlands
2
+ #
3
+ # This software is released under the MIT license.
4
+
5
+ ###
6
+ # wxRuby3 rake file
7
+ ###
8
+
9
+ require_relative './gem'
10
+
11
+ namespace :wxruby do
12
+
13
+ namespace :gem do
14
+
15
+ task :srcgem => ['bin:build', WXRuby3::Gem.gem_file]
16
+
17
+ # this task only exists for installed (source) gems (where run tasks have been removed)
18
+ unless File.file?(File.join(__dir__, 'run.rake'))
19
+
20
+ task :setup => 'config:bootstrap' do |_t, args|
21
+ begin
22
+ $stdout.print "Building wxRuby3 extensions..." if WXRuby3.config.run_silent?
23
+ WXRuby3.config.set_silent_run_incremental
24
+ Rake::Task['wxruby:build'].invoke
25
+ WXRuby3.config.set_silent_run_batched
26
+ $stdout.puts 'done!' if WXRuby3.config.run_silent?
27
+ Rake::Task['wxruby:post:srcgem'].invoke
28
+ # all is well -> cleanup
29
+ if args.extras.include?(':keep_log')
30
+ $stdout.puts "Log: #{WXRuby3.config.silent_log_name}"
31
+ else
32
+ rm_f(WXRuby3.config.silent_log_name, verbose: WXRuby3.config.verbose?)
33
+ end
34
+ rescue Exception => ex
35
+ $stderr.puts <<~__ERR_TXT
36
+ #{ex.message}#{WXRuby3.config.verbose? ? "\n#{ex.backtrace.join("\n")}" : ''}
37
+
38
+ For error details check #{WXRuby3.config.silent_log_name}
39
+ __ERR_TXT
40
+ exit(1)
41
+ end
42
+ $stdout.puts <<~__MSG
43
+
44
+ wxRuby3 has been successfully installed including the 'wxruby' utility.
45
+
46
+ You can run the regression tests to verify the installation by executing:
47
+
48
+ $ ./wxruby test
49
+
50
+ The wxRuby3 sample explorer can be run by executing:
51
+
52
+ $ ./wxruby sampler
53
+
54
+ Have fun using wxRuby3.
55
+ __MSG
56
+ end
57
+ end
58
+
59
+ end
60
+
61
+ end
62
+
63
+ # source gem file
64
+ file WXRuby3::Gem.gem_file => WXRuby3::Gem.manifest do
65
+ gemspec = WXRuby3::Gem.define_spec do |gem|
66
+ gem.summary = %Q{wxWidgets extension for Ruby}
67
+ gem.description = %Q{wxRuby3 is a Ruby library providing an extension for the wxWidgets C++ UI framework}
68
+ gem.email = 'mcorino@m2c-software.nl'
69
+ gem.homepage = "https://github.com/mcorino/wxRuby3"
70
+ gem.authors = ['Martin Corino']
71
+ gem.extensions = ['ext/mkrf_conf_ext.rb']
72
+ gem.files = WXRuby3::Gem.manifest
73
+ gem.require_paths = %w{lib}
74
+ gem.bindir = 'bin'
75
+ gem.executables = WXRuby3::Bin.binaries
76
+ gem.required_ruby_version = '>= 2.5'
77
+ gem.licenses = ['MIT']
78
+ gem.add_dependency 'nokogiri', '~> 1.12'
79
+ gem.add_dependency 'rake'
80
+ gem.add_dependency 'minitest', '~> 5.15'
81
+ gem.add_dependency 'test-unit', '~> 3.5'
82
+ gem.add_dependency 'plat4m', '~> 1.0'
83
+ gem.rdoc_options <<
84
+ '--exclude=\\.dll' <<
85
+ '--exclude=\\.so' <<
86
+ '--exclude=lib/wx.rb' <<
87
+ '--exclude=lib/wx/*.rb' <<
88
+ "'--exclude=lib/wx/(aui|core|grid|html|pg|prt|rbn|rtc|stc|wxruby)/.*'"
89
+ gem.metadata = {
90
+ "bug_tracker_uri" => "https://github.com/mcorino/wxRuby3/issues",
91
+ "homepage_uri" => "https://github.com/mcorino/wxRuby3",
92
+ "documentation_uri" => "https://mcorino.github.io/wxRuby3",
93
+ "github_repo" => "https://github.com/mcorino/wxRuby3"
94
+ }
95
+ gem.post_install_message = <<~__MSG
96
+
97
+ The wxRuby3 Gem has been successfully installed including the 'wxruby' utility.
98
+
99
+ In case no suitable binary release package was available for your platform you
100
+ will need to run the post-install setup process by executing:
101
+
102
+ $ wxruby setup
103
+
104
+ To check whether wxRuby3 is ready to run or not you can at any time execute the
105
+ following command:
106
+
107
+ $ wxruby check
108
+
109
+ Run 'wxruby check -h' for more information.
110
+
111
+ When the wxRuby3 setup has been fully completed you can start using wxRuby3.
112
+
113
+ You can run the regression tests to verify the installation by executing:
114
+
115
+ $ wxruby test
116
+
117
+ The wxRuby3 sample explorer can be run by executing:
118
+
119
+ $ wxruby sampler
120
+
121
+ Have fun using wxRuby3.
122
+
123
+ Run 'wxruby -h' to see information on the available commands.
124
+
125
+ __MSG
126
+ end
127
+ WXRuby3::Gem.build_gem(gemspec)
128
+ end
129
+
130
+ desc 'Build wxRuby 3 gem'
131
+ task :gem => 'wxruby:gem:srcgem'
132
+
133
+ # these tasks do not exist for installed (source) gems (where run tasks have been removed)
134
+ if File.file?(File.join(__dir__, 'run.rake'))
135
+
136
+ if WXRuby3.is_bootstrapped?
137
+
138
+ namespace :wxruby do
139
+
140
+ namespace :gem do
141
+ task :binpkg => ['wxruby:build', 'wxruby:doc', 'bin:build', WXRuby3::Gem.bin_pkg_file]
142
+ end
143
+
144
+ end
145
+
146
+ # binary package file
147
+ file WXRuby3::Gem.bin_pkg_file => WXRuby3::Gem.bin_pkg_manifest do |t|
148
+ WXRuby3::Install.install_wxwin_shlibs
149
+ begin
150
+ # create bin package
151
+ WXRuby3::Gem.build_bin_pkg
152
+ ensure
153
+ # cleanup
154
+ WXRuby3::Install.remove_wxwin_shlibs
155
+ end
156
+ end
157
+
158
+ desc 'Build wxRuby 3 binary release package'
159
+ task :binpkg => 'wxruby:gem:binpkg'
160
+
161
+ end
162
+
163
+ else # in case of installed source gem the following tasks exist
164
+
165
+ namespace :wxruby do
166
+
167
+ namespace :gem do
168
+ kwargs = {}
169
+ no_prebuilt = false
170
+ task :install do |_, args|
171
+ argv = args.extras
172
+ until argv.empty?
173
+ switch = argv.shift
174
+ case switch
175
+ when '--prebuilt'
176
+ kwargs[:prebuilt_only] = true
177
+ when '--no-prebuilt'
178
+ no_prebuilt = true unless kwargs[:package]
179
+ when '--package'
180
+ fail "Missing value for '--package' argument for wxruby:gem:install." if argv.empty?
181
+ kwargs[:package] = argv.shift
182
+ no_prebuilt = false
183
+ else
184
+ fail "Invalid argument #{switch} for wxruby:gem:install."
185
+ end
186
+ end
187
+ unless no_prebuilt # do not even try to find&install a binary package
188
+ if WXRuby3::Gem.install_gem(**kwargs)
189
+ # binaries have been installed -> finish install
190
+ Rake::Task['wxruby:post:binpkg'].invoke
191
+ end
192
+ end
193
+ end
194
+
195
+ end
196
+
197
+ end
198
+
199
+ end
data/rakelib/gem.rb ADDED
@@ -0,0 +1,334 @@
1
+ # Copyright (c) 2023 M.J.N. Corino, The Netherlands
2
+ #
3
+ # This software is released under the MIT license.
4
+
5
+ ###
6
+ # wxRuby3 rake gem support
7
+ ###
8
+
9
+ require 'set'
10
+ require 'rubygems'
11
+ require 'rubygems/package'
12
+ begin
13
+ require 'rubygems/builder'
14
+ rescue LoadError
15
+ end
16
+ require 'zlib'
17
+ require 'tempfile'
18
+ require 'json'
19
+ require 'uri'
20
+ require 'net/https'
21
+ require 'fileutils'
22
+ require 'digest/sha2'
23
+
24
+ require_relative './lib/config'
25
+ require_relative './install'
26
+
27
+ module WXRuby3
28
+
29
+ module Gem
30
+
31
+ BINPKG_EXT = '.pkg'
32
+ DIGEST_EXT = '.sha'
33
+
34
+ class << self
35
+
36
+ # Gem helpers
37
+
38
+ def manifest
39
+ # create MANIFEST list with included files
40
+ manifest = Rake::FileList.new
41
+ manifest.include %w[bin/*] # *nix executables in bin/
42
+ manifest.exclude %w[bin/*.bat] unless WXRuby3.config.windows?
43
+ manifest.include %w[assets/**/* lib/**/* samples/**/* tests/**/*]
44
+ manifest.exclude "lib/*.#{WXRuby3.config.dll_mask}"
45
+ manifest.include 'ext/mkrf_conf_ext.rb', 'ext/wxruby3/wxruby.ico', 'ext/wxruby3/swig/**/*', 'ext/wxruby3/include/**/*'
46
+ manifest.exclude 'ext/wxruby3/swig/classes/**/*'
47
+ manifest.include 'rakelib/**/*'
48
+ manifest.exclude %w[rakelib/run.* rakelib/help.* rakelib/package.* rakelib/memcheck.* rakelib/memcheck/**/*]
49
+ manifest.include %w{LICENSE README.md CREDITS.md INSTALL.md .yardopts}
50
+ manifest
51
+ end
52
+
53
+ def define_spec(&block)
54
+ gemspec = ::Gem::Specification.new('wxruby3', WXRuby3::WXRUBY_VERSION)
55
+ gemspec.required_rubygems_version = ::Gem::Requirement.new(">= 0") if gemspec.respond_to? :required_rubygems_version=
56
+ block.call(gemspec) if block_given?
57
+ gemspec
58
+ end
59
+
60
+ def gem_name
61
+ define_spec.full_name
62
+ end
63
+ private :gem_name
64
+
65
+ def gem_file
66
+ File.join('pkg', "#{gem_name}.gem")
67
+ end
68
+
69
+ def build_gem(gemspec)
70
+ if defined?(::Gem::Package) && ::Gem::Package.respond_to?(:build)
71
+ gem_file_name = ::Gem::Package.build(gemspec)
72
+ else
73
+ gem_file_name = ::Gem::Builder.new(gemspec).build
74
+ end
75
+
76
+ FileUtils.mkdir_p('pkg')
77
+
78
+ FileUtils.mv(gem_file_name, 'pkg')
79
+ end
80
+
81
+ # Binary package helpers
82
+
83
+ def bin_pkg_manifest
84
+ # create MANIFEST list with included files
85
+ manifest = Rake::FileList.new
86
+ manifest.include "lib/*.#{WXRuby3.config.dll_mask}"
87
+ manifest.include 'lib/wx/**/events/*.rb', 'lib/wx/**/ext/*.rb', 'lib/wx/core/font/*.rb'
88
+ manifest.include "lib/wx/doc/gen/**/*.rb"
89
+ if WXRuby3.config.get_config('with-wxwin')
90
+ manifest.include "ext/*.#{WXRuby3.config.dll_mask}"
91
+ end
92
+ manifest
93
+ end
94
+
95
+ def make_bin_name
96
+ os = WXRuby3.config.sysinfo.os
97
+ case os.id
98
+ when :windows
99
+ "wxruby3_#{os.distro}_ruby#{WXRuby3::Config.rb_ver_major}#{WXRuby3::Config.rb_ver_minor}"
100
+ else
101
+ "wxruby3_#{os.distro}_#{os.release || '0'}_ruby#{WXRuby3::Config.rb_ver_major}#{WXRuby3::Config.rb_ver_minor}"
102
+ end
103
+ end
104
+ private :make_bin_name
105
+
106
+ def bin_pkg_name
107
+ gemspec = ::Gem::Specification.new(make_bin_name, WXRuby3::WXRUBY_VERSION)
108
+ platform = ::Gem::Platform.new(RB_CONFIG["arch"])
109
+ if platform.os == 'darwin'
110
+ # loose the version for darwin kernels as that does not seem to affect wxRuby runtime compatibility
111
+ # (until proven otherwise)
112
+ platform.version = nil
113
+ end
114
+ gemspec.platform = platform.to_s
115
+ gemspec.full_name
116
+ end
117
+ private :bin_pkg_name
118
+
119
+ def bin_pkg_file
120
+ File.join('pkg', bin_pkg_name+BINPKG_EXT)
121
+ end
122
+
123
+ def build_bin_pkg
124
+ # make sure pkg directory exists
125
+ FileUtils.mkdir_p('pkg')
126
+
127
+ fname = bin_pkg_file
128
+
129
+ # package registry and essential config
130
+ registry = []
131
+ config = %w{wxwininstdir with-wxwin}.reduce({}) { |h, k| h[k] = WXRuby3.config.get_config(k); h }
132
+ # package temp deflate stream
133
+ deflate_stream = Tempfile.new(File.basename(fname, '.*'), binmode: true)
134
+ begin
135
+ # pack binaries into temp deflate stream
136
+ bin_pkg_manifest.each do |path|
137
+ registry << pack_file(deflate_stream, path)
138
+ end
139
+ # convert registry and config to deflated json string
140
+ registry_json_z = Zlib::Deflate.deflate(registry.to_json)
141
+ config_json_z = Zlib::Deflate.deflate(config.to_json)
142
+
143
+ # create final package archive
144
+ deflate_stream.rewind
145
+ digest = Digest::SHA256.new
146
+ File.open(fname, 'w', binmode: true) do |fout|
147
+ # pack config
148
+ data = [config_json_z.size].pack('Q')
149
+ digest << data
150
+ fout.write(data)
151
+ digest << config_json_z
152
+ fout.write(config_json_z)
153
+ # pack registry
154
+ data = [registry_json_z.size].pack('Q')
155
+ digest << data
156
+ fout.write(data)
157
+ digest << registry_json_z
158
+ fout.write(registry_json_z)
159
+ # pack files
160
+ registry.each do |entry|
161
+ if entry[2] > 0
162
+ data = deflate_stream.read(entry[2])
163
+ digest << data
164
+ fout.write(data)
165
+ end
166
+ end
167
+ end
168
+ sha_file = File.join('pkg', bin_pkg_name+DIGEST_EXT)
169
+ File.open(sha_file, 'w') { |fsha| fsha << digest.hexdigest! }
170
+ ensure
171
+ deflate_stream.close(true)
172
+ end
173
+ end
174
+
175
+ def pack_file(os, path)
176
+ pack = true
177
+ entry = [path, File.stat(path).mode, 0]
178
+ unless WXRuby3.config.windows?
179
+ if File.symlink?(path)
180
+ pack = false
181
+ entry << File.readlink(path)
182
+ end
183
+ end
184
+ if pack
185
+ offs = os.tell
186
+ os.write(Zlib::Deflate.deflate(File.read(path, binmode: true)))
187
+ entry[2] = os.tell - offs # packed data size
188
+ end
189
+ entry
190
+ end
191
+ private :pack_file
192
+
193
+ # Gem installation helpers
194
+
195
+ def install_gem(prebuilt_only: false, package: nil)
196
+ # check if a user specified binary package is to be used
197
+ if package
198
+ uri = File.file?(package) ? nil : URI(package)
199
+ if uri.nil? || uri.scheme == 'file'
200
+ filename = package
201
+ if uri
202
+ filename = uri.host ? "#{uri.host}:#{uri.path}" : uri.path
203
+ filename = nil unless File.file?(filename)
204
+ end
205
+ if filename
206
+ $stdout.puts "Installing user package #{filename}..."
207
+ exit(1) unless install_bin_pkg(filename)
208
+ $stdout.puts 'Done!'
209
+ true
210
+ else
211
+ $stderr.puts "ERROR: Cannot access file #{package}."
212
+ exit(1)
213
+ end
214
+ elsif uri.scheme == 'http' || uri.scheme == 'https'
215
+ # download the binary release package
216
+ $stdout.puts "Downloading #{uri.path}..."
217
+ filename = File.basename(uri.path)
218
+ if WXRuby3.config.download_file(uri.path, filename)
219
+ sha_file = File.basename(filename, '.*')+DIGEST_EXT
220
+ uri.path = File.join(File.dirname(uri.path), sha_file)
221
+ unless WXRuby3.config.download_file(uri.path, sha_file)
222
+ $stderr.puts "ERROR: Unable to download digest signature for binary release package : #{package}"
223
+ exit(1)
224
+ end
225
+ exit(1) unless install_bin_pkg(filename)
226
+ true
227
+ else
228
+ $stderr.puts "ERROR: Unable to download binary release package (#{package})!"
229
+ exit(1)
230
+ end
231
+ else
232
+ end
233
+ # check if there exists a pre-built binary release package for the current platform
234
+ elsif has_release_package?
235
+ # download the binary release package
236
+ $stdout.puts "Downloading #{bin_pkg_url(BINPKG_EXT)}..."
237
+ if WXRuby3.config.download_file(bin_pkg_url(BINPKG_EXT), bin_pkg_name+BINPKG_EXT)
238
+ unless WXRuby3.config.download_file(bin_pkg_url(DIGEST_EXT), bin_pkg_name+DIGEST_EXT)
239
+ $stderr.puts "ERROR: Unable to download digest signature for binary release package : #{bin_pkg_name}"
240
+ exit(1)
241
+ end
242
+ exit(1) unless install_bin_pkg(bin_pkg_name+BINPKG_EXT)
243
+ true
244
+ else
245
+ if prebuilt_only
246
+ $stderr.puts "ERROR: Unable to download binary release package (#{bin_pkg_name})!"
247
+ exit(1)
248
+ end
249
+ $stdout.puts "WARNING: Unable to download binary release package (#{bin_pkg_name})! Reverting to source install."
250
+ false
251
+ end
252
+ else
253
+ if prebuilt_only
254
+ $stderr.puts "ERROR: No binary release package available!"
255
+ exit(1)
256
+ end
257
+ false
258
+ end
259
+ end
260
+
261
+ def bin_pkg_url(ext)
262
+ # which package are we looking for
263
+ pkg_name = bin_pkg_name
264
+ "https://github.com/mcorino/wxRuby3/releases/download/v#{WXRuby3::WXRUBY_VERSION}/#{pkg_name}#{ext}"
265
+ end
266
+ private :bin_pkg_url
267
+
268
+ def has_release_package?
269
+ # check if the release package exists on Github
270
+ uri = URI(bin_pkg_url(BINPKG_EXT))
271
+ $stdout.print "Checking #{uri.to_s}..." if WXRuby3.config.verbose?
272
+ response = Net::HTTP.start('github.com', use_ssl: true) do |http|
273
+ request = Net::HTTP::Head.new(uri)
274
+ http.request(request)
275
+ end
276
+ $stdout.puts "response #{response}" if WXRuby3.config.verbose?
277
+ # directly found or with redirect
278
+ Net::HTTPOK === response || Net::HTTPRedirection === response
279
+ end
280
+ private :has_release_package?
281
+
282
+ def install_bin_pkg(fname)
283
+ # first get digest signature (if available)
284
+ sha_file = File.join(File.dirname(fname), File.basename(fname, '.*')+DIGEST_EXT)
285
+ unless File.file?(sha_file)
286
+ $stderr.puts "ERROR: Cannot access package digest signature file : #{sha_file}."
287
+ return false
288
+ end
289
+ sha_sig = File.read(sha_file)
290
+ File.open(fname, 'r', binmode: true) do |fin|
291
+ # check digest signature
292
+ digest = Digest::SHA256.new
293
+ while (data = fin.read(1024*1024))
294
+ digest << data
295
+ end
296
+ if sha_sig != digest.hexdigest!
297
+ $stderr.puts 'ERROR: Package digest signature does NOT match.'
298
+ return false
299
+ end
300
+ fin.rewind
301
+ # get packed config size
302
+ config_size = fin.read(8).unpack('Q').shift
303
+ # unpack config
304
+ config = JSON.parse!(Zlib::Inflate.inflate(fin.read(config_size)))
305
+ # get packed registry size
306
+ registry_size = fin.read(8).unpack('Q').shift
307
+ # unpack registry
308
+ registry = JSON.parse!(Zlib::Inflate.inflate(fin.read(registry_size)))
309
+ # unpack and create binaries
310
+ registry.each do |entry|
311
+ path, mode, size, symlink = entry
312
+ if symlink
313
+ FileUtils.mkdir_p(File.dirname(symlink))
314
+ FileUtils.ln_s(symlink, path)
315
+ else
316
+ FileUtils.mkdir_p(File.dirname(path))
317
+ File.open(path, 'w', binmode: true) do |fbin|
318
+ fbin << Zlib::Inflate.inflate(fin.read(size))
319
+ end
320
+ File.chmod(mode, path)
321
+ end
322
+ end
323
+ # merge config
324
+ config.each_pair { |k,v| WXRuby3.config.set_config(k, v) }
325
+ end
326
+ true
327
+ end
328
+ private :install_bin_pkg
329
+
330
+ end
331
+
332
+ end
333
+
334
+ end
data/rakelib/install.rb CHANGED
@@ -57,6 +57,7 @@ module WXRuby3
57
57
 
58
58
  def install_wxwin_shlibs
59
59
  if WXRuby3.config.get_config('with-wxwin')
60
+ $stdout.print "Installing wxRuby3 extensions..." if WXRuby3.config.run_silent?
60
61
  # prepare required wxWidgets shared libs
61
62
  wxwin_inshlibs = []
62
63
  WXRuby3::Install.wxwin_shlibs.each do |shlib|
@@ -66,7 +67,7 @@ module WXRuby3
66
67
  FileUtils.ln_s(File.join('.', File.basename(src_shlib)), File.join('ext', File.basename(shlib)))
67
68
  else
68
69
  FileUtils.cp(shlib, inshlib = File.join('ext', File.basename(shlib)))
69
- unless WXRuby3.config.patch_rpath(inshlib, WXRuby3.config.get_rpath_origin)
70
+ unless WXRuby3.config.update_shlib_loadpaths(inshlib)
70
71
  # cleanup and exit
71
72
  FileUtils.rm_f(Dir["ext/*.#{WXRuby3.config.dll_mask}"])
72
73
  exit(1)
@@ -76,19 +77,20 @@ module WXRuby3
76
77
  end
77
78
  # prepare wxRuby shared libs
78
79
  Dir["lib/*.#{WXRuby3.config.dll_mask}"].each do |shlib|
79
- unless WXRuby3.config.patch_rpath(shlib, WXRuby3.config.get_rpath_origin, "#{WXRuby3.config.get_rpath_origin}/../ext")
80
+ unless WXRuby3.config.update_shlib_loadpaths(shlib) && WXRuby3.config.update_shlib_ruby_libpath(shlib)
80
81
  # cleanup and exit
81
82
  FileUtils.rm_f(Dir["ext/*.#{WXRuby3.config.dll_mask}"])
82
83
  exit(1)
83
84
  end
84
85
  end
85
86
  (wxwin_inshlibs + Dir["lib/*.#{WXRuby3.config.dll_mask}"]).each do |shlib|
86
- unless WXRuby3.config.update_shlib_loadpaths(shlib, WXRuby3::Install.wxwin_shlibs)
87
+ unless WXRuby3.config.update_shlib_wxwin_libpaths(shlib, WXRuby3::Install.wxwin_shlibs)
87
88
  # cleanup and exit
88
89
  FileUtils.rm_f(Dir["ext/*.#{WXRuby3.config.dll_mask}"])
89
90
  exit(1)
90
91
  end
91
92
  end
93
+ $stdout.puts 'done!' if WXRuby3.config.run_silent?
92
94
  end
93
95
  end
94
96
 
@@ -6,4 +6,4 @@
6
6
  # wxRuby3 buildtools configuration
7
7
  ###
8
8
 
9
- raise "Cygwin platform is unsupported as yet."
9
+ raise "Freebsd platform is unsupported as yet."
@@ -7,6 +7,7 @@
7
7
  ###
8
8
 
9
9
  require_relative './unixish'
10
+ require_relative 'pkgman/linux'
10
11
 
11
12
  module WXRuby3
12
13
 
@@ -17,6 +18,7 @@ module WXRuby3
17
18
  def self.included(base)
18
19
  base.class_eval do
19
20
  include Config::UnixLike
21
+
20
22
  alias :base_ldflags :ldflags
21
23
  def ldflags(target)
22
24
  "-Wl,-soname,#{File.basename(target)} #{base_ldflags(target)}"
@@ -31,15 +33,16 @@ module WXRuby3
31
33
 
32
34
  def check_rpath_patch
33
35
  unless @rpath_patch
34
- if system('which patchelf > /dev/null 2>&1')
36
+ if system('command -v patchelf > /dev/null')
35
37
  @rpath_patch = 'patchelf --set-rpath'
36
38
  else
37
- STDERR.puts 'Installation of binary gem with-wxwin requires an installed version of either the patchelf utility.'
39
+ STDERR.puts 'Installation of binary gem with-wxwin requires an installed version of the patchelf utility.'
38
40
  return false
39
41
  end
40
42
  end
41
43
  true
42
44
  end
45
+ protected :check_rpath_patch
43
46
 
44
47
  def patch_rpath(shlib, *rpath)
45
48
  if check_rpath_patch
@@ -48,6 +51,27 @@ module WXRuby3
48
51
  end
49
52
  false
50
53
  end
54
+ protected :patch_rpath
55
+
56
+ def check_tool_pkgs
57
+ pkg_deps = super
58
+ # need g++ to build wxRuby3 extensions in any case
59
+ pkg_deps << 'g++' unless system('command -v g++>/dev/null')
60
+ # do we need to build wxWidgets?
61
+ if get_config('with-wxwin') && get_cfg_string('wxwin').empty?
62
+ pkg_deps << 'patchelf' unless system('command -v patchelf>/dev/null')
63
+ pkg_deps << 'make' unless system('command -v make>/dev/null')
64
+ pkg_deps << 'git' unless system('command -v git>/dev/null')
65
+ end
66
+ pkg_deps
67
+ end
68
+
69
+ def install_prerequisites
70
+ pkg_deps = check_tool_pkgs
71
+ PkgManager.install(pkg_deps)
72
+ []
73
+ end
74
+
51
75
  end
52
76
  end
53
77