autobuild 1.5.25 → 1.5.26

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,3 +1,6 @@
1
+ == Version 1.5.26
2
+ * add statistics support
3
+
1
4
  == Version 1.5.25
2
5
  * small bugfixes
3
6
 
@@ -71,6 +71,14 @@ module Autobuild
71
71
  # The list of packages this one depends upon
72
72
  attr_reader :dependencies
73
73
 
74
+ # Some statistics about the commands that have been run
75
+ attr_reader :statistics
76
+
77
+ def add_stat(phase, duration)
78
+ @statistics[phase] ||= 0
79
+ @statistics[phase] += duration
80
+ end
81
+
74
82
  # Absolute path to the source directory. See #srcdir=
75
83
  def srcdir; File.expand_path(@srcdir || name, Autobuild.srcdir) end
76
84
  # Absolute path to the installation directory. See #prefix=
@@ -97,6 +105,7 @@ module Autobuild
97
105
  @dependencies = Array.new
98
106
  @provides = Array.new
99
107
  @parallel_build_level = nil
108
+ @statistics = Hash.new
100
109
 
101
110
  if Hash === spec
102
111
  name, depends = spec.to_a.first
@@ -189,7 +189,7 @@ module Autobuild
189
189
  def install
190
190
  Dir.chdir(builddir) do
191
191
  progress "installing %s"
192
- Subprocess.run(self, 'build', Autobuild.tool(:make), "-j#{parallel_build_level}", 'install')
192
+ Subprocess.run(self, 'install', Autobuild.tool(:make), "-j#{parallel_build_level}", 'install')
193
193
  end
194
194
  super
195
195
  end
@@ -21,6 +21,23 @@ module Autobuild
21
21
  @logfiles.include?(logfile)
22
22
  end
23
23
 
24
+ def self.statistics
25
+ @statistics
26
+ end
27
+ def self.reset_statistics
28
+ @statistics = Hash.new
29
+ end
30
+ def self.add_stat(package, phase, duration)
31
+ if !@statistics[package]
32
+ @statistics[package] = { phase => duration }
33
+ elsif !@statistics[package][phase]
34
+ @statistics[package][phase] = duration
35
+ else
36
+ @statistics[package][phase] += duration
37
+ end
38
+ end
39
+ reset_statistics
40
+
24
41
  @parallel_build_level = nil
25
42
  class << self
26
43
  # Sets the level of parallelism during the build
@@ -86,6 +103,8 @@ module Autobuild::Subprocess
86
103
  def self.run(target, phase, *command)
87
104
  STDOUT.sync = true
88
105
 
106
+ start_time = Time.now
107
+
89
108
  # Filter nil and empty? in command
90
109
  command.reject! { |o| o.nil? || (o.respond_to?(:empty?) && o.empty?) }
91
110
  command.collect! { |o| o.to_s }
@@ -223,6 +242,15 @@ module Autobuild::Subprocess
223
242
  raise Failed.new(status.exitstatus), "'#{command.join(' ')}' returned status #{status.exitstatus}"
224
243
  end
225
244
 
245
+ duration = Time.now - start_time
246
+ Autobuild.add_stat(target, phase, duration)
247
+ File.open(File.join(Autobuild.logdir, "stats.log"), 'a') do |io|
248
+ io.puts "#{target} #{phase} #{duration}"
249
+ end
250
+ if target.respond_to?(:add_stat)
251
+ target.add_stat(phase, duration)
252
+ end
253
+
226
254
  rescue Failed => e
227
255
  error = Autobuild::SubcommandFailed.new(target_name, command.join(" "), logname, e.status)
228
256
  error.phase = phase
@@ -1,5 +1,5 @@
1
1
  module Autobuild
2
- VERSION = "1.5.25" unless defined? Autobuild::VERSION
2
+ VERSION = "1.5.26" unless defined? Autobuild::VERSION
3
3
  end
4
4
 
5
5
 
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: autobuild
3
3
  version: !ruby/object:Gem::Version
4
- hash: 49
4
+ hash: 55
5
5
  prerelease: false
6
6
  segments:
7
7
  - 1
8
8
  - 5
9
- - 25
10
- version: 1.5.25
9
+ - 26
10
+ version: 1.5.26
11
11
  platform: ruby
12
12
  authors:
13
13
  - Sylvain Joyeux
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2010-11-24 00:00:00 +01:00
18
+ date: 2010-11-26 00:00:00 +01:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency