autoproj 1.9.6 → 1.9.7.rc1

Sign up to get free protection for your applications and to get access to all the features.
data/lib/autoproj.rb CHANGED
@@ -2,7 +2,16 @@ require "enumerator"
2
2
  require 'autobuild'
3
3
  require 'autoproj/base'
4
4
  require 'autoproj/version'
5
+ require 'autoproj/environment'
6
+ require 'autoproj/variable_expansion'
7
+ require 'autoproj/vcs_definition'
8
+ require 'autoproj/package_set'
9
+ require 'autoproj/package_definition'
10
+ require 'autoproj/package_selection'
11
+ require 'autoproj/metapackage'
5
12
  require 'autoproj/manifest'
13
+ require 'autoproj/package_manifest'
14
+ require 'autoproj/installation_manifest'
6
15
  require 'autoproj/osdeps'
7
16
  require 'autoproj/system'
8
17
  require 'autoproj/options'
@@ -327,14 +327,14 @@ module Autoproj
327
327
  if !Dir.enum_for(:glob, File.join(full_path, "*.orogen")).to_a.empty?
328
328
  return "orogen_package", full_path
329
329
  elsif File.file?(File.join(full_path, "CMakeLists.txt"))
330
- dir = find_topmost_directory_containing(full_path) do |dir|
330
+ toplevel_dir = find_topmost_directory_containing(full_path) do |dir|
331
331
  cmakelists = File.join(dir, 'CMakeLists.txt')
332
332
  File.file?(cmakelists) &&
333
333
  (File.read(cmakelists) =~ /PROJECT/i)
334
334
  end
335
- dir ||= find_topmost_directory_containing(full_path, 'CMakeLists.txt')
335
+ toplevel_dir ||= find_topmost_directory_containing(full_path, 'CMakeLists.txt')
336
336
 
337
- return "cmake_package", dir
337
+ return "cmake_package", toplevel_dir
338
338
  elsif dir = find_topmost_directory_containing(full_path, "Rakefile") ||
339
339
  find_topmost_directory_containing(full_path, "lib/*.rb")
340
340
 
@@ -386,6 +386,29 @@ def import_package(options, &block)
386
386
  package_common(:import, options, &block)
387
387
  end
388
388
 
389
+ def common_make_based_package_setup(pkg)
390
+ unless pkg.has_doc? && pkg.doc_dir
391
+ pkg.with_doc do
392
+ doc_html = File.join(pkg.builddir, 'doc', 'html')
393
+ if File.directory?(doc_html)
394
+ pkg.doc_dir = doc_html
395
+ end
396
+ end
397
+ end
398
+ if !pkg.test_utility.has_task?
399
+ if !pkg.test_utility.source_dir
400
+ test_dir = File.join(pkg.srcdir, 'test')
401
+ if File.directory?(test_dir)
402
+ pkg.test_utility.source_dir = test_dir
403
+ end
404
+ end
405
+
406
+ if pkg.test_utility.source_dir
407
+ pkg.with_tests
408
+ end
409
+ end
410
+ end
411
+
389
412
  # Define a cmake package
390
413
  #
391
414
  # Example:
@@ -400,14 +423,7 @@ def cmake_package(options, &block)
400
423
  package_common(:cmake, options) do |pkg|
401
424
  Autoproj.add_build_system_dependency 'cmake'
402
425
  yield(pkg) if block_given?
403
- unless pkg.has_doc? && pkg.doc_dir
404
- pkg.with_doc do
405
- doc_html = File.join(pkg.builddir, 'doc', 'html')
406
- if File.directory?(doc_html)
407
- pkg.doc_dir = doc_html
408
- end
409
- end
410
- end
426
+ common_make_based_package_setup(pkg)
411
427
  end
412
428
  end
413
429
 
@@ -424,65 +440,10 @@ def autotools_package(options, &block)
424
440
  package_common(:autotools, options) do |pkg|
425
441
  Autoproj.add_build_system_dependency 'autotools'
426
442
  yield(pkg) if block_given?
427
- unless pkg.has_doc? && pkg.doc_dir
428
- pkg.with_doc do
429
- doc_html = File.join(pkg.builddir, 'doc', 'html')
430
- if File.directory? doc_html
431
- pkg.doc_dir = doc_html
432
- end
433
- end
434
- end
443
+ common_make_based_package_setup(pkg)
435
444
  end
436
445
  end
437
446
 
