autobuild 1.10.0.rc13 → 1.10.0.rc14

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 62f1f8b5be427ce16c5f90acaa29148f6aec1898
4
- data.tar.gz: 3b3e04ed491d7640d8cd66c65623ac50de886a1d
3
+ metadata.gz: 9e04850122480c75777d04748145ca9415f084cc
4
+ data.tar.gz: 8d0247d6239a8d2847c36dee651484b5de6f4698
5
5
  SHA512:
6
- metadata.gz: acc2cabb0c47592702162a230f039e3b2c7138d51ba8a5baa43e62bcb5c0ec8acdc6027a71a3dbad324d839a728bb0606f334556278b7a2c66bb16fc073a58a0
7
- data.tar.gz: ef56847f897e5f2ba1df4635d731aef7e0590a87a0ece26fa667bd74d4ccd4315215672306a3e414cbb49a75ef3a2ebcf42f0209a4c759b8cc89cafda27a307c
6
+ metadata.gz: 3824e574d80cf76b09eff053bd5aa870d10975dfdcc6c9f4e5c5da5869bd4a83d845c828357d3202cf7cf5da141c7ea6182f62cba61931f6bb19c845ebcdf1c4
7
+ data.tar.gz: 4b22b978f8205df7ad38e08e9f7923abd02ef9bcea670a29b71518a36c9a0b301fdbfbff36990653a9f4826d4a25a7a8311775c3ae77608ddf0206b53ef4cf5a
@@ -49,8 +49,8 @@ def each_utility
49
49
  utilities.each { |name, (utl, options)| yield(name, utl, options) }
50
50
  end
51
51
 
52
- def register_utility_class(name, klass, options = Hash.new)
53
- utilities[name] = [klass, options]
52
+ def register_utility_class(name, klass, disabled_by_default: false, **options)
53
+ utilities[name] = [klass, Hash[disabled_by_default: disabled_by_default], options]
54
54
  singleton_class.class_eval do
55
55
  attr_accessor "only_#{name}"
56
56
  attr_accessor "do_#{name}"
@@ -64,11 +64,11 @@ def register_utility_class(name, klass, options = Hash.new)
64
64
  end
65
65
 
66
66
  def create_utility(utility_name, package)
67
- klass, options = utilities[utility_name]
67
+ klass, creation_options, options = utilities[utility_name]
68
68
  if klass
69
- utility = klass.new(utility_name, package)
69
+ utility = klass.new(utility_name, package, **options)
70
70
  package.utilities[utility_name] = utility
71
- utility.enabled = !options[:disabled_by_default]
71
+ utility.enabled = !creation_options[:disabled_by_default]
72
72
  utility
73
73
  else raise ArgumentError, "there is no utility called #{utility_name}, available utilities are #{utilities.keys.sort.join(", ")}"
74
74
  end
@@ -83,12 +83,17 @@ def full_build?
83
83
  end
84
84
  @utilities = Hash.new
85
85
  register_utility_class 'doc', Utility, disabled_by_default: false
86
- register_utility_class 'test', Utility, disabled_by_default: true
86
+ register_utility_class 'test', Utility, disabled_by_default: true, install_on_error: true
87
87
 
88
88
  @colorizer = Pastel.new
89
89
  class << self
90
90
  def color=(flag)
91
- @colorizer = Pastel.new(enabled: flag)
91
+ @colorizer =
92
+ if flag.nil?
93
+ Pastel.new
94
+ else
95
+ Pastel.new(enabled: flag)
96
+ end
92
97
  end
93
98
 
94
99
  def color?
@@ -0,0 +1,10 @@
1
+ module Autobuild
2
+ Git.add_post_hook do |importer, package|
3
+ if File.join(package.srcdir, '.git', 'lfs')
4
+
5
+ package.run 'import', Autobuild.tool(:git), 'lfs', 'pull', importer.remote_name,
6
+ working_directory: package.srcdir
7
+ end
8
+ end
9
+ end
10
+
@@ -150,6 +150,7 @@ def initialize(options)
150
150
  @repository_id = options[:repository_id] || "#{self.class.name}:#{object_id}"
