wxruby3 0.9.4 → 0.9.7

Sign up to get free protection for your applications and to get access to all the features.
Files changed (65) hide show
  1. checksums.yaml +4 -4
  2. data/INSTALL.md +315 -78
  3. data/README.md +32 -21
  4. data/ext/wxruby3/include/wxruby-ComboPopup.h +777 -0
  5. data/lib/wx/core/combo_ctrl.rb +171 -0
  6. data/lib/wx/core/ext.rb +22 -3
  7. data/lib/wx/doc/comboctrl.rb +128 -3
  8. data/lib/wx/doc/owner_drawn_combobox.rb +5 -1
  9. data/lib/wx/version.rb +1 -1
  10. data/lib/wx/wxruby/base.rb +6 -4
  11. data/lib/wx/wxruby/cmd/sampler.rb +39 -29
  12. data/lib/wx/wxruby/cmd/setup.rb +122 -0
  13. data/lib/wx/wxruby/cmd/test.rb +56 -6
  14. data/rakefile +14 -0
  15. data/rakelib/bin.rake +48 -0
  16. data/rakelib/bin.rb +62 -0
  17. data/rakelib/build.rb +11 -7
  18. data/rakelib/config.rake +3 -1
  19. data/rakelib/configure.rb +28 -8
  20. data/rakelib/doc.rake +3 -1
  21. data/rakelib/gem.rake +169 -0
  22. data/rakelib/gem.rb +82 -0
  23. data/rakelib/install.rb +2 -0
  24. data/rakelib/lib/config/linux.rb +24 -2
  25. data/rakelib/lib/config/macosx.rb +16 -0
  26. data/rakelib/lib/config/mingw.rb +133 -9
  27. data/rakelib/lib/config/pkgman/arch.rb +53 -0
  28. data/rakelib/lib/config/pkgman/base.rb +169 -0
  29. data/rakelib/lib/config/pkgman/debian.rb +66 -0
  30. data/rakelib/lib/config/pkgman/macosx.rb +183 -0
  31. data/rakelib/lib/config/pkgman/rhel.rb +54 -0
  32. data/rakelib/lib/config/pkgman/suse.rb +54 -0
  33. data/rakelib/lib/config/unixish.rb +36 -19
  34. data/rakelib/lib/config.rb +254 -61
  35. data/rakelib/lib/core/include/funcall.inc +2 -1
  36. data/rakelib/lib/core/package.rb +47 -49
  37. data/rakelib/lib/director/comboctrl.rb +104 -3
  38. data/rakelib/lib/director/defs.rb +1 -3
  39. data/rakelib/lib/director/gdicommon.rb +5 -0
  40. data/rakelib/lib/director/menu_item.rb +1 -1
  41. data/rakelib/lib/director/num_validator.rb +5 -7
  42. data/rakelib/lib/director/owner_drawn_combobox.rb +1 -0
  43. data/rakelib/lib/director/persistent_window.rb +2 -2
  44. data/rakelib/lib/director/pgeditor.rb +1 -1
  45. data/rakelib/lib/director/pgproperties.rb +3 -3
  46. data/rakelib/lib/director/pgproperty.rb +5 -1
  47. data/rakelib/lib/director/richtext_style_listbox.rb +5 -0
  48. data/rakelib/lib/director/sizer.rb +1 -1
  49. data/rakelib/lib/director/window.rb +4 -0
  50. data/rakelib/lib/extractor/module.rb +15 -0
  51. data/rakelib/lib/generate/doc/combo_ctrl.yaml +135 -0
  52. data/rakelib/lib/generate/doc/file_dialog_customize_hook.yaml +62 -0
  53. data/rakelib/lib/generate/doc/file_system.yaml +28 -0
  54. data/rakelib/lib/generate/doc.rb +29 -14
  55. data/rakelib/lib/generate/interface.rb +16 -6
  56. data/rakelib/lib/swig_runner.rb +18 -15
  57. data/rakelib/lib/typemap/combo_popup.rb +42 -0
  58. data/rakelib/prepost.rake +9 -4
  59. data/rakelib/yard/templates/default/fulldoc/html/css/wxruby3.css +14 -0
  60. data/rakelib/yard/templates/default/fulldoc/html/setup.rb +5 -5
  61. data/rakelib/yard/yard/relative_markdown_links.rb +7 -1
  62. data/tests/test_combo_ctrl.rb +196 -0
  63. metadata +28 -17
  64. data/ext/mkrf_conf_srcgem.rb +0 -67
  65. data/rakelib/run.rake +0 -52
