origen 0.38.0 → 0.40.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/bin/origen +1 -236
- data/config/application.rb +10 -1
- data/config/version.rb +1 -1
- data/lib/origen/{boot_api.rb → boot/api.rb} +2 -2
- data/lib/origen/boot/app.rb +324 -0
- data/lib/origen/boot.rb +287 -0
- data/lib/origen/commands/archive.rb +175 -0
- data/lib/origen/commands/extract.rb +43 -0
- data/lib/origen/commands/new.rb +33 -23
- data/lib/origen/commands.rb +4 -1
- data/lib/origen/commands_global.rb +3 -2
- data/lib/origen/operating_systems.rb +4 -0
- data/lib/origen/revision_control.rb +1 -1
- data/lib/origen/site_config.rb +4 -1
- data/lib/origen.rb +3 -2
- data/origen_app_generators/Gemfile +16 -0
- data/origen_app_generators/Gemfile.lock +147 -0
- data/origen_app_generators/LICENSE +21 -0
- data/origen_app_generators/README.md +368 -0
- data/origen_app_generators/Rakefile +10 -0
- data/origen_app_generators/bin/boot.rb +37 -0
- data/{bin → origen_app_generators/bin}/fix_my_workspace +0 -0
- data/origen_app_generators/config/application.rb +153 -0
- data/origen_app_generators/config/boot.rb +1 -0
- data/origen_app_generators/config/commands.rb +63 -0
- data/origen_app_generators/config/shared_commands.rb +172 -0
- data/origen_app_generators/config/version.rb +8 -0
- data/origen_app_generators/doc/history +213 -0
- data/origen_app_generators/lib/origen_app_generators/application.rb +62 -0
- data/origen_app_generators/lib/origen_app_generators/base.rb +231 -0
- data/origen_app_generators/lib/origen_app_generators/empty_application.rb +15 -0
- data/origen_app_generators/lib/origen_app_generators/empty_plugin.rb +15 -0
- data/origen_app_generators/lib/origen_app_generators/new.rb +162 -0
- data/origen_app_generators/lib/origen_app_generators/origen_infrastructure/app_generator_plugin.rb +109 -0
- data/origen_app_generators/lib/origen_app_generators/plugin.rb +58 -0
- data/origen_app_generators/lib/origen_app_generators/sub_block_parser.rb +81 -0
- data/origen_app_generators/lib/origen_app_generators/test_engineering/stand_alone_application.rb +236 -0
- data/origen_app_generators/lib/origen_app_generators/test_engineering/test_block.rb +162 -0
- data/origen_app_generators/lib/origen_app_generators.rb +123 -0
- data/origen_app_generators/lib/tasks/app_generators.rake +6 -0
- data/origen_app_generators/lib/tasks/new_app_tests.rake +8 -0
- data/origen_app_generators/origen_app_generators.gemspec +33 -0
- data/origen_app_generators/spec/spec_helper.rb +49 -0
- data/origen_app_generators/spec/sub_block_spec.rb +36 -0
- data/origen_app_generators/target/debug.rb +8 -0
- data/origen_app_generators/target/default.rb +8 -0
- data/origen_app_generators/target/production.rb +0 -0
- data/origen_app_generators/templates/app_generators/application/Gemfile +19 -0
- data/origen_app_generators/templates/app_generators/application/Rakefile +7 -0
- data/origen_app_generators/templates/app_generators/application/config/application.rb +125 -0
- data/origen_app_generators/templates/app_generators/application/config/boot.rb +4 -0
- data/origen_app_generators/templates/app_generators/application/config/commands.rb +79 -0
- data/origen_app_generators/templates/app_generators/application/config/maillist_dev.txt +4 -0
- data/origen_app_generators/templates/app_generators/application/config/maillist_prod.txt +3 -0
- data/origen_app_generators/templates/app_generators/application/config/version.rb +8 -0
- data/origen_app_generators/templates/app_generators/application/doc/history +0 -0
- data/origen_app_generators/templates/app_generators/application/dot_keep +0 -0
- data/origen_app_generators/templates/app_generators/application/lib/app.rake +6 -0
- data/origen_app_generators/templates/app_generators/application/lib/module.rb +22 -0
- data/origen_app_generators/templates/app_generators/application/lib/top_level.rb +12 -0
- data/origen_app_generators/templates/app_generators/application/origen_core_session +2 -0
- data/origen_app_generators/templates/app_generators/application/spec/spec_helper.rb +44 -0
- data/origen_app_generators/templates/app_generators/application/target/debug.rb +8 -0
- data/origen_app_generators/templates/app_generators/application/target/default.rb +1 -0
- data/origen_app_generators/templates/app_generators/application/target/production.rb +4 -0
- data/origen_app_generators/templates/app_generators/application/templates/web/index.md.erb +19 -0
- data/origen_app_generators/templates/app_generators/application/templates/web/layouts/_basic.html.erb +13 -0
- data/origen_app_generators/templates/app_generators/application/templates/web/partials/_navbar.html.erb +20 -0
- data/origen_app_generators/templates/app_generators/application/templates/web/release_notes.md.erb +5 -0
- data/origen_app_generators/templates/app_generators/new/generator.rb +102 -0
- data/origen_app_generators/templates/app_generators/new/info.md.erb +9 -0
- data/origen_app_generators/templates/app_generators/origen_infrastructure/app_generator_plugin/config/load_generators.rb +6 -0
- data/origen_app_generators/templates/app_generators/origen_infrastructure/app_generator_plugin/lib/application.rb +54 -0
- data/origen_app_generators/templates/app_generators/origen_infrastructure/app_generator_plugin/lib/base.rb +55 -0
- data/origen_app_generators/templates/app_generators/origen_infrastructure/app_generator_plugin/lib/module.rb +28 -0
- data/origen_app_generators/templates/app_generators/origen_infrastructure/app_generator_plugin/lib/plugin.rb +64 -0
- data/origen_app_generators/templates/app_generators/plugin/Gemfile +26 -0
- data/origen_app_generators/templates/app_generators/plugin/Rakefile +10 -0
- data/origen_app_generators/templates/app_generators/plugin/config/boot.rb +24 -0
- data/origen_app_generators/templates/app_generators/plugin/gemspec.rb +42 -0
- data/origen_app_generators/templates/app_generators/plugin/lib/README +4 -0
- data/origen_app_generators/templates/app_generators/plugin/lib_dev/README +5 -0
- data/origen_app_generators/templates/app_generators/plugin/templates/web/index.md.erb +37 -0
- data/origen_app_generators/templates/app_generators/plugin/templates/web/partials/_navbar_external.html.erb +20 -0
- data/origen_app_generators/templates/app_generators/plugin/templates/web/partials/_navbar_internal.html.erb +20 -0
- data/origen_app_generators/templates/app_generators/test_engineering/stand_alone_application/Gemfile +23 -0
- data/origen_app_generators/templates/app_generators/test_engineering/stand_alone_application/environment/j750.rb +1 -0
- data/origen_app_generators/templates/app_generators/test_engineering/stand_alone_application/environment/jlink.rb +1 -0
- data/origen_app_generators/templates/app_generators/test_engineering/stand_alone_application/environment/uflex.rb +1 -0
- data/origen_app_generators/templates/app_generators/test_engineering/stand_alone_application/environment/v93k.rb +1 -0
- data/origen_app_generators/templates/app_generators/test_engineering/stand_alone_application/lib/ip_block.rb +23 -0
- data/origen_app_generators/templates/app_generators/test_engineering/stand_alone_application/lib/ip_block_controller.rb +5 -0
- data/origen_app_generators/templates/app_generators/test_engineering/stand_alone_application/lib/top_level.rb +33 -0
- data/origen_app_generators/templates/app_generators/test_engineering/stand_alone_application/lib/top_level_controller.rb +21 -0
- data/origen_app_generators/templates/app_generators/test_engineering/stand_alone_application/pattern/example.rb +4 -0
- data/origen_app_generators/templates/app_generators/test_engineering/stand_alone_application/target/top_level.rb +4 -0
- data/origen_app_generators/templates/app_generators/test_engineering/test_block/environment/j750.rb +2 -0
- data/origen_app_generators/templates/app_generators/test_engineering/test_block/environment/ultraflex.rb +2 -0
- data/origen_app_generators/templates/app_generators/test_engineering/test_block/environment/v93k.rb +2 -0
- data/origen_app_generators/templates/app_generators/test_engineering/test_block/lib/controller.rb +12 -0
- data/origen_app_generators/templates/app_generators/test_engineering/test_block/lib/interface.rb +21 -0
- data/origen_app_generators/templates/app_generators/test_engineering/test_block/lib/model.rb +18 -0
- data/origen_app_generators/templates/app_generators/test_engineering/test_block/lib_dev/dut.rb +27 -0
- data/origen_app_generators/templates/app_generators/test_engineering/test_block/lib_dev/dut_controller.rb +26 -0
- data/origen_app_generators/templates/app_generators/test_engineering/test_block/pattern/example.rb +5 -0
- data/origen_app_generators/templates/app_generators/test_engineering/test_block/program/prb1.rb +11 -0
- data/origen_app_generators/templates/app_generators/test_engineering/test_block/target/default.rb +2 -0
- data/origen_site_config.yml +13 -2
- data/templates/git/gitignore.erb +0 -1
- metadata +99 -4
data/origen_app_generators/lib/origen_app_generators/test_engineering/stand_alone_application.rb
ADDED
@@ -0,0 +1,236 @@
|
|
1
|
+
module OrigenAppGenerators
|
2
|
+
module TestEngineering
|
3
|
+
require 'origen_app_generators/sub_block_parser'
|
4
|
+
# Generates a generic application shell
|
5
|
+
class StandAloneApplication < Application
|
6
|
+
desc 'A stand alone test engineering application'
|
7
|
+
|
8
|
+
# Any methods that are not protected will get invoked in the order that they are
|
9
|
+
# defined when the generator is run, method naming is irrelevant unless you want
|
10
|
+
# to override a method that is defined by the parent class
|
11
|
+
|
12
|
+
def get_user_input
|
13
|
+
# The methods to get the common user input that applies to all applications will
|
14
|
+
# get called at the start automatically, you have a chance here to ask any additional
|
15
|
+
# questions that are specific to the type of application being generated
|
16
|
+
get_top_level_names
|
17
|
+
get_sub_block_names
|
18
|
+
end
|
19
|
+
|
20
|
+
def generate_files
|
21
|
+
# Calling this will build all files, directories and symlinks contained in the
|
22
|
+
# hash returned by the filelist method
|
23
|
+
build_filelist
|
24
|
+
end
|
25
|
+
|
26
|
+
def modify_files
|
27
|
+
# If you want to modify any of the generated files you can do so now, you have access
|
28
|
+
# to all of the Thor Action methods described here:
|
29
|
+
# http://www.rubydoc.info/github/wycats/thor/Thor/Actions
|
30
|
+
# See the enable method in lib/app_generators/new.rb for some examples of using these.
|
31
|
+
end
|
32
|
+
|
33
|
+
def conclude
|
34
|
+
# Print out anything you think the user should know about their new application at the end
|
35
|
+
puts "New app created at: #{destination_root}"
|
36
|
+
end
|
37
|
+
|
38
|
+
protected
|
39
|
+
|
40
|
+
def sub_block_parser
|
41
|
+
@sub_block_parser ||= SubBlockParser.new
|
42
|
+
end
|
43
|
+
|
44
|
+
def get_top_level_names
|
45
|
+
puts
|
46
|
+
puts 'NAME YOUR TOP-LEVEL DEVICE(S)'
|
47
|
+
puts
|
48
|
+
puts 'What do you want to call the top-level class that represents your device?'
|
49
|
+
puts 'By default it will be called TopLevel, but if you want this application to support multiple devices you should'
|
50
|
+
puts 'give them unique names.'
|
51
|
+
puts 'Separate multiple names with a comma: Falcon, Eagle, Vulture'
|
52
|
+
puts
|
53
|
+
|
54
|
+
valid = false
|
55
|
+
until valid
|
56
|
+
@top_level_names = get_text(single: true, default: 'TopLevel').strip.split(',').map do |name|
|
57
|
+
name.strip.gsub(/\s+/, '_').camelize
|
58
|
+
end
|
59
|
+
unless @top_level_names.empty?
|
60
|
+
# Should we check anything here?
|
61
|
+
valid = true
|
62
|
+
end
|
63
|
+
end
|
64
|
+
@top_level_names
|
65
|
+
end
|
66
|
+
|
67
|
+
def get_sub_block_names
|
68
|
+
puts
|
69
|
+
puts 'DEFINE YOUR SUB-BLOCKS'
|
70
|
+
puts
|
71
|
+
puts 'What sub-blocks does this device contain?'
|
72
|
+
puts 'You can leave this blank, but entering some details of the sub-blocks you will want to involve in your tests'
|
73
|
+
puts 'will save you some manual setup of the associated models and controllers.'
|
74
|
+
puts 'You can specify layers of hierarchy and multiple instantiations, here are some examples:'
|
75
|
+
puts
|
76
|
+
puts ' A RAM, OSC, PLL and 2 ATDs at the top-level: ram, osc, pll, atd(2)'
|
77
|
+
puts ' With 3 COMMS blocks with embedded components: ram, osc, pll, atd(2), comms[ram(2), osc](3)'
|
78
|
+
if @top_level_names.size > 1
|
79
|
+
puts
|
80
|
+
puts 'If you want different modules for each of your top-level devices you can do:'
|
81
|
+
puts
|
82
|
+
puts " #{@top_level_names[0]}[ram, atd(2)], #{@top_level_names[1]}[ram(2), atd(4)]"
|
83
|
+
end
|
84
|
+
puts
|
85
|
+
|
86
|
+
valid = false
|
87
|
+
until valid
|
88
|
+
input = get_text(single: true).strip
|
89
|
+
if input.empty?
|
90
|
+
@sub_blocks_lookup = {}
|
91
|
+
valid = true
|
92
|
+
else
|
93
|
+
begin
|
94
|
+
@sub_blocks_lookup = sub_block_parser.parse(input)
|
95
|
+
valid = true
|
96
|
+
rescue
|
97
|
+
valid = false
|
98
|
+
end
|
99
|
+
end
|
100
|
+
end
|
101
|
+
@sub_blocks_lookup
|
102
|
+
end
|
103
|
+
|
104
|
+
# Returns a hash that looks like:
|
105
|
+
#
|
106
|
+
# {"Falcon"=>{"RAM"=>{}, "ATD"=>{:instances=>2}}, "Eagle"=>{"RAM"=>{:instances=>2}, "ATD"=>{:instances=>4}}}
|
107
|
+
def top_level_sub_blocks
|
108
|
+
blocks = {}
|
109
|
+
# Make sure that each top-level object has a sub blocks assignment
|
110
|
+
if @top_level_names.any? { |n| @sub_blocks_lookup[n] }
|
111
|
+
@top_level_names.each do |name|
|
112
|
+
if @sub_blocks_lookup[name]
|
113
|
+
blocks[name] = @sub_blocks_lookup[name][:children] || {}
|
114
|
+
else
|
115
|
+
blocks[name] = {}
|
116
|
+
end
|
117
|
+
end
|
118
|
+
# Duplicate the given sub blocks to all top-level objects if none have been specified
|
119
|
+
else
|
120
|
+
@top_level_names.each do |name|
|
121
|
+
blocks[name] = @sub_blocks_lookup
|
122
|
+
end
|
123
|
+
end
|
124
|
+
blocks
|
125
|
+
end
|
126
|
+
|
127
|
+
# Returns a hash with all sub-blocks at the top-level, e.g.:
|
128
|
+
#
|
129
|
+
# {"RAM"=>{}, "ATD"=>{}, "Comms"=>{"RAM"=>{:instances=>2}, "Osc"=>{}}, "Osc"=>{}}
|
130
|
+
def sub_blocks
|
131
|
+
blocks = {}
|
132
|
+
top_level_sub_blocks.each do |top, attrs|
|
133
|
+
extract_sub_blocks(attrs) do |name, attrs|
|
134
|
+
if blocks[name]
|
135
|
+
if blocks[name] != (attrs[:children] || {})
|
136
|
+
Origen.log.warning "The app builder does not currently support different sub-block definitions for block #{name}"
|
137
|
+
Origen.log.warning 'Only the first defintion has been built'
|
138
|
+
end
|
139
|
+
else
|
140
|
+
blocks[name] = attrs[:children] || {}
|
141
|
+
end
|
142
|
+
end
|
143
|
+
end
|
144
|
+
blocks
|
145
|
+
end
|
146
|
+
|
147
|
+
def extract_sub_blocks(blocks, &block)
|
148
|
+
blocks.each do |name, attrs|
|
149
|
+
yield name, attrs
|
150
|
+
extract_sub_blocks(attrs[:children], &block) if attrs[:children]
|
151
|
+
end
|
152
|
+
end
|
153
|
+
|
154
|
+
# Defines the filelist for the generator, the default list is inherited from the
|
155
|
+
# parent class (Application).
|
156
|
+
# The filelist can contain references to generate files, directories or symlinks in the
|
157
|
+
# new application.
|
158
|
+
#
|
159
|
+
# Generally to make your generator more maintainable try and re-use as much as possible
|
160
|
+
# from the parent generator, this means that your generator will automatically stay up
|
161
|
+
# to date with the latest conventions
|
162
|
+
#
|
163
|
+
# The master templates live in templates/app_generators/application, but
|
164
|
+
# DO NOT MODIFY THESE FILES DIRECTLY.
|
165
|
+
# Either add or remove things post-generation in the modify_files method or copy the
|
166
|
+
# master file to the equivalent sub-directory of templates/app_generators/test_engineering/generic_stand_alone_application
|
167
|
+
# which will override the version in the master directory.
|
168
|
+
#
|
169
|
+
# Additional files can be added or removed from the filelist as shown below.
|
170
|
+
def filelist
|
171
|
+
@filelist ||= begin
|
172
|
+
list = super # Always pick up the parent list
|
173
|
+
# Example of how to remove a file from the parent list
|
174
|
+
list.delete(:lib_top_level)
|
175
|
+
list.delete(:target_debug)
|
176
|
+
list.delete(:target_production)
|
177
|
+
list.delete(:target_default)
|
178
|
+
# Example of how to add a file, in this case the file will be compiled and copied to
|
179
|
+
# the same location in the new app
|
180
|
+
@top_level_names.each_with_index do |name, i|
|
181
|
+
list["top_level_model_#{i}"] = { source: 'lib/top_level.rb',
|
182
|
+
dest: "lib/#{@name}/#{name.underscore}.rb",
|
183
|
+
options: { name: name, sub_blocks: top_level_sub_blocks[name] }
|
184
|
+
}
|
185
|
+
|
186
|
+
list["top_level_controller_#{i}"] = { source: 'lib/top_level_controller.rb',
|
187
|
+
dest: "lib/#{@name}/#{name.underscore}_controller.rb",
|
188
|
+
options: { name: name }
|
189
|
+
}
|
190
|
+
|
191
|
+
list["target_#{name}"] = { source: 'target/top_level.rb',
|
192
|
+
dest: "target/#{name.underscore}.rb",
|
193
|
+
options: { name: name }
|
194
|
+
}
|
195
|
+
if i == 0
|
196
|
+
list[:target_default] = { source: "#{name.underscore}.rb", # Relative to the file being linked to
|
197
|
+
dest: 'target/default.rb', # Relative to destination_root
|
198
|
+
type: :symlink }
|
199
|
+
end
|
200
|
+
end
|
201
|
+
|
202
|
+
sub_blocks.each do |name, blocks|
|
203
|
+
list["ip_block_#{name}"] = { source: 'lib/ip_block.rb',
|
204
|
+
dest: "lib/#{@name}/#{name.underscore}.rb",
|
205
|
+
options: { name: name, sub_blocks: blocks }
|
206
|
+
}
|
207
|
+
|
208
|
+
list["ip_block_controller_#{name}"] = { source: 'lib/ip_block_controller.rb',
|
209
|
+
dest: "lib/#{@name}/#{name.underscore}_controller.rb" }
|
210
|
+
end
|
211
|
+
|
212
|
+
list[:environment_j750] = { source: 'environment/j750.rb' }
|
213
|
+
list[:environment_uflex] = { source: 'environment/uflex.rb' }
|
214
|
+
list[:environment_v93k] = { source: 'environment/v93k.rb' }
|
215
|
+
list[:environment_jlink] = { source: 'environment/jlink.rb' }
|
216
|
+
# Alternatively specifying a different destination, typically you would do this when
|
217
|
+
# the final location is dynamic
|
218
|
+
# list[:gemspec] = { source: 'gemspec.rb', dest: "#{@name}.gemspec" }
|
219
|
+
# Example of how to create a directory
|
220
|
+
# list[:pattern_dir] = { dest: "pattern", type: :directory }
|
221
|
+
# Example of how to create a symlink
|
222
|
+
list[:environment_default] = { source: 'j750.rb', # Relative to the file being linked to
|
223
|
+
dest: 'environment/default.rb', # Relative to destination_root
|
224
|
+
type: :symlink }
|
225
|
+
# Test engineering source directories
|
226
|
+
list[:program_dir] = { dest: 'program', type: :directory }
|
227
|
+
list[:pattern_dir] = { dest: 'pattern', type: :directory }
|
228
|
+
# Example source files
|
229
|
+
list[:pattern_example] = { source: 'pattern/example.rb' }
|
230
|
+
# Remember to return the final list
|
231
|
+
list
|
232
|
+
end
|
233
|
+
end
|
234
|
+
end
|
235
|
+
end
|
236
|
+
end
|
@@ -0,0 +1,162 @@
|
|
1
|
+
module OrigenAppGenerators
|
2
|
+
module TestEngineering
|
3
|
+
# Generates a generic plugin shell
|
4
|
+
class TestBlock < Plugin
|
5
|
+
desc 'An IP test module intended to plugin into a top-level (SoC) application'
|
6
|
+
|
7
|
+
def initialize(*args)
|
8
|
+
@audience = :internal
|
9
|
+
super
|
10
|
+
end
|
11
|
+
|
12
|
+
def get_user_input
|
13
|
+
# The methods to get the common user input that applies to all applications will
|
14
|
+
# get called at the start automatically, you have a chance here to ask any additional
|
15
|
+
# questions that are specific to the type of application being generated
|
16
|
+
get_ip_names
|
17
|
+
get_sub_block_name
|
18
|
+
end
|
19
|
+
|
20
|
+
def generate_files
|
21
|
+
@runtime_dependencies = [
|
22
|
+
['origen_testers', '>= 0.6.1']
|
23
|
+
]
|
24
|
+
build_filelist
|
25
|
+
end
|
26
|
+
|
27
|
+
def final_modifications
|
28
|
+
prepend_to_file "lib/#{@name}.rb", "require 'origen_testers'\n"
|
29
|
+
# Add require line
|
30
|
+
doc_helpers = /gem 'origen_doc_helpers'/
|
31
|
+
inject_into_file 'Gemfile', "\ngem 'origen_jtag'\ngem 'origen_arm_debug'\n",
|
32
|
+
after: doc_helpers
|
33
|
+
end
|
34
|
+
|
35
|
+
def conclude
|
36
|
+
puts "New test module created at: #{destination_root}"
|
37
|
+
puts
|
38
|
+
puts 'Generate an example pattern by running "origen g example"'
|
39
|
+
end
|
40
|
+
|
41
|
+
protected
|
42
|
+
|
43
|
+
def get_ip_names
|
44
|
+
puts
|
45
|
+
puts 'NAME THE IP BLOCKS THAT THIS MODULE WILL SUPPORT'
|
46
|
+
puts
|
47
|
+
puts "You don't need to name them all up front, but you must declare at least one."
|
48
|
+
puts 'We recommend that you use the official name(s) for the IP(s) as used by your design team.'
|
49
|
+
puts 'Separate multiple names with a comma: FLASH_C40_512K, FLASH_C40_2M'
|
50
|
+
puts
|
51
|
+
|
52
|
+
valid = false
|
53
|
+
until valid
|
54
|
+
@ip_names = get_text(single: true).strip.split(',').map do |name|
|
55
|
+
n = name.strip.symbolize.to_s.upcase
|
56
|
+
unless n.empty?
|
57
|
+
n
|
58
|
+
end
|
59
|
+
end.compact
|
60
|
+
unless @ip_names.empty?
|
61
|
+
# Should we check anything here?
|
62
|
+
valid = true
|
63
|
+
end
|
64
|
+
end
|
65
|
+
@ip_names
|
66
|
+
end
|
67
|
+
|
68
|
+
def get_sub_block_name
|
69
|
+
puts
|
70
|
+
puts "WHAT SHOULD BE THE PATH TO #{@ip_names.first} WHEN IT IS INSTANTIATED IN AN SOC?"
|
71
|
+
puts
|
72
|
+
puts 'Your IP(s) will be instantiated by a top-level (SoC) model, at which point it should be given a generic nickname'
|
73
|
+
puts 'that will provide an easy way to access it.'
|
74
|
+
puts 'For example, if you had an IP model for an NVM block, the IP name might be "FLASH_C40_512K_128K", but when it is'
|
75
|
+
puts 'instantiated it would be given the name "flash", allowing it be easily accessed as "dut.flash".'
|
76
|
+
puts
|
77
|
+
|
78
|
+
valid = false
|
79
|
+
until valid
|
80
|
+
@sub_block_name = get_text(single: true).strip.split(',').map do |name|
|
81
|
+
n = name.strip.symbolize.to_s.downcase
|
82
|
+
unless n.empty?
|
83
|
+
n
|
84
|
+
end
|
85
|
+
end.compact
|
86
|
+
unless @sub_block_name.empty?
|
87
|
+
# Should we check anything here?
|
88
|
+
valid = true
|
89
|
+
end
|
90
|
+
end
|
91
|
+
@sub_block_name = @sub_block_name.first
|
92
|
+
end
|
93
|
+
|
94
|
+
# Defines the filelist for the generator, the default list is inherited from the
|
95
|
+
# parent class (Plugin).
|
96
|
+
# The filelist can contain references to generate files, directories or symlinks in the
|
97
|
+
# new application.
|
98
|
+
#
|
99
|
+
# Generally to make your generator more maintainable try and re-use as much as possible
|
100
|
+
# from the parent generator, this means that your generator will automatically stay up
|
101
|
+
# to date with the latest conventions
|
102
|
+
#
|
103
|
+
# The master templates live in templates/app_generators/plugin, but
|
104
|
+
# DO NOT MODIFY THESE FILES DIRECTLY.
|
105
|
+
# Either add or remove things post-generation in the modify_files method or copy the
|
106
|
+
# master file to the equivalent sub-directory of templates/app_generators/test_engineering/mpg_test_block
|
107
|
+
# which will override the version in the master directory.
|
108
|
+
#
|
109
|
+
# Additional files can be added or removed from the filelist as shown below.
|
110
|
+
def filelist
|
111
|
+
@filelist ||= begin
|
112
|
+
list = super # Always pick up the parent list
|
113
|
+
# Example of how to remove a file from the parent list
|
114
|
+
list.delete(:target_debug)
|
115
|
+
list.delete(:target_production)
|
116
|
+
# Example of how to add a file, in this case the file will be compiled and copied to
|
117
|
+
# the same location in the new app
|
118
|
+
list[:target_default] = { source: 'target/default.rb' }
|
119
|
+
list[:environment_v93k] = { source: 'environment/v93k.rb' }
|
120
|
+
list[:environment_j750] = { source: 'environment/j750.rb' }
|
121
|
+
list[:environment_ultraflex] = { source: 'environment/ultraflex.rb' }
|
122
|
+
list[:program_prb1] = { source: 'program/prb1.rb' }
|
123
|
+
list[:lib_interface] = { source: 'lib/interface.rb', dest: "lib/#{@name}/interface.rb" }
|
124
|
+
# Alternatively specifying a different destination, typically you would do this when
|
125
|
+
# the final location is dynamic
|
126
|
+
# list[:gemspec] = { source: 'gemspec.rb', dest: "#{@name}.gemspec" }
|
127
|
+
# Example of how to create a directory
|
128
|
+
list[:pattern_dir] = { dest: 'pattern', type: :directory }
|
129
|
+
# Example of how to create a symlink
|
130
|
+
list[:environment_default] = { source: 'ultraflex.rb', # Relative to the file being linked to
|
131
|
+
dest: 'environment/default.rb', # Relative to destination_root
|
132
|
+
type: :symlink }
|
133
|
+
list[:dev_dut] = { source: 'lib_dev/dut.rb',
|
134
|
+
dest: "lib/#{@name}_dev/dut.rb",
|
135
|
+
options: { class_name: @ip_names.first, sub_block_name: @sub_block_name }
|
136
|
+
}
|
137
|
+
list[:dev_dutc] = { source: 'lib_dev/dut_controller.rb',
|
138
|
+
dest: "lib/#{@name}_dev/dut_controller.rb"
|
139
|
+
}
|
140
|
+
|
141
|
+
@ip_names.each_with_index do |name, i|
|
142
|
+
list["ip_#{i}"] = { source: 'lib/model.rb',
|
143
|
+
dest: "lib/#{@name}/#{name.underscore}.rb",
|
144
|
+
options: { name: name }
|
145
|
+
}
|
146
|
+
|
147
|
+
list["ip_controller_#{i}"] = { source: 'lib/controller.rb',
|
148
|
+
dest: "lib/#{@name}/#{name.underscore}_controller.rb",
|
149
|
+
options: { name: name }
|
150
|
+
}
|
151
|
+
end
|
152
|
+
|
153
|
+
list[:pattern_example] = { source: 'pattern/example.rb',
|
154
|
+
options: { sub_block_name: @sub_block_name }
|
155
|
+
}
|
156
|
+
# Remember to return the final list
|
157
|
+
list
|
158
|
+
end
|
159
|
+
end
|
160
|
+
end
|
161
|
+
end
|
162
|
+
end
|
@@ -0,0 +1,123 @@
|
|
1
|
+
require 'origen'
|
2
|
+
require_relative '../config/application.rb'
|
3
|
+
require 'colored'
|
4
|
+
require 'origen_app_generators/base'
|
5
|
+
require 'origen_app_generators/application'
|
6
|
+
require 'origen_app_generators/plugin'
|
7
|
+
require 'origen_app_generators/empty_application'
|
8
|
+
require 'origen_app_generators/empty_plugin'
|
9
|
+
require 'origen_app_generators/new'
|
10
|
+
require 'origen_app_generators/test_engineering/test_block'
|
11
|
+
require 'origen_app_generators/test_engineering/stand_alone_application'
|
12
|
+
require 'origen_app_generators/origen_infrastructure/app_generator_plugin'
|
13
|
+
|
14
|
+
module OrigenAppGenerators
|
15
|
+
extend Origen::Utility::InputCapture
|
16
|
+
|
17
|
+
TEST_INPUTS = [
|
18
|
+
# 0 - Empty app
|
19
|
+
['0', '0', :default, :default, :default],
|
20
|
+
# 1 - Empty plugin
|
21
|
+
['0', '1', :default, :default, 'A test block', 'yes', :default],
|
22
|
+
# 2 - Stand alone test engineering app
|
23
|
+
['2', '0', :default, :default, 'Falcon, Eagle', 'Falcon[ram, atd(2), comm[ram(2), osc](3)], Eagle[ram(2), atd(4)]', [:default, 'origen g example']],
|
24
|
+
# 3 - Test module
|
25
|
+
['2', '1', :default, :default, 'Test module for all flash IPs', 'FLASH_512K, FLASH_1024K', 'flash', [:default, 'origen g example']],
|
26
|
+
# 4 - An app generators plugin
|
27
|
+
['1', '0', :default, :default, 'My application generators', :default]
|
28
|
+
] # END_OF_TEST_INPUTS Don't remove this comment, it is used by the app_gen:new command!
|
29
|
+
|
30
|
+
# As you add new generators to this app they will be entered here, this enables the
|
31
|
+
# mechanism to register them with the 'origen new' command.
|
32
|
+
# You should generally not modify this by hand, instead use the 'origen app_gen:new'
|
33
|
+
# command every time you want to create a new generator, and this will be filled in
|
34
|
+
# for you.
|
35
|
+
AVAILABLE = {
|
36
|
+
'Test Engineering' => [
|
37
|
+
OrigenAppGenerators::TestEngineering::TestBlock,
|
38
|
+
OrigenAppGenerators::TestEngineering::StandAloneApplication
|
39
|
+
],
|
40
|
+
'Origen Infrastructure' => [
|
41
|
+
OrigenAppGenerators::OrigenInfrastructure::AppGeneratorPlugin
|
42
|
+
]
|
43
|
+
}
|
44
|
+
|
45
|
+
# @api private
|
46
|
+
def self.add_generators(new_generators, options = {})
|
47
|
+
new_generators.each do |domain, gens|
|
48
|
+
gens.each { |gen| template_dirs[gen] ||= options[:template_dir] if options[:template_dir] }
|
49
|
+
if generators[domain]
|
50
|
+
gens.each { |g| generators[domain].unshift(g) }
|
51
|
+
new_generators.delete(domain)
|
52
|
+
end
|
53
|
+
end
|
54
|
+
@generators = new_generators.merge(generators)
|
55
|
+
end
|
56
|
+
|
57
|
+
# @api private
|
58
|
+
def self.unload_generators
|
59
|
+
@generators = {}
|
60
|
+
end
|
61
|
+
|
62
|
+
# @api private
|
63
|
+
def self.generators
|
64
|
+
@generators ||= AVAILABLE
|
65
|
+
end
|
66
|
+
|
67
|
+
# @api private
|
68
|
+
def self.template_dirs
|
69
|
+
@template_dirs ||= {}
|
70
|
+
end
|
71
|
+
|
72
|
+
# @api private
|
73
|
+
def self.invoke(path)
|
74
|
+
puts
|
75
|
+
puts 'CHOOSE AN APPLICATION DOMAIN'
|
76
|
+
puts
|
77
|
+
puts "Domain-specific application templates are available for the following areas (enter '0' to build an empty generic one)"
|
78
|
+
puts
|
79
|
+
i = 0
|
80
|
+
accept = [0]
|
81
|
+
puts '0 - Empty / Not listed'
|
82
|
+
generators.reverse_each do |domain, _generators|
|
83
|
+
i += 1
|
84
|
+
accept << i
|
85
|
+
puts "#{i} - #{domain}"
|
86
|
+
end
|
87
|
+
puts
|
88
|
+
selection = get_text(single: true, default: '0', accept: accept).to_i
|
89
|
+
if selection == 0
|
90
|
+
puts
|
91
|
+
puts "WHAT TYPE OF APPLICATION DO YOU WANT TO BUILD? (if you don't know go with 'application')"
|
92
|
+
puts
|
93
|
+
puts '0 - Application'
|
94
|
+
puts '1 - Plugin'
|
95
|
+
puts
|
96
|
+
accept = [0, 1]
|
97
|
+
selection = get_text(single: true, accept: accept, default: 0).to_i
|
98
|
+
|
99
|
+
case selection
|
100
|
+
when 0
|
101
|
+
OrigenAppGenerators::EmptyApplication.start [path]
|
102
|
+
when 1
|
103
|
+
OrigenAppGenerators::EmptyPlugin.start [path]
|
104
|
+
end
|
105
|
+
else
|
106
|
+
domain = generators.to_a
|
107
|
+
domain = domain[domain.size - selection]
|
108
|
+
puts
|
109
|
+
puts "CHOOSE FROM THE FOLLOWING #{domain[0].upcase} APPLICATION TEMPLATES"
|
110
|
+
puts
|
111
|
+
accept = []
|
112
|
+
i = 0
|
113
|
+
domain[1].reverse_each do |generator|
|
114
|
+
accept << i
|
115
|
+
puts "#{i} - #{generator.desc}"
|
116
|
+
i += 1
|
117
|
+
end
|
118
|
+
puts
|
119
|
+
selection = get_text(single: true, accept: accept).to_i
|
120
|
+
domain[1][domain[1].size - 1 - selection].start [path]
|
121
|
+
end
|
122
|
+
end
|
123
|
+
end
|
@@ -0,0 +1,6 @@
|
|
1
|
+
# You can define any Rake tasks to support your application here (or in any file
|
2
|
+
# ending in .rake in this directory).
|
3
|
+
#
|
4
|
+
# Rake (Ruby Make) is very useful for creating build scripts, see this short video
|
5
|
+
# for a quick introduction:
|
6
|
+
# http://railscasts.com/episodes/66-custom-rake-tasks
|
@@ -0,0 +1,8 @@
|
|
1
|
+
# This file has been added by origen_app_generators to test that the target can be
|
2
|
+
# loaded within this application, it will not be included in your final application
|
3
|
+
# builds once your generator has been released.
|
4
|
+
namespace :new_app_tests do
|
5
|
+
task :load_target do
|
6
|
+
Origen.app.target.load!
|
7
|
+
end
|
8
|
+
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
# stub: origen_app_generators 1.2.0 ruby lib
|
3
|
+
|
4
|
+
Gem::Specification.new do |s|
|
5
|
+
s.name = "origen_app_generators".freeze
|
6
|
+
s.version = "1.2.0"
|
7
|
+
|
8
|
+
s.required_rubygems_version = Gem::Requirement.new(">= 1.8.11".freeze) if s.respond_to? :required_rubygems_version=
|
9
|
+
s.require_paths = ["lib".freeze]
|
10
|
+
s.authors = ["Stephen McGinty".freeze]
|
11
|
+
s.date = "2018-12-10"
|
12
|
+
s.email = ["stephen.f.mcginty@gmail.com".freeze]
|
13
|
+
s.files = ["bin/boot.rb".freeze, "bin/fix_my_workspace".freeze, "config/application.rb".freeze, "config/boot.rb".freeze, "config/commands.rb".freeze, "config/shared_commands.rb".freeze, "config/version.rb".freeze, "lib/origen_app_generators.rb".freeze, "lib/origen_app_generators/application.rb".freeze, "lib/origen_app_generators/base.rb".freeze, "lib/origen_app_generators/empty_application.rb".freeze, "lib/origen_app_generators/empty_plugin.rb".freeze, "lib/origen_app_generators/new.rb".freeze, "lib/origen_app_generators/origen_infrastructure/app_generator_plugin.rb".freeze, "lib/origen_app_generators/plugin.rb".freeze, "lib/origen_app_generators/sub_block_parser.rb".freeze, "lib/origen_app_generators/test_engineering/stand_alone_application.rb".freeze, "lib/origen_app_generators/test_engineering/test_block.rb".freeze, "lib/tasks/app_generators.rake".freeze, "lib/tasks/new_app_tests.rake".freeze, "templates/app_generators".freeze, "templates/app_generators/application".freeze, "templates/app_generators/application/.gitignore".freeze, "templates/app_generators/application/.irbrc".freeze, "templates/app_generators/application/.rspec".freeze, "templates/app_generators/application/.travis.yml".freeze, "templates/app_generators/application/Gemfile".freeze, "templates/app_generators/application/Rakefile".freeze, "templates/app_generators/application/config".freeze, "templates/app_generators/application/config/application.rb".freeze, "templates/app_generators/application/config/boot.rb".freeze, "templates/app_generators/application/config/commands.rb".freeze, "templates/app_generators/application/config/maillist_dev.txt".freeze, "templates/app_generators/application/config/maillist_prod.txt".freeze, "templates/app_generators/application/config/version.rb".freeze, "templates/app_generators/application/doc".freeze, "templates/app_generators/application/doc/history".freeze, "templates/app_generators/application/dot_keep".freeze, "templates/app_generators/application/lib".freeze, "templates/app_generators/application/lib/app.rake".freeze, "templates/app_generators/application/lib/module.rb".freeze, "templates/app_generators/application/lib/top_level.rb".freeze, "templates/app_generators/application/origen_core_session".freeze, "templates/app_generators/application/spec".freeze, "templates/app_generators/application/spec/spec_helper.rb".freeze, "templates/app_generators/application/target".freeze, "templates/app_generators/application/target/debug.rb".freeze, "templates/app_generators/application/target/default.rb".freeze, "templates/app_generators/application/target/production.rb".freeze, "templates/app_generators/application/templates".freeze, "templates/app_generators/application/templates/web".freeze, "templates/app_generators/application/templates/web/index.md.erb".freeze, "templates/app_generators/application/templates/web/layouts".freeze, "templates/app_generators/application/templates/web/layouts/_basic.html.erb".freeze, "templates/app_generators/application/templates/web/partials".freeze, "templates/app_generators/application/templates/web/partials/_navbar.html.erb".freeze, "templates/app_generators/application/templates/web/release_notes.md.erb".freeze, "templates/app_generators/new".freeze, "templates/app_generators/new/generator.rb".freeze, "templates/app_generators/new/info.md.erb".freeze, "templates/app_generators/origen_infrastructure".freeze, "templates/app_generators/origen_infrastructure/app_generator_plugin".freeze, "templates/app_generators/origen_infrastructure/app_generator_plugin/config".freeze, "templates/app_generators/origen_infrastructure/app_generator_plugin/config/load_generators.rb".freeze, "templates/app_generators/origen_infrastructure/app_generator_plugin/lib".freeze, "templates/app_generators/origen_infrastructure/app_generator_plugin/lib/application.rb".freeze, "templates/app_generators/origen_infrastructure/app_generator_plugin/lib/base.rb".freeze, "templates/app_generators/origen_infrastructure/app_generator_plugin/lib/module.rb".freeze, "templates/app_generators/origen_infrastructure/app_generator_plugin/lib/plugin.rb".freeze, "templates/app_generators/plugin".freeze, "templates/app_generators/plugin/Gemfile".freeze, "templates/app_generators/plugin/Rakefile".freeze, "templates/app_generators/plugin/config".freeze, "templates/app_generators/plugin/config/boot.rb".freeze, "templates/app_generators/plugin/gemspec.rb".freeze, "templates/app_generators/plugin/lib".freeze, "templates/app_generators/plugin/lib/README".freeze, "templates/app_generators/plugin/lib_dev".freeze, "templates/app_generators/plugin/lib_dev/README".freeze, "templates/app_generators/plugin/templates".freeze, "templates/app_generators/plugin/templates/web".freeze, "templates/app_generators/plugin/templates/web/index.md.erb".freeze, "templates/app_generators/plugin/templates/web/partials".freeze, "templates/app_generators/plugin/templates/web/partials/_navbar_external.html.erb".freeze, "templates/app_generators/plugin/templates/web/partials/_navbar_internal.html.erb".freeze, "templates/app_generators/test_engineering".freeze, "templates/app_generators/test_engineering/stand_alone_application".freeze, "templates/app_generators/test_engineering/stand_alone_application/Gemfile".freeze, "templates/app_generators/test_engineering/stand_alone_application/environment".freeze, "templates/app_generators/test_engineering/stand_alone_application/environment/j750.rb".freeze, "templates/app_generators/test_engineering/stand_alone_application/environment/jlink.rb".freeze, "templates/app_generators/test_engineering/stand_alone_application/environment/uflex.rb".freeze, "templates/app_generators/test_engineering/stand_alone_application/environment/v93k.rb".freeze, "templates/app_generators/test_engineering/stand_alone_application/lib".freeze, "templates/app_generators/test_engineering/stand_alone_application/lib/ip_block.rb".freeze, "templates/app_generators/test_engineering/stand_alone_application/lib/ip_block_controller.rb".freeze, "templates/app_generators/test_engineering/stand_alone_application/lib/top_level.rb".freeze, "templates/app_generators/test_engineering/stand_alone_application/lib/top_level_controller.rb".freeze, "templates/app_generators/test_engineering/stand_alone_application/pattern".freeze, "templates/app_generators/test_engineering/stand_alone_application/pattern/example.rb".freeze, "templates/app_generators/test_engineering/stand_alone_application/target".freeze, "templates/app_generators/test_engineering/stand_alone_application/target/top_level.rb".freeze, "templates/app_generators/test_engineering/test_block".freeze, "templates/app_generators/test_engineering/test_block/environment".freeze, "templates/app_generators/test_engineering/test_block/environment/j750.rb".freeze, "templates/app_generators/test_engineering/test_block/environment/ultraflex.rb".freeze, "templates/app_generators/test_engineering/test_block/environment/v93k.rb".freeze, "templates/app_generators/test_engineering/test_block/lib".freeze, "templates/app_generators/test_engineering/test_block/lib/controller.rb".freeze, "templates/app_generators/test_engineering/test_block/lib/interface.rb".freeze, "templates/app_generators/test_engineering/test_block/lib/model.rb".freeze, "templates/app_generators/test_engineering/test_block/lib_dev".freeze, "templates/app_generators/test_engineering/test_block/lib_dev/dut.rb".freeze, "templates/app_generators/test_engineering/test_block/lib_dev/dut_controller.rb".freeze, "templates/app_generators/test_engineering/test_block/pattern".freeze, "templates/app_generators/test_engineering/test_block/pattern/example.rb".freeze, "templates/app_generators/test_engineering/test_block/program".freeze, "templates/app_generators/test_engineering/test_block/program/prb1.rb".freeze, "templates/app_generators/test_engineering/test_block/target".freeze, "templates/app_generators/test_engineering/test_block/target/default.rb".freeze]
|
14
|
+
s.homepage = "http://origen-sdk.org/origen_app_generators".freeze
|
15
|
+
s.licenses = ["MIT".freeze]
|
16
|
+
s.required_ruby_version = Gem::Requirement.new(">= 1.9.3".freeze)
|
17
|
+
s.rubygems_version = "2.7.6".freeze
|
18
|
+
s.summary = "Origen application generators".freeze
|
19
|
+
|
20
|
+
s.installed_by_version = "2.7.6" if s.respond_to? :installed_by_version
|
21
|
+
|
22
|
+
if s.respond_to? :specification_version then
|
23
|
+
s.specification_version = 4
|
24
|
+
|
25
|
+
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
26
|
+
s.add_runtime_dependency(%q<origen>.freeze, [">= 0.23.0"])
|
27
|
+
else
|
28
|
+
s.add_dependency(%q<origen>.freeze, [">= 0.23.0"])
|
29
|
+
end
|
30
|
+
else
|
31
|
+
s.add_dependency(%q<origen>.freeze, [">= 0.23.0"])
|
32
|
+
end
|
33
|
+
end
|
@@ -0,0 +1,49 @@
|
|
1
|
+
$VERBOSE=nil # Don't care about world writable dir warnings and the like
|
2
|
+
|
3
|
+
require 'pathname'
|
4
|
+
if File.exist? File.expand_path("../Gemfile", Pathname.new(__FILE__).realpath)
|
5
|
+
require 'rubygems'
|
6
|
+
require 'bundler/setup'
|
7
|
+
else
|
8
|
+
# If running on windows, can't use Origen helpers 'till we load it...
|
9
|
+
if RUBY_PLATFORM == 'i386-mingw32'
|
10
|
+
`where origen`.split("\n").find do |match|
|
11
|
+
match =~ /(.*)\\bin\\origen$/
|
12
|
+
end
|
13
|
+
origen_top = $1.gsub("\\", "/")
|
14
|
+
else
|
15
|
+
origen_top = `which origen`.strip.sub("/bin/origen", "")
|
16
|
+
end
|
17
|
+
|
18
|
+
$LOAD_PATH.unshift "#{origen_top}/lib"
|
19
|
+
end
|
20
|
+
|
21
|
+
require "origen"
|
22
|
+
|
23
|
+
require "rspec/legacy_formatters"
|
24
|
+
require "#{Origen.top}/spec/format/origen_formatter"
|
25
|
+
|
26
|
+
if RUBY_VERSION >= '2.0.0'
|
27
|
+
require "byebug"
|
28
|
+
else
|
29
|
+
require 'debugger'
|
30
|
+
end
|
31
|
+
require 'pry'
|
32
|
+
|
33
|
+
def load_target(target="default")
|
34
|
+
Origen.target.switch_to target
|
35
|
+
Origen.target.load!
|
36
|
+
end
|
37
|
+
|
38
|
+
RSpec.configure do |config|
|
39
|
+
config.formatter = OrigenFormatter
|
40
|
+
# rspec-expectations config goes here. You can use an alternate
|
41
|
+
# assertion/expectation library such as wrong or the stdlib/minitest
|
42
|
+
# assertions if you prefer.
|
43
|
+
config.expect_with :rspec do |expectations|
|
44
|
+
# Enable only the newer, non-monkey-patching expect syntax.
|
45
|
+
# For more details, see:
|
46
|
+
# - http://myronmars.to/n/dev-blog/2012/06/rspecs-new-expectation-syntax
|
47
|
+
expectations.syntax = :should
|
48
|
+
end
|
49
|
+
end
|