autobuild 1.17.0 → 1.21.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (46) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop.yml +107 -0
  3. data/.travis.yml +3 -2
  4. data/Gemfile +2 -1
  5. data/Rakefile +1 -4
  6. data/autobuild.gemspec +18 -13
  7. data/bin/autobuild +4 -3
  8. data/lib/autobuild.rb +4 -5
  9. data/lib/autobuild/build_logfile.rb +6 -4
  10. data/lib/autobuild/config.rb +104 -41
  11. data/lib/autobuild/configurable.rb +32 -18
  12. data/lib/autobuild/environment.rb +126 -120
  13. data/lib/autobuild/exceptions.rb +48 -31
  14. data/lib/autobuild/import/archive.rb +134 -82
  15. data/lib/autobuild/import/cvs.rb +28 -24
  16. data/lib/autobuild/import/darcs.rb +13 -16
  17. data/lib/autobuild/import/git-lfs.rb +37 -30
  18. data/lib/autobuild/import/git.rb +246 -182
  19. data/lib/autobuild/import/hg.rb +23 -18
  20. data/lib/autobuild/import/svn.rb +48 -29
  21. data/lib/autobuild/importer.rb +534 -499
  22. data/lib/autobuild/mail_reporter.rb +77 -77
  23. data/lib/autobuild/package.rb +200 -122
  24. data/lib/autobuild/packages/autotools.rb +47 -42
  25. data/lib/autobuild/packages/cmake.rb +77 -65
  26. data/lib/autobuild/packages/dummy.rb +9 -8
  27. data/lib/autobuild/packages/genom.rb +1 -1
  28. data/lib/autobuild/packages/gnumake.rb +74 -31
  29. data/lib/autobuild/packages/import.rb +2 -6
  30. data/lib/autobuild/packages/orogen.rb +32 -31
  31. data/lib/autobuild/packages/pkgconfig.rb +2 -2
  32. data/lib/autobuild/packages/python.rb +12 -8
  33. data/lib/autobuild/packages/ruby.rb +22 -17
  34. data/lib/autobuild/parallel.rb +50 -46
  35. data/lib/autobuild/pkgconfig.rb +25 -13
  36. data/lib/autobuild/progress_display.rb +149 -64
  37. data/lib/autobuild/rake_task_extension.rb +12 -7
  38. data/lib/autobuild/reporting.rb +51 -26
  39. data/lib/autobuild/subcommand.rb +72 -65
  40. data/lib/autobuild/test.rb +9 -7
  41. data/lib/autobuild/test_utility.rb +12 -10
  42. data/lib/autobuild/timestamps.rb +28 -23
  43. data/lib/autobuild/tools.rb +17 -16
  44. data/lib/autobuild/utility.rb +67 -23
  45. data/lib/autobuild/version.rb +1 -1
  46. metadata +53 -37
@@ -7,27 +7,28 @@ class DummyPackage < Package
7
7
  def installstamp
8
8
  "#{srcdir}/#{STAMPFILE}"
9
9
  end
10
-
10
+
11
11
  def initialize(*args)
12
12
  super
13
13
  end
14
14
 
15
- def import(options = Hash.new)
16
- end
15
+ def import(options = Hash.new); end
17
16
 
18
17
  def prepare
19
- %w{import prepare build doc}.each do |phase|
18
+ %w[import prepare build doc].each do |phase|
20
19
  task "#{name}-#{phase}"
21
20
  t = Rake::Task["#{name}-#{phase}"]
22
- def t.needed?; false end
21
+ def t.needed?
22
+ false
23
+ end
23
24
  end
24
25
  task(installstamp)
25
26
  t = Rake::Task[installstamp]
26
- def t.needed?; false end
27
+ def t.needed?
28
+ false
29
+ end
27
30
 
28
31
  super
29
32
  end
30
33
  end
31
34
  end
32
-
33
-
@@ -74,7 +74,7 @@ def get_requires
74
74
  end
75
75
  end
76
76
 
77
- # Alias this package to the ones defined in the EXTRA_PKGCONFIG
77
+ # Alias this package to the ones defined in the EXTRA_PKGCONFIG
78
78
  # flag in configure.ac.user