@@ -10,21 +10,71 @@ require 'fileutils'
10
10
  module WxRuby
11
11
  module Commands
12
12
  class Test
13
+
14
+ DESC = 'Run wxRuby3 regression tests.'
15
+
13
16
  def self.description
14
- " test\t\t\tRun wxRuby3 regression tests."
17
+ " test -h|[options] [TEST [...]]\t#{DESC}"
18
+ end
19
+
20
+ def self.options
21
+ Commands.options['test'] ||= { verbose: Commands.options[:verbose], excludes: [] }
22
+ end
23
+
24
+ def self.parse_args(args)
25
+ opts = OptionParser.new
26
+ opts.banner = "#{DESC}\n\nUsage: wxruby test -h|--help OR wxruby test [options] [TEST [...]]\n\n" +
27
+ "TEST == test name\n" +
28
+ "Runs all tests (except any specified to exclude) if no test specified.\n\n"
29
+ opts.separator ''
30
+ opts.on('--list',
31
+ "display the list of names of the installed tests") do |v|
32
+ tests = Dir[File.join(WxRuby::ROOT, 'tests', '*.rb')].collect { |t| File.basename(t, '.*') }
33
+ $stdout.puts <<~__INFO
34
+ Installed wxRuby tests:
35
+ #{tests.join(', ')}
36
+
37
+ __INFO
38
+ exit(0)
39
+ end
40
+ opts.on('--exclude=TEST',
41
+ "exclude the specified test from running") {|v| Test.options[:excludes] << v }
42
+ opts.on('-h', '--help',
43
+ 'Show this message.') do |v|
44
+ puts opts
45
+ puts
46
+ exit(0)
47
+ end
48
+ opts.parse!(args)
15
49
  end
16
50
 
17
51
  def self.run(argv)
18
- if argv == :describe
19
- description
20
- else
21
- Dir[File.join(WxRuby::ROOT, 'tests', '*.rb')].each do |test|
52
+ return description if argv == :describe
53
+
54
+ parse_args(argv)
55
+
56
+ tests = if argv.empty?
57
+ Dir[File.join(WxRuby::ROOT, 'tests', '*.rb')]
58
+ else
59
+ argv.collect do |a|
60
+ fn = File.join(WxRuby::ROOT, 'tests', a+'.rb')
61
+ unless File.file?(fn)
62
+ $stderr.puts "ERROR: Invalid test [#{a}] specified."
63
+ exit(1)
64
+ end
65
+ fn
66
+ end
67
+ end
68
+ tests.each do |test|
69
+ unless Test.options[:excludes].include?(File.basename(test, '.*'))
22
70
  exit(1) unless system(RUBY, test)
23
71
  end
24
72
  end
25
73
  end
26
74
  end
27
75
 
28
- self.register('test', Test)
76
+ if self.setup_done?
77
+ self.register('test', Test)
78
+ end
29
79
  end
30
80
  end
data/rakefile ADDED
@@ -0,0 +1,14 @@
1
+ ###
2
+ # wxRuby3 rake file
3
+ # Copyright (c) M.J.N. Corino, The Netherlands
4
+ ###
5
+
6
+ # Influential environment variables
7
+ # WXRUBY_VERBOSE : define verbosity for (rake) build scripts
8
+ # WXRUBY_VERSION : define the version info (x.x.x) for this tree
9
+ # WXRUBY_EXCLUDED : exclude certain classes from being compiled, even if present
10
+ #
11
+ # WXWIN : install folder of wxWidgets library if not system default
12
+ # WXXML : folder containing doxygen generated wxWidgets XML interface specs if not using wxRuby bootstrap
13
+
14
+ task :default => 'wxruby:help'
data/rakelib/bin.rake ADDED
@@ -0,0 +1,48 @@
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 'rake/clean'
10
+
11
+ require_relative './bin'
12
+
13
+ directory 'bin'
14
+
15
+ file File.join('bin', 'wxruby') => 'bin' do |t|
16
+ File.open(t.name, 'w') { |f| f.puts WXRuby3::Bin.wxruby }
17
+ File.chmod(0755, t.name)
18
+ end
19
+
20
+ namespace :wxruby do
21
+
22
+ namespace :bin do
23
+
24
+ task :build => ['wxruby:bin:check', File.join('bin', 'wxruby')]
25
+
26
+ task :check do
27
+ WXRuby3::Bin.binaries.each do |bin|
28
+ if File.exist?(File.join('bin', bin))
29
+ content = IO.read(File.join('bin', bin))
30
+ rm_f(File.join('bin', bin)) unless content == WXRuby3::Bin.__send__(bin.gsub('.','_').to_sym)
31
+ end
32
+ end
33
+ end
34
+ end
35
+ end
36
+
37
+ CLOBBER.include File.join('bin', 'wxruby')
38
+
39
+ if WXRuby3.config.windows?
40
+
41
+ file File.join('bin', 'wxruby.bat') => ['bin'] do |t|
42
+ File.open(t.name, 'w') { |f| f.puts WXRuby3::Bin.wxruby_bat }
43
+ end
44
+ Rake::Task['wxruby:bin:build'].enhance [File.join('bin', 'wxruby.bat')]
45
+
46
+ CLOBBER.include File.join('bin', 'wxruby.bat')
47
+
48
+ end
data/rakelib/bin.rb ADDED
@@ -0,0 +1,62 @@
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 bin support
7
+ ###
8
+
9
+ require_relative './lib/config'
10
+
11
+ module WXRuby3
12
+
13
+ module Bin
14
+
15
+ class << self
16
+ def wxruby
17
+ <<~_SH_TXT
18
+ #!#{WXRuby3.config.windows? ? '/bin/' : (`which env`).strip+' '}#{RB_CONFIG['ruby_install_name']}
19
+ #---------------------------------
20
+ # This file is generated
21
+ #---------------------------------
22
+ module WxRuby
23
+ ROOT = File.expand_path(File.join(File.dirname(__FILE__), '..'))
24
+ end
25
+ require 'wx/wxruby/base'
26
+ WxRuby.run
27
+ _SH_TXT
28
+ end
29
+
30
+ def wxruby_bat
31
+ <<~_BAT_TXT
32
+ @echo off
33
+ if not "%~f0" == "~f0" goto WinNT
34
+ #{RB_CONFIG['ruby_install_name']} -Sx "%0" %1 %2 %3 %4 %5 %6 %7 %8 %9
35
+ goto endofruby
36
+ :WinNT
37
+ if not exist "%~d0%~p0#{RB_CONFIG['ruby_install_name']}" goto rubyfrompath
38
+ if exist "%~d0%~p0#{RB_CONFIG['ruby_install_name']}" "%~d0%~p0#{RB_CONFIG['ruby_install_name']}" -x "%~f0" %*
39
+ goto endofruby
40
+ :rubyfrompath
41
+ #{RB_CONFIG['ruby_install_name']} -x "%~f0" %*
42
+ goto endofruby
43
+ #!/bin/#{RB_CONFIG['ruby_install_name']}
44
+ #
45
+ module WxRuby
46
+ ROOT = File.expand_path(File.join(File.dirname(__FILE__), '..'))
47
+ end
48
+ require 'wx/wxruby/base'
49
+ WxRuby.run
50
+ __END__
51
+ :endofruby
52
+ _BAT_TXT
53
+ end
54
+
55
+ def binaries
56
+ %w{wxruby}
57
+ end
58
+ end
59
+
60
+ end
61
+
62
+ end
data/rakelib/build.rb CHANGED
@@ -11,8 +11,11 @@ require_relative './lib/config'
11
11
 
12
12
  if WXRuby3.is_bootstrapped?
13
13
 
