autoproj 1.4.4 → 1.5.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,3 +1,18 @@
1
+ = Version 1.5.0
2
+ * the "clean up this mess" release. Autoproj's main logic is now properly
3
+ split into separate methods instead of being all in a monolitic bin/autoproj
4
+ * autoproj build does not update by default anymore. This was a behaviour
5
+ change that was requested by quite a few users.
6
+ * OS dependencies and normal dependencies are unified. An OS dependency will
7
+ have priority, if one is available on the OS. Otherwise, an autoproj package
8
+ will be searched for.
9
+ * remote package sets have become first-class citizens. The package sets are
10
+ still checked out in .remotes/WEIRD_NAME, but they are then symlinked to
11
+ autoproj/remotes/package_set_name for manipulation and inspection.
12
+ * a lot of fixes related to partial builds and partial package selections
13
+ * fixed wrong generation of env.sh files in some cases (mostly related to
14
+ partial builds)
15
+
1
16
  = Version 1.4.4
2
17
  * really fix the bug mentioned in 1.4.3
3
18
 
@@ -21,14 +21,18 @@ doc/guide/src/images/gradient1.png
21
21
  doc/guide/src/images/gradient2.png
22
22
  doc/guide/src/index.page
23
23
  doc/guide/src/manifest.xml
24
+ doc/guide/src/overview.png
25
+ doc/guide/src/overview.svg
24
26
  doc/guide/src/package_sets/autobuild.page
25
27
  doc/guide/src/package_sets/importers.page
26
28
  doc/guide/src/package_sets/index.page
27
29
  doc/guide/src/package_sets/manifest-xml.page
28
30
  doc/guide/src/package_sets/osdeps.page
29
- doc/guide/src/structure.page
31
+ doc/guide/src/quick_start.page
32
+ doc/guide/src/writing_manifest.page
30
33
  lib/autoproj.rb
31
34
  lib/autoproj/autobuild.rb
35
+ lib/autoproj/cmdline.rb
32
36
  lib/autoproj/default.osdeps
33
37
  lib/autoproj/manifest.rb
34
38
  lib/autoproj/options.rb
data/README.txt CHANGED
@@ -43,48 +43,8 @@ Each package definition includes:
43
43
  * on what the package depends. This can be either another package built by
44
44
  autoproj, or an operating system package.
45
45
 
46
- See [this page](structure.html) for more information.
46
+ See [this page](writing_manifest.html) for more information.
47
47
 
48
- Bootstrapping
49
- -------------
50
- "Bootstrapping" means getting autoproj itself before it can work its magic ...
51
- The canonical way is the following:
52
-
53
- * install Ruby by yourself. On Debian or Ubuntu, this is done with
54
- done with
55
-
56
- sudo apt-get install wget ruby
57
- {.cmdline}
58
-
59
- * then, [download this script](autoproj_bootstrap) *in the directory where
60
- you want to create an autoproj installation*, and run it. This can be done with
61
-
62
- wget http://doudou.github.com/autoproj/autoproj\_bootstrap <br />
63
- ruby autoproj\_bootstrap
64
- {.cmdline}
65
-
66
- * follow the instructions printed by the script<tt>manifest</tt>.
67
-
68
- Additionally, if you are given a reference to a source code repository in which
69
- an autoproj configuration is stored (i.e. a directory in which a manifest is
70
- present), you can bootstrap this configuration directly:
71
-
72
- wget http://doudou.github.com/autoproj/autoproj\_bootstrap <br />
73
- ruby autoproj\_bootstrap VCS
74
- {.cmdline}
75
-
76
- For instance, to build all packages made available by the RubyInMotion project,
77
- do
78
-
79
- wget http://doudou.github.com/autoproj/autoproj\_bootstrap <br />
80
- ruby autoproj\_bootstrap git git://github.com/doudou/rubim.all.git
81
- {.cmdline}
82
-
83
- Additional options can be given for the version control system. For instance,
84
-
85
- wget http://doudou.github.com/autoproj/autoproj\_bootstrap <br />
86
- ruby autoproj\_bootstrap git git://github.com/doudou/rubim.all.git branch=stable
87
- {.cmdline}
88
48
 
89
49
  Software packages in Autoproj
90
50
  -----------------------------
data/Rakefile CHANGED
@@ -14,7 +14,7 @@ begin
14
14
  self.changes = paragraphs_of('History.txt', 0..1).join("\n\n")
15
15
 
16
16
  extra_deps <<
17
- ['autobuild', '>= 1.4.3'] <<
17
+ ['autobuild', '>= 1.5.9'] <<
18
18
  ['rmail', '>= 1.0.0'] <<
19
19
  ['utilrb', '>= 1.3.3'] <<
20
20
  ['nokogiri', '>= 1.3.3'] <<
@@ -8,6 +8,7 @@ end
8
8
  require 'autoproj'
9
9
  require 'autoproj/autobuild'
10
10
  require 'open-uri'
11
+ require 'autoproj/cmdline'
11
12
 
12
13
  require 'highline'
13
14
  include Autoproj
@@ -23,351 +24,12 @@ module Autoproj
23
24
  end
24
25
  end