79
79
  def get_provides
80
80
  configure_ac_user = File.join(srcdir, 'configure.ac.user')
@@ -1,19 +1,46 @@
1
1
  require 'rubygems/version'
2
2
 
3
3
  module Autobuild
4
- def self.make_is_gnumake?(pkg, path = Autobuild.tool(:make))
4
+ def self.reset_gnumake_detection
5
+ @make_is_gnumake = Hash.new
6
+ @gnumake_version = Hash.new
7
+ end
8
+
9
+ def self.ensure_gnumake_detected(pkg, path = Autobuild.tool(:make))
5
10
  @make_is_gnumake ||= Hash.new
6
11
  @gnumake_version ||= Hash.new
7
- if @make_is_gnumake.has_key?(path)
8
- @make_is_gnumake[path]
12
+ return @make_is_gnumake[path] if @make_is_gnumake.key?(path)
13
+
14
+ begin
15
+ gnumake_version_string = pkg.run('prepare', path, '--version')
16
+ rescue Autobuild::SubcommandFailed
17
+ @make_is_gnumake[path] = false
18
+ return
19
+ end
20
+
21
+ gnumake_match = /^GNU Make[^\d]+(\d[\d.]+)/.match(gnumake_version_string.first)
22
+ unless gnumake_match
23
+ @make_is_gnumake[path] = false
24
+ return
25
+ end
26
+
27
+ @gnumake_version[path] = Gem::Version.new(gnumake_match[1])
28
+ @make_is_gnumake[path] = true
29
+ end
30
+
31
+ def self.make_is_gnumake?(pkg, path = Autobuild.tool(:make))
32
+ ensure_gnumake_detected(pkg, path)
33
+ end
34
+
35
+ class NotGNUMake < RuntimeError
36
+ end
37
+
38
+ def self.gnumake_version(pkg, path = Autobuild.tool(:make))
39
+ if ensure_gnumake_detected(pkg, path)
40
+ @gnumake_version.fetch(path)
9
41
  else
10
- begin
11
- result = pkg.run('prepare', path, '--version')
12
- @make_is_gnumake[path] = (result.first =~ /GNU Make/)
13
- @gnumake_version[path] = result.first.scan(/[\d.]+/)[0]
14
- rescue Autobuild::SubcommandFailed
15
- @make_is_gnumake[path] = false
16
- end
42
+ raise NotGNUMake, "either #{path} is not a GNU Make or it does not have "\
43
+ "the expected version string"
17
44
  end
18
45
  end
19
46
 
@@ -25,34 +52,50 @@ def self.make_has_gnumake_jobserver?(pkg, path = Autobuild.tool(:make))
25
52
  make_is_gnumake?(pkg, path)
26
53
  end
27
54
 
55
+ GNUMAKE_JOBSERVER_AUTH_VERSION = Gem::Version.new("4.2.0")
56
+
57
+ def self.gnumake_jobserver_option(job_server, pkg, path = Autobuild.tool(:make))
58
+ jobserver_fds_arg = "#{job_server.rio.fileno},#{job_server.wio.fileno}"
59
+
60
+ version = gnumake_version(pkg, path)
61
+ if version >= GNUMAKE_JOBSERVER_AUTH_VERSION
62
+ ["--jobserver-auth=#{jobserver_fds_arg}"]
63
+ else
64
+ ["--jobserver-fds=#{jobserver_fds_arg}", "-j"]
65
+ end
66
+ end
67
+
28
68
  def self.invoke_make_parallel(pkg, cmd_path = Autobuild.tool(:make))
29
69
  reserved = nil