14
- Rake.application.options.always_multitask =
15
- Rake.application.top_level_tasks.size == 1 && Rake.application.top_level_tasks.first == 'build'
14
+ # only if not part of installed Gem
15
+ if File.file?(File.join(__dir__, 'package.rake'))
16
+ Rake.application.options.always_multitask =
17
+ Rake.application.top_level_tasks.size == 1 && Rake.application.top_level_tasks.first == 'build'
18
+ end
16
19
 
17
20
  require_relative './lib/director'
18
21
 
@@ -102,22 +105,23 @@ if WXRuby3.is_bootstrapped?
102
105
 
103
106
  file WXRuby3::Director.enum_cache_control_path do |t_|
104
107
  WXRuby3::Director.all_packages.each { |p| p.extract(genint: false) }
105
- touch(WXRuby3::Director.enum_cache_control_path)
108
+ touch(WXRuby3::Director.enum_cache_control_path, verbose: !WXRuby3.config.run_silent?)
106
109
  end
107
110
 
108
111
  # Compile an object file from a generated c++ source
109
112
  rule ".#{WXRuby3.config.obj_ext}" => [
110
113
  proc { |tn| "#{WXRuby3.config.src_dir}/#{File.basename(tn, ".*")}.cpp" }
111
114
  ] do | t |
112
- sh "#{WXRuby3.config.cpp} -c #{WXRuby3.config.verbose_flag} " +
113
- "#{WXRuby3.config.cxxflags} #{WXRuby3::Director.cpp_flags(t.source)} " +
114
- "#{WXRuby3.config.cpp_out_flag}#{t.name} #{t.source}"
115
+ WXRuby3.config.sh "#{WXRuby3.config.cpp} -c #{WXRuby3.config.verbose_flag} " +
116
+ "#{WXRuby3.config.cxxflags} #{WXRuby3::Director.cpp_flags(t.source)} " +
117
+ "#{WXRuby3.config.cpp_out_flag}#{t.name} #{t.source}",
118
+ fail_on_error: true
115
119
  end
116
120
 
117
121
  if WXRuby3.config.windows?
118
122
  # compile an object file from the standard wxRuby resource file
119
123
  file File.join(WXRuby3.config.obj_dir, 'wx_rc.o') => File.join(WXRuby3.config.swig_dir, 'wx.rc') do |t|
120
- sh "#{WXRuby3.config.rescomp} -i#{t.source} -o#{t.name}"
124
+ WXRuby3.config.sh "#{WXRuby3.config.rescomp} -i#{t.source} -o#{t.name}", fail_on_error: true
121
125
  end
122
126
  end
123
127
 
data/rakelib/config.rake CHANGED
@@ -33,7 +33,9 @@ namespace :wxruby do
33
33
  end
34
34
 
35
35
  WXRuby3.config.build_paths.each do |p|
36
- directory p
36
+ directory p do
37
+ mkdir_p(p, verbose: !WXRuby3.config.run_silent?)
38
+ end
37
39
  end
38
40
  end
39
41
 
data/rakelib/configure.rb CHANGED
@@ -70,6 +70,10 @@ module WXRuby3
70
70
  "the path to swig executable [#{get_config('swig')}]") {|v| CONFIG['swig'] = v}
71
71
  opts.on('--doxygen=path',
72
72
  "the path to doxygen executable [#{get_config('doxygen')}]") {|v| CONFIG['doxygen'] = v}
73
+ opts.on('--git=path',
74
+ "the path to git executable [#{get_config('git')}]") {|v| CONFIG['git'] = v}
75
+ opts.on('--[no-]autoinstall',
76
+ "do (not) attempt to automatically install any required packages") {|v| CONFIG['autoinstall'] = !!v }
73
77
 
74
78
  opts.separator ""
75
79
 
@@ -110,20 +114,36 @@ module WXRuby3
110
114
  # check wxWidgets availability through 'wx-config' command
111
115
  if instance.check_wx_config
112
116
  if instance.wx_config("--version") < '3.2.0'
