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,257 @@
|
|
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/code_area'
|
18
|
+
require 'base_chip/action'
|
19
|
+
require 'base_chip/test_list'
|
20
|
+
require 'base_chip/bom'
|
21
|
+
require 'base_chip/hierarchy'
|
22
|
+
|
23
|
+
module BaseChip
|
24
|
+
class Configuration
|
25
|
+
include Dsl
|
26
|
+
include Base
|
27
|
+
include Hierarchy
|
28
|
+
|
29
|
+
# Defines aliases within this block:configuration pointing to actions, test lists or tests.
|
30
|
+
# Consider using "shortcut" to avoid destroying shortcuts already defined.
|
31
|
+
# @example Create a "build" shortcut pointing to 3 build stages, and a "gate" shortcut to build and run the starter list
|
32
|
+
# shortcuts :build => %w{stage1 stage2 stage3}, :gate => %w{build starter}
|
33
|
+
define_setting :shortcuts , [ Hash ]
|
34
|
+
# Defines aliases within this block:configuration pointing to actions, test lists or tests.
|
35
|
+
# Consider using "append_subblocks" to avoid destroying shortcuts already defined.
|
36
|
+
# @example This block:configuration depends on the default config of the memory controller, and the x16 configuration of PCI Express
|
37
|
+
# subblocks %w{mem pci:x16}
|
38
|
+
define_setting :subblocks , [ String,Array ]
|
39
|
+
# define an action in this
|
40
|
+
define_child :action , Action
|
41
|
+
define_child :test_list , TestList
|
42
|
+
define_child :source_type , SourceType
|
43
|
+
define_child :tool , Tool
|
44
|
+
#define_child :synthesis , ScriptArea
|
45
|
+
#define_child :timing , ScriptArea
|
46
|
+
#define_child :bin , ScriptArea
|
47
|
+
|
48
|
+
# Defines an alias within this block:configuration pointing to actions, test lists or tests.
|
49
|
+
# Equvalent to \{append_shortcuts}
|
50
|
+
# @example create a "build" shortcut pointing to 3 build stages
|
51
|
+
# shortcut :build , %w{stage1 stage2 stage3}
|
52
|
+
# @example create a "gate" shortcut to build (from the above example) and run the starter list
|
53
|
+
# shortcut :gate , %w{build starter }
|
54
|
+
# @see shortcuts
|
55
|
+
def shortcut(name, array)
|
56
|
+
@shortcuts ||= HashWithIndifferentAccess.new
|
57
|
+
@shortcuts[name] = array
|
58
|
+
end
|
59
|
+
|
60
|
+
# create a "Bom" object based on the source code in this configuration, and the selected configurations of it's subblocks
|
61
|
+
# @return [BaseChip::Bom]
|
62
|
+
def bom
|
63
|
+
return @bom if @bom
|
64
|
+
hash = HashWithIndifferentAccess.new
|
65
|
+
all_configs.each do |sc|
|
66
|
+
sc.configure
|
67
|
+
next unless sc.source_types
|
68
|
+
sc.source_types.each do |stn,st|
|
69
|
+
next if sc != self and stn.to_s =~ /^top/
|
70
|
+
st.configure
|
71
|
+
next unless st.source_languages
|
72
|
+
tmp = hash[stn] ||= HashWithIndifferentAccess.new
|
73
|
+
st.source_languages.each do |sln,sl|
|
74
|
+
sl.configure
|
75
|
+
tmp[sln] ||= []
|
76
|
+
tmp[sln] += sl.files
|
77
|
+
end
|
78
|
+
end
|
79
|
+
end
|
80
|
+
@bom = Bom.new(hash)
|
81
|
+
end
|
82
|
+
# @private
|
83
|
+
def all_configs ; @all_configs ||= self.subblock_configs + [self] ; end
|
84
|
+
# @private
|
85
|
+
def up_configs ; @up_configs ||= self. upblock_configs + [self] ; end
|
86
|
+
# @private
|
87
|
+
def subblock_configs
|
88
|
+
return @subblock_configs if @subblock_configs
|
89
|
+
configure
|
90
|
+
@subblock_configs = []
|
91
|
+
return @subblock_configs unless @subblocks
|
92
|
+
@subblocks.map do |s|
|
93
|
+
full = s.to_s.split(/:/)
|
94
|
+
|
95
|
+
if @project.subprojects && (project = @project.subprojects[full[0].to_sym])
|
96
|
+
full.shift
|
97
|
+
project.configure
|
98
|
+
else
|
99
|
+
project = @project
|
100
|
+
end
|
101
|
+
|
102
|
+
block = project.blocks[full[0].to_sym]
|
103
|
+
if block
|
104
|
+
full.shift
|
105
|
+
elsif project != @project
|
106
|
+
fault "couldn't find block '#{full[0]}' in project '#{project.name}' needed by #{full_name} as subblock"
|
107
|
+
else
|
108
|
+
fault "couldn't find block/subproject '#{full[0]}' needed by #{full_name} as subblock"
|
109
|
+
end
|
110
|
+
block.configure
|
111
|
+
|
112
|
+
full[0] ||= :default
|
113
|
+
c = block.configurations[full[0].to_sym] || (fault "couldn't find configuration '#{full[1]}' for block '#{block.full_name}' needed by #{full_name} as subblock")
|
114
|
+
@subblock_configs += c.all_configs
|
115
|
+
end
|
116
|
+
@subblock_configs.uniq!
|
117
|
+
@subblock_configs
|
118
|
+
end
|
119
|
+
# @private
|
120
|
+
def upblock_configs
|
121
|
+
return @upblock_configs if @upblock_configs
|
122
|
+
configure
|
123
|
+
@upblock_configs = []
|
124
|
+
BaseChip.configurations.each do |c|
|
125
|
+
@upblock_configs << c if c.all_configs.include? self
|
126
|
+
end
|
127
|
+
@upblock_configs.uniq!
|
128
|
+
@upblock_configs
|
129
|
+
end
|
130
|
+
|
131
|
+
# OK to delete? def configure_test_lists(test_list_names)
|
132
|
+
# OK to delete? test_list_names.each do |tl_name|
|
133
|
+
# OK to delete? @test_lists[tl_name].deep_configure
|
134
|
+
# OK to delete? end
|
135
|
+
# OK to delete? end
|
136
|
+
|
137
|
+
# @private
|
138
|
+
def action_dereference(name,passive)
|
139
|
+
if action = @actions[name]
|
140
|
+
action.deep_configure
|
141
|
+
[action]
|
142
|
+
elsif passive
|
143
|
+
[]
|
144
|
+
else
|
145
|
+
fault "Could not find action or shortcut #{n} in configuration #{full_name}" # FIXME say who wanted it, and if shortcut occurred
|
146
|
+
end
|
147
|
+
end
|
148
|
+
# @private
|
149
|
+
def test_list_dereference(name,names,passive)
|
150
|
+
if test_list = @test_lists[name]
|
151
|
+
test_list.deep_configure
|
152
|
+
test_list.dereference_workload(names,passive)
|
153
|
+
elsif passive
|
154
|
+
[]
|
155
|
+
else
|
156
|
+
fault "Could not find test list or shortcut #{n} in configuration #{full_name}" # FIXME say who wanted it, and if shortcut occurred
|
157
|
+
end
|
158
|
+
end
|
159
|
+
# @private
|
160
|
+
def dereference_workload(names = nil,passive=false)
|
161
|
+
configure
|
162
|
+
names = names ? names.dup : ['all']
|
163
|
+
if @shortcuts
|
164
|
+
loop do # dereference shortcuts
|
165
|
+
found = false
|
166
|
+
names.map! do |n| # FIXME error if shortcuts contain 'all' or 'gate'
|
167
|
+
if a = @shortcuts[n.to_sym]
|
168
|
+
found = n
|
169
|
+
a
|
170
|
+
else
|
171
|
+
n
|
172
|
+
end
|
173
|
+
end
|
174
|
+
if found
|
175
|
+
names.flatten!
|
176
|
+
# TODO Catch infinite shortcut loop
|
177
|
+
else
|
178
|
+
break
|
179
|
+
end
|
180
|
+
end
|
181
|
+
end
|
182
|
+
|
183
|
+
out = Array.new
|
184
|
+
test_lists = HashWithIndifferentAccess.new
|
185
|
+
names.each do |n|
|
186
|
+
n = n.to_s
|
187
|
+
case n
|
188
|
+
when 'upgate' ; up_configs.each {|c| out += c.dereference_workload(['gate'], true)}
|
189
|
+
when 'downgate' ; all_configs.each {|c| out += c.dereference_workload(['gate'], true)}
|
190
|
+
when 'diffgate' ;
|
191
|
+
all_configs.each do |c|
|
192
|
+
if c.files_changed?
|
193
|
+
out += self.dereference_workload(['upgate'], true)
|
194
|
+
break
|
195
|
+
end
|
196
|
+
end
|
197
|
+
when 'all' # FIXME , 'alltests', 'allactions'
|
198
|
+
if @actions ; @actions .each { |k,v| out += action_dereference(k, true) unless v.abstract } end
|
199
|
+
if @test_lists; @test_lists.keys.each { |k | out += test_list_dereference(k, ['all'], true) } end
|
200
|
+
when /^all:(.*)$/
|
201
|
+
tmp = $1
|
202
|
+
@test_lists.each_key do |k|
|
203
|
+
out += test_list_dereference k, [tmp], passive
|
204
|
+
end
|
205
|
+
when /^(.*?):(.*)$/
|
206
|
+
out += test_list_dereference $1.to_sym, [$2], passive
|
207
|
+
else
|
208
|
+
fault "No actions or test lists specified for configuration #{full_name}" unless @actions || @test_lists || passive
|
209
|
+
if @actions && @actions[n.to_sym]
|
210
|
+
out += action_dereference n.to_sym, passive
|
211
|
+
elsif @test_lists && @test_lists[n.to_sym]
|
212
|
+
out += test_list_dereference n.to_sym, ['all'], true
|
213
|
+
else
|
214
|
+
fault "Could not find action, test list, or shortcut named #{n} in configuration #{full_name}" unless passive # FIXME say who wanted it, and if shortcut occurred
|
215
|
+
end
|
216
|
+
end
|
217
|
+
end
|
218
|
+
out.uniq!
|
219
|
+
out
|
220
|
+
end
|
221
|
+
# @private
|
222
|
+
def files_changed?
|
223
|
+
my_dirs = [ "base_chip",
|
224
|
+
"#{block.directory}/base_chip",
|
225
|
+
"#{self .directory}/base_chip"]
|
226
|
+
if self.source_types
|
227
|
+
self.source_types.values.each do |st|
|
228
|
+
next unless st.source_languages
|
229
|
+
st.source_languages.values.each do |sl|
|
230
|
+
my_dirs += sl.directories if sl.directories
|
231
|
+
end
|
232
|
+
end
|
233
|
+
end
|
234
|
+
|
235
|
+
BaseChip.version_control.changed.each do |theirs|
|
236
|
+
my_dirs.each do |mine|
|
237
|
+
mine = mine.gsub(/#{Regexp.escape project.directory}\/?\b/,'')
|
238
|
+
if theirs =~ /#{Regexp.escape mine}\b/
|
239
|
+
puts "theirs = #{theirs} mine = #{mine}"
|
240
|
+
return true
|
241
|
+
end
|
242
|
+
end
|
243
|
+
end
|
244
|
+
false
|
245
|
+
end
|
246
|
+
|
247
|
+
# @private
|
248
|
+
def out_directory
|
249
|
+
@out_directory ||= if BaseChip.options.out_dir
|
250
|
+
BaseChip.options.out_dir
|
251
|
+
else
|
252
|
+
@directory + '/out'
|
253
|
+
end
|
254
|
+
end
|
255
|
+
|
256
|
+
end
|
257
|
+
end
|