basechip 0.0.1
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.
- data/.document +5 -0
- data/Gemfile +20 -0
- data/Gemfile.lock +32 -0
- data/LICENSE.txt +14 -0
- data/README.rdoc +19 -0
- data/VERSION +1 -0
- data/bin/basechip +25 -0
- data/collateral/block/block.rb.erb +20 -0
- data/collateral/configuration/configuration.rb.erb +19 -0
- data/collateral/project/Gemfile +19 -0
- data/collateral/project/gitignore +6 -0
- data/collateral/project/project.rb.erb +76 -0
- data/collateral/project/settings.rb.erb +26 -0
- data/collateral/recipes/icarus.rb +73 -0
- data/collateral/recipes/icarus.rb.erb +88 -0
- data/collateral/recipes/local_cluster.rb +27 -0
- data/lib/array.rb +26 -0
- data/lib/base_chip/action.rb +309 -0
- data/lib/base_chip/base.rb +105 -0
- data/lib/base_chip/block.rb +75 -0
- data/lib/base_chip/bom.rb +75 -0
- data/lib/base_chip/bom_file.rb +45 -0
- data/lib/base_chip/cli.rb +371 -0
- data/lib/base_chip/cluster.rb +93 -0
- data/lib/base_chip/cluster_type.rb +45 -0
- data/lib/base_chip/code_area.rb +30 -0
- data/lib/base_chip/configuration.rb +257 -0
- data/lib/base_chip/dsl.rb +593 -0
- data/lib/base_chip/exit_error.rb +20 -0
- data/lib/base_chip/generator_menu.rb +64 -0
- data/lib/base_chip/git.rb +32 -0
- data/lib/base_chip/hierarchy.rb +84 -0
- data/lib/base_chip/install_menu.rb +89 -0
- data/lib/base_chip/ipc.rb +50 -0
- data/lib/base_chip/list_menu.rb +134 -0
- data/lib/base_chip/menu.rb +70 -0
- data/lib/base_chip/out_file.rb +68 -0
- data/lib/base_chip/permutation.rb +26 -0
- data/lib/base_chip/permute.rb +25 -0
- data/lib/base_chip/post.rb +26 -0
- data/lib/base_chip/problem.rb +33 -0
- data/lib/base_chip/project.rb +472 -0
- data/lib/base_chip/requirement.rb +26 -0
- data/lib/base_chip/runable.rb +36 -0
- data/lib/base_chip/source_language.rb +40 -0
- data/lib/base_chip/source_type.rb +24 -0
- data/lib/base_chip/statistic.rb +27 -0
- data/lib/base_chip/task.rb +21 -0
- data/lib/base_chip/task_master.rb +50 -0
- data/lib/base_chip/taskable.rb +77 -0
- data/lib/base_chip/tasker.rb +260 -0
- data/lib/base_chip/test.rb +202 -0
- data/lib/base_chip/test_list.rb +120 -0
- data/lib/base_chip/tool.rb +51 -0
- data/lib/base_chip/tool_version.rb +34 -0
- data/lib/base_chip/top_menu.rb +203 -0
- data/lib/base_chip/track_state.rb +61 -0
- data/lib/base_chip.rb +215 -0
- data/lib/dir.rb +30 -0
- data/lib/reporting.rb +97 -0
- metadata +215 -0
@@ -0,0 +1,32 @@
|
|
1
|
+
# Copyright 2011 Tommy Poulter
|
2
|
+
#
|
3
|
+
# This file is part of basechip.
|
4
|
+
#
|
5
|
+
# basechip is free software: you can redistribute it and/or modify
|
6
|
+
# it under the terms of the GNU General Public License version 3 as
|
7
|
+
# published by the Free Software Foundation.
|
8
|
+
#
|
9
|
+
# basechip is distributed in the hope that it will be useful,
|
10
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
11
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
12
|
+
# GNU General Public License for more details.
|
13
|
+
#
|
14
|
+
# You should have received a copy of the GNU General Public License
|
15
|
+
# along with basechip. If not, see <http://www.gnu.org/licenses/>.
|
16
|
+
|
17
|
+
module BaseChip
|
18
|
+
class Git
|
19
|
+
def initialize(root)
|
20
|
+
@root = root
|
21
|
+
end
|
22
|
+
def changed
|
23
|
+
files = `cd #{@root} && git status`.split(/\n/)
|
24
|
+
files.delete_if do |f|
|
25
|
+
f !~ /#\t/
|
26
|
+
end
|
27
|
+
files.map! do |f|
|
28
|
+
f.gsub(/#\s+(modified|new file):\s+/,'')
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
@@ -0,0 +1,84 @@
|
|
1
|
+
# Copyright 2011 Tommy Poulter
|
2
|
+
#
|
3
|
+
# This file is part of basechip.
|
4
|
+
#
|
5
|
+
# basechip is free software: you can redistribute it and/or modify
|
6
|
+
# it under the terms of the GNU General Public License version 3 as
|
7
|
+
# published by the Free Software Foundation.
|
8
|
+
#
|
9
|
+
# basechip is distributed in the hope that it will be useful,
|
10
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
11
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
12
|
+
# GNU General Public License for more details.
|
13
|
+
#
|
14
|
+
# You should have received a copy of the GNU General Public License
|
15
|
+
# along with basechip. If not, see <http://www.gnu.org/licenses/>.
|
16
|
+
|
17
|
+
require 'reporting'
|
18
|
+
module BaseChip
|
19
|
+
module Hierarchy
|
20
|
+
def self.included mod
|
21
|
+
mod.extend Hierarchy::ClassMethods
|
22
|
+
mod.class_eval do
|
23
|
+
include Reporting
|
24
|
+
include Hierarchy::InstanceMethods
|
25
|
+
end
|
26
|
+
end
|
27
|
+
module ClassMethods
|
28
|
+
end
|
29
|
+
module InstanceMethods
|
30
|
+
def configure
|
31
|
+
return if @configured
|
32
|
+
@directory ||= "#{parent.directory}/#{name}"
|
33
|
+
super
|
34
|
+
end
|
35
|
+
|
36
|
+
def discover_tools ; file_glob("#{@directory}/base_chip/tools/*.rb" , /base_chip\/tools\/(\w+)\.rb$/ , :tool ) end
|
37
|
+
def discover_actions ; file_glob("#{@directory}/base_chip/actions/*.rb" , /base_chip\/actions\/(\w+)\.rb$/ , :action ) end
|
38
|
+
def discover_test_lists ; file_glob("#{@directory}/base_chip/test_lists/*.rb" , /base_chip\/test_lists\/(\w+)\.rb$/ , :test_list ) end
|
39
|
+
def discover_recipes ; file_glob("#{@directory}/base_chip/recipes/*.rb" ) end
|
40
|
+
|
41
|
+
def rtl( &blk) ; source_type( :rtl , &blk) ; end
|
42
|
+
def top_rtl( &blk) ; source_type(:top_rtl , &blk) ; end
|
43
|
+
def gates( &blk) ; source_type( :gates , &blk) ; end
|
44
|
+
def top_gates( &blk) ; source_type(:top_gates , &blk) ; end
|
45
|
+
def testbench( &blk) ; source_type( :testbench , &blk) ; end
|
46
|
+
def top_testbench( &blk) ; source_type(:top_testbench , &blk) ; end
|
47
|
+
def stimulus( &blk) ; source_type( :stimulus , &blk) ; end
|
48
|
+
def top_stimulus( &blk) ; source_type(:top_stimulus , &blk) ; end
|
49
|
+
|
50
|
+
def verilog( &blk) ; source_language(:verilog , &blk) ; end
|
51
|
+
def classes( &blk) ; source_language(:classes , &blk) ; end
|
52
|
+
def vhdl( &blk) ; source_language(:vhdl , &blk) ; end
|
53
|
+
def systemc( &blk) ; source_language(:systemc , &blk) ; end
|
54
|
+
def headers( &blk) ; source_language(:headers , &blk) ; end
|
55
|
+
|
56
|
+
def default_directory_structure_called
|
57
|
+
return true if @default_directory_structure_called
|
58
|
+
return true if parent && parent.default_directory_structure_called
|
59
|
+
false
|
60
|
+
end
|
61
|
+
def default_directory_structure
|
62
|
+
return if default_directory_structure_called
|
63
|
+
@default_directory_structure_called = true
|
64
|
+
|
65
|
+
rtl { |source| source.directories [ "#{source.block.name }/rtl" , "#{source.block.name}/#{source.configuration.name }/rtl" ] }
|
66
|
+
top_rtl { |source| source.directories [ "#{source.block.name}/top_rtl" , "#{source.block.name}/#{source.configuration.name}/top_rtl" ] }
|
67
|
+
gates { |source| source.directories [ "#{source.block.name }/gates" , "#{source.block.name}/#{source.configuration.name }/gates" ] }
|
68
|
+
top_gates { |source| source.directories [ "#{source.block.name}/top_gates" , "#{source.block.name}/#{source.configuration.name}/top_gates" ] }
|
69
|
+
testbench { |source| source.directories [ "#{source.block.name }/testbench" , "#{source.block.name}/#{source.configuration.name }/testbench" ] }
|
70
|
+
top_testbench { |source| source.directories [ "#{source.block.name}/top_testbench" , "#{source.block.name}/#{source.configuration.name}/top_testbench" ] }
|
71
|
+
stimulus { |source| source.directories [ "#{source.block.name }/stimulus" , "#{source.block.name}/#{source.configuration.name }/stimulus" ] }
|
72
|
+
top_stimulus { |source| source.directories [ "#{source.block.name}/top_stimulus" , "#{source.block.name}/#{source.configuration.name}/top_stimulus" ] }
|
73
|
+
|
74
|
+
# FIXME include directory
|
75
|
+
verilog { |language| language.append_directories(language.directories.map {|d| "#{d}/#{language.name}"}); language.globs %w{*.def *.v *.vbh *.sv } }
|
76
|
+
classes { |language| language. directories(language.directories.map {|d| "#{d}/#{language.name}"}); language.globs %w{ *.sv } }
|
77
|
+
vhdl { |language| language. directories(language.directories.map {|d| "#{d}/#{language.name}"}); language.globs %w{ *.v *.vhd *.vhdl} }
|
78
|
+
systemc { |language| language. directories(language.directories.map {|d| "#{d}/#{language.name}"}); language.globs %w{*.c } }
|
79
|
+
headers { |language| language. directories(language.directories.map {|d| "#{d}/#{language.name}"}); language.globs [''] }
|
80
|
+
end
|
81
|
+
|
82
|
+
end
|
83
|
+
end
|
84
|
+
end
|
@@ -0,0 +1,89 @@
|
|
1
|
+
# Copyright 2011 Tommy Poulter
|
2
|
+
#
|
3
|
+
# This file is part of basechip.
|
4
|
+
#
|
5
|
+
# basechip is free software: you can redistribute it and/or modify
|
6
|
+
# it under the terms of the GNU General Public License version 3 as
|
7
|
+
# published by the Free Software Foundation.
|
8
|
+
#
|
9
|
+
# basechip is distributed in the hope that it will be useful,
|
10
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
11
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
12
|
+
# GNU General Public License for more details.
|
13
|
+
#
|
14
|
+
# You should have received a copy of the GNU General Public License
|
15
|
+
# along with basechip. If not, see <http://www.gnu.org/licenses/>.
|
16
|
+
|
17
|
+
require 'base_chip/menu'
|
18
|
+
module BaseChip
|
19
|
+
class InstallMenu < Menu
|
20
|
+
include Cli
|
21
|
+
def before(name)
|
22
|
+
BaseChip.load_environment
|
23
|
+
# \@table = []
|
24
|
+
# case pattern
|
25
|
+
# when /^\/(.*)\/$/ ; @pattern = /#\{$1}/
|
26
|
+
# else ; @pattern = pattern
|
27
|
+
# end
|
28
|
+
# # exit unless BaseChip.project.blocks
|
29
|
+
end
|
30
|
+
def after
|
31
|
+
if @table.size > 0
|
32
|
+
print_table(@table,'=>')
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
desc "Install recipe by name"
|
37
|
+
def recipe(name)
|
38
|
+
fault "This feature is soon forthcoming"
|
39
|
+
end
|
40
|
+
|
41
|
+
desc "Install plugin by name"
|
42
|
+
def plugin(name)
|
43
|
+
fault "This feature is soon forthcoming"
|
44
|
+
end
|
45
|
+
|
46
|
+
desc "Install tool by name"
|
47
|
+
def tool(name, version=nil)
|
48
|
+
before(name)
|
49
|
+
tools = []
|
50
|
+
n = name.to_sym
|
51
|
+
BaseChip.tools.each do |tool|
|
52
|
+
next unless tool.name == n
|
53
|
+
tools << tool
|
54
|
+
end
|
55
|
+
unless tools[0]
|
56
|
+
puts "Available tools are:"
|
57
|
+
ListMenu.new.run_cli(%w{tools --show select_version})
|
58
|
+
fault "No tool found named '#{name}'. Consider installing a recipe to teach basechip how to install '#{name}'"
|
59
|
+
end
|
60
|
+
|
61
|
+
versions = []
|
62
|
+
tools.each do |tool|
|
63
|
+
tool.configure
|
64
|
+
if version
|
65
|
+
if v = tool.versions[version]
|
66
|
+
versions << v
|
67
|
+
end
|
68
|
+
else
|
69
|
+
versions << tool.selected_version
|
70
|
+
end
|
71
|
+
end
|
72
|
+
unless versions[0]
|
73
|
+
puts "Available versions for tool '#{name}' are:"
|
74
|
+
ListMenu.new.run_cli(['tools', name, '--show', 'available_versions'])
|
75
|
+
fault "No version found named '#{version}' for tool '#{name}'."
|
76
|
+
end
|
77
|
+
puts "Installing version(s) #{versions.map{|v|v.name}.uniq} for tool '#{name}'"
|
78
|
+
installed = []
|
79
|
+
versions.each do |version|
|
80
|
+
next if installed.include? version.name
|
81
|
+
installed << version.name
|
82
|
+
version.configure
|
83
|
+
fault "shared_directory must be specified in project for install locations" unless version.project.shared_directory
|
84
|
+
puts "cd #{version.project.shared_directory}\n#{version.install}"
|
85
|
+
system "cd #{version.project.shared_directory}\n#{version.install}"
|
86
|
+
end
|
87
|
+
end
|
88
|
+
end
|
89
|
+
end
|
@@ -0,0 +1,50 @@
|
|
1
|
+
# Copyright 2011 Tommy Poulter
|
2
|
+
#
|
3
|
+
# This file is part of basechip.
|
4
|
+
#
|
5
|
+
# basechip is free software: you can redistribute it and/or modify
|
6
|
+
# it under the terms of the GNU General Public License version 3 as
|
7
|
+
# published by the Free Software Foundation.
|
8
|
+
#
|
9
|
+
# basechip is distributed in the hope that it will be useful,
|
10
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
11
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
12
|
+
# GNU General Public License for more details.
|
13
|
+
#
|
14
|
+
# You should have received a copy of the GNU General Public License
|
15
|
+
# along with basechip. If not, see <http://www.gnu.org/licenses/>.
|
16
|
+
|
17
|
+
require 'drb'
|
18
|
+
|
19
|
+
# require 'zmq'
|
20
|
+
# require 'ffi'
|
21
|
+
Thread.abort_on_exception = true
|
22
|
+
|
23
|
+
module BaseChip
|
24
|
+
module Ipc
|
25
|
+
def self.included mod
|
26
|
+
mod.extend Ipc::ClassMethods
|
27
|
+
mod.class_eval do
|
28
|
+
include Ipc::InstanceMethods
|
29
|
+
end
|
30
|
+
end
|
31
|
+
module ClassMethods
|
32
|
+
# class instance variables
|
33
|
+
end
|
34
|
+
module InstanceMethods
|
35
|
+
def init_test_sockets(type = :client) # or :server
|
36
|
+
DRb.start_service nil, self
|
37
|
+
if @client_of
|
38
|
+
@server = DRbObject.new nil, @client_of
|
39
|
+
@server.register_client(DRb.uri)
|
40
|
+
else
|
41
|
+
@clients_ready = []
|
42
|
+
@clients_all = []
|
43
|
+
end
|
44
|
+
end
|
45
|
+
def register_client(address)
|
46
|
+
@clients_all << DRbObject.new(nil, address)
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
@@ -0,0 +1,134 @@
|
|
1
|
+
# Copyright 2011 Tommy Poulter
|
2
|
+
#
|
3
|
+
# This file is part of basechip.
|
4
|
+
#
|
5
|
+
# basechip is free software: you can redistribute it and/or modify
|
6
|
+
# it under the terms of the GNU General Public License version 3 as
|
7
|
+
# published by the Free Software Foundation.
|
8
|
+
#
|
9
|
+
# basechip is distributed in the hope that it will be useful,
|
10
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
11
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
12
|
+
# GNU General Public License for more details.
|
13
|
+
#
|
14
|
+
# You should have received a copy of the GNU General Public License
|
15
|
+
# along with basechip. If not, see <http://www.gnu.org/licenses/>.
|
16
|
+
|
17
|
+
require 'base_chip/menu'
|
18
|
+
module BaseChip
|
19
|
+
class ListMenu < Menu
|
20
|
+
include Cli
|
21
|
+
def before(pattern)
|
22
|
+
BaseChip.load_environment
|
23
|
+
@table = []
|
24
|
+
case pattern
|
25
|
+
when /^\/(.*)\/$/ ; @pattern = /#{$1}/
|
26
|
+
else ; @pattern = pattern
|
27
|
+
end
|
28
|
+
exit unless BaseChip.project.blocks
|
29
|
+
end
|
30
|
+
def after
|
31
|
+
if @table.size > 0
|
32
|
+
print_table(@table,'=>')
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
option :show, :description=>"Show a data element for each listed item", :type=>:string, :alias=>[:s]
|
37
|
+
|
38
|
+
desc "List available blocks matching pattern"
|
39
|
+
def blocks(pattern=nil)
|
40
|
+
before(pattern)
|
41
|
+
BaseChip.blocks.each do |block|
|
42
|
+
smart_print block.name.to_s, block
|
43
|
+
end
|
44
|
+
after
|
45
|
+
end
|
46
|
+
|
47
|
+
desc "List available configurations matching pattern"
|
48
|
+
def configurations(pattern=nil)
|
49
|
+
before(pattern)
|
50
|
+
BaseChip.configurations.each do |configuration|
|
51
|
+
name = configuration.name
|
52
|
+
b_name = configuration.block.name
|
53
|
+
smart_print "#{b_name}:#{name}", configuration, b_name.to_s, name.to_s
|
54
|
+
end
|
55
|
+
after
|
56
|
+
end
|
57
|
+
|
58
|
+
desc "List available actions matching pattern"
|
59
|
+
def actions(pattern=nil)
|
60
|
+
before(pattern)
|
61
|
+
BaseChip.actions.each do |action|
|
62
|
+
name = action.name
|
63
|
+
c = action.configuration
|
64
|
+
b = c.block
|
65
|
+
smart_print "#{b.name}:#{c.name}:#{name}", action, b.name.to_s, c.name.to_s, name.to_s
|
66
|
+
end
|
67
|
+
after
|
68
|
+
end
|
69
|
+
|
70
|
+
desc "List available test lists matching pattern"
|
71
|
+
def test_lists(pattern=nil)
|
72
|
+
before(pattern)
|
73
|
+
BaseChip.test_lists.each do |list|
|
74
|
+
name = list.name
|
75
|
+
c = list.configuration
|
76
|
+
b = c.block
|
77
|
+
smart_print "#{b.name}:#{c.name}:#{name}", list, b.name.to_s, c.name.to_s, name.to_s
|
78
|
+
end
|
79
|
+
after
|
80
|
+
end
|
81
|
+
|
82
|
+
desc "List available tests matching pattern"
|
83
|
+
def tests(pattern=nil)
|
84
|
+
before(pattern)
|
85
|
+
BaseChip.tests.each do |test|
|
86
|
+
name = test.name
|
87
|
+
l = test.test_list
|
88
|
+
c = l.configuration
|
89
|
+
b = c.block
|
90
|
+
smart_print "#{b.name}:#{c.name}:#{l.name}:#{name}", test, b.name.to_s, c.name.to_s, l.name.to_s, name.to_s
|
91
|
+
end
|
92
|
+
after
|
93
|
+
end
|
94
|
+
|
95
|
+
desc "List available tools matching pattern"
|
96
|
+
def tools(pattern=nil)
|
97
|
+
before(pattern)
|
98
|
+
BaseChip.tools.each do |tool|
|
99
|
+
name = tool.name
|
100
|
+
smart_print [name,"used by #{tool.configuration.full_name}"], tool, name.to_s
|
101
|
+
end
|
102
|
+
after
|
103
|
+
end
|
104
|
+
|
105
|
+
desc "List available plugins matching pattern"
|
106
|
+
option :remote , :description=>"list downloadable plugins", :type=>:string , :alias=>[:r]
|
107
|
+
def plugins(pattern=nil)
|
108
|
+
fault "This feature is soon forthcoming"
|
109
|
+
end
|
110
|
+
|
111
|
+
desc "List available recipes matching pattern"
|
112
|
+
option :remote , :description=>"list downloadable recipes", :type=>:string , :alias=>[:r]
|
113
|
+
def recipes(pattern=nil)
|
114
|
+
fault "This feature is soon forthcoming"
|
115
|
+
end
|
116
|
+
|
117
|
+
desc "List the workload that would run if the listed targets were supplied on the command line"
|
118
|
+
full_usage "<targets+> [options]"
|
119
|
+
default
|
120
|
+
def workload(*targets)
|
121
|
+
if targets.empty?
|
122
|
+
help
|
123
|
+
fault "please specify targets"
|
124
|
+
end
|
125
|
+
BaseChip.load_environment
|
126
|
+
@table = []
|
127
|
+
BaseChip.project.dereference_workload(targets).each do |item|
|
128
|
+
list_line item.full_name, item
|
129
|
+
end
|
130
|
+
after
|
131
|
+
end
|
132
|
+
|
133
|
+
end
|
134
|
+
end
|
@@ -0,0 +1,70 @@
|
|
1
|
+
# Copyright 2011 Tommy Poulter
|
2
|
+
#
|
3
|
+
# This file is part of basechip.
|
4
|
+
#
|
5
|
+
# basechip is free software: you can redistribute it and/or modify
|
6
|
+
# it under the terms of the GNU General Public License version 3 as
|
7
|
+
# published by the Free Software Foundation.
|
8
|
+
#
|
9
|
+
# basechip is distributed in the hope that it will be useful,
|
10
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
11
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
12
|
+
# GNU General Public License for more details.
|
13
|
+
#
|
14
|
+
# You should have received a copy of the GNU General Public License
|
15
|
+
# along with basechip. If not, see <http://www.gnu.org/licenses/>.
|
16
|
+
|
17
|
+
require 'thor'
|
18
|
+
require 'reporting'
|
19
|
+
module BaseChip
|
20
|
+
class Menu # < Thor
|
21
|
+
include Reporting
|
22
|
+
def smart_print(string, object, *array)
|
23
|
+
if @pattern == nil
|
24
|
+
list_line(string,object)
|
25
|
+
return
|
26
|
+
end
|
27
|
+
if @pattern.is_a? Regexp
|
28
|
+
if string.is_a? Array
|
29
|
+
array += string
|
30
|
+
else
|
31
|
+
array << string
|
32
|
+
end
|
33
|
+
array.each do |str|
|
34
|
+
if str =~ @pattern
|
35
|
+
list_line(string,object)
|
36
|
+
return
|
37
|
+
end
|
38
|
+
end
|
39
|
+
else
|
40
|
+
if array.include? @pattern
|
41
|
+
list_line(string,object)
|
42
|
+
return
|
43
|
+
end
|
44
|
+
if string == @pattern
|
45
|
+
list_line(string,object)
|
46
|
+
return
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
50
|
+
def list_line(string,object)
|
51
|
+
array = (string.is_a? Array) ? string : [string]
|
52
|
+
|
53
|
+
if self.options.show
|
54
|
+
object.configure
|
55
|
+
tmp = object
|
56
|
+
self.options.show.split(/\./).each do |fun|
|
57
|
+
fault("Object of type #{tmp.respond_to?(:class_string) ? tmp.class_string : tmp.class} does not have a data element #{fun.inspect}") unless tmp.respond_to?(fun)
|
58
|
+
tmp = tmp.send(fun)
|
59
|
+
end
|
60
|
+
array << tmp
|
61
|
+
end
|
62
|
+
|
63
|
+
if array.size == 1
|
64
|
+
puts string
|
65
|
+
else
|
66
|
+
@table << array
|
67
|
+
end
|
68
|
+
end
|
69
|
+
end
|
70
|
+
end
|
@@ -0,0 +1,68 @@
|
|
1
|
+
# Copyright 2011 Tommy Poulter
|
2
|
+
#
|
3
|
+
# This file is part of basechip.
|
4
|
+
#
|
5
|
+
# basechip is free software: you can redistribute it and/or modify
|
6
|
+
# it under the terms of the GNU General Public License version 3 as
|
7
|
+
# published by the Free Software Foundation.
|
8
|
+
#
|
9
|
+
# basechip is distributed in the hope that it will be useful,
|
10
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
11
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
12
|
+
# GNU General Public License for more details.
|
13
|
+
#
|
14
|
+
# You should have received a copy of the GNU General Public License
|
15
|
+
# along with basechip. If not, see <http://www.gnu.org/licenses/>.
|
16
|
+
|
17
|
+
module BaseChip
|
18
|
+
class OutFile
|
19
|
+
include Dsl
|
20
|
+
include Base
|
21
|
+
include TrackState
|
22
|
+
define_children({:statistic => Statistic })
|
23
|
+
define_settings({:warning_regex => [ Regexp , Array ],
|
24
|
+
:error_regex => [ Regexp , Array ],
|
25
|
+
:pass_regex => [ Regexp , Array ],
|
26
|
+
:optional => [ Boolean ],
|
27
|
+
:min_ratio => [ Array ],
|
28
|
+
:max_ratio => [ Array ],
|
29
|
+
:file_delay => [ Integer ]})
|
30
|
+
|
31
|
+
attr_accessor :totals
|
32
|
+
|
33
|
+
def initialize
|
34
|
+
super
|
35
|
+
@totals = {}
|
36
|
+
end
|
37
|
+
# def find_parent_values
|
38
|
+
# super
|
39
|
+
# @warning_regex = to_regex(@warning_regex) if @warning_regex
|
40
|
+
# @error_regex = to_regex(@error_regex ) if @error_regex
|
41
|
+
# @pass_regex = to_regex(@pass_regex ) if @pass_regex
|
42
|
+
# end
|
43
|
+
def go(name)
|
44
|
+
sleep(@file_delay || 0)
|
45
|
+
files = Dir.glob(@name.to_s)
|
46
|
+
error!(@name,"Could not find any files matching #{@name}") unless files[0] || @optional
|
47
|
+
|
48
|
+
# FIXME fault if file doesn't exist
|
49
|
+
files.each do |fname|
|
50
|
+
f = File.open(fname,'r')
|
51
|
+
f.each do |l|
|
52
|
+
if @warning_regex && (match = @warning_regex.match(l)); warning!(fname,match.to_s) end
|
53
|
+
if @error_regex && (match = @error_regex .match(l)); error!( fname,match.to_s) end
|
54
|
+
if @pass_regex && (match = @pass_regex .match(l)); pass! end
|
55
|
+
if @statistics
|
56
|
+
@statistics.each_value do |s|
|
57
|
+
fault("statistic '#{s.full_name}' has no regex defined") unless s.regex
|
58
|
+
if match = s.regex.match(l); @totals[s.name] = (match[1] && match[1].to_i) || 1 end
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
62
|
+
if @pass_regex && @state.nil?
|
63
|
+
error!(fname,"passing banner /#{@pass_regex}/ could not be found")
|
64
|
+
end
|
65
|
+
end
|
66
|
+
end
|
67
|
+
end
|
68
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
# Copyright 2011 Tommy Poulter
|
2
|
+
#
|
3
|
+
# This file is part of basechip.
|
4
|
+
#
|
5
|
+
# basechip is free software: you can redistribute it and/or modify
|
6
|
+
# it under the terms of the GNU General Public License version 3 as
|
7
|
+
# published by the Free Software Foundation.
|
8
|
+
#
|
9
|
+
# basechip is distributed in the hope that it will be useful,
|
10
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
11
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
12
|
+
# GNU General Public License for more details.
|
13
|
+
#
|
14
|
+
# You should have received a copy of the GNU General Public License
|
15
|
+
# along with basechip. If not, see <http://www.gnu.org/licenses/>.
|
16
|
+
|
17
|
+
module BaseChip
|
18
|
+
class Permutation
|
19
|
+
include Dsl
|
20
|
+
include Base
|
21
|
+
|
22
|
+
def configure
|
23
|
+
@configure = true
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
# Copyright 2011 Tommy Poulter
|
2
|
+
#
|
3
|
+
# This file is part of basechip.
|
4
|
+
#
|
5
|
+
# basechip is free software: you can redistribute it and/or modify
|
6
|
+
# it under the terms of the GNU General Public License version 3 as
|
7
|
+
# published by the Free Software Foundation.
|
8
|
+
#
|
9
|
+
# basechip is distributed in the hope that it will be useful,
|
10
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
11
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
12
|
+
# GNU General Public License for more details.
|
13
|
+
#
|
14
|
+
# You should have received a copy of the GNU General Public License
|
15
|
+
# along with basechip. If not, see <http://www.gnu.org/licenses/>.
|
16
|
+
|
17
|
+
require 'base_chip/permutation'
|
18
|
+
|
19
|
+
module BaseChip
|
20
|
+
class Permute
|
21
|
+
include Dsl
|
22
|
+
include Base
|
23
|
+
define_children({:permutation => Permutation})
|
24
|
+
end
|
25
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
# Copyright 2011 Tommy Poulter
|
2
|
+
#
|
3
|
+
# This file is part of basechip.
|
4
|
+
#
|
5
|
+
# basechip is free software: you can redistribute it and/or modify
|
6
|
+
# it under the terms of the GNU General Public License version 3 as
|
7
|
+
# published by the Free Software Foundation.
|
8
|
+
#
|
9
|
+
# basechip is distributed in the hope that it will be useful,
|
10
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
11
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
12
|
+
# GNU General Public License for more details.
|
13
|
+
#
|
14
|
+
# You should have received a copy of the GNU General Public License
|
15
|
+
# along with basechip. If not, see <http://www.gnu.org/licenses/>.
|
16
|
+
|
17
|
+
module BaseChip
|
18
|
+
class Post
|
19
|
+
include Dsl
|
20
|
+
include Base
|
21
|
+
|
22
|
+
def configure
|
23
|
+
@configure = true
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
# Copyright 2011 Tommy Poulter
|
2
|
+
#
|
3
|
+
# This file is part of basechip.
|
4
|
+
#
|
5
|
+
# basechip is free software: you can redistribute it and/or modify
|
6
|
+
# it under the terms of the GNU General Public License version 3 as
|
7
|
+
# published by the Free Software Foundation.
|
8
|
+
#
|
9
|
+
# basechip is distributed in the hope that it will be useful,
|
10
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
11
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
12
|
+
# GNU General Public License for more details.
|
13
|
+
#
|
14
|
+
# You should have received a copy of the GNU General Public License
|
15
|
+
# along with basechip. If not, see <http://www.gnu.org/licenses/>.
|
16
|
+
|
17
|
+
module BaseChip
|
18
|
+
class Problem
|
19
|
+
attr_accessor :bundle
|
20
|
+
attr_accessor :file
|
21
|
+
attr_accessor :signature
|
22
|
+
def to_s
|
23
|
+
if @bundle
|
24
|
+
"#{File.absolute_path(@bundle).gsub(/#{Regexp.escape($project_root)}\/?/,'$PROJECT_ROOT/')} #{@file} #{@signature}"
|
25
|
+
else
|
26
|
+
"#{@file} #{@signature}"
|
27
|
+
end
|
28
|
+
end
|
29
|
+
def file_and_signature
|
30
|
+
"#{@file} #{@signature}"
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|