origen_app_generators 1.2.0 → 2.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/bin/boot.rb +4 -2
- data/config/commands.rb +3 -3
- data/config/shared_commands.rb +11 -6
- data/config/version.rb +2 -2
- data/lib/origen_app_generators.rb +6 -4
- data/lib/origen_app_generators/application.rb +12 -12
- data/lib/origen_app_generators/base.rb +34 -8
- data/lib/origen_app_generators/new.rb +17 -9
- data/lib/{tasks/new_app_tests.rake → origen_app_generators/new_app_tests.rb} +1 -5
- data/lib/origen_app_generators/origen_infrastructure/app_generator_plugin.rb +6 -8
- data/lib/origen_app_generators/plugin.rb +4 -7
- data/lib/origen_app_generators/test_engineering/common.rb +29 -0
- data/lib/origen_app_generators/test_engineering/stand_alone_application.rb +9 -181
- data/lib/origen_app_generators/test_engineering/test_block.rb +4 -105
- data/templates/app_generators/application/Gemfile +12 -2
- data/templates/app_generators/application/{lib → app/blocks}/top_level.rb +1 -1
- data/templates/app_generators/application/app/lib/module.rb +6 -0
- data/templates/app_generators/application/{templates → app/templates}/web/index.md.erb +0 -0
- data/templates/app_generators/application/{templates → app/templates}/web/layouts/_basic.html.erb +0 -0
- data/templates/app_generators/application/{templates → app/templates}/web/partials/_navbar.html.erb +0 -0
- data/templates/app_generators/application/{templates → app/templates}/web/release_notes.md.erb +0 -0
- data/templates/app_generators/application/config/application.rb +51 -55
- data/templates/app_generators/origen_infrastructure/app_generator_plugin/{lib → app/lib}/application.rb +0 -0
- data/templates/app_generators/origen_infrastructure/app_generator_plugin/{lib → app/lib}/base.rb +0 -0
- data/templates/app_generators/origen_infrastructure/app_generator_plugin/{lib → app/lib}/module.rb +0 -0
- data/templates/app_generators/origen_infrastructure/app_generator_plugin/{lib → app/lib}/plugin.rb +0 -0
- data/templates/app_generators/origen_infrastructure/app_generator_plugin/config/load_generators.rb +1 -1
- data/templates/app_generators/plugin/Gemfile +3 -2
- data/templates/app_generators/plugin/{templates → app/templates}/web/index.md.erb +0 -0
- data/templates/app_generators/plugin/{templates → app/templates}/web/partials/_navbar_external.html.erb +0 -0
- data/templates/app_generators/plugin/{templates → app/templates}/web/partials/_navbar_internal.html.erb +0 -0
- data/templates/app_generators/plugin/gemspec.rb +4 -3
- data/templates/app_generators/test_engineering/{stand_alone_application/environment → environment}/j750.rb +0 -0
- data/templates/app_generators/test_engineering/{stand_alone_application/environment → environment}/uflex.rb +0 -0
- data/templates/app_generators/test_engineering/{stand_alone_application/environment → environment}/v93k.rb +0 -0
- data/templates/app_generators/test_engineering/stand_alone_application/.keep +0 -0
- data/templates/app_generators/test_engineering/test_block/.keep +0 -0
- metadata +25 -47
- data/bin/fix_my_workspace +0 -100
- data/lib/origen_app_generators/sub_block_parser.rb +0 -81
- data/lib/tasks/app_generators.rake +0 -6
- data/templates/app_generators/application/lib/app.rake +0 -6
- data/templates/app_generators/application/lib/module.rb +0 -22
- data/templates/app_generators/plugin/lib/README +0 -4
- data/templates/app_generators/plugin/lib_dev/README +0 -5
- data/templates/app_generators/test_engineering/stand_alone_application/Gemfile +0 -23
- data/templates/app_generators/test_engineering/stand_alone_application/environment/jlink.rb +0 -1
- data/templates/app_generators/test_engineering/stand_alone_application/lib/ip_block.rb +0 -23
- data/templates/app_generators/test_engineering/stand_alone_application/lib/ip_block_controller.rb +0 -5
- data/templates/app_generators/test_engineering/stand_alone_application/lib/top_level.rb +0 -33
- data/templates/app_generators/test_engineering/stand_alone_application/lib/top_level_controller.rb +0 -21
- data/templates/app_generators/test_engineering/stand_alone_application/pattern/example.rb +0 -4
- data/templates/app_generators/test_engineering/stand_alone_application/target/top_level.rb +0 -4
- data/templates/app_generators/test_engineering/test_block/environment/j750.rb +0 -2
- data/templates/app_generators/test_engineering/test_block/environment/ultraflex.rb +0 -2
- data/templates/app_generators/test_engineering/test_block/environment/v93k.rb +0 -2
- data/templates/app_generators/test_engineering/test_block/lib/controller.rb +0 -12
- data/templates/app_generators/test_engineering/test_block/lib/interface.rb +0 -21
- data/templates/app_generators/test_engineering/test_block/lib/model.rb +0 -18
- data/templates/app_generators/test_engineering/test_block/lib_dev/dut.rb +0 -27
- data/templates/app_generators/test_engineering/test_block/lib_dev/dut_controller.rb +0 -26
- data/templates/app_generators/test_engineering/test_block/pattern/example.rb +0 -5
- data/templates/app_generators/test_engineering/test_block/program/prb1.rb +0 -11
- data/templates/app_generators/test_engineering/test_block/target/default.rb +0 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 975e090af5f2395ac6a1875189204b913c936cccd0b17922a2dfe308ef6d0230
|
4
|
+
data.tar.gz: c09a5e52d72b11249b858af6a71413becaef6515c25ad003d2cb6806f9e60f0c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 56c60abf4528a4b18503b93abe04c54f9a78f878a0a91154c595790162b7983a6bfb534a1772382b80b44fff7d70702beee81b1c0da14420bc7d41c2e6c7bfe1
|
7
|
+
data.tar.gz: 3711966a4d4271c23aea76b9078947dfa2688162a7a19f57f292d414166b63d45ae26989cdabb56c41b55de3a17e5d6dc384aa5ef6174c81625d6e596abc314e
|
data/bin/boot.rb
CHANGED
@@ -30,8 +30,10 @@ begin
|
|
30
30
|
OrigenAppGenerators.unload_generators unless ARGV[0]
|
31
31
|
require load_generators if File.exist?(load_generators)
|
32
32
|
|
33
|
-
OrigenAppGenerators.invoke('
|
33
|
+
OrigenAppGenerators.invoke('my_app')
|
34
34
|
end
|
35
35
|
ensure
|
36
|
-
FileUtils.mv "#{tmp_dir}/
|
36
|
+
FileUtils.mv "#{tmp_dir}/my_app", 'output' if File.exist?("#{tmp_dir}/my_app")
|
37
|
+
puts
|
38
|
+
puts "Ignore the above, your new app is in: output/my_app"
|
37
39
|
end
|
data/config/commands.rb
CHANGED
@@ -56,8 +56,8 @@ when "specs"
|
|
56
56
|
## origen -h, you can do this be assigning the required text to @application_commands
|
57
57
|
## before handing control back to Origen. Un-comment the example below to get started.
|
58
58
|
else
|
59
|
-
@application_commands = <<-EOT
|
60
|
-
specs Run the specs (tests), -c will enable coverage
|
61
|
-
EOT
|
59
|
+
# @application_commands = <<-EOT
|
60
|
+
# specs Run the specs (tests), -c will enable coverage
|
61
|
+
# EOT
|
62
62
|
|
63
63
|
end
|
data/config/shared_commands.rb
CHANGED
@@ -7,9 +7,11 @@ when "app_gen:test"
|
|
7
7
|
opt_parser = OptionParser.new do |opts|
|
8
8
|
opts.banner = <<-END
|
9
9
|
Test the generators by emulating the 'origen new' command execution and building the new
|
10
|
-
application into the
|
10
|
+
application into the output/my_app directory.
|
11
11
|
|
12
12
|
Usage: origen app_gen:test [options]
|
13
|
+
origen app_gen:test --regression # Test all generators
|
14
|
+
origen app_gen:test --inputs 0 # Test with user inputs set 0
|
13
15
|
END
|
14
16
|
opts.on('-d', '--debugger', 'Enable the debugger') { options[:debugger] = true }
|
15
17
|
opts.on('-i', '--inputs INDEX', Integer, "Apply the set of test inputs defined in #{Origen.app.namespace}::TEST_INPUTS[INDEX]") { |f| options[:inputs] = f }
|
@@ -21,7 +23,9 @@ END
|
|
21
23
|
|
22
24
|
opt_parser.orig_parse! ARGV
|
23
25
|
|
24
|
-
|
26
|
+
output_dir = File.join(Origen.root, 'output')
|
27
|
+
FileUtils.rm_rf output_dir if File.exist?(output_dir)
|
28
|
+
FileUtils.mkdir_p output_dir
|
25
29
|
|
26
30
|
if options[:inputs] || options[:regression]
|
27
31
|
if options[:regression]
|
@@ -45,12 +49,12 @@ END
|
|
45
49
|
# For some reason this command doesn't work in Travis CI, don't know why and
|
46
50
|
# couldn't work out how to fix (looks like a Bundler-related issue)
|
47
51
|
cmds << 'origen lint --no-correct' unless ENV['TRAVIS']
|
48
|
-
cmds << 'bundle exec
|
52
|
+
cmds << 'bundle exec origen exec tmp/new_app_tests.rb'
|
49
53
|
cmds << 'origen web compile --no-serve'
|
50
54
|
cmds
|
51
55
|
elsif op.to_s == 'load_target'
|
52
56
|
target_load_test_required = true
|
53
|
-
'
|
57
|
+
'origen exec tmp/new_app_tests.rb'
|
54
58
|
else
|
55
59
|
op
|
56
60
|
end
|
@@ -69,12 +73,13 @@ END
|
|
69
73
|
# The app is successfully built, now see if it works...
|
70
74
|
unless post_build_operations.empty?
|
71
75
|
if target_load_test_required
|
72
|
-
FileUtils.
|
76
|
+
FileUtils.mkdir_p('output/my_app/tmp')
|
77
|
+
FileUtils.cp "#{Origen.root!}/lib/origen_app_generators/new_app_tests.rb", 'output/my_app/tmp'
|
73
78
|
end
|
74
79
|
|
75
80
|
operation_failed = false
|
76
81
|
Bundler.with_clean_env do
|
77
|
-
Dir.chdir "#{Origen.root}/
|
82
|
+
Dir.chdir "#{Origen.root}/output/my_app" do
|
78
83
|
post_build_operations.each_with_index do |op, i|
|
79
84
|
if i == 0 && !Origen.site_config.gem_manage_bundler
|
80
85
|
system('bundle')
|
data/config/version.rb
CHANGED
@@ -7,6 +7,7 @@ require 'origen_app_generators/plugin'
|
|
7
7
|
require 'origen_app_generators/empty_application'
|
8
8
|
require 'origen_app_generators/empty_plugin'
|
9
9
|
require 'origen_app_generators/new'
|
10
|
+
require 'origen_app_generators/test_engineering/common'
|
10
11
|
require 'origen_app_generators/test_engineering/test_block'
|
11
12
|
require 'origen_app_generators/test_engineering/stand_alone_application'
|
12
13
|
require 'origen_app_generators/origen_infrastructure/app_generator_plugin'
|
@@ -16,15 +17,16 @@ module OrigenAppGenerators
|
|
16
17
|
|
17
18
|
TEST_INPUTS = [
|
18
19
|
# 0 - Empty app
|
19
|
-
['0', '0', :default
|
20
|
+
['0', '0', :default],
|
20
21
|
# 1 - Empty plugin
|
21
22
|
['0', '1', :default, :default, 'A test block', 'yes', :default],
|
22
23
|
# 2 - Stand alone test engineering app
|
23
|
-
['2', '0',
|
24
|
+
['2', '0', [:default]],
|
24
25
|
# 3 - Test module
|
25
|
-
['2', '1',
|
26
|
+
# ['2', '1', 'Test module for all flash IPs', [:default, 'origen g example']],
|
27
|
+
['2', '1', 'Test module for all flash IPs', :default],
|
26
28
|
# 4 - An app generators plugin
|
27
|
-
['1', '0',
|
29
|
+
['1', '0', 'My application generators', :default]
|
28
30
|
] # END_OF_TEST_INPUTS Don't remove this comment, it is used by the app_gen:new command!
|
29
31
|
|
30
32
|
# As you add new generators to this app they will be entered here, this enables the
|
@@ -33,19 +33,19 @@ module OrigenAppGenerators
|
|
33
33
|
config_prod: { source: 'config/maillist_prod.txt' },
|
34
34
|
doc_history: { source: 'doc/history' },
|
35
35
|
target_default: { source: 'target/default.rb' },
|
36
|
-
# target_default:
|
37
|
-
#
|
38
|
-
#
|
36
|
+
# target_default: { source: 'debug.rb', # Relative to the file being linked to
|
37
|
+
# dest: 'target/default.rb', # Relative to destination_root
|
38
|
+
# type: :symlink },
|
39
39
|
environment_dir: { dest: 'environment', type: :directory },
|
40
|
-
lib_module: { source: 'lib/module.rb',
|
41
|
-
dest: "lib/#{@name}.rb" },
|
42
|
-
|
43
|
-
|
40
|
+
lib_module: { source: 'app/lib/module.rb',
|
41
|
+
dest: "app/lib/#{@name}.rb" },
|
42
|
+
lib_module_dir: { dest: "app/lib/#{@name}", type: :directory },
|
43
|
+
app_blocks_dir: { dest: 'app/blocks', type: :directory },
|
44
44
|
spec_helper: { source: 'spec/spec_helper.rb' },
|
45
|
-
web_index: { source: 'templates/web/index.md.erb' },
|
46
|
-
web_basic_layout: { source: 'templates/web/layouts/_basic.html.erb' },
|
47
|
-
web_navbar: { source: 'templates/web/partials/_navbar.html.erb' },
|
48
|
-
web_release_notes: { source: 'templates/web/release_notes.md.erb' },
|
45
|
+
web_index: { source: 'app/templates/web/index.md.erb' },
|
46
|
+
web_basic_layout: { source: 'app/templates/web/layouts/_basic.html.erb' },
|
47
|
+
web_navbar: { source: 'app/templates/web/partials/_navbar.html.erb' },
|
48
|
+
web_release_notes: { source: 'app/templates/web/release_notes.md.erb' },
|
49
49
|
rakefile: { source: 'Rakefile' },
|
50
50
|
gemfile: { source: 'Gemfile' },
|
51
51
|
gitignore: { source: '.gitignore' },
|
@@ -55,7 +55,7 @@ module OrigenAppGenerators
|
|
55
55
|
session: { source: 'origen_core_session',
|
56
56
|
dest: '.session/origen_core',
|
57
57
|
copy: true
|
58
|
-
|
58
|
+
}
|
59
59
|
}
|
60
60
|
end
|
61
61
|
end
|
@@ -5,6 +5,21 @@ module OrigenAppGenerators
|
|
5
5
|
|
6
6
|
require 'gems'
|
7
7
|
|
8
|
+
def validate_application_name
|
9
|
+
@name = args.first.to_s.strip
|
10
|
+
if @name == ''
|
11
|
+
puts
|
12
|
+
puts "You must supply a name for what you want to call your application: 'origen new my_name'"
|
13
|
+
puts
|
14
|
+
exit 1
|
15
|
+
elsif @name != @name.symbolize.to_s
|
16
|
+
puts
|
17
|
+
puts 'The name of your new app must be lowercased and underscored and contain no special characters'
|
18
|
+
puts
|
19
|
+
exit 1
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
8
23
|
def set_source_paths
|
9
24
|
# The base Origen generator puts the Origen core directory on the source path, in retrospect this
|
10
25
|
# was a bad idea and makes for hard to debug errors if an app generator resolves a template from
|
@@ -25,7 +40,11 @@ module OrigenAppGenerators
|
|
25
40
|
dir << "#{template_dir}/base"
|
26
41
|
klass = last_class
|
27
42
|
else
|
28
|
-
dir =
|
43
|
+
dir = []
|
44
|
+
class_dirs(klass).each do |class_dir|
|
45
|
+
dir << "#{Origen.root!}/templates/app_generators/#{class_dir}"
|
46
|
+
dir << "#{Origen.root!}/app/templates/app_generators/#{class_dir}"
|
47
|
+
end
|
29
48
|
end
|
30
49
|
Array(dir).each do |dir|
|
31
50
|
self.class.source_paths << dir if File.exist?(dir) && !self.class.source_paths.include?(dir)
|
@@ -40,7 +59,9 @@ module OrigenAppGenerators
|
|
40
59
|
end
|
41
60
|
|
42
61
|
def get_common_user_input
|
43
|
-
|
62
|
+
# Don't bother asking the user for this, their life will be easier if they just go with
|
63
|
+
# Origen's default namespace based on their app's name
|
64
|
+
@namespace = @name.to_s.camelize
|
44
65
|
end
|
45
66
|
|
46
67
|
def get_lastest_origen_version
|
@@ -73,6 +94,17 @@ module OrigenAppGenerators
|
|
73
94
|
names.map(&:underscore).join('/')
|
74
95
|
end
|
75
96
|
|
97
|
+
def class_dirs(klass)
|
98
|
+
names = klass.to_s.split('::')
|
99
|
+
names.shift
|
100
|
+
dirs = []
|
101
|
+
until names.empty?
|
102
|
+
dirs << names.map(&:underscore).join('/')
|
103
|
+
names.pop
|
104
|
+
end
|
105
|
+
dirs
|
106
|
+
end
|
107
|
+
|
76
108
|
# def application_class?(klass)
|
77
109
|
# until klass == OrigenAppGenerators::Base
|
78
110
|
# end
|
@@ -133,12 +165,6 @@ module OrigenAppGenerators
|
|
133
165
|
symlink_cmds.each { |cmd| system(cmd) }
|
134
166
|
end
|
135
167
|
|
136
|
-
# Convenience method that is equivalent to calling get_name and then get_namespace
|
137
|
-
def get_name_and_namespace
|
138
|
-
get_name
|
139
|
-
get_namespace
|
140
|
-
end
|
141
|
-
|
142
168
|
# Prompts the user to confirm or enter the Ruby namespace to be used in the app.
|
143
169
|
#
|
144
170
|
# If @name is already defined a proposal will be generated from that, alternatively a proposal
|
@@ -28,13 +28,13 @@ module OrigenAppGenerators
|
|
28
28
|
|
29
29
|
# **** Add require line ****
|
30
30
|
module_declaration = /\nmodule #{Origen.app.namespace}/
|
31
|
-
inject_into_file "lib/#{Origen.app.name}.rb", "require '#{Origen.app.name}/#{@domain_namespace.underscore}/#{@classname.underscore}'\n",
|
31
|
+
inject_into_file "#{app_dir}lib/#{Origen.app.name}.rb", "require '#{Origen.app.name}/#{@domain_namespace.underscore}/#{@classname.underscore}'\n",
|
32
32
|
before: module_declaration
|
33
33
|
|
34
34
|
# **** Add to the AVAILABLE hash ****
|
35
35
|
if available[@domain_summary]
|
36
36
|
existing_domain = /\s*('|")#{@domain_summary}('|") => \[\s*\n/
|
37
|
-
inject_into_file "lib/#{Origen.app.name}.rb", " #{Origen.app.namespace}::#{@domain_namespace}::#{@classname},\n",
|
37
|
+
inject_into_file "#{app_dir}lib/#{Origen.app.name}.rb", " #{Origen.app.namespace}::#{@domain_namespace}::#{@classname},\n",
|
38
38
|
after: existing_domain
|
39
39
|
else
|
40
40
|
new_domain = <<-END
|
@@ -43,7 +43,7 @@ module OrigenAppGenerators
|
|
43
43
|
],
|
44
44
|
END
|
45
45
|
available_hash = /AVAILABLE = {\s*\n/
|
46
|
-
inject_into_file "lib/#{Origen.app.name}.rb", new_domain, after: available_hash
|
46
|
+
inject_into_file "#{app_dir}lib/#{Origen.app.name}.rb", new_domain, after: available_hash
|
47
47
|
end
|
48
48
|
|
49
49
|
# **** Add a starter set of test inputs ****
|
@@ -59,11 +59,11 @@ module OrigenAppGenerators
|
|
59
59
|
if @parentclass == 'Plugin'
|
60
60
|
inputs += " ['#{first}', '#{second}', :default, :default, 'A cool plugin', 'yes', :default]"
|
61
61
|
else
|
62
|
-
inputs += " ['#{first}', '#{second}', :default
|
62
|
+
inputs += " ['#{first}', '#{second}', :default]"
|
63
63
|
end
|
64
64
|
inputs = ",#{inputs}" unless test_inputs.empty?
|
65
65
|
end_of_test_inputs = /\n\s*\]\s*#\s*END_OF_TEST_INPUTS/
|
66
|
-
inject_into_file "lib/#{Origen.app.name}.rb", inputs, before: end_of_test_inputs
|
66
|
+
inject_into_file "#{app_dir}lib/#{Origen.app.name}.rb", inputs, before: end_of_test_inputs
|
67
67
|
end
|
68
68
|
|
69
69
|
# Can't compile this as contains some final ERB, so substitute instead
|
@@ -78,7 +78,7 @@ module OrigenAppGenerators
|
|
78
78
|
# end
|
79
79
|
|
80
80
|
def conclude
|
81
|
-
system "origen lint #{Origen.root}
|
81
|
+
system "origen lint #{Origen.root}/#{app_dir}lib/#{Origen.app.name}.rb"
|
82
82
|
puts
|
83
83
|
puts "New generator created at: #{filelist[:generator][:dest]}"
|
84
84
|
puts
|
@@ -90,6 +90,14 @@ module OrigenAppGenerators
|
|
90
90
|
|
91
91
|
protected
|
92
92
|
|
93
|
+
def app_dir
|
94
|
+
if File.exist?("#{Origen.root}/app/lib")
|
95
|
+
'app/'
|
96
|
+
else
|
97
|
+
''
|
98
|
+
end
|
99
|
+
end
|
100
|
+
|
93
101
|
def get_summary
|
94
102
|
puts
|
95
103
|
puts 'DESCRIBE YOUR NEW GENERATOR IN A FEW WORDS'
|
@@ -151,11 +159,11 @@ module OrigenAppGenerators
|
|
151
159
|
def filelist
|
152
160
|
@filelist ||= {
|
153
161
|
generator: { source: 'generator.rb',
|
154
|
-
dest: "lib/#{Origen.app.name}/#{@domain_namespace.underscore}/#{@classname.underscore}.rb" },
|
155
|
-
templates_dir: { dest: "templates/app_generators/#{@domain_namespace.underscore}/#{@classname.underscore}",
|
162
|
+
dest: "#{app_dir}lib/#{Origen.app.name}/#{@domain_namespace.underscore}/#{@classname.underscore}.rb" },
|
163
|
+
templates_dir: { dest: "#{app_dir}templates/app_generators/#{@domain_namespace.underscore}/#{@classname.underscore}",
|
156
164
|
type: :directory },
|
157
165
|
# doc_info: { source: 'info.md.erb',
|
158
|
-
# dest: "templates/web/#{Origen.app.name}/#{@domain_namespace.underscore}/#{@classname.underscore}.md.erb" }
|
166
|
+
# dest: "#{app_dir}templates/web/#{Origen.app.name}/#{@domain_namespace.underscore}/#{@classname.underscore}.md.erb" }
|
159
167
|
}
|
160
168
|
end
|
161
169
|
end
|
@@ -1,8 +1,4 @@
|
|
1
1
|
# This file has been added by origen_app_generators to test that the target can be
|
2
2
|
# loaded within this application, it will not be included in your final application
|
3
3
|
# builds once your generator has been released.
|
4
|
-
|
5
|
-
task :load_target do
|
6
|
-
Origen.app.target.load!
|
7
|
-
end
|
8
|
-
end
|
4
|
+
Origen.app.target.load!
|
@@ -77,23 +77,21 @@ module OrigenAppGenerators
|
|
77
77
|
list = super # Always pick up the parent list
|
78
78
|
# Example of how to remove a file from the parent list
|
79
79
|
# list.delete(:web_doc_layout)
|
80
|
-
list.delete(:lib_readme)
|
81
|
-
list.delete(:lib_readme_dev)
|
82
80
|
list.delete(:templates_shared)
|
83
81
|
# Example of how to add a file, in this case the file will be compiled and copied to
|
84
82
|
# the same location in the new app
|
85
83
|
# list[:config_shared_commands] = { source: 'config/shared_commands.rb' }
|
86
84
|
list[:config_load_generators] = { source: 'config/load_generators.rb' }
|
87
|
-
list[:lib_base] = { source: 'lib/base.rb', dest: "lib/#{@name}/base.rb" }
|
88
|
-
list[:lib_plugin] = { source: 'lib/plugin.rb', dest: "lib/#{@name}/plugin.rb" }
|
89
|
-
list[:lib_application] = { source: 'lib/application.rb', dest: "lib/#{@name}/application.rb" }
|
85
|
+
list[:lib_base] = { source: 'app/lib/base.rb', dest: "app/lib/#{@name}/base.rb" }
|
86
|
+
list[:lib_plugin] = { source: 'app/lib/plugin.rb', dest: "app/lib/#{@name}/plugin.rb" }
|
87
|
+
list[:lib_application] = { source: 'app/lib/application.rb', dest: "app/lib/#{@name}/application.rb" }
|
90
88
|
# Alternatively specifying a different destination, typically you would do this when
|
91
89
|
# the final location is dynamic
|
92
90
|
# list[:gemspec] = { source: 'gemspec.rb', dest: "#{@name}.gemspec" }
|
93
91
|
# Example of how to create a directory
|
94
|
-
list[:templates_app] = { dest: 'templates/app_generators/application', type: :directory }
|
95
|
-
list[:templates_plugin] = { dest: 'templates/app_generators/plugin', type: :directory }
|
96
|
-
list[:templates_base] = { dest: 'templates/app_generators/base', type: :directory }
|
92
|
+
list[:templates_app] = { dest: 'app/templates/app_generators/application', type: :directory }
|
93
|
+
list[:templates_plugin] = { dest: 'app/templates/app_generators/plugin', type: :directory }
|
94
|
+
list[:templates_base] = { dest: 'app/templates/app_generators/base', type: :directory }
|
97
95
|
# By default, directories created in this way will contain a .keep file, to inhibit this:
|
98
96
|
# list[:pattern_dir] = { dest: "pattern", type: :directory, nokeep: true }
|
99
97
|
# Example of how to create a symlink
|
@@ -1,8 +1,7 @@
|
|
1
1
|
module OrigenAppGenerators
|
2
2
|
# The base generator class that should be used by all plugin generators
|
3
3
|
class Plugin < Application
|
4
|
-
def
|
5
|
-
get_name_and_namespace
|
4
|
+
def get_additional_user_input
|
6
5
|
get_summary
|
7
6
|
get_audience unless @audience
|
8
7
|
end
|
@@ -19,15 +18,13 @@ module OrigenAppGenerators
|
|
19
18
|
list.delete(:web_installation)
|
20
19
|
list.delete(:web_introduction)
|
21
20
|
list[:gemspec] = { source: 'gemspec.rb', dest: "#{@name}.gemspec" }
|
22
|
-
list[:templates_shared] = { dest: 'templates/shared', type: :directory }
|
21
|
+
list[:templates_shared] = { dest: 'app/templates/shared', type: :directory }
|
23
22
|
if @audience == :external
|
24
23
|
list[:travis] = { source: '.travis.yml' }
|
25
|
-
list[:web_navbar] = { source: 'templates/web/partials/_navbar_external.html.erb', dest: 'templates/web/partials/_navbar.html.erb' }
|
24
|
+
list[:web_navbar] = { source: 'app/templates/web/partials/_navbar_external.html.erb', dest: 'app/templates/web/partials/_navbar.html.erb' }
|
26
25
|
else
|
27
|
-
list[:web_navbar] = { source: 'templates/web/partials/_navbar_internal.html.erb', dest: 'templates/web/partials/_navbar.html.erb' }
|
26
|
+
list[:web_navbar] = { source: 'app/templates/web/partials/_navbar_internal.html.erb', dest: 'app/templates/web/partials/_navbar.html.erb' }
|
28
27
|
end
|
29
|
-
list[:lib_readme] = { source: 'lib/README', dest: "lib/#{@name}/README" }
|
30
|
-
list[:lib_readme_dev] = { source: 'lib_dev/README', dest: "lib/#{@name}_dev/README" }
|
31
28
|
list
|
32
29
|
end
|
33
30
|
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
module OrigenAppGenerators
|
2
|
+
module TestEngineering
|
3
|
+
module Common
|
4
|
+
def common_filelist(list)
|
5
|
+
# Example of how to remove a file from the parent list
|
6
|
+
# list.delete(:target_debug)
|
7
|
+
# Example of how to add a file, in this case the file will be compiled and copied to
|
8
|
+
# the same location in the new app
|
9
|
+
list[:environment_v93k] = { source: 'environment/v93k.rb' }
|
10
|
+
list[:environment_j750] = { source: 'environment/j750.rb' }
|
11
|
+
list[:environment_uflex] = { source: 'environment/uflex.rb' }
|
12
|
+
# Alternatively specifying a different destination, typically you would do this when
|
13
|
+
# the final location is dynamic
|
14
|
+
# list[:gemspec] = { source: 'gemspec.rb', dest: "#{@name}.gemspec" }
|
15
|
+
# Example of how to create a directory
|
16
|
+
# list[:pattern_dir] = { dest: 'pattern', type: :directory }
|
17
|
+
# Example of how to create a symlink
|
18
|
+
list[:environment_default] = { source: 'uflex.rb', # Relative to the file being linked to
|
19
|
+
dest: 'environment/default.rb', # Relative to destination_root
|
20
|
+
type: :symlink }
|
21
|
+
# Test engineering source directories
|
22
|
+
list[:patterns_dir] = { dest: 'app/patterns', type: :directory }
|
23
|
+
list[:flows_dir] = { dest: 'app/flows', type: :directory }
|
24
|
+
# Remember to return the final list
|
25
|
+
list
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
@@ -1,8 +1,9 @@
|
|
1
1
|
module OrigenAppGenerators
|
2
2
|
module TestEngineering
|
3
|
-
require 'origen_app_generators/sub_block_parser'
|
4
3
|
# Generates a generic application shell
|
5
4
|
class StandAloneApplication < Application
|
5
|
+
include Common
|
6
|
+
|
6
7
|
desc 'A stand alone test engineering application'
|
7
8
|
|
8
9
|
# Any methods that are not protected will get invoked in the order that they are
|
@@ -13,13 +14,12 @@ module OrigenAppGenerators
|
|
13
14
|
# The methods to get the common user input that applies to all applications will
|
14
15
|
# get called at the start automatically, you have a chance here to ask any additional
|
15
16
|
# questions that are specific to the type of application being generated
|
16
|
-
get_top_level_names
|
17
|
-
get_sub_block_names
|
18
17
|
end
|
19
18
|
|
20
19
|
def generate_files
|
21
|
-
|
22
|
-
|
20
|
+
@development_dependencies = [
|
21
|
+
['origen_testers']
|
22
|
+
]
|
23
23
|
build_filelist
|
24
24
|
end
|
25
25
|
|
@@ -37,122 +37,8 @@ module OrigenAppGenerators
|
|
37
37
|
|
38
38
|
protected
|
39
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
40
|
# Defines the filelist for the generator, the default list is inherited from the
|
155
|
-
# parent class (
|
41
|
+
# parent class (Plugin).
|
156
42
|
# The filelist can contain references to generate files, directories or symlinks in the
|
157
43
|
# new application.
|
158
44
|
#
|
@@ -160,74 +46,16 @@ module OrigenAppGenerators
|
|
160
46
|
# from the parent generator, this means that your generator will automatically stay up
|
161
47
|
# to date with the latest conventions
|
162
48
|
#
|
163
|
-
# The master templates live in templates/app_generators/
|
49
|
+
# The master templates live in templates/app_generators/plugin, but
|
164
50
|
# DO NOT MODIFY THESE FILES DIRECTLY.
|
165
51
|
# 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/
|
52
|
+
# master file to the equivalent sub-directory of templates/app_generators/test_engineering/mpg_test_block
|
167
53
|
# which will override the version in the master directory.
|
168
54
|
#
|
169
55
|
# Additional files can be added or removed from the filelist as shown below.
|
170
56
|
def filelist
|
171
57
|
@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
|
58
|
+
list = common_filelist(super) # Always pick up the parent list
|
231
59
|
list
|
232
60
|
end
|
233
61
|
end
|