autobuild 1.12.3 → 1.13.0.pre1

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.
@@ -39,7 +39,7 @@ def configurestamp; "#{builddir}/config.status" end
39
39
 
40
40
  def initialize(options)
41
41
  @using = Hash.new
42
- @configureflags = []
42
+ @configureflags = []
43
43
  @aclocal_flags = Array.new
44
44
  @autoheader_flags = Array.new
45
45
  @autoconf_flags = Array.new
@@ -70,29 +70,29 @@ def with_tests(target = 'test', &block)
70
70
  common_utility_handling(test_utility, target, &block)
71
71
  end
72
72
 
73
- # Overrides the default behaviour w.r.t. autotools script generation
74
- #
75
- # Use it like that:
76
- # * to force a generation step (skipping autodetection), do
77
- # pkg.use <program> => true
78
- # For instance, for aclocal
79
- # pkg.use :aclocal => true
80
- #
81
- # * to force a generation step, overriding the program defined on Autobuild
82
- # pkg.use <program> => true
83
- # For instance, for autoconf
84
- # pkg.use :autoconf => 'my_autoconf_program'
85
- #
86
- # * to disable a generation step, do
87
- # pkg.use <program> => false
88
- # For instance, for automake
89
- # pkg.use :automake => false
90
- #
91
- # * to restore autodetection, do
92
- # pkg.use <program> => nil
93
- # For instance, for automake
94
- # pkg.use :automake => nil
95
- #
73
+ # Overrides the default behaviour w.r.t. autotools script generation
74
+ #
75
+ # Use it like that:
76
+ # * to force a generation step (skipping autodetection), do
77
+ # pkg.use <program> => true
78
+ # For instance, for aclocal
79
+ # pkg.use :aclocal => true
80
+ #
81
+ # * to force a generation step, overriding the program defined on Autobuild
82
+ # pkg.use <program> => true
83
+ # For instance, for autoconf
84
+ # pkg.use :autoconf => 'my_autoconf_program'
85
+ #
86
+ # * to disable a generation step, do
87
+ # pkg.use <program> => false
88
+ # For instance, for automake
89
+ # pkg.use :automake => false
90
+ #
91
+ # * to restore autodetection, do
92
+ # pkg.use <program> => nil
93
+ # For instance, for automake
94
+ # pkg.use :automake => nil
95
+ #
96
96
  def use(*programs)
97
97
  programs =
98
98
  if programs.size == 1
@@ -152,6 +152,8 @@ def import(options = Hash.new)
152
152
  end
153
153
  end
154
154
 
155
+ class UnexpectedConfigStatusOutput < RuntimeError; end
156
+
155
157
  def prepare
156
158
  super
157
159
  autodetect_needed_stages
@@ -162,22 +164,22 @@ def prepare
162
164
  FileUtils.rm_f fresh_checkout_mark
163
165
  end
164
166
 
165
- # Check if config.status has been generated with the
166
- # same options than the ones in configureflags
167
+ # Check if config.status has been generated with the
168
+ # same options than the ones in configureflags
167
169
  #
168
170
  # If it is not the case, remove it to force reconfiguration
169
- configureflags.flatten!
170
- if File.exist?(configurestamp)
171
- output = run('prepare', configurestamp, '--version').
172
- grep(/with options/).first.chomp
173
- if !output
174
- raise "invalid output of config.status --version, expected a line starting with `with options`"
171
+ if File.exist?(configurestamp)
172
+ output = run('prepare', configurestamp, '--version').
173
+ grep(/with options/).first
174
+ if output && (match = /with options "(.*)"/.match(output))
175
+ options = Shellwords.shellwords(match[1])
176
+ else
177
+ raise UnexpectedConfigStatusOutput, "invalid output of config.status --version, expected a line with `with options \"OPTIONS\"`"
175
178
  end
176
- options = Shellwords.shellwords(output.scan(/with options "(.*)"$/).join(" "))
177
179
 
178
- # Add the --prefix option to the configureflags array
179
- testflags = ["--prefix=#{prefix}"] + Array[*configureflags]
180
- old_opt = options.find do |o|
180
+ # Add the --prefix option to the configureflags array
181
+ testflags = ["--prefix=#{prefix}"] + configureflags.flatten
182
+ old_opt = options.find do |o|
181
183
  if testflags.include?(o)
182
184
  false
183
185
  elsif o =~ /^-/
@@ -189,19 +191,19 @@ def prepare
189
191
  # explicitely given in configureflags
190
192
  varname, value = o.split("=").first