30
- if make_has_j_option?(pkg, cmd_path) && pkg.parallel_build_level != 1
31
- if manager = Autobuild.parallel_task_manager
32
- job_server = manager.job_server
33
- if !make_has_gnumake_jobserver?(pkg, cmd_path) || (pkg.parallel_build_level != Autobuild.parallel_build_level)
34
- reserved = pkg.parallel_build_level
35
- job_server.get(reserved - 1) # We already have one token taken by autobuild itself
36
- yield("-j#{pkg.parallel_build_level}")
37
- end
38
- if Gem::Version.new(@gnumake_version[cmd_path]) >= Gem::Version.new("4.2.0")
39
- yield("--jobserver-auth=#{job_server.rio.fileno},#{job_server.wio.fileno}", "-j")
40
- else
41
- yield("--jobserver-fds=#{job_server.rio.fileno},#{job_server.wio.fileno}", "-j")
42
- end
70
+ return yield unless make_has_j_option?(pkg, cmd_path)
71
+
72
+ manager = Autobuild.parallel_task_manager
73
+ return yield("-j#{pkg.parallel_build_level}") unless manager
74
+
75
+ job_server = manager.job_server
76
+
77
+ specific_parallel_level = (
78
+ pkg.parallel_build_level != Autobuild.parallel_build_level
79
+ )
80
+ if !make_has_gnumake_jobserver?(pkg, cmd_path) || specific_parallel_level
81
+ reserved = pkg.parallel_build_level
82
+ # Account for the one token autobuild uses
83
+ begin
84
+ job_server.get(reserved - 1)
85
+ return yield("-j#{pkg.parallel_build_level}")
86
+ ensure
87
+ job_server.put(reserved - 1)
43
88
  end
44
- yield("-j#{pkg.parallel_build_level}")
45
- else yield
46
- end
47
- ensure
48
- if reserved
49
- job_server.put(reserved)
50
89
  end
90
+
91
+ options = gnumake_jobserver_option(job_server, pkg, cmd_path)
92
+ yield(*options)
51
93
  end
52
-
94
+
53
95
  def self.make_subcommand(pkg, phase, *options, &block)
54
96
  invoke_make_parallel(pkg, Autobuild.tool(:make)) do |*make_parallel_options|
55
- pkg.run(phase, Autobuild.tool(:make), *make_parallel_options, *options, &block)
97
+ pkg.run(phase, Autobuild.tool(:make),
98
+ *make_parallel_options, *options, &block)
56
99
  end
57
100
  end
58
101
  end
@@ -5,7 +5,7 @@ module Autobuild
5
5
  def self.import(spec, &proc)
6
6
  ImporterPackage.new(spec, &proc)
7
7
  end
8
-
8
+
9
9
  class ImporterPackage < Package
10
10
  attr_reader :exclude
11
11
 
@@ -19,9 +19,7 @@ def prepare
19
19
 
20
20
  exclude = self.exclude.dup
21
21
  exclude << Regexp.new("^#{Regexp.quote(installstamp)}")
22
- if doc_dir
23
- exclude << Regexp.new("^#{Regexp.quote(doc_dir)}")
24
- end
22
+ exclude << Regexp.new("^#{Regexp.quote(doc_dir)}") if doc_dir
25
23
 
26
24
  source_tree(srcdir) do |pkg|
27
25
  pkg.exclude.concat exclude
@@ -32,5 +30,3 @@ def prepare
32
30
  end
33
31
  end
34
32
  end
35
-
36
-
@@ -41,7 +41,7 @@ class << self
41
41
  # This is still considered experimental. Use
42
42
  # Orogen.always_regenerate= to set it
43
43
  def always_regenerate?
44
- !!@always_regenerate
44
+ @always_regenerate
45
45
  end
46
46
  end
47
47
 
@@ -63,14 +63,15 @@ def self.orocos_target
63
63
 
64
64
  class << self
65
65
  attr_accessor :default_type_export_policy
66
- # The list of enabled transports as an array of strings (default: typelib, corba)
66
+ # The list of enabled transports as an array of strings (default:
67
+ # typelib, corba)
67
68
  attr_reader :transports
68
69
 
69
70
  attr_reader :orogen_options
70
71
  end
71
72
  @orogen_options = []
72
73
  @default_type_export_policy = :used
73
- @transports = %w{corba typelib mqueue}
74
+ @transports = %w[corba typelib mqueue]
74
75
  @rtt_scripting = true
75
76
 
76
77
  attr_reader :orogen_options
@@ -121,12 +122,13 @@ def orogen_file
121
122
  if @orogen_file
122
123
  @orogen_file
123
124
  else