438
- # This module is used to extend importer packages to handle ruby packages
439
- # properly
440
- module Autoproj::RubyPackage
441
- def prepare_for_forced_build # :nodoc:
442
- super
443
- extdir = File.join(srcdir, 'ext')
444
- if File.directory?(extdir)
445
- Find.find(extdir) do |file|
446
- next if file !~ /\<Makefile\>|\<CMakeCache.txt\>$/
447
- FileUtils.rm_rf file
448
- end
449
- end
450
- end
451
-
452
- def prepare_for_rebuild # :nodoc:
453
- super
454
- extdir = File.join(srcdir, 'ext')
455
- if File.directory?(extdir)
456
- Find.find(extdir) do |file|
457
- if File.directory?(file) && File.basename(file) == "build"
458
- FileUtils.rm_rf file
459
- Find.prune
460
- end
461
- end
462
- Find.find(extdir) do |file|
463
- if File.basename(file) == "Makefile"
464
- Autobuild::Subprocess.run self, 'build', Autobuild.tool("make"), "-C", File.dirname(file), "clean"
465
- end
466
- end
467
- end
468
- end
469
-
470
- def update_environment
471
- Autobuild.update_environment srcdir
472
- libdir = File.join(srcdir, 'lib')
473
- if File.directory?(libdir)
474
- Autobuild.env_add_path 'RUBYLIB', libdir
475
- end
476
- end
477
-
478
- # The Rake task that is used to set up the package. Defaults to "default".
479
- # Set to nil to disable setup altogether
480
- attr_accessor :rake_setup_task
481
- # The Rake task that is used to generate documentation. Defaults to "doc".
482
- # Set to nil to disable documentation generation
483
- attr_accessor :rake_doc_task
484
- end
485
-
486
447
  def env_set(name, value)
487
448
  Autoproj.env_set(name, value)
488
449
  end
@@ -502,46 +463,26 @@ end
502
463
  # +pkg+ is an Autobuild::Importer instance. See the Autobuild API for more
503
464
  # information.
504
465
  def ruby_package(options)
505
- package_common(:import, options) do |pkg|
506
- pkg.exclude << /\.so$/
507
- pkg.exclude << /Makefile$/
508
- pkg.exclude << /mkmf.log$/
509
- pkg.exclude << /\.o$/
510
- pkg.exclude << /doc$/
511
-
512
- pkg.extend Autoproj::RubyPackage
513
- pkg.rake_setup_task = "default"
514
- pkg.rake_doc_task = "redocs"
515
-
516
- # Set up code
517
- pkg.post_install do
518
- pkg.progress_start "setting up Ruby package %s", :done_message => 'set up Ruby package %s' do
519
- Autobuild.update_environment pkg.srcdir
520
- # Add lib/ unconditionally, as we know that it is a ruby package.
521
- # Autobuild will add it only if there is a .rb file in the directory
522
- libdir = File.join(pkg.srcdir, 'lib')
523
- if File.directory?(libdir)
524
- Autobuild.env_add_path 'RUBYLIB', libdir
525
- end
526
-
527
- if pkg.rake_setup_task && File.file?(File.join(pkg.srcdir, 'Rakefile'))
528
- Autobuild::Subprocess.run pkg, 'post-install',
529
- Autoproj::CmdLine.ruby_executable, Autoproj.find_in_path('rake'), pkg.rake_setup_task, :working_directory => pkg.srcdir
530
- end
531
- end
532
- end
533
-
466
+ package_common(:ruby, options) do |pkg|
534
467
  yield(pkg) if block_given?
535
468
 
536
469
  # Documentation code. Ignore if the user provided its own documentation
537
470
  # task, or disabled the documentation generation altogether by setting
538
471
  # rake_doc_task to nil
539
472
  if !pkg.has_doc? && pkg.rake_doc_task
540
- pkg.doc_task do
541
- pkg.progress_start "generating documentation for %s", :done_message => 'generated documentation for %s' do
542
- Autobuild::Subprocess.run pkg, 'doc', Autoproj::CmdLine.ruby_executable, Autoproj.find_in_path('rake'), pkg.rake_doc_task, :working_directory => pkg.srcdir
473
+ pkg.with_doc
474
+ end
475
+ if !pkg.test_utility.has_task?
476
+ if !pkg.test_utility.source_dir
477
+ test_dir = File.join(pkg.srcdir, 'test')
478
+ if File.directory?(test_dir)
479
+ pkg.test_utility.source_dir = test_dir
543
480
  end
