autoproj 2.0.0.rc37 → 2.0.0.rc38

Sign up to get free protection for your applications and to get access to all the features.
Files changed (65) hide show
  1. checksums.yaml +4 -4
  2. data/.travis.yml +4 -2
  3. data/Rakefile +1 -1
  4. data/bin/autoproj_bootstrap +34 -2
  5. data/bin/autoproj_bootstrap.in +4 -2
  6. data/bin/autoproj_install +34 -2
  7. data/bin/autoproj_install.in +4 -2
  8. data/lib/autoproj.rb +9 -2
  9. data/lib/autoproj/autobuild.rb +13 -742
  10. data/lib/autoproj/autobuild_extensions/archive_importer.rb +44 -0
  11. data/lib/autoproj/autobuild_extensions/dsl.rb +439 -0
  12. data/lib/autoproj/autobuild_extensions/git.rb +116 -0
  13. data/lib/autoproj/autobuild_extensions/package.rb +159 -0
  14. data/lib/autoproj/autobuild_extensions/svn.rb +11 -0
  15. data/lib/autoproj/cli/base.rb +17 -18
  16. data/lib/autoproj/cli/clean.rb +1 -2
  17. data/lib/autoproj/cli/envsh.rb +1 -2
  18. data/lib/autoproj/cli/inspection_tool.rb +12 -21
  19. data/lib/autoproj/cli/locate.rb +130 -73
  20. data/lib/autoproj/cli/main.rb +31 -5
  21. data/lib/autoproj/cli/main_plugin.rb +79 -0
  22. data/lib/autoproj/cli/main_test.rb +19 -5
  23. data/lib/autoproj/cli/osdeps.rb +1 -2
  24. data/lib/autoproj/cli/patcher.rb +21 -0
  25. data/lib/autoproj/cli/query.rb +34 -41
  26. data/lib/autoproj/cli/show.rb +121 -52
  27. data/lib/autoproj/cli/status.rb +4 -5
  28. data/lib/autoproj/cli/tag.rb +1 -1
  29. data/lib/autoproj/cli/test.rb +7 -6
  30. data/lib/autoproj/cli/update.rb +8 -22
  31. data/lib/autoproj/cli/versions.rb +1 -2
  32. data/lib/autoproj/configuration.rb +1 -1
  33. data/lib/autoproj/environment.rb +2 -7
  34. data/lib/autoproj/exceptions.rb +10 -8
  35. data/lib/autoproj/find_workspace.rb +46 -12
  36. data/lib/autoproj/installation_manifest.rb +34 -25
  37. data/lib/autoproj/local_package_set.rb +86 -0
  38. data/lib/autoproj/manifest.rb +448 -503
  39. data/lib/autoproj/metapackage.rb +31 -5
  40. data/lib/autoproj/ops/configuration.rb +46 -45
  41. data/lib/autoproj/ops/import.rb +150 -60
  42. data/lib/autoproj/ops/install.rb +25 -1
  43. data/lib/autoproj/ops/loader.rb +4 -1
  44. data/lib/autoproj/ops/main_config_switcher.rb +4 -4
  45. data/lib/autoproj/ops/snapshot.rb +4 -3
  46. data/lib/autoproj/os_package_installer.rb +105 -46
  47. data/lib/autoproj/os_package_resolver.rb +63 -36
  48. data/lib/autoproj/package_definition.rb +1 -0
  49. data/lib/autoproj/package_managers/apt_dpkg_manager.rb +30 -27
  50. data/lib/autoproj/package_managers/bundler_manager.rb +64 -18
  51. data/lib/autoproj/package_managers/gem_manager.rb +4 -2
  52. data/lib/autoproj/package_managers/manager.rb +26 -7
  53. data/lib/autoproj/package_managers/shell_script_manager.rb +4 -4
  54. data/lib/autoproj/package_managers/zypper_manager.rb +1 -1
  55. data/lib/autoproj/package_manifest.rb +154 -137
  56. data/lib/autoproj/package_selection.rb +16 -2
  57. data/lib/autoproj/package_set.rb +352 -309
  58. data/lib/autoproj/query.rb +13 -1
  59. data/lib/autoproj/system.rb +2 -2
  60. data/lib/autoproj/test.rb +164 -11
  61. data/lib/autoproj/variable_expansion.rb +15 -42
  62. data/lib/autoproj/vcs_definition.rb +93 -76
  63. data/lib/autoproj/version.rb +1 -1
  64. data/lib/autoproj/workspace.rb +116 -80
  65. metadata +10 -2