113
- STDERR.puts "ERROR: Incompatible wxWidgets version. wxRuby requires a wxWidgets >= 3.2.0 release."
114
- exit(1)
117
+ if get_cfg_string('wxwin').empty? && get_cfg_string('wxxml').empty?
118
+ # no custom wxWidgets build specified so switch to assuming we should include building wxWidgets ourselves
119
+ set_config('with-wxwin', true)
120
+ else
121
+ # if someone wants to customize they HAVE to do it right
122
+ STDERR.puts "ERROR: Incompatible wxWidgets version. wxRuby requires a wxWidgets >= 3.2.0 release."
123
+ exit(1)
124
+ end
115
125
  end
116
126
  else
117
- STDERR.puts "ERROR: Cannot find wxWidgets. wxRuby requires a wxWidgets >= 3.2.0 release."
118
- exit(1)
127
+ if get_cfg_string('wxwin').empty? && get_cfg_string('wxxml').empty?
128
+ # no custom wxWidgets build specified so switch to assuming we should include building wxWidgets ourselves
129
+ set_config('with-wxwin', true)
130
+ else
131
+ # if someone wants to customize they HAVE to do it right
132
+ STDERR.puts "ERROR: Cannot find wxWidgets. wxRuby requires a wxWidgets >= 3.2.0 release."
133
+ exit(1)
134
+ end
119
135
  end
120
136
  # else we're are assumed to build wxWidgets ourselves so cannot test anything yet
121
137
  end
122
138
 
123
- if get_cfg_string('wxxml').empty?
124
- # no pre-generated XML specified so we are going to need Git and Doxygen
125
- instance.check_git
126
- instance.check_doxygen
139
+ if get_cfg_string('wxxml').empty? && !get_cfg_string('wxwin').empty?
140
+ # in case of a custom wxWidgets build and no explicit xml path check if the custom build holds this
141
+ xml_path = File.join(get_cfg_string('wxwin'), 'docs', 'doxygen', 'out', 'xml')
142
+ # if not there see if the standard setup 'wxw_root/<install dir>' was used
143
+ xml_path = File.join(get_cfg_string('wxwin'), '..', 'docs', 'doxygen', 'out', 'xml') unless File.directory?(xml_path)
144
+ if File.directory?(xml_path) && !Dir.glob(File.join(xml_path, '*.xml')).empty?
145
+ set_config('wxxml', xml_path)
146
+ end
127
147
  end
128
148
 
129
149
  end
data/rakelib/doc.rake CHANGED
@@ -16,7 +16,9 @@ namespace :wxruby do
16
16
 
17
17
  end
18
18
 
19
- directory WXRuby3.config.rb_docgen_path
19
+ directory WXRuby3.config.rb_docgen_path do
20
+ mkdir_p(WXRuby3.config.rb_docgen_path, verbose: !WXRuby3.config.run_silent?)
21
+ end
20
22
 
21
23
  file File.join(WXRuby3.config.rb_docgen_path, 'window.rb') => [WXRuby3.config.rb_docgen_path, *all_doc_targets]
22
24
 