25
26
 
26
- # Some configuration variables
27
- mail_config = Hash.new
28
- only_update_sources = false
29
- only_do_status = false
30
- no_os_deps = false
31
- force_re_build_with_depends = false
32
- debug = false
33
-
34
- # Parse the configuration options
35
- parser = OptionParser.new do |opts|
36
- opts.banner = <<-EOBANNER
37
- autoproj mode [options]
38
- where 'mode' is one of:
39
-
40
- -- Build
41
- build: import, build and install all packages that need it. A package or package
42
- set name can be given, in which case only this package and its dependencies
43
- will be taken into account. Example:
44
-
45
- autoproj build drivers/hokuyo
46
-
47
- fast-build: builds without updating and without considering OS dependencies
48
- force-build: triggers all build commands, i.e. don't be lazy like in "build".
49
- If packages are selected on the command line, only those packages
50
- will be affected unless the --with-depends option is used.
51
- rebuild: clean and then rebuild. If packages are selected on the command line,
52
- only those packages will be affected unless the --with-depends option
53
- is used.
54
- doc: generate and install documentation for packages that have some
55
-
56
- -- Status & Update
57
- envsh: update the env.sh script
58
- status: displays the state of the packages w.r.t. their source VCS
59
- list-sets: list all available package sets
60
- update: only import/update packages, do not build them
61
- update-sets: update the package sets definitions, but not the packages themselves
62
-
63
- -- Autoproj Configuration
64
- bootstrap: starts a new autoproj installation. Usage:
65
- autoproj bootstrap [manifest_url|source_vcs source_url opt1=value1 opt2=value2 ...]
66
- switch-config: change where the configuration should be taken from. Syntax:
67
- autoproj switch-config source_vcs source_url opt1=value1 opt2=value2 ...
68
-
69
- For example:
70
- autoproj switch-config git git://github.com/doudou/rubim-all.git branch=all
71
-
72
- -- Additional options:
73
- EOBANNER
74
- opts.on("--reconfigure", "re-ask all configuration options (build modes only)") do
75
- Autoproj.reconfigure = true
76
- end
77
- opts.on("--no-update", "do not update already checked-out packages (build mode only)") do
78
- Autobuild.do_update = false
79
- end
80
-
81
- opts.on("--no-osdeps", "do not install prepackaged dependencies") do
82
- no_os_deps = true
83
- end
84
- opts.on("--with-depends", "apply rebuild and force-build to both packages selected on the command line and their dependencies") do
85
- force_re_build_with_depends = true
86
- end
87
-
88
- opts.on("--verbose", "verbose output") do
89
- Autoproj.verbose = true
90
- Autobuild.verbose = true
91
- Rake.application.options.trace = false
92
- end
93
- opts.on("--debug", "debugging output") do
94
- Autoproj.verbose = true
95
- Autobuild.verbose = true
96
- Rake.application.options.trace = true
97
- debug = true
98
- Autobuild.debug = true
99
- end
100
- opts.on('--nice NICE', Integer, 'nice the subprocesses to the given value') do |value|
101
- Autobuild.nice = value
102
- end
103
- opts.on("-h", "--help", "Show this message") do
104
- puts opts
105
- exit
106
- end
107
- opts.on("--mail-from EMAIL", String, "From: field of the sent mails") do |from_email|
108
- mail_config[:from] = from_email
109
- end
110
- opts.on("--mail-to EMAILS", String, "comma-separated list of emails to which the reports should be sent") do |emails|
111
- mail_config[:to] ||= []
112
- mail_config[:to] += emails.split(',')
113
- end
114
- opts.on("--mail-subject SUBJECT", String, "Subject: field of the sent mails") do |subject_email|
115
- mail_config[:subject] = subject_email
116
- end
117
- opts.on("--mail-smtp HOSTNAME", String, " address of the mail server written as hostname[:port]") do |smtp|
118
- raise "invalid SMTP specification #{smtp}" unless smtp =~ /^([^:]+)(?::(\d+))?$/
119
- mail_config[:smtp] = $1
120
- mail_config[:port] = Integer($2) if $2 && !$2.empty?
121
- end
122
- opts.on("--mail-only-errors", "send mail only on errors") do
123
- mail_config[:only_errors] = true
124
- end
125
- end
126
-
127
- args = ARGV.dup
128
- parser.parse!(args)
129
- mode = args.shift
130
- selected_packages = args.dup
131
- Autobuild::Reporting << Autoproj::Reporter.new
27
+ selected_packages = Autoproj::CmdLine.parse_arguments(ARGV.dup)
132
28
 
133
29
  def color(*args)
134
30
  Autoproj.console.color(*args)
135
31
  end
136
32
 