191
193
  if current_flag = testflags.find { |fl| fl =~ /^#{varname}=/ }
192
- current_flag != value
194
+ current_flag != o
193
195
  else false
194
196
  end
195
197
  end
196
198
  end
197
- new_opt = testflags.find { |o| !options.include?(o) }
198
- if old_opt || new_opt
199
+ new_opt = testflags.find { |o| !options.include?(o) }
200
+ if old_opt || new_opt
199
201
  if Autobuild.verbose
200
202
  Autobuild.message "forcing reconfiguration of #{name} (#{old_opt} != #{new_opt})"
201
203
  end
202
- FileUtils.rm_f configurestamp # to force reconfiguration
203
- end
204
- end
204
+ FileUtils.rm_f configurestamp # to force reconfiguration
205
+ end
206
+ end
205
207
 
206
208
  regen_target = create_regen_target
207
209
  file configurestamp => regen_target
@@ -232,68 +234,69 @@ def autodetect_needed_stages
232
234
  if using[:libtool].nil?
233
235
  using[:libtool] = File.exist?(File.join(srcdir, 'ltmain.sh'))
234
236
  end
237
+
238
+ if using[:autogen].nil?
239
+ using[:autogen] = %w{autogen autogen.sh}.find { |f| File.exist?(File.join(srcdir, f)) }
240
+ end
235
241
  end
236
242
 
237
243
  # Adds a target to rebuild the autotools environment
238
244
  def create_regen_target(confsource = nil)
239
- conffile = "#{srcdir}/configure"
240
- if confsource
241
- file conffile => confsource
242
- elsif confext = %w{.ac .in}.find { |ext| File.exist?("#{conffile}#{ext}") }
243
- file conffile => "#{conffile}#{confext}"
244
- else
245
- raise PackageException.new(self, 'prepare'), "neither configure.ac nor configure.in present in #{srcdir}"
246
- end
245
+ conffile = "#{srcdir}/configure"
246
+ if confsource
247
+ file conffile => confsource
248
+ elsif confext = %w{.ac .in}.find { |ext| File.exist?("#{conffile}#{ext}") }
249
+ file conffile => "#{conffile}#{confext}"
250
+ elsif using[:autoconf]
251
+ raise PackageException.new(self, 'prepare'), "neither configure.ac nor configure.in present in #{srcdir}"
252
+ end
247
253
 
248
254
  file conffile do
249
255
  isolate_errors do
250
- in_dir(srcdir) do
251
- if using[:autogen].nil?
252
- using[:autogen] = %w{autogen autogen.sh}.find { |f| File.exist?(File.join(srcdir, f)) }
253
- end
254
-
255
- autodetect_needed_stages
256
-
257
256
  progress_start "generating autotools for %s", :done_message => 'generated autotools for %s' do
258
- if using[:libtool]
259
- run('configure', Autobuild.tool('libtoolize'), '--copy')
260
- end
261
- if using[:autogen]
262
- run('configure', File.expand_path(using[:autogen], srcdir))
263
- else
264
- [ :aclocal, :autoconf, :autoheader, :automake ].each do |tool|
265
- if tool_flag = using[tool]
266
- tool_program = if tool_flag.respond_to?(:to_str)
267
- tool_flag.to_str
268
- else; Autobuild.tool(tool)
269
- end
270
-
271
- run('configure', tool_program, *send("#{tool}_flags"))
272
- end
273
- end
274
- end
257
+ regen
275
258
  end
276
259
  end
277
- end
278
260
  end
279
261
 
280
262
  return conffile
281
263
  end
282
264
 
265
+ def regen
266
+ if using[:libtool]
267
+ run 'configure', Autobuild.tool('libtoolize'), '--copy',
268
+ working_directory: srcdir
269
+ end
270
+ if using[:autogen]
271
+ run 'configure', File.expand_path(using[:autogen], srcdir),
272
+ working_directory: srcdir
273
+ else
274
+ [ :aclocal, :autoconf, :autoheader, :automake ].each do |tool|
275
+ if tool_flag = using[tool]
276
+ tool_program = if tool_flag.respond_to?(:to_str)
277
+ tool_flag.to_str
278
+ else; Autobuild.tool(tool)
279
+ end
280
+
281
+ run 'configure', tool_program, *send("#{tool}_flags"),
282
+ working_directory: srcdir
283
+ end
284
+ end
285
+ end
286
+ end
287
+
283
288
  # Configure the builddir directory before starting make
284
289
  def configure
285
290
  super do
286
- in_dir(builddir) do
287
- command = [ "#{srcdir}/configure"]
288
- if force_config_status
289
- command << "--no-create"
290
- end
291
- command << "--prefix=#{prefix}"
292
- command += Array[*configureflags]
291
+ command = [ "#{srcdir}/configure"]
292
+ if force_config_status
293
+ command << "--no-create"
294
+ end
295
+ command << "--prefix=#{prefix}"
296
+ command += configureflags.flatten
293
297
 
294
- progress_start "configuring autotools for %s", :done_message => 'configured autotools for %s' do
295
- run('configure', *command)
296
- end
298
+ progress_start "configuring autotools for %s", done_message: 'configured autotools for %s' do
299
+ run('configure', *command, working_directory: builddir)
297
300
  end
298
301
  end
299
302
  end
@@ -323,4 +326,3 @@ def install
323
326
  end
324
327
  end
325
328
  end
326
-
@@ -100,7 +100,7 @@ def cmake_cache; File.join(builddir, "CMakeCache.txt") end
100
100
  def configurestamp; cmake_cache end
101
101
 
102
102
  def initialize(options)
103
- @defines = Hash.new
103
+ @defines = Hash.new
104
104
  super
105
105
  @delete_obsolete_files_in_prefix = self.class.delete_obsolete_files_in_prefix?
106
106
  end
@@ -7,7 +7,7 @@ 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,27 +14,27 @@ def initialize(*args, &config)
14
14
  @genomflags = []
15
15
  super
16
16
 
17
- use :autogen => 'autogen'
17
+ use :autogen => 'autogen'
18
18
  end
19
19
 
20
20
  def import(options = Hash.new)
21
- super
22
- get_provides
23
- end
21
+ super
22
+ get_provides
23
+ end
24
24
 
25
25
  # Called before running the rake tasks and
26
26
  # after all imports have been made
27
27
  def prepare
28
- genomflags.flatten!
29
- get_requires
28
+ genomflags.flatten!
29
+ get_requires
30
30
 
31
31
  super
32
32
 
33
- file genomstamp => dependencies.map { |p| Package[p].installstamp }
33
+ file genomstamp => dependencies.map { |p| Package[p].installstamp }
34
34
  end
35
35
 
36
36
  # The file touched by genom on successful generation
37
- def genomstamp; File.join(srcdir, '.genom', 'genom-stamp') end
37
+ def genomstamp; File.join(srcdir, '.genom', 'genom-stamp') end
38
38
 
39
39
  # Extract the cpp options from the genom options
40
40
  def cpp_options
@@ -43,7 +43,7 @@ def cpp_options
43
43
 
44
44
  # Extracts dependencies using the requires: field in the .gen file
45
45
  def get_requires
46
- apionly = genomflags.find { |f| f == '-a' }
46
+ apionly = genomflags.find { |f| f == '-a' }
47
47
  cpp = Autobuild.tool(:cpp)
48
48
  currentBuffer = nil
49
49
  Open3.popen3("#{cpp} #{cpp_options.join(" ")} #{srcdir}/#{name}.gen") do |cin, out, err|
@@ -77,8 +77,8 @@ def get_requires
77
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
- configure_ac_user = File.join(srcdir, 'configure.ac.user')
81
- return unless File.readable?(configure_ac_user)
80
+ configure_ac_user = File.join(srcdir, 'configure.ac.user')
81
+ return unless File.readable?(configure_ac_user)
82
82
  File.open(configure_ac_user) do |f|
83
83
  f.each_line { |line|
84
84
  if line =~ /^\s*EXTRA_PKGCONFIG\s*=\s*"?([\w\-]+(?:\s+[\w\-]+)*)"?/
@@ -88,48 +88,48 @@ def get_provides
88
88
  end
89
89
  end
90
90
 
91
- # Make the genom-stamp file depend on
92
- # * genom includes
93
- # * genom canvas
94
- # * the genom binary itself
95
- def genom_dependencies
96
- # Get the genom pkg-config
97
- if Package['genom']
98
- 'genom'
99
- else
100
- genom_pkg = PkgConfig.new('genom')
91
+ # Make the genom-stamp file depend on
92
+ # * genom includes
93
+ # * genom canvas
94
+ # * the genom binary itself
95
+ def genom_dependencies
96
+ # Get the genom pkg-config
97
+ if Package['genom']
98
+ 'genom'
99
+ else
100
+ genom_pkg = PkgConfig.new('genom')
101
101
 
102
- includedir = File.join(genom_pkg.includedir, 'genom')
103
- source_tree includedir
102
+ includedir = File.join(genom_pkg.includedir, 'genom')
103
+ source_tree includedir
104
104
 
105
- canvasdir = File.join(genom_pkg.prefix, "share", "genom", genom_pkg.version);;
106
- source_tree canvasdir
105
+ canvasdir = File.join(genom_pkg.prefix, "share", "genom", genom_pkg.version);;
106
+ source_tree canvasdir
107
107
 
108
- binary = File.join(genom_pkg.exec_prefix, "bin", "genom")
109
- file binary
108
+ binary = File.join(genom_pkg.exec_prefix, "bin", "genom")
109
+ file binary
110
110
 
111
- [binary, includedir, canvasdir]
112
- end
113
- end
111
+ [binary, includedir, canvasdir]
112
+ end
113
+ end
114
114
 
115
115
  def regen
116
116
  cmdline = [ 'genom', "#{name}.gen", *genomflags ]
117
117
 
118
- # Check that the module has been generated with the same flags
119
- genom_mk = "#{srcdir}/autoconf/genom.mk"
120
- if File.exist?(genom_mk)
121
- contents = File.open(genom_mk).readlines
122
- old_file = contents.find { |l| l =~ /^GENFILE/ }.gsub('GENFILE=', '').strip
123
- old_flags = Shellwords.shellwords(
124
- contents.find { |l| l =~ /^GENFLAGS/ }.gsub('GENFLAGS=', ''))
118
+ # Check that the module has been generated with the same flags
119
+ genom_mk = "#{srcdir}/autoconf/genom.mk"
120
+ if File.exist?(genom_mk)
121
+ contents = File.open(genom_mk).readlines
122
+ old_file = contents.find { |l| l =~ /^GENFILE/ }.gsub('GENFILE=', '').strip
123
+ old_flags = Shellwords.shellwords(
124
+ contents.find { |l| l =~ /^GENFLAGS/ }.gsub('GENFLAGS=', ''))
125
125
 
126
- if old_file != "#{name}.gen" || !(old_flags - genomflags).empty? || !(genomflags - old_flags).empty?
127
- FileUtils.rm_f genomstamp
128
- end
129
- end
126
+ if old_file != "#{name}.gen" || !(old_flags - genomflags).empty? || !(genomflags - old_flags).empty?
127
+ FileUtils.rm_f genomstamp
128
+ end
129
+ end
130
130
 
131
131
  file buildstamp => genomstamp
132
- file genomstamp => genom_dependencies
132
+ file genomstamp => genom_dependencies
133
133
  file genomstamp => srcdir do
134
134
  isolate_errors do
135
135
  in_dir(srcdir) do
@@ -152,7 +152,7 @@ def regen
152
152
  end
153
153
  end
154
154
 
155
- super("#{srcdir}/autoconf/configure.ac")
155
+ super("#{srcdir}/autoconf/configure.ac")
156
156
  end
157
157
  end
158
158
  end
@@ -7,10 +7,10 @@ def self.import(spec, &proc)
7
7
  end
8
8
 
9
9
  class ImporterPackage < Package
10
- attr_reader :exclude
10
+ attr_reader :exclude
11
11
 
12
12
  def initialize(*args)
13
- @exclude = []
13
+ @exclude = []
14
14
  super
15
15
  end
16
16
 
@@ -18,15 +18,15 @@ def prepare
18
18
  super
19
19
 
20
20
  exclude = self.exclude.dup
21
- exclude << Regexp.new("^#{Regexp.quote(installstamp)}")
21
+ exclude << Regexp.new("^#{Regexp.quote(installstamp)}")
22
22
  if doc_dir
23
23
  exclude << Regexp.new("^#{Regexp.quote(doc_dir)}")
24
24
  end
25
25
 
26
26
  source_tree(srcdir) do |pkg|
27
- pkg.exclude.concat exclude
28
- exclude.freeze
29
- end
27
+ pkg.exclude.concat exclude
28
+ exclude.freeze
29
+ end
30
30
 
31
31
  file installstamp => srcdir
32
32
  end
@@ -282,14 +282,14 @@ def regen
282
282
  end
283
283
  end
284
284
 
285
- def generation_uptodate?
286
- if !File.file?(genstamp)
287
- true
288
- elsif File.file?(File.join(builddir, 'Makefile'))
285
+ def generation_uptodate?
286
+ if !File.file?(genstamp)
287
+ true
288
+ elsif File.file?(File.join(builddir, 'Makefile'))
289
289
  system("#{Autobuild.tool('make')} -C #{builddir} check-uptodate > /dev/null 2>&1")
290
- else
291
- true
292
- end
290
+ else
291
+ true
292
+ end
293
293
  end
294
294
  end
295
295
  end