544
481
  end
482
+
483
+ if pkg.test_utility.source_dir
484
+ pkg.with_tests
485
+ end
545
486
  end
546
487
  end
547
488
  end
@@ -58,6 +58,7 @@ module Autoproj
58
58
  end
59
59
  end
60
60
  Autoproj.change_option('ruby_executable', ruby_executable, true)
61
+ Autobuild.programs['ruby'] = ruby_executable
61
62
 
62
63
  install_suffix = ""
63
64
  if match = /ruby(.*)$/.match(ruby)
@@ -74,7 +75,7 @@ module Autoproj
74
75
  end
75
76
  FileUtils.chmod 0755, File.join(bindir, 'ruby')
76
77
 
77
- subprograms = ['gem', 'irb', 'testrb'].each do |name|
78
+ ['gem', 'irb', 'testrb'].each do |name|
78
79
  # Look for the corresponding gem program
79
80
  prg_name = "#{name}#{install_suffix}"
80
81
  if File.file?(prg_path = File.join(ruby_bindir, prg_name))
@@ -306,6 +307,7 @@ module Autoproj
306
307
 
307
308
  def self.update_configuration
308
309
  manifest = Autoproj.manifest
310
+ Autoproj::Manifest.only_local_updates = @only_local
309
311
 
310
312
  # Load the installation's manifest a first time, to check if we should
311
313
  # update it ... We assume that the OS dependencies for this VCS is already
@@ -706,7 +708,7 @@ module Autoproj
706
708
  # packages is not important BUT the ordering of import vs.
707
709
  # prepare in one package IS important: prepare is the method
708
710
  # that takes into account dependencies.
709
- pkg.import
711
+ pkg.import(@only_local)
710
712
  Rake::Task["#{pkg.name}-import"].instance_variable_set(:@already_invoked, true)
711
713
  manifest.load_package_manifest(pkg.name)
712
714
 
@@ -809,14 +811,7 @@ module Autoproj
809
811
  return all_enabled_packages
810
812
  end
811
813
 
812
- def self.build_packages(selected_packages, all_enabled_packages)
813
- if Autoproj::CmdLine.doc?
814
- Autobuild.only_doc = true
815
- Autoproj.message("autoproj: building and installing documentation", :bold)
816
- else
817
- Autoproj.message("autoproj: building and installing packages", :bold)
818
- end
819
-
814
+ def self.build_packages(selected_packages, all_enabled_packages, phases = [])
820
815
  if Autoproj::CmdLine.update_os_dependencies?
821
816
  manifest.install_os_dependencies(all_enabled_packages)
822
817
  end
@@ -829,6 +824,16 @@ module Autoproj
829
824
  if !opt.ask(false)
830
825
  raise Interrupt
831
826
  end
827
+ if Autoproj::CmdLine.update_os_dependencies?
828
+ # We also reinstall the osdeps that provide the
829
+ # functionality
830
+ managers = Autoproj.osdeps.setup_package_handlers
831
+ managers.each do |mng|
832
+ if mng.respond_to?(:reinstall)
833
+ mng.reinstall
834
+ end
835
+ end
836
+ end
832
837
 
833
838
  elsif !selected_packages.empty? && !force_re_build_with_depends?
834
839
  if Autobuild.do_rebuild
@@ -844,7 +849,7 @@ module Autoproj
844
849
  end
845
850
  end
846
851
 
847
- Autobuild.apply(all_enabled_packages, "autoproj-build")
852
+ Autobuild.apply(all_enabled_packages, "autoproj-build", phases)
848
853
  end
849
854
 
850
855
  def self.manifest; Autoproj.manifest end
@@ -921,9 +926,6 @@ module Autoproj
921
926
  @partial_build = false
922
927
  @color = true
923
928
  Autobuild.color = true
924
- Autobuild.doc_errors = false
925
- Autobuild.do_doc = false
926
- Autobuild.only_doc = false
927
929
  Autobuild.do_update = nil
928
930
  do_update = nil
929
931
 
@@ -1225,14 +1227,6 @@ where 'mode' is one of:
1225
1227
  Autobuild.do_update = true
1226
1228
  Autobuild.do_build = true
1227
1229
  @update_os_dependencies = true