137
- def display_status(packages)
138
- last_was_in_sync = false
139
-
140
- packages.each do |pkg|
141
- lines = []
142
-
143
- if !pkg.importer.respond_to?(:status)
144
- lines << color(" the #{pkg.importer.class.name.gsub(/.*::/, '')} importer does not support status display", :bold, :red)
145
- elsif !File.directory?(pkg.srcdir)
146
- lines << color(" is not imported yet", :magenta)
147
- else
148
- status = pkg.importer.status(pkg)
149
- if status.uncommitted_code
150
- lines << color(" contains uncommitted modifications", :red)
151
- end
152
-
153
- case status.status
154
- when Autobuild::Importer::Status::UP_TO_DATE
155
- if !status.uncommitted_code
156
- if last_was_in_sync
157
- STDERR.print ", #{pkg.autoproj_name}"
158
- else
159
- STDERR.print pkg.autoproj_name
160
- end
161
- last_was_in_sync = true
162
- next
163
- else
164
- lines << color(" local and remote are in sync", :green)
165
- end
166
- when Autobuild::Importer::Status::ADVANCED
167
- lines << color(" local contains #{status.local_commits.size} commit that remote does not have:", :magenta)
168
- status.local_commits.each do |line|
169
- lines << color(" #{line}", :magenta)
170
- end
171
- when Autobuild::Importer::Status::SIMPLE_UPDATE
172
- lines << color(" remote contains #{status.remote_commits.size} commit that local does not have:", :magenta)
173
- status.remote_commits.each do |line|
174
- lines << color(" #{line}", :magenta)
175
- end
176
- when Autobuild::Importer::Status::NEEDS_MERGE
177
- lines << color(" local and remote have diverged with respectively #{status.local_commits.size} and #{status.remote_commits.size} commits each", :magenta)
178
- lines << " -- local commits --"
179
- status.local_commits.each do |line|
180
- lines << color(" #{line}", :magenta)
181
- end
182
- lines << " -- remote commits --"
183
- status.remote_commits.each do |line|
184
- lines << color(" #{line}", :magenta)
185
- end
186
- end
187
- end
188
-
189
- if last_was_in_sync
190
- STDERR.puts color(": local and remote are in sync", :green)
191
- end
192
-
193
- last_was_in_sync = false
194
- if pkg.respond_to?(:text_name)
195
- STDERR.print "#{pkg.text_name}:"
196
- else
197
- STDERR.print "#{pkg.autoproj_name}:"
198
- end
199
-
200
- if lines.size == 1
201
- STDERR.puts lines.first
202
- else
203
- STDERR.puts
204
- STDERR.puts lines.join("\n")
205
- end
206
- end
207
- if last_was_in_sync
208
- STDERR.puts color(": local and remote are in sync", :green)
209
- end
210
- end
211
- def do_status(packages)
212
- console = Autoproj.console
213
-
214
- sources = Autoproj.manifest.each_configuration_source.
215
- map do |vcs, text_name, pkg_name, local_dir|
216
- Autoproj::Manifest.create_autobuild_package(vcs, text_name, pkg_name, local_dir)
217
- end
218
-
219
- if !sources.empty?
220
- STDERR.puts color("autoproj: displaying status of configuration", :bold)
221
- display_status(sources)
222
- STDERR.puts
223
- end
224
-
225
-
226
- STDERR.puts color("autoproj: displaying status of packages", :bold)
227
- packages = packages.sort.map do |pkg_name|
228
- Autobuild::Package[pkg_name]
229
- end
230
- display_status(packages)
231
-
232
- end
233
-
234
- def switch_config(*args)
235
- Autoproj.load_config
236
- if Autoproj.has_config_key?('manifest_source')
237
- vcs = Autoproj.normalize_vcs_definition(Autoproj.user_config('manifest_source'))
238
- end
239
-
240
- if vcs && (vcs.type == args[0] && vcs.url == args[1])
241
- # Don't need to do much: simply change the options and save the config
242
- # file, the VCS handler will take care of the actual switching
243
- else
244
- # We will have to delete the current autoproj directory. Ask the user.
245
- opt = Autoproj::BuildOption.new("delete current config", "boolean",
246
- Hash[:default => "false",
247
- :doc => "delete the current configuration ? (required to switch)"], nil)
248
-
249
- return if !opt.ask(nil)
250
-
251
- Dir.chdir(Autoproj.root_dir) do
252
- do_switch_config(true, *args)
253
- end
254
- end
255
-
256
- # And now save the options: note that we keep the current option set even
257
- # though we switched configuration. This is not a problem as undefined
258
- # options will not be reused
259
- #
260
- # TODO: cleanup the options to only keep the relevant ones
261
- vcs_def = Hash['type' => args.shift, 'url' => args.shift]
262
- args.each do |opt|
263
- opt_name, opt_val = opt.split '='
264
- vcs_def[opt_name] = opt_val
265
- end
266
- # Validate the option hash, just in case
267
- Autoproj.normalize_vcs_definition(vcs_def)
268
- # Save the new options
269
- Autoproj.change_option('manifest_source', vcs_def, true)
270
- Autoproj.save_config
271
- end
272
-
273
- def do_switch_config(delete_current, *args)
274
- vcs_def = Hash.new
275
- vcs_def[:type] = args.shift
276
- vcs_def[:url] = args.shift
277
- while !args.empty?
278
- name, value = args.shift.split("=")
279
- vcs_def[name] = value
280
- end
281
-
282
- vcs = Autoproj.normalize_vcs_definition(vcs_def)
283
-
284
- # Install the OS dependencies required for this VCS
285
- osdeps = Autoproj::OSDependencies.load_default
286
- osdeps.install([vcs.type])
287
-
288
- # Now check out the actual configuration
289
- config_dir = File.join(Dir.pwd, "autoproj")
290
- if delete_current
291
- FileUtils.rm_rf config_dir
292
- end
293
- Autoproj::Manifest.update_source(vcs, "autoproj main configuration", 'autoproj_config', config_dir)
294
-
295
- # Now write it in the config file
296
- File.open(File.join(Autoproj.config_dir, "config.yml"), "a") do |io|
297
- io.puts <<-EOTEXT
298
- manifest_source:
299
- type: #{vcs_def.delete(:type)}
300
- url: #{vcs_def.delete(:url)}
301
- #{vcs_def.map { |k, v| "#{k}: #{v}" }.join("\n ")}
302
- EOTEXT
303
- end
304
- end
305
-
306
- def do_bootstrap(*args)
307
- if File.exists?(File.join("autoproj", "manifest"))
308
- raise ConfigError, "this installation is already bootstrapped. Remove the autoproj directory if it is not the case"
309
- end
310
- Autobuild.logdir = File.join('build', 'log')
311
-
312
- # Check if we are being called from another GEM_HOME. If it is the case,
313
- # assume that we are bootstrapping from another installation directory and
314
- # start by copying the .gems directory
315
- if ENV['GEM_HOME'] && ENV['GEM_HOME'] =~ /\.gems\/?$/ && ENV['GEM_HOME'] != File.join(Dir.pwd, ".gems")
316
- STDERR.puts "autoproj: reusing bootstrap from #{File.dirname(ENV['GEM_HOME'])}"
317
- FileUtils.cp_r ENV['GEM_HOME'], ".gems"
318
- ENV['GEM_HOME'] = File.join(Dir.pwd, ".gems")
319
-
320
- require 'rbconfig'
321
- ruby = RbConfig::CONFIG['RUBY_INSTALL_NAME']
322
- exec ruby, $0, *ARGV
323
- end
324
-
325
- # If we are not getting the installation setup from a VCS, copy the template
326
- # files
327
- if args.empty? || args.size == 1
328
- sample_dir = File.expand_path(File.join("..", "samples"), File.dirname(__FILE__))
329
- FileUtils.cp_r File.join(sample_dir, "autoproj"), "autoproj"
330
- end
331
-
332
- if args.size == 1 # the user asks us to download a manifest
333
- manifest_url = args.first
334
- STDERR.puts color("autoproj: downloading manifest file #{manifest_url}", :bold)
335
- manifest_data =
336
- begin open(manifest_url) { |file| file.read }
337
- rescue
338
- raise ConfigError, "cannot read #{manifest_url}, did you mean 'autoproj bootstrap VCSTYPE #{manifest_url}' ?"
339
- end
340
-
341
- File.open(File.join(Autoproj.config_dir, "manifest"), "w") do |io|
342
- io.write(manifest_data)
343
- end
344
-
345
- elsif args.size >= 2 # is a VCS definition for the manifest itself ...
346
- do_switch_config(false, *args)
347
- end
348
-
349
- # Finally, generate an env.sh script
350
- File.open('env.sh', 'w') do |io|
351
- io.write <<-EOSHELL
352
- export RUBYOPT=-rubygems
353
- export GEM_HOME=#{Dir.pwd}/.gems
354
- export PATH=$GEM_HOME/bin:$PATH
355
- EOSHELL
356
- end
357
-
358
- STDERR.puts <<EOTEXT
359
-
360
- add the following line at the bottom of your .bashrc:
361
- source #{Dir.pwd}/env.sh
362
-
363
- WARNING: autoproj will not work until your restart all
364
- your consoles, or run the following in them:
365
- $ source #{Dir.pwd}/env.sh
366
-
367
- EOTEXT
368
-
369
- end
370
-
371
33
  def report(debug)
