autobuild 1.7.11.rc2 → 1.7.11.rc3

Sign up to get free protection for your applications and to get access to all the features.
data/Manifest.txt CHANGED
@@ -33,6 +33,7 @@ lib/autobuild/parallel.rb
33
33
  lib/autobuild/pkgconfig.rb
34
34
  lib/autobuild/reporting.rb
35
35
  lib/autobuild/subcommand.rb
36
+ lib/autobuild/tools.rb
36
37
  lib/autobuild/timestamps.rb
37
38
  lib/autobuild/version.rb
38
39
  lib/autobuild/rake_task_extension.rb
data/lib/autobuild.rb CHANGED
@@ -5,6 +5,7 @@ if defined? Rake::DSL
5
5
  end
6
6
 
7
7
  module Autobuild
8
+ LIB_DIR = File.expand_path(File.dirname(__FILE__))
8
9
  end
9
10
 
10
11
  begin
@@ -2,6 +2,7 @@ require 'optparse'
2
2
  require 'rake'
3
3
  require 'singleton'
4
4
  require 'highline'
5
+ require 'autobuild/tools'
5
6
 
6
7
  # Evaluates +script+ in autobuild context
7
8
  def Autobuild(&script)
@@ -63,17 +64,6 @@ module Autobuild
63
64
  else raise ArgumentError, "there is no utility called #{utility_name}, available utilities are #{utilities.keys.sort.join(", ")}"
64
65
  end
65
66
  end
66
-
67
- # Configure the programs used by different packages
68
- attr_reader :programs
69
- # A cache of entries in programs to their resolved full path
70
- #
71
- # @return [{String=>[String,String,String]}] the triplet (full path,
72
- # tool name, value of ENV['PATH']). The last two values are used to
73
- # invalidate the cache when needed
74
- #
75
- # @see tool_in_path
76
- attr_reader :programs_in_path
77
67
  # The directory in which logs are saved. Defaults to PREFIX/log.
78
68
  attr_writer :logdir
79
69
 
@@ -112,8 +102,6 @@ module Autobuild
112
102
  :verbose => false, :debug => false, :do_build => true, :do_forced_build => false, :do_rebuild => false, :do_update => true,
113
103
  :daemonize => false, :packages => [], :default_packages => [], :keep_oldlogs => false }
114
104
 
115
- @programs = Hash.new
116
- @programs_in_path = Hash.new
117
105
  DEFAULT_OPTIONS.each do |name, value|
118
106
  send("#{name}=", value)
119
107
  end
@@ -192,50 +180,6 @@ module Autobuild
192
180
  end
193
181
  end
194
182
 
195
- # Get a given program, using its name as default value. For
196
- # instance
197
- # tool('automake')
198
- # will return 'automake' unless the autobuild script defined
199
- # another automake program in Autobuild.programs by doing
200
- # Autobuild.programs['automake'] = 'automake1.9'
201
- def tool(name)
202
- programs[name.to_sym] || programs[name.to_s] || name.to_s
203
- end
204
-
205
- # Resolves the absolute path to a given tool
206
- def tool_in_path(name)
207
- path, path_name, path_env = programs_in_path[name]
208
- current = tool(name)
209
- if path_env != ENV['PATH'] || path_name != current
210
- # Delete the current entry given that it is invalid
211
- programs_in_path.delete(name)
212
- if current[0, 1] == "/"
213
- # This is already a full path
214
- path = current
215
- else
216
- path = ENV['PATH'].split(':').
217
- find { |dir| File.exists?(File.join(dir, current)) }
218
- if path
219
- path = File.join(path, current)
220
- end
221
- end
222
-
223
- if !path
224
- raise ArgumentError, "tool #{name}, set to #{current}, can not be found in PATH=#{path_env}"
225
- end
226
-
227
- # Verify that the new value is a file and is executable
228
- if !File.file?(path)
229
- raise ArgumentError, "tool #{name} is set to #{current}, but this resolves to #{path} which is not a file"
230
- elsif !File.executable?(path)
231
- raise ArgumentError, "tool #{name} is set to #{current}, but this resolves to #{path} which is not executable"
232
- end
233
- programs_in_path[name] = [path, current, ENV['PATH']]
234
- end
235
-
236
- return path
237
- end
238
-
239
183
  # Gets autobuild options from the command line and returns the
240
184
  # remaining elements
241
185
  def commandline(args)
@@ -0,0 +1,62 @@
1
+ module Autobuild
2
+ class << self
3
+ # Configure the programs used by different packages
4
+ attr_reader :programs
5
+ # A cache of entries in programs to their resolved full path
6
+ #
7
+ # @return [{String=>[String,String,String]}] the triplet (full path,
8
+ # tool name, value of ENV['PATH']). The last two values are used to
9
+ # invalidate the cache when needed
10
+ #
11
+ # @see tool_in_path
12
+ attr_reader :programs_in_path
13
+
14
+ # Get a given program, using its name as default value. For
15
+ # instance
16
+ # tool('automake')
17
+ # will return 'automake' unless the autobuild script defined
18
+ # another automake program in Autobuild.programs by doing
19
+ # Autobuild.programs['automake'] = 'automake1.9'
20
+ def tool(name)
21
+ programs[name.to_sym] || programs[name.to_s] || name.to_s
22
+ end
23
+
24
+ # Resolves the absolute path to a given tool
25
+ def tool_in_path(name)
26
+ path, path_name, path_env = programs_in_path[name]
27
+ current = tool(name)
28
+ if path_env != ENV['PATH'] || path_name != current
29
+ # Delete the current entry given that it is invalid
30
+ programs_in_path.delete(name)
31
+ if current[0, 1] == "/"
32
+ # This is already a full path
33
+ path = current
34
+ else
35
+ path = ENV['PATH'].split(':').
36
+ find { |dir| File.exists?(File.join(dir, current)) }
37
+ if path
38
+ path = File.join(path, current)
39
+ end
40
+ end
41
+
42
+ if !path
43
+ raise ArgumentError, "tool #{name}, set to #{current}, can not be found in PATH=#{path_env}"
44
+ end
45
+
46
+ # Verify that the new value is a file and is executable
47
+ if !File.file?(path)
48
+ raise ArgumentError, "tool #{name} is set to #{current}, but this resolves to #{path} which is not a file"
49
+ elsif !File.executable?(path)
50
+ raise ArgumentError, "tool #{name} is set to #{current}, but this resolves to #{path} which is not executable"
51
+ end
52
+ programs_in_path[name] = [path, current, ENV['PATH']]
53
+ end
54
+
55
+ return path
56
+ end
57
+ end
58
+
59
+ @programs = Hash.new
60
+ @programs_in_path = Hash.new
61
+ end
62
+
@@ -1,5 +1,5 @@
1
1
  module Autobuild
2
- VERSION = "1.7.11.rc2" unless defined? Autobuild::VERSION
2
+ VERSION = "1.7.11.rc3" unless defined? Autobuild::VERSION
3
3
  end
4
4
 
5
5
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: autobuild
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.7.11.rc2
4
+ version: 1.7.11.rc3
5
5
  prerelease: 7
6
6
  platform: ruby
7
7
  authors:
@@ -139,6 +139,7 @@ files:
139
139
  - lib/autobuild/pkgconfig.rb
140
140
  - lib/autobuild/reporting.rb
141
141
  - lib/autobuild/subcommand.rb
142
+ - lib/autobuild/tools.rb
142
143
  - lib/autobuild/timestamps.rb
143
144
  - lib/autobuild/version.rb
144
145
  - lib/autobuild/rake_task_extension.rb