151
151
  @interactive = options[:interactive]
152
152
  @source_id = options[:source_id] || @repository_id
153
+ @post_hooks = Array.new
153
154
  end
154
155
 
155
156
  # Returns a string that identifies the remote repository uniquely
@@ -236,6 +237,57 @@ def update_retry_count(original_error, retry_count)
236
237
  end
237
238
  end
238
239
 
240
+ # A list of hooks that are called after a successful checkout or update
241
+ #
242
+ # They are added either at the instance level with {#add_post_hook} or
243
+ # globally for all importers of a given type with {Importer.add_post_hook}
244
+ attr_reader :post_hooks
245
+
246
+ # Define a post-import hook for all instances of this class
247
+ #
248
+ # @yieldparam [Importer] importer the importer that finished
249
+ # @yieldparam [Package] package the package we're acting on
250
+ # @see Importer#add_post_hook
251
+ def self.add_post_hook(&hook)
252
+ @post_hooks ||= Array.new
253
+ @post_hooks << hook
254
+ end
255
+
256
+ # Enumerate the post-import hooks defined for all instances of this class
257
+ def self.each_post_hook(&hook)
258
+ (@post_hooks || Array.new).each(&hook)
259
+ end
260
+
261
+ # @api private
262
+ #
263
+ # Call the post-import hooks added with {#add_post_hook}
264
+ def execute_post_hooks(package)
265
+ self.class.each_post_hook do |hook|
266
+ hook.call(self, package)
267
+ end
268
+ each_post_hook.each do |block|
269
+ block.call(self, package)
270
+ end
271
+ end
272
+
273
+ # Add a block that should be called when the import has successfully
274
+ # finished
275
+ #
276
+ # @yieldparam [Importer] importer the importer that finished
277
+ # @yieldparam [Package] package the package we're acting on
278
+ # @see Importer.add_post_hook
279
+ def add_post_hook(&hook)
280
+ post_hooks << hook
281
+ end
282
+
283
+ # Enumerate the post-import hooks for this importer
284
+ def each_post_hook(&hook)
285
+ return enum_for(__method__) if !block_given?
286
+
287
+ self.class.each_post_hook(&hook)
288
+ post_hooks.each(&hook)
289
+ end
290
+
239
291
  def perform_update(package,only_local=false)
240
292
  cur_patches = currently_applied_patches(package)
241
293
  needed_patches = self.patches
@@ -243,13 +295,19 @@ def perform_update(package,only_local=false)
243
295
  patch(package, [])
244
296
  end
245
297
 
298
+ last_error = nil
246
299
  retry_count = 0
247
300
  package.progress_start "updating %s"
248
301
  begin
249
302
  update(package,only_local)
303
+ execute_post_hooks(package)
250
304
  rescue Interrupt
251
- raise
305
+ if last_error
306
+ raise last_error
307
+ else raise
308
+ end
252
309
  rescue ::Exception => original_error
310
+ last_error = original_error
253
311
  # If the package is patched, it might be that the update
254
312
  # failed because we needed to unpatch first. Try it out
255
313
  #
@@ -288,13 +346,18 @@ def perform_update(package,only_local=false)
288
346
  end
289
347
 
290
348
  def perform_checkout(package, options = Hash.new)
349
+ last_error = nil
291
350
  package.progress_start "checking out %s", :done_message => 'checked out %s' do
292
351
  retry_count = 0
293
352
  begin
294
353
  checkout(package, options)
354
+ execute_post_hooks(package)
295
355
  rescue Interrupt
296
- raise
356
+ if last_error then raise last_error
357
+ else raise
358
+ end
297
359
  rescue ::Exception => original_error
360
+ last_error = original_error
298
361
  retry_count = update_retry_count(original_error, retry_count)
299
362
  if !retry_count
300
363
  raise
@@ -289,18 +289,28 @@ def resolve_dependency_env(env, set, ops)
289
289
  ops
290
290
  end
291
291
 
