setup 4.2.0 → 5.0.0
Sign up to get free protection for your applications and to get access to all the features.
- data/HISTORY +47 -3
- data/MANIFEST +49 -16
- data/README.rdoc +148 -0
- data/bin/setup.rb +1 -5
- data/lib/setup.rb +2 -2
- data/lib/setup/base.rb +143 -0
- data/lib/setup/command.rb +218 -114
- data/lib/setup/compiler.rb +69 -0
- data/lib/setup/configuration.rb +822 -0
- data/lib/setup/constants.rb +12 -0
- data/lib/setup/{rubyver.rb → core_ext.rb} +0 -0
- data/lib/setup/documentor.rb +149 -0
- data/lib/setup/installer.rb +363 -0
- data/lib/setup/project.rb +68 -0
- data/lib/setup/rake.rb +44 -45
- data/lib/setup/session.rb +233 -0
- data/lib/setup/tester.rb +92 -0
- data/lib/setup/uninstaller.rb +76 -0
- data/meta/active +1 -0
- data/meta/collection +1 -0
- data/meta/{abstract → description} +0 -0
- data/meta/{package → name} +0 -0
- data/meta/repository +1 -0
- data/meta/ruby +3 -0
- data/meta/version +1 -1
- data/script/bstrap +5 -0
- data/script/bundle +64 -0
- data/script/setup +1338 -0
- data/script/test +3 -0
- data/test/cases/installer.rb +28 -0
- data/test/features/config.feature +16 -0
- data/test/features/document.feature +2 -0
- data/test/features/install.feature +72 -0
- data/test/features/make.feature +18 -0
- data/test/features/step_definitions/common_steps.rb +34 -0
- data/test/features/step_definitions/config_steps.rb +24 -0
- data/test/features/step_definitions/env.rb +37 -0
- data/test/features/step_definitions/install_steps.rb +75 -0
- data/test/features/step_definitions/setup_steps.rb +30 -0
- data/test/features/step_definitions/uninstall_steps.rb +8 -0
- data/test/features/test.feature +2 -0
- data/test/features/uninstall.feature +13 -0
- data/test/fixtures/faux-project/bin/faux +3 -0
- data/test/fixtures/faux-project/ext/faux/extconf.rb +12 -0
- data/test/fixtures/faux-project/ext/faux/faux.c +24 -0
- data/test/fixtures/faux-project/lib/faux.rb +1 -0
- metadata +58 -29
- data/README +0 -106
- data/RELEASE +0 -41
- data/lib/setup/build.rb +0 -2
- data/lib/setup/config.rb +0 -452
- data/lib/setup/error.rb +0 -4
- data/lib/setup/install.rb +0 -1007
- data/meta/setup/metaconfig.rb +0 -3
- data/test/test_installer.rb +0 -139
data/lib/setup/command.rb
CHANGED
@@ -1,174 +1,278 @@
|
|
1
|
-
require 'setup/
|
2
|
-
require '
|
3
|
-
require 'setup/install'
|
4
|
-
require 'setup/error'
|
1
|
+
require 'setup/session'
|
2
|
+
require 'optparse'
|
5
3
|
|
6
4
|
module Setup
|
7
5
|
|
8
|
-
#
|
6
|
+
# Command-line interface for Setup.rb.
|
7
|
+
|
9
8
|
class Command
|
10
9
|
|
11
|
-
|
12
|
-
|
13
|
-
TASK_DESCRIPTIONS = [
|
14
|
-
[ 'all', "do config, setup, then install" ],
|
15
|
-
[ 'config', "saves your configurations" ],
|
16
|
-
[ 'show', "shows current configuration" ],
|
17
|
-
[ 'setup', "compiles ruby extentions and others" ],
|
18
|
-
[ 'rdoc', "generate rdoc documentation" ],
|
19
|
-
[ 'ri', "generate ri documentation" ],
|
20
|
-
[ 'install', "installs files" ],
|
21
|
-
[ 'uninstall', "uninstalls files" ],
|
22
|
-
[ 'test', "run all tests in test/" ],
|
23
|
-
[ 'clean', "does `make clean' for each extention" ],
|
24
|
-
[ 'distclean', "does `make distclean' for each extention" ]
|
25
|
-
]
|
10
|
+
# Initialize and run.
|
26
11
|
|
27
|
-
#
|
28
12
|
def self.run(*argv)
|
29
13
|
new.run(*argv)
|
30
14
|
end
|
31
15
|
|
32
|
-
#
|
16
|
+
# Hash of <tt>task => description</tt>.
|
17
|
+
|
18
|
+
def self.tasks
|
19
|
+
@tasks ||= {}
|
20
|
+
end
|
21
|
+
|
22
|
+
# Task names listed in order of information.
|
23
|
+
|
24
|
+
def self.order
|
25
|
+
@order ||= []
|
26
|
+
end
|
27
|
+
|
28
|
+
# Define a task.
|
29
|
+
|
30
|
+
def self.task(name, description)
|
31
|
+
tasks[name] = description
|
32
|
+
order << name
|
33
|
+
end
|
34
|
+
|
35
|
+
task 'all' , "config, setup, test, install"
|
36
|
+
task 'config' , "saves your configuration"
|
37
|
+
task 'show' , "show current configuration"
|
38
|
+
task 'make' , "compile ruby extentions"
|
39
|
+
task 'test' , "run test suite"
|
40
|
+
task 'doc' , "generate ri documentation"
|
41
|
+
task 'install' , "install project files"
|
42
|
+
task 'uninstall', "uninstall previously installed files"
|
43
|
+
task 'clean' , "does `make clean' for each extention"
|
44
|
+
task 'distclean', "does `make distclean' for each extention"
|
45
|
+
|
46
|
+
# Run command.
|
47
|
+
|
33
48
|
def run(*argv)
|
34
49
|
ARGV.replace(argv) unless argv.empty?
|
35
50
|
|
36
|
-
|
37
|
-
|
51
|
+
#session = Session.new(:io=>$stdio)
|
52
|
+
#config = session.configuration
|
38
53
|
|
39
54
|
task = ARGV.find{ |a| a !~ /^[-]/ }
|
40
55
|
task = 'all' unless task
|
41
56
|
|
42
|
-
unless
|
57
|
+
unless task_names.include?(task)
|
43
58
|
$stderr.puts "Not a valid task -- #{task}"
|
44
59
|
exit 1
|
45
60
|
end
|
46
61
|
|
47
|
-
|
62
|
+
parser = OptionParser.new
|
63
|
+
options = {}
|
48
64
|
|
49
|
-
|
65
|
+
parser.banner = "Usage: #{File.basename($0)} [TASK] [OPTIONS]"
|
50
66
|
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
67
|
+
optparse_header(parser, options)
|
68
|
+
case task
|
69
|
+
when 'all'
|
70
|
+
optparse_all(parser, options)
|
71
|
+
when 'config'
|
72
|
+
optparse_config(parser, options)
|
73
|
+
when 'install'
|
74
|
+
optparse_install(parser, options)
|
59
75
|
end
|
76
|
+
optparse_common(parser, options)
|
60
77
|
|
61
|
-
|
62
|
-
|
63
|
-
|
78
|
+
begin
|
79
|
+
parser.parse!(ARGV)
|
80
|
+
rescue OptionParser::InvalidOption
|
81
|
+
$stderr.puts $!.to_s.capitalize
|
82
|
+
exit 1
|
83
|
+
end
|
64
84
|
|
65
|
-
|
66
|
-
|
67
|
-
end
|
85
|
+
# This ensures we are in a project directory.
|
86
|
+
rootdir = session.project.rootdir
|
68
87
|
|
69
|
-
|
70
|
-
|
71
|
-
|
88
|
+
print_header
|
89
|
+
|
90
|
+
begin
|
91
|
+
session.__send__(task)
|
92
|
+
rescue Error
|
93
|
+
raise if $DEBUG
|
94
|
+
$stderr.puts $!.message
|
95
|
+
$stderr.puts "Try 'setup.rb --help' for detailed usage."
|
96
|
+
exit 1
|
72
97
|
end
|
73
98
|
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
99
|
+
puts unless session.quiet?
|
100
|
+
end
|
101
|
+
|
102
|
+
# Setup session.
|
103
|
+
|
104
|
+
def session
|
105
|
+
@session ||= Session.new(:io=>$stdout)
|
106
|
+
end
|
107
|
+
|
108
|
+
# Setup configuration. This comes from the +session+ object.
|
109
|
+
|
110
|
+
def configuration
|
111
|
+
@configuration ||= session.configuration
|
112
|
+
end
|
113
|
+
|
114
|
+
#
|
115
|
+
def optparse_header(parser, options)
|
116
|
+
parser.banner = "USAGE: #{File.basename($0)} [command] [options]"
|
117
|
+
end
|
118
|
+
|
119
|
+
# Setup options for +all+ task.
|
120
|
+
|
121
|
+
def optparse_all(parser, options)
|
122
|
+
optparse_config(parser, options)
|
123
|
+
#optparse_install(parser, options)
|
124
|
+
#parser.on("-t", "--[no-]test", "run tests") do |val|
|
125
|
+
# configuration.no_test = val
|
126
|
+
#end
|
127
|
+
#parser.on("--[no-]ri", "generate ri documentation") do |val|
|
128
|
+
# configuration.no_doc = val
|
81
129
|
#end
|
130
|
+
#parser.on("--[no-]doc", "do not install documentation") do |val|
|
131
|
+
# configuration.no_doc = val
|
132
|
+
#end
|
133
|
+
end
|
134
|
+
|
135
|
+
# Setup options for +config+ task.
|
136
|
+
|
137
|
+
def optparse_config(parser, options)
|
138
|
+
parser.separator ""
|
139
|
+
parser.separator "Configuration options:"
|
140
|
+
configuration.options.each do |args|
|
141
|
+
args = args.dup
|
142
|
+
desc = args.pop
|
143
|
+
type = args.pop
|
144
|
+
name, shortcut = *args
|
145
|
+
#raise ArgumentError unless name, type, desc
|
146
|
+
optname = name.to_s.gsub('_', '-')
|
147
|
+
case type
|
148
|
+
when :bool
|
149
|
+
if optname.index('no-') == 0
|
150
|
+
optname = "[no-]" + optname.sub(/^no-/, '')
|
151
|
+
opts = shortcut ? ["-#{shortcut}", "--#{optname}", desc] : ["--#{optname}", desc]
|
152
|
+
parser.on(*opts) do |val|
|
153
|
+
configuration.__send__("#{name}=", !val)
|
154
|
+
end
|
155
|
+
else
|
156
|
+
optname = "[no-]" + optname.sub(/^no-/, '')
|
157
|
+
opts = shortcut ? ["-#{shortcut}", "--#{optname}", desc] : ["--#{optname}", desc]
|
158
|
+
parser.on(*opts) do |val|
|
159
|
+
configuration.__send__("#{name}=", val)
|
160
|
+
end
|
161
|
+
end
|
162
|
+
else
|
163
|
+
opts = shortcut ? ["-#{shortcut}", "--#{optname} #{type.to_s.upcase}", desc] : ["--#{optname} #{type.to_s.upcase}", desc]
|
164
|
+
parser.on(*opts) do |val|
|
165
|
+
configuration.__send__("#{name}=", val)
|
166
|
+
end
|
167
|
+
end
|
168
|
+
end
|
169
|
+
end
|
170
|
+
|
171
|
+
# Setup options for +install+ task.
|
172
|
+
|
173
|
+
def optparse_install(parser, options)
|
174
|
+
parser.separator ""
|
175
|
+
parser.separator "Install options:"
|
176
|
+
parser.on("--prefix PATH", "Installation prefix") do |val|
|
177
|
+
#session.options[:install_prefix] = val
|
178
|
+
configuration.install_prefix = val
|
179
|
+
end
|
180
|
+
end
|
181
|
+
|
182
|
+
# Setup options for +test+ task.
|
183
|
+
|
184
|
+
#def optparse_test(parser, options)
|
185
|
+
# parser.separator ""
|
186
|
+
# parser.separator "Test options:"
|
187
|
+
# parser.on("--runner TYPE", "Test runner (auto|console|gtk|gtk2|tk)") do |val|
|
188
|
+
# ENV['RUBYSETUP_TESTRUNNER'] = val
|
189
|
+
# end
|
190
|
+
#end
|
191
|
+
|
192
|
+
# Setup options for +uninstall+ task.
|
193
|
+
|
194
|
+
#def optparse_uninstall(parser, options)
|
195
|
+
# parser.separator ""
|
196
|
+
# parser.separator "Uninstall options:"
|
197
|
+
# parser.on("--prefix [PATH]", "Installation prefix") do |val|
|
198
|
+
# session.options[:install_prefix] = val
|
199
|
+
# end
|
200
|
+
#end
|
201
|
+
|
202
|
+
# Common options for every task.
|
82
203
|
|
83
|
-
|
84
|
-
|
85
|
-
|
204
|
+
def optparse_common(parser, options)
|
205
|
+
parser.separator ""
|
206
|
+
parser.separator "General options:"
|
86
207
|
|
87
|
-
|
88
|
-
|
208
|
+
parser.on("-q", "--quiet", "Suppress output") do
|
209
|
+
session.quiet = true
|
89
210
|
end
|
90
211
|
|
91
|
-
|
92
|
-
|
212
|
+
parser.on("-f", "--force", "Force operation") do
|
213
|
+
session.force = true
|
93
214
|
end
|
94
215
|
|
95
|
-
|
96
|
-
|
216
|
+
parser.on("--trace", "--verbose", "Watch execution") do |val|
|
217
|
+
session.trace = true
|
97
218
|
end
|
98
219
|
|
99
|
-
|
100
|
-
|
220
|
+
parser.on("--trial", "--no-harm", "Do not write to disk") do |val|
|
221
|
+
session.trial = true
|
101
222
|
end
|
102
223
|
|
103
|
-
|
104
|
-
|
105
|
-
|
224
|
+
parser.on("--debug", "Turn on debug mode") do |val|
|
225
|
+
$DEBUG = true
|
226
|
+
end
|
227
|
+
|
228
|
+
parser.separator ""
|
229
|
+
parser.separator "Inform options:"
|
106
230
|
|
107
231
|
# Tail options (eg. commands in option form)
|
108
|
-
|
109
|
-
puts help
|
232
|
+
parser.on_tail("-h", "--help", "display this help information") do
|
233
|
+
#puts help
|
234
|
+
puts parser
|
110
235
|
exit
|
111
236
|
end
|
112
237
|
|
113
|
-
|
238
|
+
parser.on_tail("--version", "-v", "Show version") do
|
114
239
|
puts File.basename($0) + ' v' + Setup::VERSION #Version.join('.')
|
115
240
|
exit
|
116
241
|
end
|
117
242
|
|
118
|
-
|
243
|
+
parser.on_tail("--copyright", "Show copyright") do
|
119
244
|
puts Setup::COPYRIGHT #opyright
|
120
245
|
exit
|
121
246
|
end
|
122
|
-
|
123
|
-
begin
|
124
|
-
opts.parse!(ARGV)
|
125
|
-
rescue OptionParser::InvalidOption
|
126
|
-
$stderr.puts $!.to_s.capitalize
|
127
|
-
exit 1
|
128
|
-
end
|
129
|
-
|
130
|
-
begin
|
131
|
-
installer.__send__("exec_#{task}")
|
132
|
-
rescue Error
|
133
|
-
raise if $DEBUG
|
134
|
-
$stderr.puts $!.message
|
135
|
-
$stderr.puts "Try 'ruby #{$0} --help' for detailed usage."
|
136
|
-
exit 1
|
137
|
-
end
|
138
247
|
end
|
139
248
|
|
140
|
-
#
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
(fmt % ["#{k}", d])
|
145
|
-
end.join("\n").strip
|
146
|
-
|
147
|
-
fmt = " " * 13 + "%-20s %s"
|
148
|
-
configs = ConfigTable::DESCRIPTIONS.collect do |k,t,d|
|
149
|
-
(fmt % ["--#{k}", d])
|
150
|
-
end.join("\n").strip
|
249
|
+
# List of task names.
|
250
|
+
#--
|
251
|
+
# TODO: shouldn't this use +self.class.order+ ?
|
252
|
+
#++
|
151
253
|
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
#{commands}
|
157
|
-
|
158
|
-
Options for CONFIG:
|
159
|
-
#{configs}
|
160
|
-
|
161
|
-
Options for INSTALL:
|
162
|
-
--prefix Set the install prefix
|
163
|
-
|
164
|
-
Options in common:
|
165
|
-
-q --quiet Silence output
|
166
|
-
--verbose Provide verbose output
|
167
|
-
-n --no-write Do not write to disk
|
254
|
+
def task_names
|
255
|
+
#self.class.order
|
256
|
+
self.class.tasks.keys
|
257
|
+
end
|
168
258
|
|
169
|
-
|
170
|
-
|
259
|
+
# Output Header.
|
260
|
+
#
|
261
|
+
# TODO: This is not yet used. It might be nice to have,
|
262
|
+
# but not sure what it should contain or look like.
|
263
|
+
|
264
|
+
def print_header
|
265
|
+
#unless session.quiet?
|
266
|
+
# if session.project.name
|
267
|
+
# puts "= #{session.project.name} (#{rootdir})"
|
268
|
+
# else
|
269
|
+
# puts "= #{rootdir}"
|
270
|
+
# end
|
271
|
+
#end
|
272
|
+
#$stderr << "#{session.options.inspect}\n" if session.trace? or session.trial?
|
171
273
|
end
|
172
274
|
|
173
275
|
end
|
276
|
+
|
174
277
|
end
|
278
|
+
|
@@ -0,0 +1,69 @@
|
|
1
|
+
require 'setup/base'
|
2
|
+
|
3
|
+
module Setup
|
4
|
+
|
5
|
+
#
|
6
|
+
class Compiler < Base
|
7
|
+
|
8
|
+
#
|
9
|
+
def compiles?
|
10
|
+
!extdirs.empty?
|
11
|
+
#extdirs.any?{ |dir| File.exist?(File.join(dir, 'extconf.rb')) }
|
12
|
+
end
|
13
|
+
|
14
|
+
#
|
15
|
+
def configure
|
16
|
+
extdirs.each do |dir|
|
17
|
+
Dir.chdir(dir) do
|
18
|
+
if File.exist?('extconf.rb') && !FileUtils.uptodate?('Makefile', ['extconf.rb'])
|
19
|
+
#load("extconf.rb", true)
|
20
|
+
ruby("extconf.rb")
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
#
|
27
|
+
def compile
|
28
|
+
extdirs.each do |dir|
|
29
|
+
Dir.chdir(dir) do
|
30
|
+
make
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
#
|
36
|
+
def clean
|
37
|
+
extdirs.each do |dir|
|
38
|
+
Dir.chdir(dir) do
|
39
|
+
make('clean')
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
#
|
45
|
+
def distclean
|
46
|
+
extdirs.each do |dir|
|
47
|
+
Dir.chdir(dir) do
|
48
|
+
make('distclean')
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
# TODO: get from project
|
54
|
+
def extdirs
|
55
|
+
Dir['ext/**/*/{MANIFEST,extconf.rb}'].map do |f|
|
56
|
+
File.dirname(f)
|
57
|
+
end.uniq
|
58
|
+
end
|
59
|
+
|
60
|
+
#
|
61
|
+
def make(task=nil)
|
62
|
+
return unless File.exist?('Makefile')
|
63
|
+
bash(*[config.makeprog, task].compact)
|
64
|
+
end
|
65
|
+
|
66
|
+
end
|
67
|
+
|
68
|
+
end
|
69
|
+
|