372
34
  Autobuild::Reporting.report do
373
35
  yield
@@ -388,72 +50,17 @@ rescue Interrupt
388
50
  end
389
51
  end
390
52
 
391
- Autobuild.doc_errors = false
392
- Autobuild.do_doc = false
393
-
394
53
  Autoproj::OSDependencies.autodetect_ruby
395
54
 
396
55
  # Find the autoproj root dir
397
- report(debug) do
398
- case mode
399
- when "bootstrap"
400
- # If there is no argument, We need one more argument. It is either a VCS type or a path to a
401
- # manifest.
402
- #
403
- # In the first case, we create a new manifest and add the source given on
404
- # the command line to it. In the second case, we simply use it as a
405
- # manifest.
406
- do_bootstrap(*args)
407
- if args.empty?
408
- # no package sets defined, we're done
409
- exit(0)
410
- end
411
- only_update_sources = true
412
-
413
- when "build"
414
- when "force-build"
415
- Autobuild.do_forced_build = true
416
- when "rebuild"
417
- Autobuild.do_rebuild = true
418
- when "fast-build"
419
- Autobuild.do_update = false
420
- no_os_deps = true
421
- when "update"
422
- Autobuild.do_build = false
423
- when "status"
424
- only_do_status = true
425
- Autobuild.do_update = false
426
- no_os_deps = true
427
- when "envsh"
428
- Autobuild.do_build = false
429
- Autobuild.do_update = false
430
- no_os_deps = true
431
- when "update-sets"
432
- only_update_sources = true
433
- when "list-sets"
434
- only_update_sources = true
435
- Autobuild.do_update = false
436
- when "switch-config"
437
- if switch_config(*args)
438
- exit 0
439
- else
440
- exit 1
441
- end
442
- when "doc"
443
- Autobuild.do_update = false
444
- no_os_deps = true
445
- Autobuild.do_doc = true
446
- Autobuild.only_doc = true
447
- else
448
- puts parser
449
- exit(1)
450
- end
56
+ report(Autobuild.debug) do
451
57
 
