Module: BaseChip

Includes:
Reporting
Defined in:
lib/base_chip/git.rb,
lib/base_chip.rb,
lib/reporting.rb,
lib/base_chip/bom.rb,
lib/base_chip/cli.rb,
lib/base_chip/dsl.rb,
lib/base_chip/ipc.rb,
lib/base_chip/base.rb,
lib/base_chip/menu.rb,
lib/base_chip/post.rb,
lib/base_chip/task.rb,
lib/base_chip/test.rb,
lib/base_chip/tool.rb,
lib/base_chip/block.rb,
lib/base_chip/action.rb,
lib/base_chip/tasker.rb,
lib/base_chip/cluster.rb,
lib/base_chip/permute.rb,
lib/base_chip/problem.rb,
lib/base_chip/project.rb,
lib/base_chip/runable.rb,
lib/base_chip/bom_file.rb,
lib/base_chip/out_file.rb,
lib/base_chip/taskable.rb,
lib/base_chip/top_menu.rb,
lib/base_chip/code_area.rb,
lib/base_chip/hierarchy.rb,
lib/base_chip/list_menu.rb,
lib/base_chip/statistic.rb,
lib/base_chip/test_list.rb,
lib/base_chip/exit_error.rb,
lib/base_chip/permutation.rb,
lib/base_chip/requirement.rb,
lib/base_chip/source_type.rb,
lib/base_chip/task_master.rb,
lib/base_chip/track_state.rb,
lib/base_chip/cluster_type.rb,
lib/base_chip/install_menu.rb,
lib/base_chip/tool_version.rb,
lib/base_chip/configuration.rb,
lib/base_chip/generator_menu.rb,
lib/base_chip/source_language.rb

Overview

Copyright 2011 Tommy Poulter

This file is part of basechip.

basechip is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License version 3 as published by the Free Software Foundation.

basechip is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with basechip. If not, see <www.gnu.org/licenses/>.

Defined Under Namespace

Modules: Base, Cli, Dsl, Hierarchy, Ipc, Reporting, Runable, TaskMaster, Taskable, TrackState Classes: Action, Block, Bom, BomType, Cluster, ClusterType, CodeArea, Configuration, ExitError, GeneratorMenu, Git, InstallMenu, ListMenu, Menu, OutFile, Permutation, Permute, Post, Problem, Project, ReportingError, Requirement, SourceLanguage, SourceType, Statistic, Task, Tasker, Test, TestList, Tool, ToolVersion, TopMenu

Constant Summary collapse

RANDOM_NAME_PIECES =
('0'..'9').to_a + ('a'..'z').to_a +  ('A'..'Z').to_a
RANDOM_NAME_PIECES_SIZE =
RANDOM_NAME_PIECES.size
GEM_DIR =
File.expand_path('../..',  File.realpath(__FILE__))
@@options =
OpenStruct.new
@@common_directories =
%w{
    base_chip/tools
    base_chip/recipes
    base_chip/actions
    base_chip/test_lists
    documentation
} 
@@configuration_directories =

base_chip/configurations questionable FIXME

@@common_directories + 
( %w{behavioral rtl gates testbench stimulus}.map{|function| %w{verilog classes vhdl systemc headers}.map{|language| "#{function}/#{language}"}}.flatten +
  %w{synthesis timing sw}
).map {|function| [function,"top_#{function}"] }.flatten
@@block_directories =
@@configuration_directories +
%w{
  base_chip/configurations
}
@@project_directories =
@@common_directories +
%w{
  base_chip/plugins
  base_chip/subprojects
  base_chip/blocks
  base_chip/configurations
  base_chip/cluster_types
}
@@random_generator =
nil

Class Method Summary collapse

Methods included from Reporting

included

Class Method Details

.actionsObject



166
# File 'lib/base_chip.rb', line 166

def self.actions        ; @actions        ||= get_children(self.configurations , :actions       ) end

.block_directoriesObject



99
# File 'lib/base_chip.rb', line 99

def self.        block_directories ;         @@block_directories end

.blocksObject



151
152
153
# File 'lib/base_chip.rb', line 151

def self.blocks
  @project.blocks.values
end

.build_directory_structure(dir, array) ⇒ Object



85
86
87
88
89
# File 'lib/base_chip.rb', line 85

def self.build_directory_structure(dir, array)
  array.each do |subdir|
    FileUtils.mkdir_p dir + "/" + subdir
  end
end

.configuration_directoriesObject



100
# File 'lib/base_chip.rb', line 100

def self.configuration_directories ; @@configuration_directories end

.configurationsObject