data/rakelib/gem.rake ADDED
@@ -0,0 +1,169 @@
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('wxruby3', WXRuby3::WXRUBY_VERSION)]
16
+
17
+ if WXRuby3.is_bootstrapped?
18
+ task :bingem => ['bin:build', File.join(WXRuby3.config.rb_docgen_path, 'window.rb'), WXRuby3::Gem.gem_file('wxruby3', WXRuby3::WXRUBY_VERSION, :bin)]
19
+ end
20
+
21
+ # this task only exists for installed source gems (where package tasks have been removed)
22
+ unless File.file?(File.join(__dir__, 'package.rake'))
23
+
24
+ task :setup => 'config:bootstrap' do |_t, args|
25
+ begin
26
+ $stdout.print "Building wxRuby3 extensions..." if WXRuby3.config.run_silent?
27
+ WXRuby3.config.set_silent_run_incremental
28
+ Rake::Task['wxruby:build'].invoke
29
+ WXRuby3.config.set_silent_run_batched
30
+ $stdout.puts 'done!' if WXRuby3.config.run_silent?
31
+ Rake::Task['wxruby:post:srcgem'].invoke
32
+ # all is well -> cleanup
33
+ if args.extras.include?(':keep_log')
34
+ $stdout.puts "Log: #{WXRuby3.config.silent_log_name}"
35
+ else
36
+ rm_f(WXRuby3.config.silent_log_name, verbose: WXRuby3.config.verbose?)
37
+ end
38
+ rescue Exception => ex
39
+ $stderr.puts <<~__ERR_TXT
40
+ #{ex.message}#{WXRuby3.config.verbose? ? "\n#{ex.backtrace.join("\n")}" : ''}
41
+
42
+ For error details check #{WXRuby3.config.silent_log_name}
43
+ __ERR_TXT
44
+ exit(1)
45
+ end
46
+ $stdout.puts <<~__MSG
47
+
48
+ wxRuby3 has been successfully installed including the 'wxruby' utility.
49
+
50
+ You can run the regression tests to verify the installation by executing:
51
+
52
+ $ ./wxruby test
53
+
54
+ The wxRuby3 sample selector can be run by executing:
55
+
56
+ $ ./wxruby sampler
57
+
58
+ Have fun using wxRuby3.
59
+ __MSG
60
+ end
61
+ end
62
+
63
+ end
64
+
65
+ end
66
+
67
+ # source gem file
68
+ file WXRuby3::Gem.gem_file('wxruby3', WXRuby3::WXRUBY_VERSION) => WXRuby3::Gem.manifest do
69
+ gemspec = WXRuby3::Gem.define_spec('wxruby3', WXRuby3::WXRUBY_VERSION) do |gem|
70
+ gem.summary = %Q{wxWidgets extension for Ruby}
71
+ gem.description = %Q{wxRuby3 is a Ruby library providing an extension for the wxWidgets C++ UI framework}
72
+ gem.email = 'mcorino@m2c-software.nl'
73
+ gem.homepage = "https://github.com/mcorino/wxRuby3"
74
+ gem.authors = ['Martin Corino']
75
+ gem.files = WXRuby3::Gem.manifest
76
+ gem.require_paths = %w{lib}
77
+ gem.bindir = 'bin'
78
+ gem.executables = WXRuby3::Bin.binaries
79
+ gem.required_ruby_version = '>= 2.5'
80
+ gem.licenses = ['MIT']
81
+ gem.add_dependency 'nokogiri', '~> 1.12'
82
+ gem.add_dependency 'rake'
83
+ gem.add_dependency 'minitest', '~> 5.15'
84
+ gem.add_dependency 'test-unit', '~> 3.5'
85
+ gem.rdoc_options <<
86
+ '--exclude=\\.dll' <<
87
+ '--exclude=\\.so' <<
88
+ '--exclude=lib/wx.rb' <<
89
+ '--exclude=lib/wx/*.rb' <<
90
+ "'--exclude=lib/wx/(aui|core|grid|html|pg|prt|rbn|rtc|stc|wxruby)/.*'"
91
+ gem.metadata = {
92
+ "bug_tracker_uri" => "https://github.com/mcorino/wxRuby3/issues",
93
+ "source_code_uri" => "https://github.com/mcorino/wxRuby3",
94
+ "documentation_uri" => "https://mcorino.github.io/wxRuby3",
95
+ "homepage_uri" => "https://github.com/mcorino/wxRuby3",
96
+ }
97
+ gem.post_install_message = <<~__MSG
98
+
99
+ The wxRuby3 Gem has been successfully installed.
100
+ Before being able to use wxRuby3 you need to run the post-install setup process
101
+ by executing the command 'wxruby setup'.
102
+
103
+ Run 'wxruby setup -h' to see information on the available commandline options.
104
+
105
+ __MSG
106
+ end
107
+ WXRuby3::Gem.build_gem(gemspec)
108
+ end
109
+
110
+ desc 'Build wxRuby 3 gem'
111
+ task :gem => 'wxruby:gem:srcgem'
112
+
113
+ if WXRuby3.is_bootstrapped?
114
+
115
+ # binary gem file
116
+ file WXRuby3::Gem.gem_file('wxruby3', WXRuby3::WXRUBY_VERSION, :bin) => WXRuby3::Gem.manifest(:bin) + ['ext/mkrf_conf_bingem.rb'] do
117
+ WXRuby3::Install.install_wxwin_shlibs
118
+ begin
119
+ # create gemspec
120
+ gemspec = WXRuby3::Gem.define_spec('wxruby3', WXRuby3::WXRUBY_VERSION, :bin) do |gem|
121
+ gem.summary = %Q{wxWidgets extension for Ruby}
122
+ gem.description = %Q{wxRuby3 is a Ruby library providing an extension for the wxWidgets C++ UI framework}
123
+ gem.email = 'mcorino@m2c-software.nl'
124
+ gem.homepage = "https://github.com/mcorino/wxRuby3"
125
+ gem.authors = ['Martin Corino']
126
+ gem.files = WXRuby3::Gem.manifest(:bin)
127
+ gem.require_paths = %w{lib}
128
+ gem.require_paths << 'ext' if WXRuby3.config.get_config('with-wxwin')
129
+ gem.bindir = 'bin'
130
+ gem.executables = WXRuby3::Bin.binaries
131
+ gem.extensions = ['ext/mkrf_conf_bingem.rb']
132
+ gem.required_ruby_version = ">= #{WXRuby3::Config.rb_ver_major}.#{WXRuby3::Config.rb_ver_minor}",
133
+ "< #{WXRuby3::Config.rb_ver_major}.#{WXRuby3::Config.rb_ver_minor+1}"
134
+ gem.licenses = ['MIT']
135
+ gem.add_dependency 'rake'
136
+ gem.add_dependency 'minitest', '~> 5.15'
137
+ gem.add_dependency 'test-unit', '~> 3.5'
138
+ gem.rdoc_options << '--exclude=\\.dll' << '--exclude=\\.so'
139
+ gem.metadata = {
140
+ "bug_tracker_uri" => "https://github.com/mcorino/wxRuby3/issues",
141
+ "source_code_uri" => "https://github.com/mcorino/wxRuby3",
142
+ "documentation_uri" => "https://mcorino.github.io/wxRuby3",
143
+ "homepage_uri" => "https://github.com/mcorino/wxRuby3",
144
+ }
145
+ gem.post_install_message = <<~__MSG
146
+
147
+ wxRuby3 has been successfully installed including the 'wxruby' utility.
148
+
149
+ You can run the regression tests to verify the installation by executing:
150
+
151
+ $ ./wxruby test
152
+
153
+ The wxRuby3 sample selector can be run by executing:
154
+
155
+ $ ./wxruby sampler
156
+
157
+ Have fun using wxRuby3.
158
+ __MSG
159
+ end
160
+ WXRuby3::Gem.build_gem(gemspec)
161
+ ensure
162
+ WXRuby3::Install.remove_wxwin_shlibs
163
+ end
164
+ end
165
+
166
+ desc 'Build wxRuby 3 binary gem'
167
+ task :bingem => 'wxruby:gem:bingem'
168
+
169
+ end
data/rakelib/gem.rb ADDED
@@ -0,0 +1,82 @@
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
+
17
+ require_relative './lib/config'
18
+ require_relative './install'
19
+
20
+ module WXRuby3
21
+
22
+ module Gem
23
+
24
+ def self.manifest(gemtype = :src)
25
+ # create MANIFEST list with included files
26
+ manifest = Rake::FileList.new
27
+ manifest.include %w[bin/*] # *nix executables in bin/
28
+ manifest.exclude %w[bin/*.bat] unless WXRuby3.config.windows?
29
+ manifest.include %w[assets/**/* lib/**/* samples/**/* tests/**/*]
30
+ if gemtype == :bin
31
+ if WXRuby3.config.get_config('with-wxwin')
32
+ manifest.include "ext/*.#{WXRuby3.config.dll_mask}"
33
+ end
34
+ manifest.include 'ext/mkrf_conf_bingem.rb'
35
+ manifest.include %w[rakelib/prepost.* rakelib/install.rb rakelib/lib/config.rb rakelib/lib/config/**/* rakelib/lib/ext/**/* rakelib/yard/**/*]
36
+ manifest.include WXRuby3::BUILD_CFG
37
+ else
38
+ manifest.exclude "lib/*.#{WXRuby3.config.dll_mask}"
39
+ manifest.include 'ext/wxruby3/wxruby.ico', 'ext/wxruby3/swig/**/*', 'ext/wxruby3/include/**/*'
40
+ manifest.exclude 'ext/wxruby3/swig/classes/**/*'
41
+ manifest.include 'rakelib/**/*'
42
+ manifest.exclude %w[rakelib/run.* rakelib/help.* rakelib/package.* rakelib/memcheck.* rakelib/memcheck/**/*]
43
+ manifest.include 'rakefile'
44
+ end
45
+ manifest.include %w{LICENSE README.md CREDITS.md INSTALL.md .yardopts}
46
+ manifest
47
+ end
48
+
49
+ def self.define_spec(name, version, gemtype = :src, &block)
50
+ gemspec = ::Gem::Specification.new(name, version)
51
+ if gemtype == :bin
52
+ platform = ::Gem::Platform.local.to_s
53
+ gemspec.platform = platform
54
+ end
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 self.gem_name(name, version, gemtype = :src)
61
+ define_spec(name, version, gemtype).full_name
62
+ end
63
+
64
+ def self.gem_file(name, version, gemtype = :src)
65
+ File.join('pkg', "#{WXRuby3::Gem.gem_name(name, version, gemtype)}.gem")
66
+ end
67
+
68
+ def self.build_gem(gemspec)
69
+ if defined?(::Gem::Package) && ::Gem::Package.respond_to?(:build)
70
+ gem_file_name = ::Gem::Package.build(gemspec)
71
+ else
72
+ gem_file_name = ::Gem::Builder.new(gemspec).build
73
+ end
74
+
75
+ FileUtils.mkdir_p('pkg')
76
+
77
+ FileUtils.mv(gem_file_name, 'pkg')
78
+ end
79
+
80
+ end
81
+
82
+ 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|
@@ -89,6 +90,7 @@ module WXRuby3
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
 