1228
- when "snapshot"
1229
- @snapshot_dir = remaining_args.shift
1230
- if !snapshot_dir
1231
- raise ConfigError.new, "target directory missing\nusage: autoproj snapshot target_dir"
1232
- end
1233
- Autobuild.do_update = false
1234
- Autobuild.do_build = false
1235
- @update_os_dependencies = false
1236
1230
  when "update"
1237
1231
  Autobuild.do_update = true
1238
1232
  Autobuild.do_build = false
@@ -1710,18 +1704,49 @@ where 'mode' is one of:
1710
1704
  end
1711
1705
  end
1712
1706
 
1713
- def self.snapshot(target_dir, packages)
1707
+ def self.snapshot(manifest, target_dir, packages)
1714
1708
  # First, copy the configuration directory to create target_dir
1715
1709
  if File.exists?(target_dir)
1716
1710
  raise ArgumentError, "#{target_dir} already exists"
1717
1711
  end
1718
1712
  FileUtils.cp_r Autoproj.config_dir, target_dir
1713
+ # Finally, remove the remotes/ directory from the generated
1714
+ # buildconf, it is obsolete now
1715
+ FileUtils.rm_rf File.join(target_dir, 'remotes')
1716
+
1717
+ # Pin package sets
1718
+ package_sets = Array.new
1719
+ manifest.each_package_set do |pkg_set|
1720
+ next if pkg_set.name == 'local'
1721
+ if pkg_set.local?
1722
+ package_sets << Pathname.new(pkg_set.local_dir).
1723
+ relative_path_from(Pathname.new(manifest.file).dirname).
1724
+ to_s
1725
+ else
1726
+ vcs_info = pkg_set.vcs.to_hash
1727
+ if pin_info = pkg_set.snapshot(target_dir)
1728
+ vcs_info = vcs_info.merge(pin_info)
1729
+ end
1730
+ package_sets << vcs_info
1731
+ end
1732
+ end
1733
+ manifest_path = File.join(target_dir, 'manifest')
1734
+ manifest_data = YAML.load(File.read(manifest_path))
1735
+ manifest_data['package_sets'] = package_sets
1736
+ File.open(manifest_path, 'w') do |io|
1737
+ YAML.dump(manifest_data, io)
1738
+ end
1719
1739
 
1720
1740
  # Now, create snapshot information for each of the packages
1721
- version_control = []
1741
+ version_control_info = []
1742
+ overrides_info = []
1722
1743
  packages.each do |package_name|
1723
- package = Autobuild::Package[package_name]
1724
- importer = package.importer
1744
+ package = manifest.packages[package_name]
1745
+ if !package
1746
+ raise ArgumentError, "#{package_name} is not a known package"
1747
+ end
1748
+ package_set = package.package_set
1749
+ importer = package.autobuild.importer
1725
1750
  if !importer
1726
1751
  Autoproj.message "cannot snapshot #{package_name} as it has no importer"
1727
1752
  next
@@ -1730,9 +1755,13 @@ where 'mode' is one of:
1730
1755
  next
1731
1756
  end
1732
1757
 
1733
- vcs_info = importer.snapshot(package, target_dir)
1758
+ vcs_info = importer.snapshot(package.autobuild, target_dir)
1734
1759
  if vcs_info
1735
- version_control << Hash[package_name, vcs_info]
1760
+ if package_set.name == 'local'
1761
+ version_control_info << Hash[package_name, vcs_info]
1762
+ else
1763
+ overrides_info << Hash[package_name, vcs_info]
1764
+ end
1736
1765
  end
1737
1766
  end
1738
1767
 
@@ -1742,12 +1771,10 @@ where 'mode' is one of:
1742
1771
  end
1743
1772
  # In Ruby 1.9, an empty file results in YAML.load returning false
1744
1773
  overrides ||= Hash.new
1745
-
1746
- if overrides['overrides']
1747
- overrides['overrides'].concat(version_control)
1748
- else
1749
- overrides['overrides'] = version_control
1750
- end
1774
+ (overrides['version_control'] ||= Array.new).
1775
+ concat(version_control_info)
1776
+ (overrides['overrides'] ||= Array.new).
1777
+ concat(overrides_info)
1751
1778
 
1752
1779
  File.open(overrides_path, 'w') do |io|
1753
1780
  io.write YAML.dump(overrides)
@@ -1943,12 +1970,12 @@ where 'mode' is one of:
1943
1970
 
1944
1971
  rescue ConfigError => e
1945
1972
  STDERR.puts
