-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathprepost.rake
106 lines (92 loc) · 3.61 KB
/
prepost.rake
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
# Copyright (c) 2023 M.J.N. Corino, The Netherlands
#
# This software is released under the MIT license.
###
# wxRuby3 rake file
###
require_relative './prepost'
namespace 'wxruby' do
namespace 'pre' do
task :uninstall do
if WXRuby3.config.windows? && WXRuby3.config.get_config('with-wxwin') && !Rake::FileUtilsExt.nowrite_flag
# since we created this file ourselves remove it before uninstalling
rm_f(File.join(WXRuby3.config.get_cfg_string('siterubyver'), 'wx/startup.rb'), verbose: false)
end
end
end
namespace 'post' do
task :srcgem => %w[gem:wxwin gem:install] do
$stdout.print "Generating wxRuby3 reference documentation..." if WXRuby3.config.run_silent?
Rake::Task['wxruby:doc'].invoke
$stdout.puts 'done!' if WXRuby3.config.run_silent?
# cleanup
rm_rf('rakelib', verbose: !WXRuby3.config.run_silent?)
rm_f('Rakefile', verbose: !WXRuby3.config.run_silent?)
rm_f('ext/mkrf_conf_ext.rb', verbose: !WXRuby3.config.run_silent?)
rm_rf('ext/wxruby3', verbose: !WXRuby3.config.run_silent?)
WXRuby3.config.cleanup_bootstrap
File.open(File.join(WXRuby3::Config.wxruby_root, 'ext', 'wxruby.setup.done'), 'w') { |f| f << '1' }
end
task :binpkg => 'gem:install' do
# cleanup
rm_rf('rakelib')
rm_f('Rakefile')
rm_f('ext/mkrf_conf_ext.rb')
rm_rf('ext/wxruby3')
rm_f('*.pkg')
rm_f('*.sha')
File.open(File.join(WXRuby3::Config.wxruby_root, 'ext', 'wxruby.setup.done'), 'w') { |f| f << '1' }
end
namespace 'gem' do
task :wxwin do
WXRuby3::Install.install_wxwin_shlibs
end
task :install do
if WXRuby3.config.windows?
if WXRuby3.config.get_config('with-wxwin')
WXRuby3::Post.create_startup <<~__CODE
begin
require 'ruby_installer'
if RubyInstaller::Runtime.respond_to?(:add_dll_directory)
RubyInstaller::Runtime.add_dll_directory('#{File.expand_path('ext')}')
else
RubyInstaller::Build.add_dll_directory('#{File.expand_path('ext')}')
end
rescue LoadError
end
__CODE
elsif !WXRuby3.config.get_cfg_string('wxwin').empty? && File.directory?(WXRuby3.config.get_cfg_string('wxwininstdir'))
WXRuby3::Post.create_startup <<~__CODE
begin
require 'ruby_installer'
if RubyInstaller::Runtime.respond_to?(:add_dll_directory)
RubyInstaller::Runtime.add_dll_directory('#{WXRuby3.config.get_cfg_string('wxwininstdir')}')
else
RubyInstaller::Build.add_dll_directory('#{WXRuby3.config.get_cfg_string('wxwininstdir')}')
end
rescue LoadError
end
__CODE
end
end
end
end
task :install do
if WXRuby3.config.windows? && WXRuby3.config.get_config('with-wxwin') && !Rake::FileUtilsExt.nowrite_flag
File.open(File.join(WXRuby3.config.get_cfg_string('siterubyver'), 'wx/startup.rb'), 'w') do |f|
f.puts <<~__CODE
begin
require 'ruby_installer'
if RubyInstaller::Runtime.respond_to?(:add_dll_directory)
RubyInstaller::Runtime.add_dll_directory('#{WXRuby3.config.get_cfg_string('siterubyverarch')}')
else
RubyInstaller::Build.add_dll_directory('#{WXRuby3.config.get_cfg_string('siterubyverarch')}')
end
rescue LoadError
end
__CODE
end
end
end
end
end