@@ -7,6 +7,7 @@
7
7
  ###
8
8
 
9
9
  require_relative './unixish'
10
+ require_relative 'pkgman/base'
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,10 +33,10 @@ 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
@@ -48,6 +50,26 @@ module WXRuby3
48
50
  end
49
51
  false
50
52
  end
53
+
54
+ def check_tool_pkgs
55
+ pkg_deps = super
56
+ # need g++ to build wxRuby3 extensions in any case
57
+ pkg_deps << 'g++' unless system('command -v g++>/dev/null')
58
+ # do we need to build wxWidgets?
59
+ if get_config('with-wxwin') && get_cfg_string('wxwin').empty?
60
+ pkg_deps << 'patchelf' unless system('command -v patchelf>/dev/null')
61
+ pkg_deps << 'make' unless system('command -v make>/dev/null')
62
+ pkg_deps << 'git' unless system('command -v git>/dev/null')
63
+ end
64
+ pkg_deps
65
+ end
66
+
67
+ def install_prerequisites
68
+ pkg_deps = check_tool_pkgs
69
+ PkgManager.install(pkg_deps)
70
+ []
71
+ end
72
+
51
73
  end
52
74
  end
53
75
 
@@ -7,6 +7,7 @@
7
7
  ###
8
8
 
9
9
  require_relative './unixish'
10
+ require_relative 'pkgman/macosx'
10
11
 
11
12
  module WXRuby3
12
13
 
@@ -53,6 +54,21 @@ module WXRuby3
53
54
  true
54
55
  end
55
56
 
57
+ def check_tool_pkgs
58
+ pkg_deps = super
59
+ # need g++ to build wxRuby3 extensions in any case
60
+ pkg_deps << 'gcc' unless system('command -v g++>/dev/null')
61
+ # need this to build anything (like wxRuby3 extensions itself)
62
+ pkg_deps << 'xcode' unless system('command -v install_name_tool>/dev/null')
63
+ pkg_deps
64
+ end
65
+
66
+ def install_prerequisites
67
+ pkg_deps = check_tool_pkgs
68
+ PkgManager.install(pkg_deps)
69
+ []
70
+ end
71
+
56
72
  def get_wx_libs
57
73
  wx_libset = ::Set.new
58
74
  lib_list = wx_config("--libs all").split(' ')