1946
- STDERR.puts color(e.message, :red, :bold)
1973
+ STDERR.puts Autoproj.color(e.message, :red, :bold)
1947
1974
  if Autoproj.in_autoproj_installation?(Dir.pwd)
1948
1975
  root_dir = /#{Regexp.quote(Autoproj.root_dir)}(?!\/\.gems)/
1949
1976
  e.backtrace.find_all { |path| path =~ root_dir }.
1950
1977
  each do |path|
1951
- STDERR.puts color(" in #{path}", :red, :bold)
1978
+ STDERR.puts Autoproj.color(" in #{path}", :red, :bold)
1952
1979
  end
1953
1980
  end
1954
1981
  if Autobuild.debug then raise
@@ -1956,7 +1983,7 @@ where 'mode' is one of:
1956
1983
  end
1957
1984
  rescue Interrupt
1958
1985
  STDERR.puts
1959
- STDERR.puts color("Interrupted by user", :red, :bold)
1986
+ STDERR.puts Autoproj.color("Interrupted by user", :red, :bold)
1960
1987
  if Autobuild.debug then raise
1961
1988
  else exit 1
1962
1989
  end
@@ -49,8 +49,23 @@ ruby19:
49
49
  - ruby19
50
50
  - rake
51
51
  default: nonexistent
52
+ opensuse: ruby19-devel
52
53
 
53
- ruby20: ignore
54
+ ruby20:
55
+ debian:
56
+ - ruby2.0
57
+ - ruby2.0-dev
58
+ - rake
59
+ - rubygems-integration
60
+ default: ignore
61
+
62
+ ruby21:
63
+ debian:
64
+ - ruby2.1
65
+ - ruby2.1-dev
66
+ - rake
67
+ - rubygems-integration
68
+ default: ignore
54
69
 
55
70
  build-essential:
56
71
  debian,ubuntu: build-essential
@@ -58,6 +73,7 @@ build-essential:
58
73
  arch,manjarolinux: base-dev
59
74
  fedora: ignore
60
75
  darwin: ignore
76
+ opensuse: ignore #Toto add scemata
61
77
 
62
78
  autobuild: gem
63
79
  autoproj: gem
@@ -72,6 +88,7 @@ git:
72
88
  arch,manjarolinux: git
73
89
  fedora: git
74
90
  darwin: git-core
91
+ opensuse: git
75
92
 
76
93
  hg:
77
94
  debian,ubuntu: mercurial
@@ -79,6 +96,7 @@ hg:
79
96
  arch,manjarolinux: mercurial
80
97
  fedora: mercurial
81
98
  darwin: mercurial
99
+ opensuse: mercurial
82
100
 
83
101
  svn:
84
102
  debian,ubuntu: subversion
@@ -86,6 +104,7 @@ svn:
86
104
  arch,manjarolinux: subversion
87
105
  fedora: subversion
88
106
  darwin: subversion
107
+ opensuse: subversion
89
108
 
90
109
  cmake:
91
110
  debian,ubuntu: cmake
@@ -93,6 +112,7 @@ cmake:
93
112
  arch,manjarolinux: cmake
94
113
  fedora: cmake
95
114
  darwin: cmake
115
+ opensuse: cmake
96
116
 
97
117
  autotools:
98
118
  debian,ubuntu:
@@ -110,6 +130,9 @@ autotools:
110
130
  darwin:
111
131
  - automake
112
132
  - autoconf
133
+ opensuse:
134
+ - automake
135
+ - autoconf
113
136
 
114
137
  lsb_release:
115
138
  debian,ubuntu: lsb-release
@@ -117,6 +140,7 @@ lsb_release:
117
140
  arch,manjarolinux: lsb-release
118
141
  fedora: redhat-lsb
119
142
  darwin: ignore
143
+ opensuse: ignore
120
144
 
121
145
  archive:
122
146
  debian,ubuntu:
@@ -134,16 +158,21 @@ archive:
134
158
  darwin:
135
159
  - gnutar
136
160
  - unzip
161
+ opensuse:
162
+ - tar
163
+ - unzip
137
164
 
138
165
  cvs:
139
166
  debian,ubuntu: cvs
140
167
  fedora: cvs
141
168
  darwin: cvs
142
169
  arch,manjarolinux: cvs
170
+ opensuse: cvs
143
171
 
144
172
  pip:
145
173
  debian,ubuntu: python-pip
146
174
  arch,manjarolinux: python2-pip
175
+ opensuse: python-pip
147
176
 
148
177
  # vim: expandtab
149
178