165
# File 'lib/base_chip.rb', line 165

def self.configurations ; @configurations ||= get_children(self.blocks         , :configurations) end

.erb_template(in_file, out_file) ⇒ Object



90
91
92
93
94
95
96
# File 'lib/base_chip.rb', line 90

def self.erb_template(in_file, out_file)
  erb = ERB.new(File.read in_file)
  erb.filename = in_file
  File.open(out_file,'w') do |f|
    f.print(erb.result)
  end
end

.find_root(dir = nil, passive = false) ⇒ Object



67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
# File 'lib/base_chip.rb', line 67

def self.find_root(dir = nil, passive=false)
  dir ||= @work_dir ||= Dir.pwd
  @dirs_to_top = []
  loop do
    @dirs_to_top << dir
    break if File.exist? dir + '/base_chip/settings.rb'

    if dir == '/'
      return nil if passive
      fault "Couldn't find file 'base_chip/settings.rb' in any directory above #{Dir.pwd}.\n" +
            "'base_chip/settings.rb' is expected to reside at the top of the checked " +
            "out project, and is generated using the command 'base_chip init'."
    end
    dir = File.expand_path(dir + '/../')
  end
  $project_root = @root = dir
end

.get_children(parents, child_name) ⇒ Object



154
155
156
157
158
159
160
161
162
163
164
# File 'lib/base_chip.rb', line 154

def self.get_children(parents, child_name)
  a = []
  parents.each do |item|
    item.configure
    tmp = item.send(child_name)
    next unless tmp
    a += tmp.values
  end
  a.uniq!
  a
end

.load_environmentObject

SAFE TO DELETE? def self.action(name, &b) SAFE TO DELETE? @action_builders ||= {} SAFE TO DELETE? @action_builders ||= [] SAFE TO DELETE? @action_builders << b SAFE TO DELETE? end



142
143
144
145
146
147
148
149
# File 'lib/base_chip.rb', line 142

def self.load_environment
  find_root
  file = "#{BaseChip.root}/base_chip/settings.rb"
  instance_eval(File.read(file),file)
  file = '~/.basechip'
  instance_eval(File.read(file),file) if File.exist? file
  @project.configure
end

.new_random_generatorObject



183
184
185
186
187
188
189
# File 'lib/base_chip.rb', line 183

def self.new_random_generator
  if @@options.seed
    random_generator
  else
    Random.new(random_generator.rand(0x1_0000_0000))
  end
end

.optionsObject



63
64
65
# File 'lib/base_chip.rb', line 63

def self.options
  @@options
end

.project(name = nil, &blk) ⇒ Object



128
129
130
131
132
133
134
135
136
# File 'lib/base_chip.rb', line 128

def self.project(name = nil, &blk)
  if name
    @project = Project.new
    @project.name = name
    @project.blks << blk
  else
    @project
  end
end

.project=(project) ⇒ Object



60
# File 'lib/base_chip.rb', line 60

def self.project=(project)     ; @project = project   ; end

.project_directoriesObject



98
# File 'lib/base_chip.rb', line 98

def self.      project_directories ;       @@project_directories end

.random_generatorObject



176
177
178
179
180
181
182
# File 'lib/base_chip.rb', line 176

def self.random_generator
  @@random_generator ||= if @@options.seed
                           Random.new(@@options.seed    )
                         else
                           Random.new(rand(0x1_0000_0000))
                         end
end

.random_string(size = 10) ⇒ Object



49
50
51
52
53
54
55
# File 'lib/base_chip.rb', line 49

def self.random_string(size=10)
  str = ''
  size.times do
    str += RANDOM_NAME_PIECES[rand(RANDOM_NAME_PIECES_SIZE)]
  end
  str
end

.rootObject



59
# File 'lib/base_chip.rb', line 59

def self.root                  ; @root                ; end

.root=(root) ⇒ Object



58
# File 'lib/base_chip.rb', line 58

def self.root=(root)           ; @root    = root      ; end

.test_listsObject



167
# File 'lib/base_chip.rb', line 167

def self.test_lists     ; @test_lists     ||= get_children(self.configurations , :test_lists    ) end

.testsObject



168
# File 'lib/base_chip.rb', line 168

def self.tests          ; @tests          ||= get_children(self.test_lists     , :tests         ) end

.toolsObject



169
# File 'lib/base_chip.rb', line 169

def self.tools          ; @tools          ||= get_children(self.configurations , :tools         ) end

.version_controlObject



171
172
173
# File 'lib/base_chip.rb', line 171

def self.version_control
  @version_control ||= (Git.new(root) if File.exist?("#{root}/.git"))
end