452
- # Expand directories in the selected_packages set
58
+ # Expand directories in the selected_packages set, before we chdir to the
59
+ # autoproj root
453
60
  root_dir = Autoproj.root_dir
454
61
  selected_packages.map! do |name|
455
62
  if File.directory?(name)
456
- File.expand_path(name).gsub(/^#{Regexp.quote(root_dir)}/, '')
63
+ File.expand_path(name)
457
64
  else
458
65
  name
459
66
  end
@@ -461,380 +68,88 @@ report(debug) do
461
68
 
462
69
  Dir.chdir(root_dir)
463
70
 
464
- # Load user configuration
465
- Autoproj.load_config
466
- # If we are under rubygems, check that the GEM_HOME is right ...
467
- if $LOADED_FEATURES.any? { |l| l =~ /rubygems/ }
468
- if ENV['GEM_HOME'] != Autoproj.gem_home
469
- raise ConfigError, "RubyGems is already loaded with a different GEM_HOME, make sure you are loading the right env.sh script !"
470
- end
471
- end
472
-
473
- # Set up some important autobuild parameters
474
- Autoproj.env_inherit 'PATH', 'PKG_CONFIG_PATH', 'RUBYLIB', 'LD_LIBRARY_PATH'
475
- Autoproj.env_set 'GEM_HOME', Autoproj.gem_home
476
- Autoproj.env_add 'PATH', File.join(Autoproj.gem_home, 'bin')
477
- Autoproj.env_set 'RUBYOPT', "-rubygems"
478
- Autobuild.prefix = Autoproj.build_dir
479
- Autobuild.srcdir = root_dir
480
- Autobuild.logdir = File.join(Autobuild.prefix, 'log')
481
- if mail_config[:to]
482
- Autobuild::Reporting << Autobuild::MailReporter.new(mail_config)
483
- end
484
-
485
-
486
- ruby = RbConfig::CONFIG['RUBY_INSTALL_NAME']
487
- if ruby != 'ruby'
488
- bindir = File.join(Autoproj.build_dir, 'bin')
489
- FileUtils.mkdir_p bindir
490
- File.open(File.join(bindir, 'ruby'), 'w') do |io|
491
- io.puts "#! /bin/sh"
492
- io.puts "exec #{ruby} \"$@\""
493
- end
494
- FileUtils.chmod 0755, File.join(bindir, 'ruby')
495
-
496
- Autoproj.env_add 'PATH', bindir
497
- end
498
-
499
- # First things first, see if we need to update ourselves
500
- osdeps = Autoproj::OSDependencies.load_default
501
- if osdeps.install(%w{autobuild autoproj})
502
- # We updated autobuild or autoproj themselves ... Restart !
503
- require 'rbconfig'
504
- ruby = RbConfig::CONFIG['RUBY_INSTALL_NAME']
505
- if mode == "bootstrap"
506
- exec(ruby, $0, 'list-sets')
507
- else
508
- exec(ruby, $0, *ARGV)
509
- end
510
- end
511
-
512
- manifest_path = File.join(Autoproj.config_dir, 'manifest')
513
- # Load the installation's manifest a first time, to check if we should
514
- # update it ... We assume that the OS dependencies for this VCS is already
515
- # installed (i.e. that the user did not remove it)
516
- manifest = Manifest.load(manifest_path)
517
- if manifest.vcs && mode != "bootstrap"
518
- manifest.update_yourself
519
- manifest = Manifest.load(manifest_path)
520
- end
521
- Autoproj.manifest = manifest
522
-
523
- source_os_dependencies = manifest.each_remote_source(false).
524
- inject(Set.new) do |set, source|
525
- set << source.vcs.type if !source.local?
526
- end
527
-
528
- # Update the remote sources if there are any
529
- if manifest.has_remote_sources?
530
- STDERR.puts color("autoproj: updating remote definitions of package sets", :bold)
531
- # If we need to install some packages to import our remote sources, do it
532
- if !no_os_deps
533
- osdeps = manifest.known_os_packages
534
- osdeps.install(source_os_dependencies)
535
- end
536
-
537
- manifest.update_remote_sources
538
- STDERR.puts
539
- end
540
-
541
- # Load init.rb files. each_source must not load the source.yml file, as
542
- # init.rb may define configuration options that are used there
543
- manifest.each_source(false) do |source|
544
- Autoproj.load_if_present(source, source.local_dir, "init.rb")
545
- end
546
-
547
- # Load the required autobuild definitions
548
- STDERR.puts color("autoproj: loading ...", :bold)
549
- if !Autoproj.reconfigure?
550
- STDERR.puts color("run 'autoproj --reconfigure' to change configuration values", :bold)
551
- end
552
- manifest.each_autobuild_file do |source, name|
553
- Autoproj.import_autobuild_file source, name
554
- end
555
-
556
- # Load the package's override files. each_source must not load the
557
- # source.yml file, as init.rb may define configuration options that are used
558
- # there
559
- manifest.each_source(false).to_a.reverse.each do |source|
560
- Autoproj.load_if_present(source, source.local_dir, "overrides.rb")
561
- end
71
+ # Basic initialization
72
+ Autoproj::CmdLine.initialize
73
+ Autoproj::CmdLine.update_myself
74
+ Autoproj::CmdLine.update_configuration
75
+ Autoproj::CmdLine.load_configuration
76
+ manifest = Autoproj.manifest
562
77
 
563
- # Now, load the package's importer configurations (from the various
564
- # source.yml files)
565
- manifest.load_importers
566
-
567
- # Configuration is finished, so all relevant configuration options should
568
- # have been asked to the user. Save it.
569
- Autoproj.save_config
570
-
571
- if Autoproj.verbose
572
- # List defined packages, and in which autobuild files they are defined
573
- STDERR.puts "Available packages:"
574
- manifest.packages.each_value do |pkg|
575
- STDERR.puts " #{pkg.autobuild.name}: #{pkg.file} from #{pkg.package_set.name}"
576
- end
577
- end
578
-
579
- # If in verbose mode, or if we only update sources, list the sources
78
+ # Once thing left to do: handle the Autoproj.auto_update configuration
79
+ # parameter
580
80
  #
581
- # Note that we can't have the Manifest class load the source.yml file, as it
582
- # cannot resolve all constants. So we need to do it ourselves to get the
583
- # name ...
584
- if Autoproj.verbose || only_update_sources
585
- sources = manifest.each_source(false).to_a
586
-
587
- if sources.empty?
588
- STDERR.puts color("autoproj: no package sets defined in autoproj/manifest", :bold, :red)
589
- else
590
- STDERR.puts color("autoproj: available package sets", :bold)
591
- manifest.each_source(false) do |source|
592
- source_yml = source.raw_description_file
593
- STDERR.puts " #{source_yml['name']}"
594
- if source.local?
595
- STDERR.puts " local source in #{source.local_dir}"
596
- else
597
- STDERR.puts " from: #{source.vcs}"
598
- STDERR.puts " local: #{source.local_dir}"
599
- end
600
-
601
- lines = []
602
- source.each_package.
603
- map { |pkg| [pkg.name, manifest.package_manifests[pkg.name]] }.
604
- sort_by { |name, _| name }.
605
- each do |name, source_manifest|
606
- vcs_def = manifest.importer_definition_for(name)
607
- if source_manifest
608
- lines << [name, source_manifest.short_documentation]
609
- lines << ["", vcs_def.to_s]
610
- else
611
- lines << [name, vcs_def.to_s]
612
- end
613
- end
614
-
615
- w_col1, w_col2 = nil
616
- lines.each do |col1, col2|
617
- w_col1 = col1.size if !w_col1 || col1.size > w_col1
618
- w_col2 = col2.size if !w_col2 || col2.size > w_col2
619
- end
620
- STDERR.puts " packages:"
621
- format = " | %-#{w_col1}s | %-#{w_col2}s |"
622
- lines.each do |col1, col2|
623
- STDERR.puts(format % [col1, col2])
624
- end
625
- end
626
- end
627
- end
628
- if only_update_sources
629
- exit(0)
81
+ # Namely, we must check if Autobuild.do_update has been explicitely set to
82
+ # true or false. If that is the case, don't do anything. Otherwise, set it
83
+ # to the value of Autoproj.auto_update
84
+ if Autobuild.do_update.nil?
85
+ Autobuild.do_update = Autoproj.auto_update?
630
86
  end
631
87
 
632
- # Create the build target from the manifest if the user did not provide an
633
- # explicit one
634
- if selected_packages.empty?
635
- selected_packages = manifest.default_packages
636
- end
637
- if selected_packages.empty? # no packages, terminate
638
- STDERR.puts
639
- STDERR.puts color("autoproj: no packages defined", :red)
640
- exit 0
88
+ # If in verbose mode, or if we only update sources, list the sources
89
+ if Autoproj.verbose || Autoproj::CmdLine.display_configuration?
90
+ Autoproj::CmdLine.display_sources(manifest)
641
91
  end
642
- selected_packages = selected_packages.to_set
643
92
 
644
- # Now starts a different stage of the whole build. Until now, we were
645
- # working on the whole package set. Starting from now, we need to build the
646
- # package sets based on the layout file
647
- #
648
- # First, we allow to user to specify packages based on disk paths, so
649
- # resolve those
650
- selected_packages = manifest.expand_package_selection(selected_packages)
651
- if selected_packages.empty?
652
- STDERR.puts color("autoproj: wrong packages selection on command line", :red)
653
- exit 0
654
- elsif Autoproj.verbose
655
- STDERR.puts "will install #{selected_packages.to_a.join(", ")}"
93
+ if Autoproj::CmdLine.only_config?
94
+ exit(0)
656
95
  end
657
- seen = Set.new
658
- manifest.each_package_set do |name, packages, enabled_packages|
659
- packages -= seen
660
96
 
661
- srcdir = File.join(Autoproj.root_dir, name)
662
- prefix = File.join(Autoproj.build_dir, name)
663
- logdir = File.join(prefix, "log")
664
- packages.each do |pkg_name|
665
- pkg = Autobuild::Package[pkg_name]
666
- pkg.srcdir = File.join(srcdir, pkg_name)
667
- pkg.prefix = prefix
668
- pkg.doc_target_dir = File.join(Autoproj.build_dir, 'doc', name, pkg_name)
669
- pkg.logdir = logdir
670
- end
671
- seen |= packages
672
- end
97
+ selected_packages = Autoproj::CmdLine.resolve_user_selection(selected_packages)
98
+ Autoproj::CmdLine.initial_package_setup
673
99
 
674
- # Now call the blocks that the user defined in the autobuild files. We do it
675
- # now so that the various package directories are properly setup
676
- manifest.packages.each_value do |pkg|
677
- if pkg.user_block
678
- pkg.user_block[pkg.autobuild]
679
- end
680
- end
681
-
682
- if only_do_status
100
+ if Autoproj::CmdLine.only_status?
683
101
  STDERR.puts
684
- all_packages = Set.new
685
- manifest.handle_enabled_packages(selected_packages) do |name, _, layout_enabled|
686
- all_packages |= layout_enabled
687
- end
688
- do_status(all_packages)
102
+ all_enabled_packages = Autoproj::CmdLine.import_packages(selected_packages)
103
+ Autoproj::CmdLine.status(all_enabled_packages)
104
+ exit(0)
105
+ elsif Autoproj::CmdLine.check?
106
+ all_enabled_packages = Autoproj::CmdLine.import_packages(selected_packages)
107
+ Autoproj::CmdLine.check(all_enabled_packages)
108
+ exit(0)
109
+ elsif Autoproj::CmdLine.manifest_update?
110
+ all_enabled_packages = Autoproj::CmdLine.import_packages(selected_packages)
111
+ Autoproj::CmdLine.manifest_update(all_enabled_packages)
689
112
  exit(0)
690
113
  end
691
114
 
692
115
  STDERR.puts
693
116
  STDERR.puts color("autoproj: importing and loading selected packages", :bold)
694
117
 
695
- # Install prepackaged dependencies needed to import and build the packages
696
- if !no_os_deps
118
+ # Install prepackaged dependencies needed to import and build the packages.
119
+ # The required information is in the package sets configuration.
120
+ if Autoproj::CmdLine.update_os_dependencies?
697
121
  osdeps = manifest.known_os_packages
698
- osdeps.install(Autoproj.build_system_dependencies - source_os_dependencies)
699
- end
700
-
701
- # First thing: do the import. We are handling the imports ourselves as it
702
- # allows us to complete the enabled_packages set with the package
703
- # dependencies. The scheme is as follows:
704
- # * we import a package, prepare it and load its manifest
705
- # * we look at its dependencies. Dependencies are either already handled
706
- # (and nothing needs to be done) or are to-be-handled at this level.
707
- # Otherwise, it is considered as an error
708
- #
709
- seen = Set.new
710
- manifest.each_package_set do |name, packages, enabled_packages|
711
- packages -= seen
712
-
713
- old_update_flag = Autobuild.do_update
714
- begin
715
- Autobuild.do_update = false
716
- packages.each do |pkg_name|
717
- pkg = Autobuild::Package[pkg_name]
718
- if File.directory?(pkg.srcdir)
719
- Rake::Task["#{pkg_name}-import"].invoke
720
- end
721
- end
722
- ensure
723
- Autobuild.do_update = old_update_flag
724
- end
725
-
726
- seen |= packages
122
+ osdeps.install(Autoproj.build_system_dependencies)
727
123
  end
728
124
 
729
- all_packages = Set.new
730
- all_enabled_packages = Set.new
731
- all_sublayouts = Set.new
732
- manifest.handle_enabled_packages(selected_packages) do |name, packages, enabled_packages, _|
733
- packages -= all_enabled_packages
734
- enabled_packages -= all_enabled_packages
735
- all_sublayouts << name
125
+ # Now, we actually do the import. Unfortunately, at this stage, we need to
126
+ # import the package and its dependencies ourselves so that we are able to
127
+ # build the list of packages that have actually been selected on the command
128
+ # line.
129
+ all_enabled_packages = Autoproj::CmdLine.import_packages(selected_packages)
736
130
 
737
- packages_to_import = enabled_packages.dup.to_set
738
- while !packages_to_import.empty?
739
- import_now, packages_to_import = packages_to_import, Set.new
740
- import_now.sort.each do |pkg_name|
741
- # Already handled in this part of the layout
742
- next if all_enabled_packages.include?(pkg_name)
743
-
744
- # Not handled already. Import.
745
- Autobuild::Package[pkg_name].import
746
- manifest.load_package_manifest(pkg_name)
747
- all_enabled_packages << pkg_name
748
-
749
- # Add its dependencies to the next import set
750
- Autobuild::Package[pkg_name].dependencies.each do |dep_name|
751
- if !Autobuild::Package[dep_name]
752
- raise ConfigError, "#{pkg_name} depends on #{dep_name}, but it does not seem to exist"
753
- elsif all_enabled_packages.include?(dep_name)
754
- next
755
- end
756
- packages_to_import << dep_name
757
- end
758
- end
759
- end
760
- all_packages.merge(packages)
761
- end
762
-
763
- old_update_flag = Autobuild.do_update
764
- begin
765
- Autobuild.do_update = false
766
- prepare_targets = all_packages.
767
- find_all { |pkg_name| File.directory?(Autobuild::Package[pkg_name].srcdir) }.
768
- map { |pkg_name| "#{pkg_name}-prepare" }
769
- task "autoproj-prepare" => prepare_targets
770
- Rake::Task["autoproj-prepare"].invoke
771
- ensure
772
- Autobuild.do_update = old_update_flag
773
- end
774
-
775
- missing_packages = all_packages.
776
- find_all do |pkg_name|
777
- !File.directory?(Autobuild::Package[pkg_name].srcdir)
778
- end
779
-
780
- if missing_packages.empty?
781
- # Backward compatibility: check if name/env.sh exists, and if it is
782
- # the case, simply replace it with a link to the root one. And issue
783
- # a warning
784
- all_sublayouts.each do |name|
785
- env_file = File.join(Autoproj.root_dir, name, "env.sh")
786
- if name != '/' && File.file?(env_file)
787
- File.open(env_file, 'w') do |io|
788
- io.puts "source #{Autoproj.root_dir}/env.sh"
789
- end
790
- end
791
- end
792
- Autoproj.export_env_sh
793
- STDERR.puts color("autoproj: updated #{Autoproj.root_dir}/env.sh", :green)
794
- else
795
- STDERR.puts color("autoproj: #{missing_packages.join(", ")} are not yet imported, #{Autoproj.root_dir}/env.sh might not be up to date", :red)
796
- end
797
-
798
- if all_enabled_packages.empty?
799
- STDERR.puts color("autoproj: nothing to do", :bold)
800
- elsif Autobuild.do_build
801
- if Autobuild.only_doc
802
- STDERR.puts color("autoproj: building and installing documentation", :bold)
803
- else
804
- STDERR.puts color("autoproj: building and installing packages", :bold)
805
- end
806
-
807
- if !no_os_deps
131
+ if Autoproj::CmdLine.build? || Autoproj::CmdLine.doc? || Autoproj::CmdLine.update_os_dependencies?
132
+ if all_enabled_packages.empty?
133
+ STDERR.puts color("autoproj: nothing to do", :bold)
134
+ elsif Autoproj::CmdLine.build? || Autoproj::CmdLine.doc?
135
+ Autoproj::CmdLine.build_packages(selected_packages, all_enabled_packages)
136
+ elsif Autoproj::CmdLine.update_os_dependencies?
808
137
  manifest.install_os_dependencies(all_enabled_packages)
809
138
  end
810
139
 
811
- if !selected_packages.empty? && !force_re_build_with_depends
812
- if Autobuild.do_rebuild
813
- selected_packages.each do |pkg_name|
814
- Autobuild::Package[pkg_name].prepare_for_rebuild
815
- end
816
- Autobuild.do_rebuild = false
817
- elsif Autobuild.do_forced_build
818
- selected_packages.each do |pkg_name|
819
- Autobuild::Package[pkg_name].prepare_for_forced_build
820
- end
821
- Autobuild.do_forced_build = false
140
+ # Now, do some sanity checks on the result
141
+ prefixes = all_enabled_packages.inject(Set.new) do |set, pkg_name|
142
+ set << Autobuild::Package[pkg_name].prefix
143
+ end
144
+ prefixes.each do |prefix|
145
+ libdir = File.join(prefix, "lib")
146
+ if File.directory?(libdir)
147
+ Autoproj.validate_solib_dependencies(libdir)
822
148
  end
823
149
  end
824
-
825
- Autobuild.apply(all_enabled_packages, "autoproj-build")
826
- elsif !no_os_deps
827
- manifest.install_os_dependencies(all_enabled_packages)
828
150
  end
829
151
 
830
- prefixes = all_enabled_packages.inject(Set.new) do |set, pkg_name|
831
- set << Autobuild::Package[pkg_name].prefix
832
- end
833
- prefixes.each do |prefix|
834
- libdir = File.join(prefix, "lib")
835
- if File.directory?(libdir)
836
- Autoproj.validate_solib_dependencies(libdir)
837
- end
838
- end
152
+ Autoproj.export_env_sh
153
+ STDERR.puts color("autoproj: updated #{Autoproj.root_dir}/env.sh", :green)
839
154
  end
840
155