124
- return if !File.directory?(srcdir)
125
-
125
+ return unless File.directory?(srcdir)
126
+
126
127
  Dir.glob(File.join(srcdir, '*.orogen')) do |path|
127
128
  return File.basename(path)
128
129
  end
129
- raise ArgumentError, "cannot find an oroGen specification file in #{srcdir}"
130
+ raise ArgumentError,
131
+ "cannot find an oroGen specification file in #{srcdir}"
130
132
  end
131
133
  end
132
134
 
@@ -141,7 +143,7 @@ def initialize(*args, &config)
141
143
 
142
144
  def prepare_for_forced_build
143
145
  super
144
- FileUtils.rm_f genstamp
146
+ FileUtils.rm_f genstamp
145
147
  end
146
148
 
147
149
  def update_environment
@@ -158,9 +160,7 @@ def orogen_version
158
160
  if !@orogen_version && (root = orogen_root)
159
161
  version_file = File.join(root, 'lib', 'orogen', 'version.rb')
160
162
  version_line = File.readlines(version_file).grep(/VERSION\s*=\s*"/).first
161
- if version_line =~ /.*=\s+"(.+)"$/
162
- @orogen_version = $1
163
- end
163
+ @orogen_version = $1 if version_line =~ /.*=\s+"(.+)"$/
164
164
  end
165
165
  @orogen_version
166
166
  end
@@ -168,9 +168,7 @@ def orogen_version
168
168
  def orogen_root
169
169
  if orogen_tool_path
170
170
  root = File.expand_path(File.join('..', '..'), orogen_tool_path)
171
- if File.directory?(File.join(root, 'lib', 'orogen'))
172
- root
173
- end
171
+ root if File.directory?(File.join(root, 'lib', 'orogen'))
174
172
  end
175
173
  end
176
174
 
@@ -187,7 +185,9 @@ def prepare
187
185
  super
188
186
  end
189
187
 
190
- def genstamp; File.join(srcdir, '.orogen', 'orogen-stamp') end
188
+ def genstamp
189
+ File.join(srcdir, '.orogen', 'orogen-stamp')
190
+ end
191
191
 
192
192
  def add_cmd_to_cmdline(cmd, cmdline)
193
193
  if cmd =~ /^([\w-]+)$/
@@ -210,31 +210,30 @@ def regen
210
210
  cmdline << '--corba' if corba
211
211
 
212
212
  ext_states = extended_states
213
- if !ext_states.nil?
213
+ unless ext_states.nil?
214
214
  cmdline.delete_if { |str| str =~ /extended-states/ }
215
- if ext_states
216
- cmdline << '--extended-states'
217
- else
218
- cmdline << '--no-extended-states'
219
- end
215
+ cmdline <<
216
+ if ext_states
217
+ '--extended-states'
218
+ else
219
+ '--no-extended-states'
220
+ end
220
221
  end
221
222
 
222
- @orogen_tool_path = find_in_path 'orogen'
223
- if !orogen_tool_path
223
+ unless (@orogen_tool_path = find_in_path('orogen'))
224
224
  raise ArgumentError, "cannot find 'orogen' in #{resolved_env['PATH']}"
225
225
  end
226
226
 
227
- version = orogen_version
228
- if !version
227
+ unless (version = orogen_version)
229
228
  raise ArgumentError, "cannot determine the orogen version"
230
229
  end
231
230
 
232
- if (version >= "1.0")
231
+ if version >= "1.0" # rubocop:disable Style/IfUnlessModifier
233
232
  cmdline << "--parallel-build=#{parallel_build_level}"
234
233
  end
235
- if (version >= "1.1")
234
+ if version >= "1.1"
236
235
  cmdline << "--type-export-policy=#{Orogen.default_type_export_policy}"
237
- cmdline << "--transports=#{Orogen.transports.sort.uniq.join(",")}"
236
+ cmdline << "--transports=#{Orogen.transports.sort.uniq.join(',')}"
238
237
  end
239
238
 
240
239
  # Now, add raw options
@@ -269,9 +268,11 @@ def regen
269
268
  needs_regen ||= !generation_uptodate?
270
269
 
271
270
  if needs_regen
272
- progress_start "generating oroGen %s", :done_message => 'generated oroGen %s' do
271
+ progress_start "generating oroGen %s",
272
+ done_message: 'generated oroGen %s' do
273
273
  in_dir(srcdir) do
274
- run 'orogen', Autobuild.tool('ruby'), '-S', orogen_tool_path, *cmdline
274
+ run 'orogen', Autobuild.tool('ruby'), '-S',
275
+ orogen_tool_path, *cmdline
275
276
  File.open(genstamp, 'w') do |io|
276
277
  io.print cmdline.join("\n")
277
278
  end
@@ -287,11 +288,11 @@ def generation_uptodate?
287
288
  if !File.file?(genstamp)
288
289
  true
289
290
  elsif File.file?(File.join(builddir, 'Makefile'))
290
- system("#{Autobuild.tool('make')} -C #{builddir} check-uptodate > /dev/null 2>&1")
291
+ make = Autobuild.tool('make')
292
+ system("#{make} -C #{builddir} check-uptodate > /dev/null 2>&1")
291
293
  else
292
294
  true
293
295
  end
294
296
  end
295
297
  end
296
298
  end
297
-
@@ -16,9 +16,10 @@ def installstamp
16
16
  return std_stamp if File.file?(std_stamp)
17
17
 
18
18
  pcfile = File.join(pkgconfig.prefix, "lib", "pkgconfig", "#{name}.pc")
19
- if !File.file?(pcfile)
19
+ unless File.file?(pcfile)
20
20
  raise "cannot find the .pc file for #{name}, tried #{pcfile}"
21
21
  end
22
+
22
23
  pcfile
23
24
  end
24
25
  end
@@ -26,4 +27,3 @@ def self.installed_pkgconfig(name, &block)
26
27
  InstalledPkgConfig.new(name, &block)
27
28
  end
28
29
  end
29
-
@@ -22,9 +22,8 @@ def initialize(options)
22
22
  super
23
23
  end
24
24
 
25
- def prepare
26
- super
27
- @install_mode = File.file?(File.join(srcdir, 'setup.py'))
25
+ def install_mode?
26
+ File.file?(File.join(srcdir, 'setup.py'))
28
27
  end
29
28
 
30
29
  def prepare_for_forced_build
@@ -56,13 +55,17 @@ def python_path
56
55
  raise "Unable to set PYTHONPATH: #{e.message}"
57
56
  end
58
57
 
59
- return output.read.chomp if ret.value.success?
60
- raise 'Unable to set PYTHONPATH: user site directory disabled?'
58
+ if ret.value.success?
59
+ output.read.chomp
60
+ else
61
+ raise 'Unable to set PYTHONPATH: user site directory disabled?'
62
+ end
61
63
  end
62
64
 
63
65
  # Do the build in builddir
64
66
  def build
65
- return unless @install_mode
67
+ return unless install_mode?
68
+
66
69
  command = generate_build_command
67
70
  command << '--force' if @forced
68
71
  progress_start 'building %s [progress not available]',
@@ -74,7 +77,8 @@ def build
74
77
 
75
78
  # Install the result in prefix
76
79
  def install
77
- return unless @install_mode
80
+ return unless install_mode?
81
+
78
82
  command = generate_install_command
79
83
  command << '--force' if @forced
80
84
  progress_start 'installing %s',
@@ -86,7 +90,7 @@ def install
86
90
 
87
91
  def update_environment
88
92
  super
89
- path = @install_mode ? python_path : srcdir
93
+ path = install_mode? ? python_path : srcdir
90
94
  env_add_path 'PYTHONPATH', path
91
95
  end
92
96
  end
@@ -22,7 +22,7 @@ class Ruby < ImporterPackage
22
22
  def initialize(*args)
23
23
  self.rake_setup_task = "default"
24
24
  self.rake_doc_task = "redocs"
25
- self.rake_clean_task = "clean"
25
+ self.rake_clean_task = "clean"
26
26
  self.rake_test_task = "test"
27
27
  self.rake_test_options = []
28
28
 
@@ -36,19 +36,23 @@ def initialize(*args)
36
36
 
37
37
  def with_doc
38
38
  doc_task do
39
- progress_start "generating documentation for %s", :done_message => 'generated documentation for %s' do
39
+ progress_start "generating documentation for %s",
40
+ done_message: 'generated documentation for %s' do
40
41
  run 'doc',
41
- Autobuild.tool_in_path('ruby'), '-S', Autobuild.tool('rake'), rake_doc_task,
42
- :working_directory => srcdir
42
+ Autobuild.tool_in_path('ruby'), '-S',
43
+ Autobuild.tool('rake'), rake_doc_task,
44
+ working_directory: srcdir
43
45
  end
44
46
  end
45
47
  end
46
48
 
47
49
  def with_tests
48
50
  test_utility.task do
49
- progress_start "running tests for %s", :done_message => 'tests passed for %s' do
51
+ progress_start "running tests for %s",
52
+ done_message: 'tests passed for %s' do
50
53
  run 'test',
51
- Autobuild.tool_in_path('ruby'), '-S', Autobuild.tool('rake'), rake_test_task, *rake_test_options,
54
+ Autobuild.tool_in_path('ruby'), '-S',
55
+ Autobuild.tool('rake'), rake_test_task, *rake_test_options,
52
56
  working_directory: srcdir
53
57
  end
54
58
  end
@@ -57,13 +61,15 @@ def with_tests
57
61
  def invoke_rake(setup_task = rake_setup_task)
58
62
  if setup_task && File.file?(File.join(srcdir, 'Rakefile'))
59
63
  run 'post-install',
60
- Autobuild.tool_in_path('ruby'), '-S', Autobuild.tool('rake'), setup_task,
61
- :working_directory => srcdir
64
+ Autobuild.tool_in_path('ruby'), '-S',
65
+ Autobuild.tool('rake'), setup_task,
66
+ working_directory: srcdir
62
67
  end
63
68
  end
64
69
 
65
70
  def install
66
- progress_start "setting up Ruby package %s", :done_message => 'set up Ruby package %s' do
71
+ progress_start "setting up Ruby package %s",
72
+ done_message: 'set up Ruby package %s' do
67
73
  invoke_rake
68
74
  end
69
75
  super
@@ -71,10 +77,11 @@ def install
71
77
 
72
78
  def prepare_for_forced_build # :nodoc:
73
79
  super
74
- %w{ext tmp}.each do |extdir|
80
+ %w[ext tmp].each do |extdir|
75
81
  if File.directory?(extdir)
76
82
  Find.find(extdir) do |file|
77
83
  next if file !~ /\<Makefile\>|\<CMakeCache.txt\>$/
84
+
78
85
  FileUtils.rm_rf file
79
86
  end
80
87
  end
@@ -86,10 +93,11 @@ def prepare_for_rebuild # :nodoc:
86
93
  if rake_clean_task && File.file?(File.join(srcdir, 'Rakefile'))
87
94
  begin
88
95
  run 'clean',
89
- Autobuild.tool_in_path('ruby'), '-S', Autobuild.tool('rake'), rake_clean_task,
90
- :working_directory => srcdir
96
+ Autobuild.tool_in_path('ruby'), '-S',
97
+ Autobuild.tool('rake'), rake_clean_task,
98
+ working_directory: srcdir
91
99
  rescue Autobuild::SubcommandFailed => e
92
- warn "%s: cleaning failed. If this package does not need a clean target,"
100
+ warn "%s: clean failed. If this package does not need a clean target,"
93
101
  warn "%s: set pkg.rake_clean_task = nil in the package definition."
94
102
  warn "%s: see #{e.logfile} for more details"
95
103
  end
@@ -99,9 +107,7 @@ def prepare_for_rebuild # :nodoc:
99
107
  def update_environment
100
108
  env_add_prefix srcdir
101
109
  libdir = File.join(srcdir, 'lib')
102
- if File.directory?(libdir)
103
- env_add_path 'RUBYLIB', libdir
104
- end
110
+ env_add_path 'RUBYLIB', libdir if File.directory?(libdir)
105
111
  end
106
112
  end
107
113
 
@@ -109,4 +115,3 @@ def self.ruby(spec, &proc)
109
115
  Ruby.new(spec, &proc)
110
116
  end
111
117
  end
112
-