@@ -0,0 +1,44 @@
1
+ module Autoproj
2
+ module AutobuildExtensions
3
+ module ArchiveImporter
4
+ # Reconfigures this importer to use an already existing checkout located
5
+ # in the given autoproj root
6
+ #
7
+ # @param [Autobuild::Package] the package we are dealing with
8
+ # @param [Autoproj::InstallationManifest] the other root's installation
9
+ # manifest
10
+ def pick_from_autoproj_root(package, installation_manifest)
11
+ # Get the cachefile w.r.t. the autoproj root
12
+ cachefile = Pathname.new(self.cachefile).
13
+ relative_path_from(Pathname.new(ws.root_dir)).to_s
14
+
15
+ # The cachefile in the other autoproj installation
16
+ other_cachefile = File.join(installation_manifest.path, cachefile)
17
+ if File.file?(other_cachefile)
18
+ self.relocate("file://" + other_cachefile)
19
+ true
20
+ end
21
+ end
22
+
23
+ def snapshot(package, target_dir = nil, options = Hash.new)
24
+ result = Hash[
25
+ 'mode' => mode,
26
+ 'no_subdirectory' => !has_subdirectory?,
27
+ 'archive_dir' => archive_dir || tardir]
28
+
29
+ if target_dir
30
+ archive_dir = File.join(target_dir, 'archives')
31
+ FileUtils.mkdir_p archive_dir
32
+ FileUtils.cp @cachefile, archive_dir
33
+
34
+ result['url'] = "file://$AUTOPROJ_SOURCE_DIR/archives/#{File.basename(@cachefile)}"
35
+ else
36
+ result['url'] = @url.to_s
37
+ end
38
+
39
+ result
40
+ end
41
+ end
42
+ end
43
+ end
44
+
@@ -0,0 +1,439 @@
1
+ require 'find'
2
+ require 'fileutils'
3
+ require 'autobuild'
4
+ require 'set'
5
+
6
+ module Autoproj
7
+ # @deprecated use Workspace.config.ruby_executable instead, or
8
+ # Autoproj.config.ruby_executable if you don't have a workspace context
9
+ # object
10
+ def self.ruby_executable
11
+ config.ruby_executable
12
+ end
13
+
14
+ module CmdLine
15
+ # @deprecated use Workspace.config.ruby_executable instead, or
16
+ # Autoproj.config.ruby_executable if you don't have a workspace context
17
+ # object
18
+ def self.ruby_executable
19
+ Autoproj.config.ruby_executable
20
+ end
21
+ end
22
+
23
+ # @api private
24
+ #
25
+ # Helper method that extracts the package name from a Rake-style package
26
+ # definition (e.g. package_name => package_deps)
27
+ def self.package_name_from_options(spec)
28
+ if spec.kind_of?(Hash)
29
+ spec.to_a.first.first.to_str
30
+ else
31
+ spec.to_str
32
+ end
33
+ end
34
+
35
+ # @deprecated use Autoproj.workspace.in_package_set or add a proper Loader object to your
36
+ # class
37
+ def self.in_package_set(package_set, path, &block)
38
+ Autoproj.warn_deprecated __method__, "use Autoproj.workspace.in_package_set instead"
39
+ Autoproj.workspace.in_package_set(package_set, path, &block)
40
+ end
41
+ # @deprecated use Autoproj.workspace.current_file or add a proper Loader object to your
42
+ # class
43
+ def self.current_file
44
+ Autoproj.warn_deprecated __method__, "use AUtoproj.workspace.current_file instead"
45
+ Autoproj.workspace.current_file
46
+ end
47
+ # @deprecated use Autoproj.workspace.current_package_set or add a proper Loader object to your
48
+ # class
49
+ def self.current_package_set
50
+ Autoproj.warn_deprecated __method__, "use Autoproj.workspace.current_package_set instead"
51
+ Autoproj.workspace.current_package_set
52
+ end
53
+
54
+ # @deprecated use {Workspace#define_package} directly instead.
55
+ # Beware that the return value changed from Autobuild::Package to
56
+ # Autoproj::PackageDefinition
57
+ def self.define(package_type, spec, &block)
58
+ Autoproj.warn_deprecated __method__, "use Autoproj.workspace.define_package instead (and beware that the return value changed from Autobuild::Package to Autoproj::PackageDefinition)"
59
+ workspace.define_package(package_type, spec, block, *current_file).
60
+ autobuild
61
+ end
62
+
63
+ def self.loaded_autobuild_files
64
+ Autoproj.warn_deprecated __method__, "use Autoproj.workspace.loaded_autobuild_files"
65
+ Autoproj.workspace.loaded_autobuild_files
66
+ end
67
+
68
+ def self.import_autobuild_file(package_set, path)
69
+ Autoproj.warn_deprecated __method__, "use Autoproj.workspace.import_autobuild_file"
70
+ Autoproj.workspace.import_autobuild_file(package_set, path)
71
+ end
72
+
73
+ def self.find_topmost_directory_containing(dir, glob_pattern = nil)
74
+ result = nil
75
+ while dir != "/"
76
+ match = false
77
+ if glob_pattern
78
+ if !Dir.glob(File.join(dir, glob_pattern)).empty?
79
+ match = true
80
+ end
81
+ end
82
+
83
+ if !match && block_given? && yield(dir)
84
+ match = true
85
+ end
86
+ if !match && result
87
+ return result
88
+ elsif match
89
+ result = dir
90
+ end
91
+
92
+ dir = File.dirname(dir)
93
+ end
94
+ end
95
+
96
+ # Tries to find a handler automatically for 'full_path'
97
+ def self.package_handler_for(full_path)
98
+ if !Dir.enum_for(:glob, File.join(full_path, "*.orogen")).to_a.empty?
99
+ return "orogen_package", full_path
100
+ elsif File.file?(File.join(full_path, "CMakeLists.txt"))
101
+ toplevel_dir = find_topmost_directory_containing(full_path) do |dir|
102
+ cmakelists = File.join(dir, 'CMakeLists.txt')
103
+ File.file?(cmakelists) &&
104
+ (File.read(cmakelists) =~ /PROJECT/i)
105
+ end
106
+ toplevel_dir ||= find_topmost_directory_containing(full_path, 'CMakeLists.txt')
107
+
108
+ return "cmake_package", toplevel_dir
109
+ elsif dir = find_topmost_directory_containing(full_path, "Rakefile") ||
110
+ find_topmost_directory_containing(full_path, "lib/*.rb")
111
+
112
+ return "ruby_package", dir
113
+ end
114
+ end
115
+ end
116
+
117
+ def ignore(*paths)
118
+ paths.each do |p|
119
+ Autobuild.ignore(p)
120
+ end
121
+ end
122
+
123
+ # Adds a new setup block to an existing package
124
+ def setup_package(package_name, workspace: Autoproj.workspace, &block)
125
+ if !block
126
+ raise ConfigError.new, "you must give a block to #setup_package"
127
+ end
128
+
129
+ package_definition = workspace.manifest.find_package_definition(package_name)
130
+ if !package_definition
131
+ raise ConfigError.new, "#{package_name} is not a known package"
132
+ elsif package_definition.autobuild.kind_of?(Autobuild::DummyPackage)
133
+ # Nothing to do!
134
+ else
135
+ package_definition.add_setup_block(block)
136
+ end
137
+ end
138
+
139
+ # Common setup for packages
140
+ def package_common(package_type, spec, workspace: Autoproj.workspace, &block)
141
+ package_name = Autoproj.package_name_from_options(spec)
142
+
143
+ if existing_package = workspace.manifest.find_package_definition(package_name)
144
+ current_file = workspace.current_file[1]
145
+ old_file = existing_package.file
146
+ Autoproj.warn "#{package_name} from #{current_file} is overridden by the definition in #{old_file}"
147
+ return existing_package.autobuild
148
+ end
149
+
150
+ pkg = workspace.define_package(package_type, spec, block, *workspace.current_file)
151
+ pkg.autobuild.srcdir = pkg.name
152
+ pkg
153
+ end
154
+
155
+ def import_package(name, workspace: Autoproj.workspace, &block)
156
+ package_common(:import, name, workspace: Autoproj.workspace, &block)
157
+ end
158
+
159
+ def common_make_based_package_setup(pkg)
160
+ unless pkg.has_doc? && pkg.doc_dir
161
+ pkg.with_doc do
162
+ doc_html = File.join(pkg.builddir, 'doc', 'html')
163
+ if File.directory?(doc_html)
164
+ pkg.doc_dir = doc_html
165
+ end
166
+ end
167
+ end
168
+ if !pkg.test_utility.has_task?
169
+ if !pkg.test_utility.source_dir
170
+ test_dir = File.join(pkg.srcdir, 'test')
171
+ if File.directory?(test_dir)
172
+ pkg.test_utility.source_dir = File.join(pkg.builddir, 'test', 'results')
173
+ end
174
+ end
175
+
176
+ if pkg.test_utility.source_dir
177
+ pkg.with_tests
178
+ end
179
+ end
180
+ end
181
+
182
+ # Define a cmake package
183
+ #
184
+ # Example:
185
+ #
186
+ # cmake_package 'package_name' do |pkg|
187
+ # pkg.define "CMAKE_BUILD_TYPE", "Release"
188
+ # end
189
+ #
190
+ # +pkg+ is an Autobuild::CMake instance. See the Autobuild API for more
191
+ # information.
192
+ def cmake_package(name, workspace: Autoproj.workspace)
193
+ package_common(:cmake, name, workspace: workspace) do |pkg|
194
+ pkg.depends_on 'cmake'
195
+ common_make_based_package_setup(pkg)
196
+ yield(pkg) if block_given?
197
+ end
198
+ end
199
+
200
+ # Define an autotools package
201
+ #
202
+ # Example:
203
+ # autotools_package 'package_name' do |pkg|
204
+ # pkg.configureflags << "--enable-llvm"
205
+ # end
206
+ #
207
+ # +pkg+ is an Autobuild::Autotools instance. See the Autobuild API for more
208
+ # information.
209
+ def autotools_package(name, workspace: Autoproj.workspace)
210
+ package_common(:autotools, name, workspace: workspace) do |pkg|
211
+ pkg.depends_on 'autotools'
212
+ common_make_based_package_setup(pkg)
213
+ yield(pkg) if block_given?
214
+ end
215
+ end
216
+
217
+ # @deprecated use Autoproj.env.set instead
218
+ def env_set(name, value)
219
+ Autoproj.warn_deprecated __method__, "use Autoproj.env.set instead"
220
+ Autoproj.env.set(name, value)
221
+ end
222
+
223
+ # @deprecated use Autoproj.env.add instead
224
+ def env_add(name, value)
225
+ Autoproj.warn_deprecated __method__, "use Autoproj.env.add instead"
226
+ Autoproj.env.add(name, value)
227
+ end
228
+
229
+
230
+ # Defines a Ruby package
231
+ #
232
+ # Example:
233
+ #
234
+ # ruby_package 'package_name' do |pkg|
235
+ # pkg.doc_target = 'doc'
236
+ # end
237
+ #
238
+ # +pkg+ is an Autobuild::Importer instance. See the Autobuild API for more
239
+ # information.
240
+ def ruby_package(name, workspace: Autoproj.workspace)
241
+ package_common(:ruby, name, workspace: workspace) do |pkg|
242
+ pkg.prefix = pkg.srcdir
243
+
244
+ # Documentation code. Ignore if the user provided its own documentation
245
+ # task, or disabled the documentation generation altogether by setting
246
+ # rake_doc_task to nil
247
+ if !pkg.has_doc? && pkg.rake_doc_task
248
+ pkg.with_doc
249
+ end
250
+ if !pkg.test_utility.has_task?
251
+ if !pkg.test_utility.source_dir
252
+ test_dir = File.join(pkg.srcdir, 'test')
253
+ if File.directory?(test_dir)
254
+ pkg.test_utility.source_dir = File.join(pkg.srcdir, '.test-results')
255
+ FileUtils.mkdir_p pkg.test_utility.source_dir
256
+ end
257
+ end
258
+
259
+ if pkg.test_utility.source_dir
260
+ pkg.with_tests
261
+ end
262
+ end
263
+
264
+ yield(pkg) if block_given?
265
+ end
266
+ end
267
+
268
+ # Defines an oroGen package. By default, autoproj will look for an orogen file
269
+ # called package_basename.orogen if the package is called dir/package_basename
270
+ #
271
+ # Example:
272
+ # orogen_package 'package_name' do |pkg|
273
+ # pkg.orogen_file = "my.orogen"
274
+ # pkg.corba = false
275
+ # end
276
+ #
277
+ # +pkg+ is an Autobuild::Orogen instance. See the Autobuild API for more
278
+ # information.
279
+ def orogen_package(name, workspace: Autoproj.workspace)
280
+ package_common(:orogen, name, workspace: workspace) do |pkg|
281
+ common_make_based_package_setup(pkg)
282
+ yield(pkg) if block_given?
283
+ end
284
+ end
285
+
286
+ # Declare that the packages declared in the block should be built only on the
287
+ # given operating system. OS descriptions are space-separated strings containing
288
+ # OS name and version.
289
+ #
290
+ # The block will simply be ignored if run on another architecture
291
+ def only_on(*architectures)
292
+ architectures = architectures.map do |name|
293
+ if name.respond_to?(:to_str)
294
+ [name]
295
+ else name
296
+ end
297
+ end
298
+
299
+ os_names, os_versions = Autoproj.workspace.operating_system
300
+ matching_archs = architectures.find_all { |arch| os_names.include?(arch[0].downcase) }
301
+ if matching_archs.empty?
302
+ return
303
+ elsif matching_archs.none? { |arch| !arch[1] || os_versions.include?(arch[1].downcase) }
304
+ return
305
+ end
306
+
307
+ yield
308
+ end
309
+
310
+ # Declare that the packages declared in the block should not be built in the
311
+ # given operating system. OS descriptions are space-separated strings containing
312
+ # OS name and version.
313
+ #
314
+ # An error will occur if the user tries to build it on one of those
315
+ # architectures
316
+ def not_on(*architectures)
317
+ architectures = architectures.map do |name|
318
+ if name.respond_to?(:to_str)
319
+ [name]
320
+ else name
321
+ end
322
+ end
323
+
324
+ os_names, os_versions = Autoproj.workspace.operating_system
325
+ matching_archs = architectures.find_all { |arch| os_names.include?(arch[0].downcase) }
326
+ if matching_archs.empty?
327
+ return yield
328
+ elsif matching_archs.all? { |arch| arch[1] && !os_versions.include?(arch[1].downcase) }
329
+ return yield
330
+ end
331
+
332
+ # Simply get the current list of packages, yield the block, and exclude all
333
+ # packages that have been added
334
+ manifest = Autoproj.workspace.manifest
335
+ current_packages = manifest.each_autobuild_package.map(&:name).to_set
336
+ yield
337
+ new_packages = manifest.each_autobuild_package.map(&:name).to_set -
338
+ current_packages
339
+
340
+ new_packages.each do |pkg_name|
341
+ manifest.exclude_package(pkg_name, "#{pkg_name} is disabled on this operating system")
342
+ end
343
+ end
344
+
345
+ # Defines an import-only package, i.e. a package that is simply checked out but
346
+ # not built in any way
347
+ def source_package(options, workspace: Autoproj.workspace)
348
+ package_common(options, workspace: workspace) do |pkg|
349
+ pkg.srcdir = pkg.name
350
+ yield(pkg) if block_given?
351
+ end
352
+ end
353
+
354
+ # @deprecated use Autoproj.config.declare instead
355
+ def configuration_option(*opts, &block)
356
+ Autoproj.warn_deprecated __method__, "use Autoproj.config.declare instead"
357
+ Autoproj.config.declare(*opts, &block)
358
+ end
359
+
360
+ # @deprecated use Autoproj.config.get instead
361
+ def user_config(key)
362
+ Autoproj.warn_deprecated __method__, "use Autoproj.config.get instead"
363
+ Autoproj.config.get(key)
364
+ end
365
+
366
+ def package(name)
367
+ Autoproj.workspace.manifest.find_autobuild_package(name)
368
+ end
369
+
370
+ # Returns true if +name+ is a valid package and is neither excluded nor ignored
371
+ # from the build
372
+ def package_selected?(name)
373
+ Autoproj.workspace.manifest.package_selected?(name, false)
374
+ end
375
+
376
+ # Returns true if +name+ is a valid package and is included in the build
377
+ def package_enabled?(name)
378
+ Autoproj.workspace.manifest.package_enabled?(name, false)
379
+ end
380
+
381
+ # If used in init.rb, allows to disable automatic imports from specific package
382
+ # sets
383
+ def disable_imports_from(name)
384
+ raise NotImplementedError, "not implemented in autoproj v2"
385
+ end
386
+
387
+ # Moves the given package to a new subdirectory
388
+ def move_package(name, new_dir)
389
+ Autoproj.workspace.manifest.move_package(name, new_dir)
390
+ end
391
+
392
+ # Removes all the packages currently added from the given metapackage
393
+ #
394
+ # Calling this function will make sure that the given metapackage is now empty.
395
+ def clear_metapackage(name)
396
+ meta = Autoproj.workspace.manifest.metapackage(name)
397
+ meta.clear
398
+ end
399
+
400
+ # Declares a new metapackage, or adds packages to an existing one
401
+ def metapackage(name, *packages)
402
+ Autoproj.workspace.manifest.metapackage(name, *packages)
403
+ end
404
+
405
+ # This can be used only during the load of a package set
406
+ #
407
+ # It defines the set of packages that will be built if 'package_set_name' is
408
+ # used. By default, all of the package set's packages are included. After a call
409
+ # to default_packages, only the packages listed (and their dependencies) are.
410
+ def default_packages(*names)
411
+ pkg_set = Autoproj.current_package_set
412
+ clear_metapackage(pkg_set.name)
413
+ metapackage(pkg_set.name, *names)
414
+ end
415
+
416
+ # This can be used only during the load of a package set
417
+ #
418
+ # It removes the given packages from the set of packages that will be built if
419
+ # 'package_set_name' is used. By default, all of the package set's packages are
420
+ # included. After a call to default_packages, only the packages listed (and
421
+ # their dependencies) are.
422
+ def remove_from_default(*names)
423
+ pkg_set = Autoproj.current_package_set
424
+ metapackage = Autoproj.workspace.manifest.metapackage(pkg_set.name)
425
+ names.each do |pkg_name|
426
+ metapackage.remove(pkg_name)
427
+ end
428
+ end
429
+
430
+ def renamed_package(current_name, old_name, options)
431
+ if options[:obsolete] && !Autoproj.workspace.manifest.explicitely_selected_in_layout?(old_name)
432
+ import_package old_name
433
+ Autoproj.workspace.manifest.exclude_package old_name, "#{old_name} has been renamed to #{current_name}, you still have the option of using the old name by adding '- #{old_name}' explicitely in the layout in autoproj/manifest, but be warned that the name will stop being usable at all in the near future"
434
+ else
435
+ metapackage old_name, current_name
436
+ end
437
+ end
438
+
439
+