292
+ # This package's environment
293
+ def full_env(root = Autobuild.env)
294
+ set = Hash.new
295
+ env = root.dup
296
+ ops = Array.new
297
+ ops = resolve_dependency_env(env, set, ops)
298
+ apply_env(env, set, ops)
299
+ env
300
+ end
301
+
302
+ # Find a file in a path-like environment variable
303
+ def find_in_path(file, envvar = 'PATH')
304
+ full_env.find_in_path(file, envvar)
305
+ end
306
+
292
307
  # Resolves this package's environment into Hash form
293
308
  #
294
309
  # @param [Environment] root the base environment object to update
295
310
  # @return [Hash<String,String>] the full environment
296
311
  # @see Autobuild::Environment#resolved_env
297
312
  def resolved_env(root = Autobuild.env)
298
- set = Hash.new
299
- env = root.dup
300
- ops = Array.new
301
- ops = resolve_dependency_env(env, set, ops)
302
- apply_env(env, set, ops)
303
- env.resolved_env
313
+ full_env.resolved_env
304
314
  end
305
315
 
306
316
  # Called before a forced build. It should remove all the timestamp and
@@ -75,43 +75,8 @@ class << self
75
75
 
76
76
  attr_reader :orogen_options
77
77
 
78
- # Path to the orogen tool
79
- def self.orogen_bin(full_path = false)
80
- if @orogen_bin
81
- @orogen_bin
82
- else
83
- program_name = Autobuild.tool('orogen')
84
- if orogen_path = ENV['PATH'].split(':').find { |p| File.file?(File.join(p, program_name)) }
85
- @orogen_bin = File.join(orogen_path, program_name)
86
- elsif !full_path
87
- program_name
88
- end
89
- end
90
- end
91
-
92
- # Path to the root of the orogen package
93
- def self.orogen_root
94
- if @orogen_root
95
- @orogen_root
96
- elsif orogen_bin = self.orogen_bin(true)
97
- @orogen_root = File.expand_path('../lib', File.dirname(orogen_bin))
98
- end
99
- end
100
-
101
- # The version of orogen, given as a string
102
- #
103
- # It is used to enable/disable some configuration features based on the
104
- # orogen version string
105
- def self.orogen_version
106
- if !@orogen_version && root = orogen_root
107
- version_file = File.join(root, 'orogen', 'version.rb')
108
- version_line = File.readlines(version_file).grep(/VERSION\s*=\s*"/).first
109
- if version_line =~ /.*=\s+"(.+)"$/
110
- @orogen_version = $1
111
- end
112
- end
113
- @orogen_version
114
- end
78
+ # The path to the orogen tool as resolved from {Package#full_env}
79
+ attr_reader :orogen_tool_path
115
80
 
116
81
  # Overrides the global Orocos.orocos_target for this particular package
117
82
  attr_writer :orocos_target
@@ -168,6 +133,8 @@ def orogen_file
168
133
  def initialize(*args, &config)
169
134
  super
170
135
 
136
+ @orogen_tool_path = nil
137
+ @orogen_version = nil
171
138
  @orocos_target = nil
172
139
  @orogen_options = []
173
140
  end
@@ -183,69 +150,44 @@ def update_environment
183
150
  env_add_path 'TYPELIB_RUBY_PLUGIN_PATH', typelib_plugin
184
151
  end
185
152
 
186
- def prepare
187
- # Check if someone provides the pkgconfig/orocos-rtt-TARGET package,
188
- # and if so add it into our dependency list
189
- if rtt = Autobuild::Package["pkgconfig/orocos-rtt-#{orocos_target}"]
190
- if Autobuild.verbose
191
- message "orogen: found #{rtt.name} which provides the RTT"
153
+ # The version of orogen, given as a string
154
+ #
155
+ # It is used to enable/disable some configuration features based on the
156
+ # orogen version string
157
+ def orogen_version
158
+ if !@orogen_version && (root = orogen_root)
159
+ version_file = File.join(root, 'lib', 'orogen', 'version.rb')
160
+ version_line = File.readlines(version_file).grep(/VERSION\s*=\s*"/).first
161
+ if version_line =~ /.*=\s+"(.+)"$/
162
+ @orogen_version = $1
192
163
  end
193
- depends_on rtt.name
194
- end
195
-
196
- # Find out where orogen is, and make sure the configurestamp depend
197
- # on it. Ignore if orogen is too old to have a --base-dir option
198
- if orogen_root = self.class.orogen_root
199
- orogen_tree = source_tree(orogen_root)
200
164
  end
165
+ @orogen_version
166
+ end
201
167
 
202
- # Check if there is an orogen package registered. If it is the case,
203
- # simply depend on it. Otherwise, look out for orogen --base-dir
204
- if Autobuild::Package['orogen']
205
- depends_on "orogen"
206
- elsif orogen_tree
207
- file genstamp => orogen_tree
168
+ def orogen_root
169
+ if orogen_tool_path
170
+ root = File.expand_path(File.join('..', '..'), orogen_tool_path)
171
+ if File.directory?(File.join(root, 'lib', 'orogen'))
172
+ root
173
+ end
208
174
  end
175
+ end
209
176
 
177
+ def prepare
210
178
  file configurestamp => genstamp
179
+ stamps = dependencies.map { |pkg| Autobuild::Package[pkg].installstamp }
211
180
 
212
- # Cache the orogen file name
213
- @orogen_file ||= self.orogen_file
214
-
215
- file genstamp => source_tree(srcdir) do
216
- needs_regen = true
217
- if File.file?(genstamp)
218
- genstamp_mtime = File.stat(genstamp).mtime
219
- dependency_updated = dependencies.any? do |dep|
220
- !File.file?(Package[dep].installstamp) ||
221
- File.stat(Package[dep].installstamp).mtime > genstamp_mtime
222
- end
223
- needs_regen = dependency_updated || !generation_uptodate?
224
- end
225
-
226
- if needs_regen
227
- isolate_errors { regen }
228
- end
181
+ file genstamp => [*stamps, source_tree(srcdir)] do
182
+ isolate_errors { regen }
229
183
  end
230
184
 
231
185
  with_doc
232
186
 
233
187
  super
234
-
235
- dependencies.each do |p|
236
- file genstamp => Package[p].installstamp
237
- end
238
188
  end
239
- def genstamp; File.join(srcdir, '.orogen', 'orogen-stamp') end
240
189
 
241
- def guess_ruby_name
242
- if Autobuild.programs['ruby']
243
- Autobuild.tool('ruby')
244
- else
245
- ruby_bin = RbConfig::CONFIG['RUBY_INSTALL_NAME']
246
- Autobuild.programs['ruby'] = ruby_bin
247
- end
248
- end
190
+ def genstamp; File.join(srcdir, '.orogen', 'orogen-stamp') end
249
191
 
250
192
  def add_cmd_to_cmdline(cmd, cmdline)
251
193
  if cmd =~ /^([\w-]+)/
@@ -276,14 +218,22 @@ def regen
276
218
  end
277
219
  end
278
220
 
279
- if (version = Orogen.orogen_version)
280
- if version >= "1.0"
281
- cmdline << "--parallel-build=#{parallel_build_level}"
282
- end
283
- if version >= "1.1"
284
- cmdline << "--type-export-policy=#{Orogen.default_type_export_policy}"
285
- cmdline << "--transports=#{Orogen.transports.sort.uniq.join(",")}"
286
- end
221
+ @orogen_tool_path = find_in_path 'orogen'
222
+ if !orogen_tool_path
223
+ raise ArgumentError, "cannot find 'orogen' in #{resolved_env['PATH']}"
224
+ end
225
+
226
+ version = orogen_version
227
+ if !version
228
+ raise ArgumentError, "cannot determine the orogen version"
229
+ end
230
+
231
+ if (version >= "1.0")
232
+ cmdline << "--parallel-build=#{parallel_build_level}"
233
+ end
234
+ if (version >= "1.1")
235
+ cmdline << "--type-export-policy=#{Orogen.default_type_export_policy}"
236
+ cmdline << "--transports=#{Orogen.transports.sort.uniq.join(",")}"
287
237
  end
288
238
 
289
239
  # Now, add raw options
@@ -317,13 +267,10 @@ def regen
317
267
  # target says
318
268
  needs_regen ||= !generation_uptodate?
319
269
 
320
- # Finally, verify that orogen itself did not change
321
- needs_regen ||= (Rake::Task[Orogen.orogen_root].timestamp > Rake::Task[genstamp].timestamp)
322
-
323
270
  if needs_regen
324
271
  progress_start "generating oroGen %s", :done_message => 'generated oroGen %s' do
325
272
  in_dir(srcdir) do
326
- run 'orogen', guess_ruby_name, '-S', self.class.orogen_bin, *cmdline
273
+ run 'orogen', Autobuild.tool('ruby'), '-S', orogen_tool_path, *cmdline
327
274
  File.open(genstamp, 'w') do |io|
328
275
  io.print cmdline.join("\n")
329
276
  end
@@ -9,6 +9,8 @@ class Ruby < ImporterPackage
9
9
  # The Rake task that is used to run tests. Defaults to "test".
10
10
  # Set to nil to disable tests for this package
11
11
  attr_accessor :rake_test_task
12
+ # Options that should be passed to the rake task
13
+ attr_accessor :rake_test_options
12
14
  # The Rake task that is used to run cleanup. Defaults to "clean".
13
15
  # Set to nil to disable tests for this package
14
16
  attr_accessor :rake_clean_task
@@ -18,6 +20,7 @@ def initialize(*args)
18
20
  self.rake_doc_task = "redocs"
19
21
  self.rake_clean_task = "clean"
20
22
  self.rake_test_task = "test"
23
+ self.rake_test_options = []
21
24
 
22
25
  super
23
26
  exclude << /\.so$/
@@ -41,8 +44,8 @@ def with_tests
41
44
  test_utility.task do
42
45
  progress_start "running tests for %s", :done_message => 'tests passed for %s' do
43
46
  run 'test',
44
- Autobuild.tool_in_path('ruby'), '-S', Autobuild.tool('rake'), rake_test_task,
45
- :working_directory => srcdir
47
+ Autobuild.tool_in_path('ruby'), '-S', Autobuild.tool('rake'), rake_test_task, *rake_test_options,
48
+ working_directory: srcdir
46
49
  end
47
50
  end
48
51
  end
@@ -402,8 +402,16 @@ def self.run(target, phase, *command)
402
402
  end
403
403
 
404
404
  if !status.exitstatus || status.exitstatus > 0
405
- raise Failed.new(status.exitstatus, nil),
406
- "'#{command.join(' ')}' returned status #{status.exitstatus}"
405
+ if status.termsig == 2 # SIGINT == 2
406
+ raise Interrupt, "subcommand #{command.join(' ')} interrupted"
407
+ end
408
+ if status.termsig
409
+ raise Failed.new(status.exitstatus, nil),
410
+ "'#{command.join(' ')}' terminated by signal #{status.termsig}"
411
+ else
412
+ raise Failed.new(status.exitstatus, nil),
413
+ "'#{command.join(' ')}' returned status #{status.exitstatus}"
414
+ end
407
415
  end
408
416
 
409
417
  duration = Time.now - start_time
@@ -21,19 +21,17 @@ def tool(name)
21
21
  programs[name.to_sym] || programs[name.to_s] || name.to_s
22
22
  end
23
23
 
24
- def find_in_path(file)
25
- path = ENV['PATH'].split(File::PATH_SEPARATOR).
26
- find { |dir| File.exist?(File.join(dir, file)) }
27
- if path
28
- return File.join(path, file)
29
- end
24
+ # Find a file in a given path-like variable
25
+ def find_in_path(file, envvar = 'PATH')
26
+ env.find_in_path(file, envvar)
30
27
  end
31
28
 
32
29
  # Resolves the absolute path to a given tool
33
30
  def tool_in_path(name)
34
31
  path, path_name, path_env = programs_in_path[name]
35
32
  current = tool(name)
36
- if path_env != ENV['PATH'] || path_name != current
33
+ env_PATH = env.resolved_env['PATH']
34
+ if (path_env != env_PATH) || (path_name != current)
37
35
  # Delete the current entry given that it is invalid
38
36
  programs_in_path.delete(name)
39
37
  if current[0, 1] == "/"
@@ -53,7 +51,7 @@ def tool_in_path(name)
53
51
  elsif !File.executable?(path)
54
52
  raise ArgumentError, "tool #{name} is set to #{current}, but this resolves to #{path} which is not executable"
55
53
  end
56
- programs_in_path[name] = [path, current, ENV['PATH']]
54
+ programs_in_path[name] = [path, current, env_PATH]
57
55
  end
58
56
 
59
57
  return path
@@ -11,7 +11,15 @@ class Utility
11
11
  # nil, will use the package's source directory
12
12
  attr_accessor :source_ref_dir
13
13
 
14
- def initialize(name, package)
14
+ # Whether #install should be called even if the task failed
15
+ #
16
+ # The default is false. Set it to true for instance if the utility
17
+ # results are a report of the success/errors (e.g. test run results)
18
+ def install_on_error?
19
+ @install_on_error
20
+ end
21
+
22
+ def initialize(name, package, install_on_error: false)
15
23
  @name = name
16
24
  @task = nil
17
25
  @package = package
@@ -20,6 +28,7 @@ def initialize(name, package)
20
28
  @source_ref_dir = nil
21
29
  @source_dir = nil
22
30
  @target_dir = nil
31
+ @install_on_error = !!install_on_error
23
32
  end
24
33
 
25
34
  # Directory in which the utility will generate some files The
@@ -54,6 +63,8 @@ def source_dir
54
63
  def target_dir
55
64
  if @target_dir
56
65
  File.expand_path(@target_dir, File.expand_path(Autobuild.send("#{name}_prefix") || name, package.prefix))
66
+ else
67
+ File.join(package.logdir, "#{name}-results", package.name)
57
68
  end
58
69
  end
59
70
 
@@ -95,6 +106,10 @@ def call_task_block
95
106
  rescue Interrupt
96
107
  raise
97
108
  rescue ::Exception => e
109
+ if install_on_error? && !@installed && target_dir
110
+ install
111
+ end
112
+
98
113
  if Autobuild.send("pass_#{name}_errors")
99
114
  raise
100
115
  else
@@ -146,6 +161,7 @@ def install
146
161
  FileUtils.rm_rf target_dir
147
162
  FileUtils.mkdir_p File.dirname(target_dir)
148
163
  FileUtils.cp_r source_dir, target_dir
164
+ Autoproj.message " copied #{name} results for #{package.name} to #{target_dir}"
149
165
 
150
166
  @installed = true
151
167
  end
@@ -1,5 +1,5 @@
1
1
  module Autobuild
2
- VERSION = "1.10.0.rc13" unless defined? Autobuild::VERSION
2
+ VERSION = "1.10.0.rc14" unless defined? Autobuild::VERSION
3
3
  end
4
4
 
5
5
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: autobuild
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.10.0.rc13
4
+ version: 1.10.0.rc14
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sylvain Joyeux
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-08-11 00:00:00.000000000 Z
11
+ date: 2016-08-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake
@@ -174,6 +174,7 @@ files:
174
174
  - lib/autobuild/import/archive.rb
175
175
  - lib/autobuild/import/cvs.rb
176
176
  - lib/autobuild/import/darcs.rb
177
+ - lib/autobuild/import/git-lfs.rb
177
178
  - lib/autobuild/import/git.rb
178
179
  - lib/autobuild/import/hg.rb
179
180
  - lib/autobuild/import/svn.rb
@@ -227,3 +228,4 @@ signing_key:
227
228
  specification_version: 4
228
229
  summary: Library to handle build systems and import mechanisms
229
230
  test_files: []
231
+ has_rdoc: