origen_app_generators 0.4.0 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/{lib/tasks → bin}/boot.rb +15 -15
- data/bin/fix_my_workspace +10 -2
- data/config/application.rb +7 -0
- data/config/shared_commands.rb +170 -0
- data/config/version.rb +2 -2
- data/lib/origen_app_generators.rb +47 -15
- data/lib/origen_app_generators/new.rb +50 -32
- data/lib/origen_app_generators/origen_infrastructure/app_generator_plugin.rb +103 -0
- data/lib/origen_app_generators/plugin.rb +1 -1
- data/lib/tasks/app_generators.rake +6 -98
- data/lib/tasks/new_app_tests.rake +3 -1
- data/templates/app_generators/application/config/application.rb +12 -1
- data/templates/app_generators/new/generator.rb +45 -23
- data/templates/app_generators/origen_infrastructure/app_generator_plugin/config/load_generators.rb +7 -0
- data/templates/app_generators/origen_infrastructure/app_generator_plugin/lib/application.rb +48 -0
- data/templates/app_generators/origen_infrastructure/app_generator_plugin/lib/module.rb +27 -0
- data/templates/app_generators/origen_infrastructure/app_generator_plugin/lib/plugin.rb +58 -0
- data/templates/app_generators/plugin/Gemfile +2 -2
- data/templates/app_generators/plugin/gemspec.rb +6 -1
- data/templates/app_generators/test_engineering/stand_alone_application/Gemfile +7 -1
- metadata +12 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6bd751932ba648a39c5f1b2d8cd61d1cc224d739
|
4
|
+
data.tar.gz: a71ffc595f1da44df412126be1bcaf68e5f369e7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3990cdbb27929fb3fe39665776ddd6ad2d559ff8ba65c158e9761fe47aa8f004b1bd9ba8142a8721d4103c4e4e6c0f492ed23671a3cd105e5ae03d479160699b
|
7
|
+
data.tar.gz: 442e825f3e580a2edb99c5c32584f69c6665fc5db5015812ed5ece72bf7353ce7a10576554ecb6fef7c8f6f5440ac4402ce0d36b3f46024d07cf018b4b9db3e5
|
data/{lib/tasks → bin}/boot.rb
RENAMED
@@ -5,34 +5,34 @@
|
|
5
5
|
# that any unintended dependencies on a real app environment will
|
6
6
|
# be highlighted during test.
|
7
7
|
|
8
|
-
|
9
|
-
$LOAD_PATH.unshift ARGV
|
10
|
-
$LOAD_PATH.unshift
|
8
|
+
$LOAD_PATH.unshift ARGV.shift
|
9
|
+
$LOAD_PATH.unshift ARGV.shift
|
10
|
+
$LOAD_PATH.unshift ARGV.shift
|
11
11
|
|
12
12
|
require 'fileutils'
|
13
|
+
require 'origen'
|
13
14
|
|
14
15
|
# Prevent the bundle from loading by running this outside of the
|
15
|
-
if
|
16
|
-
tmp_dir = 'C:/tmp/
|
16
|
+
if Origen.os.windows?
|
17
|
+
tmp_dir = 'C:/tmp/my_app_generators/new_app'
|
17
18
|
else
|
18
|
-
tmp_dir = '/tmp/
|
19
|
+
tmp_dir = '/tmp/my_app_generators/new_app'
|
19
20
|
end
|
20
21
|
FileUtils.rm_rf tmp_dir if File.exist?(tmp_dir)
|
21
22
|
FileUtils.mkdir_p tmp_dir
|
22
23
|
|
23
24
|
begin
|
24
|
-
require 'origen'
|
25
25
|
Dir.chdir tmp_dir do
|
26
|
-
# For some reason this is not being defined by
|
26
|
+
# For some reason this is not being defined by require origen anymore
|
27
27
|
User = Origen::Users::User unless defined? User
|
28
|
-
|
28
|
+
require 'byebug'
|
29
29
|
require 'origen_app_generators'
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
30
|
+
load_generators = ARGV.shift
|
31
|
+
OrigenAppGenerators.unload_generators unless ARGV[0]
|
32
|
+
require load_generators if File.exist?(load_generators)
|
33
|
+
|
34
|
+
OrigenAppGenerators.invoke('tmp')
|
35
35
|
end
|
36
36
|
ensure
|
37
|
-
|
37
|
+
FileUtils.mv "#{tmp_dir}/tmp", 'tmp' if File.exist?("#{tmp_dir}/tmp")
|
38
38
|
end
|
data/bin/fix_my_workspace
CHANGED
@@ -2,9 +2,17 @@
|
|
2
2
|
$VERBOSE = nil # Don't care about world writable dir warnings and the like
|
3
3
|
|
4
4
|
if $_fix_my_workspace_version_check
|
5
|
-
$_fix_my_workspace_version = '0.
|
5
|
+
$_fix_my_workspace_version = '0.7.0'
|
6
6
|
else
|
7
|
-
|
7
|
+
if File.exist?(File.expand_path('../../lib/origen.rb', __FILE__))
|
8
|
+
# If this script is being run from within an origen-core workspace, use that Origen-core,
|
9
|
+
# not the system-installed origen-core version.
|
10
|
+
$LOAD_PATH.unshift(File.expand_path('../../lib', __FILE__))
|
11
|
+
require 'origen'
|
12
|
+
else
|
13
|
+
# Use system-installed Origen (the gem in system Ruby)
|
14
|
+
require 'origen'
|
15
|
+
end
|
8
16
|
|
9
17
|
if !Origen.site_config.gem_manage_bundler
|
10
18
|
puts 'Sorry but you have opted to manage Bundler yourself via your Origen site config, and this means'
|
data/config/application.rb
CHANGED
@@ -37,6 +37,13 @@ class OrigenAppGeneratorsApplication < Origen::Application
|
|
37
37
|
# In parallel go and edit config/version.rb to enable the semantic version code.
|
38
38
|
config.semantically_version = true
|
39
39
|
|
40
|
+
config.shared = {
|
41
|
+
#patterns: "pattern",
|
42
|
+
#templates: "templates",
|
43
|
+
#programs: "program",
|
44
|
+
command_launcher: "config/shared_commands.rb"
|
45
|
+
}
|
46
|
+
|
40
47
|
# An example of how to set application specific LSF parameters
|
41
48
|
#config.lsf.project = "msg.te"
|
42
49
|
|
@@ -0,0 +1,170 @@
|
|
1
|
+
# The requested command is passed in here as @command
|
2
|
+
case @command
|
3
|
+
|
4
|
+
when "app_gen:test"
|
5
|
+
options = {}
|
6
|
+
|
7
|
+
opt_parser = OptionParser.new do |opts|
|
8
|
+
opts.banner = <<-END
|
9
|
+
Test the generators by emulating the 'origen new' command execution and building the new
|
10
|
+
application into the tmp directory.
|
11
|
+
|
12
|
+
Usage: origen app_gen:test [options]
|
13
|
+
END
|
14
|
+
opts.on('-d', '--debugger', 'Enable the debugger') { options[:debugger] = true }
|
15
|
+
opts.on('-i', '--inputs INDEX', Integer, "Apply the set of test inputs defined in #{Origen.app.namespace}::TEST_INPUTS[INDEX]") { |f| options[:inputs] = f }
|
16
|
+
opts.on('-r', '--regression', "Run all sets of test inputs defined in #{Origen.app.namespace}::TEST_INPUTS[INDEX]") { options[:regression] = true }
|
17
|
+
opts.on('-a', '--all_generators', "Include the generators from Origen core") { options[:all_generators] = true }
|
18
|
+
opts.separator ''
|
19
|
+
opts.on('-h', '--help', 'Show this message') { puts opts; exit }
|
20
|
+
end
|
21
|
+
|
22
|
+
opt_parser.orig_parse! ARGV
|
23
|
+
|
24
|
+
FileUtils.rm_rf "#{Origen.root}/tmp" if File.exist?("#{Origen.root}/tmp")
|
25
|
+
|
26
|
+
if options[:inputs] || options[:regression]
|
27
|
+
if options[:regression]
|
28
|
+
inputs = Origen.app.namespace.constantize::TEST_INPUTS
|
29
|
+
else
|
30
|
+
inputs = [Origen.app.namespace.constantize::TEST_INPUTS[options[:inputs].to_i]]
|
31
|
+
end
|
32
|
+
|
33
|
+
prefix = 'bundle exec ' unless Origen.site_config.gem_manage_bundler
|
34
|
+
|
35
|
+
overall_fail = false
|
36
|
+
|
37
|
+
inputs.each do |vals|
|
38
|
+
test_failed = false
|
39
|
+
post_build_operations = Array(vals.pop)
|
40
|
+
target_load_test_required = false
|
41
|
+
post_build_operations = post_build_operations.map do |op|
|
42
|
+
if op.to_s == 'default'
|
43
|
+
target_load_test_required = true
|
44
|
+
['origen -v',
|
45
|
+
'origen lint --no-correct',
|
46
|
+
'bundle exec rake new_app_tests:load_target',
|
47
|
+
'origen web compile --no-serve'
|
48
|
+
]
|
49
|
+
elsif op.to_s == 'load_target'
|
50
|
+
target_load_test_required = true
|
51
|
+
'rake new_app_tests:load_target'
|
52
|
+
else
|
53
|
+
op
|
54
|
+
end
|
55
|
+
end.flatten
|
56
|
+
|
57
|
+
str = vals.map { |i| i == :default ? "\n" : "#{i}\n" }.join('')
|
58
|
+
cmd = "#{prefix} origen app_gen:test"
|
59
|
+
cmd += ' --debugger' if options[:debugger]
|
60
|
+
cmd += ' --all_generators' if options[:all_generators]
|
61
|
+
passed = false
|
62
|
+
Bundler.with_clean_env do
|
63
|
+
passed = system "echo '#{str}' | #{cmd}"
|
64
|
+
end
|
65
|
+
|
66
|
+
if passed
|
67
|
+
# The app is successfully built, now see if it works...
|
68
|
+
unless post_build_operations.empty?
|
69
|
+
if target_load_test_required
|
70
|
+
FileUtils.cp "#{Origen.root!}/lib/tasks/new_app_tests.rake", 'tmp/lib/tasks'
|
71
|
+
end
|
72
|
+
|
73
|
+
operation_failed = false
|
74
|
+
Bundler.with_clean_env do
|
75
|
+
Dir.chdir "#{Origen.root}/tmp" do
|
76
|
+
post_build_operations.each_with_index do |op, i|
|
77
|
+
if i == 0 && !Origen.site_config.gem_manage_bundler
|
78
|
+
system('bundle')
|
79
|
+
end
|
80
|
+
Origen.log.info "Running command: #{op}"
|
81
|
+
if system("#{prefix}#{op}")
|
82
|
+
Origen.log.success "Command passed: #{op}"
|
83
|
+
else
|
84
|
+
Origen.log.error "Command failed: #{op}"
|
85
|
+
operation_failed = true
|
86
|
+
end
|
87
|
+
end
|
88
|
+
end
|
89
|
+
end
|
90
|
+
|
91
|
+
if operation_failed
|
92
|
+
if options[:regression]
|
93
|
+
overall_fail = true
|
94
|
+
else
|
95
|
+
Origen.app.stats.report_fail
|
96
|
+
exit 1
|
97
|
+
end
|
98
|
+
end
|
99
|
+
end
|
100
|
+
else
|
101
|
+
Origen.log.error "The generator failed to build!"
|
102
|
+
if options[:regression]
|
103
|
+
overall_fail = true
|
104
|
+
else
|
105
|
+
Origen.app.stats.report_fail
|
106
|
+
exit 1
|
107
|
+
end
|
108
|
+
end
|
109
|
+
end
|
110
|
+
|
111
|
+
if options[:regression] && overall_fail
|
112
|
+
Origen.app.stats.report_fail
|
113
|
+
exit 1
|
114
|
+
else
|
115
|
+
Origen.app.stats.report_pass
|
116
|
+
exit 0
|
117
|
+
end
|
118
|
+
|
119
|
+
else
|
120
|
+
|
121
|
+
# Launch the generator in a standalone shell,
|
122
|
+
# this is to emulate how it will run in real life and cause it to fail if there are
|
123
|
+
# any dependencies on running within an Origen app environment
|
124
|
+
boot = "#{Origen.root!}/bin/boot.rb"
|
125
|
+
origen_lib = "#{Origen.top}/lib"
|
126
|
+
app_gen_lib = "#{Origen.root!}/lib"
|
127
|
+
app_lib = "#{Origen.root}/lib"
|
128
|
+
load_generators = "#{Origen.root}/config/load_generators.rb"
|
129
|
+
cmd = "#{boot} #{origen_lib} #{app_gen_lib} #{app_lib} #{load_generators}"
|
130
|
+
cmd = "#{cmd} true" if options[:all_generators] || Origen.app.name == :origen_app_generators
|
131
|
+
cmd = "ruby #{cmd}" if Origen.os.windows?
|
132
|
+
cmd = "bundle exec #{cmd}" unless Origen.site_config.gem_manage_bundler
|
133
|
+
# puts cmd
|
134
|
+
passed = false
|
135
|
+
Bundler.with_clean_env do
|
136
|
+
passed = system cmd
|
137
|
+
end
|
138
|
+
exit passed ? 0 : 1
|
139
|
+
end
|
140
|
+
|
141
|
+
when "app_gen:new"
|
142
|
+
options = {}
|
143
|
+
|
144
|
+
opt_parser = OptionParser.new do |opts|
|
145
|
+
opts.banner = <<-END
|
146
|
+
Create a new application generator.
|
147
|
+
|
148
|
+
Usage: origen app_gen:new [options]
|
149
|
+
END
|
150
|
+
opts.on('-d', '--debugger', 'Enable the debugger') { options[:debugger] = true }
|
151
|
+
opts.separator ''
|
152
|
+
opts.on('-h', '--help', 'Show this message') { puts opts; exit }
|
153
|
+
end
|
154
|
+
|
155
|
+
opt_parser.orig_parse! ARGV
|
156
|
+
|
157
|
+
OrigenAppGenerators::New.start []
|
158
|
+
exit 0
|
159
|
+
|
160
|
+
# Always leave an else clause to allow control to fall back through to the Origen command handler.
|
161
|
+
# You probably want to also add the command details to the help shown via 'origen -h',
|
162
|
+
# you can do this bb adding the required text to @plugin_commands before handing control back to
|
163
|
+
# Origen.
|
164
|
+
else
|
165
|
+
@plugin_commands << <<-EOT
|
166
|
+
app_gen:test Test run the 'origen new' command operation using your latest generators
|
167
|
+
app_gen:new Create a new application or plugin generator
|
168
|
+
EOT
|
169
|
+
|
170
|
+
end
|
data/config/version.rb
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
require 'origen'
|
2
|
+
require_relative '../config/application.rb'
|
2
3
|
require 'colored'
|
3
4
|
require 'origen_app_generators/base'
|
4
5
|
require 'origen_app_generators/application'
|
@@ -8,40 +9,71 @@ require 'origen_app_generators/empty_plugin'
|
|
8
9
|
require 'origen_app_generators/new'
|
9
10
|
require 'origen_app_generators/test_engineering/test_block'
|
10
11
|
require 'origen_app_generators/test_engineering/stand_alone_application'
|
12
|
+
require 'origen_app_generators/origen_infrastructure/app_generator_plugin'
|
11
13
|
|
12
14
|
module OrigenAppGenerators
|
13
15
|
extend Origen::Utility::InputCapture
|
14
16
|
|
15
17
|
TEST_INPUTS = [
|
16
|
-
# Empty app
|
17
|
-
['0', '0', :default, :default,
|
18
|
-
# Empty plugin
|
19
|
-
['0', '1', :default, :default, 'A test block', 'yes',
|
20
|
-
# Stand alone test engineering app
|
21
|
-
['
|
22
|
-
# Test module
|
23
|
-
['
|
24
|
-
|
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!
|
25
29
|
|
26
|
-
#
|
27
|
-
#
|
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.
|
28
35
|
AVAILABLE = {
|
29
|
-
'Test Engineering'
|
36
|
+
'Test Engineering' => [
|
30
37
|
OrigenAppGenerators::TestEngineering::TestBlock,
|
31
38
|
OrigenAppGenerators::TestEngineering::StandAloneApplication
|
39
|
+
],
|
40
|
+
'Origen Infrastructure' => [
|
41
|
+
OrigenAppGenerators::OrigenInfrastructure::AppGeneratorPlugin
|
32
42
|
]
|
33
43
|
}
|
34
44
|
|
45
|
+
# @api private
|
46
|
+
def self.add_generators(new_generators)
|
47
|
+
new_generators.each do |domain, gens|
|
48
|
+
if generators[domain]
|
49
|
+
gens.each { |g| generators[domain].unshift(g) }
|
50
|
+
new_generators.delete(domain)
|
51
|
+
end
|
52
|
+
end
|
53
|
+
@generators = new_generators.merge(generators)
|
54
|
+
end
|
55
|
+
|
56
|
+
# @api private
|
57
|
+
def self.unload_generators
|
58
|
+
@generators = {}
|
59
|
+
end
|
60
|
+
|
61
|
+
# @api private
|
62
|
+
def self.generators
|
63
|
+
@generators ||= AVAILABLE
|
64
|
+
end
|
65
|
+
|
66
|
+
# @api private
|
35
67
|
def self.invoke(path)
|
36
68
|
puts
|
37
|
-
puts 'CHOOSE AN
|
69
|
+
puts 'CHOOSE AN APPLICATION DOMAIN'
|
38
70
|
puts
|
39
71
|
puts "Domain-specific application templates are available for the following areas (enter '0' to build an empty generic one)"
|
40
72
|
puts
|
41
73
|
i = 0
|
42
74
|
accept = [0]
|
43
75
|
puts '0 - Empty / Not listed'
|
44
|
-
|
76
|
+
generators.reverse_each do |domain, _generators|
|
45
77
|
i += 1
|
46
78
|
accept << i
|
47
79
|
puts "#{i} - #{domain}"
|
@@ -65,7 +97,7 @@ module OrigenAppGenerators
|
|
65
97
|
OrigenAppGenerators::EmptyPlugin.start [path]
|
66
98
|
end
|
67
99
|
else
|
68
|
-
domain =
|
100
|
+
domain = generators.to_a
|
69
101
|
domain = domain[domain.size - selection]
|
70
102
|
puts
|
71
103
|
puts "CHOOSE FROM THE FOLLOWING #{domain[0].upcase} APPLICATION TEMPLATES"
|
@@ -11,6 +11,7 @@ module OrigenAppGenerators
|
|
11
11
|
get_name
|
12
12
|
get_type
|
13
13
|
get_summary
|
14
|
+
@namespace = Origen.app.namespace
|
14
15
|
end
|
15
16
|
|
16
17
|
def set_type
|
@@ -22,56 +23,73 @@ module OrigenAppGenerators
|
|
22
23
|
end
|
23
24
|
|
24
25
|
def enable
|
25
|
-
|
26
|
-
|
27
|
-
|
26
|
+
available = Origen.app.namespace.constantize::AVAILABLE
|
27
|
+
test_inputs = Origen.app.namespace.constantize::TEST_INPUTS
|
28
|
+
|
29
|
+
# **** Add require line ****
|
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",
|
28
32
|
before: module_declaration
|
29
33
|
|
30
|
-
# Add to the AVAILABLE hash
|
31
|
-
if
|
34
|
+
# **** Add to the AVAILABLE hash ****
|
35
|
+
if available[@domain_summary]
|
32
36
|
existing_domain = /\s*('|")#{@domain_summary}('|") => \[\s*\n/
|
33
|
-
inject_into_file
|
37
|
+
inject_into_file "lib/#{Origen.app.name}.rb", " #{Origen.app.namespace}::#{@domain_namespace}::#{@classname},\n",
|
34
38
|
after: existing_domain
|
35
39
|
else
|
36
40
|
new_domain = <<-END
|
37
41
|
'#{@domain_summary}' => [
|
38
|
-
|
42
|
+
#{Origen.app.namespace}::#{@domain_namespace}::#{@classname},
|
39
43
|
],
|
40
44
|
END
|
41
45
|
available_hash = /AVAILABLE = {\s*\n/
|
42
|
-
inject_into_file
|
46
|
+
inject_into_file "lib/#{Origen.app.name}.rb", new_domain, after: available_hash
|
43
47
|
end
|
44
|
-
end
|
45
48
|
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
gsub_file file, 'INTRO_GOES_HERE', "This generates a customized version of the [Generic Plugin](<%= path 'origen_app_generators/plugin' %>)."
|
49
|
+
# **** Add a starter set of test inputs ****
|
50
|
+
# First work out what the selection numbers will be for the new generator
|
51
|
+
if available[@domain_summary]
|
52
|
+
first = available.size - available.find_index { |k, _| k == @domain_summary }
|
53
|
+
second = available[@domain_summary].size
|
52
54
|
else
|
53
|
-
|
55
|
+
first = available.size + 1
|
56
|
+
second = 0
|
54
57
|
end
|
58
|
+
inputs = "\n # #{test_inputs.size} - #{@domain_namespace}::#{@classname}\n"
|
59
|
+
if @parentclass == 'Plugin'
|
60
|
+
inputs += " ['#{first}', '#{second}', :default, :default, 'A cool plugin', 'yes', :default]"
|
61
|
+
else
|
62
|
+
inputs += " ['#{first}', '#{second}', :default, :default, :default]"
|
63
|
+
end
|
64
|
+
inputs = ",#{inputs}" unless test_inputs.empty?
|
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
|
55
67
|
end
|
56
68
|
|
69
|
+
# Can't compile this as contains some final ERB, so substitute instead
|
70
|
+
# def customize_doc_page
|
71
|
+
# file = filelist[:doc_info][:dest]
|
72
|
+
# gsub_file file, 'TITLE_GOES_HERE', @title
|
73
|
+
# if @type == :plugin
|
74
|
+
# gsub_file file, 'INTRO_GOES_HERE', "This generates a customized version of the [Generic Plugin](<%= path 'origen_app_generators/plugin' %>)."
|
75
|
+
# else
|
76
|
+
# gsub_file file, 'INTRO_GOES_HERE', "This generates a customized version of the [Generic Application](<%= path 'origen_app_generators/application' %>)."
|
77
|
+
# end
|
78
|
+
# end
|
79
|
+
|
57
80
|
def conclude
|
81
|
+
system "origen lint #{Origen.root}/lib/#{Origen.app.name}.rb"
|
58
82
|
puts
|
59
83
|
puts "New generator created at: #{filelist[:generator][:dest]}"
|
60
84
|
puts
|
61
85
|
puts "Create any template files you need for this generator in: #{filelist[:templates_dir][:dest]}"
|
62
86
|
puts
|
63
|
-
puts "Before you go add some documentation about what this generates to: templates/web/origen_app_generators/origen_app_generators/#{@domain_namespace.underscore}/#{@classname.underscore}.md.erb"
|
64
|
-
puts
|
87
|
+
# puts "Before you go add some documentation about what this generates to: templates/web/origen_app_generators/origen_app_generators/#{@domain_namespace.underscore}/#{@classname.underscore}.md.erb"
|
88
|
+
# puts
|
65
89
|
end
|
66
90
|
|
67
91
|
protected
|
68
92
|
|
69
|
-
def existing_domains
|
70
|
-
OrigenAppGenerators::AVAILABLE.keys.map do |key|
|
71
|
-
key.sub(/ Engineering$/, '')
|
72
|
-
end
|
73
|
-
end
|
74
|
-
|
75
93
|
def get_summary
|
76
94
|
puts
|
77
95
|
puts 'DESCRIBE YOUR NEW GENERATOR IN A FEW WORDS'
|
@@ -100,7 +118,7 @@ module OrigenAppGenerators
|
|
100
118
|
@classname = get_text(single: true).split('::').last
|
101
119
|
unless @classname.empty?
|
102
120
|
if @classname.length >= 3
|
103
|
-
valid = valid_constant?("
|
121
|
+
valid = valid_constant?("#{Origen.app.namespace}::#{@domain_namespace}::#{@classname}")
|
104
122
|
end
|
105
123
|
unless valid
|
106
124
|
puts 'That class name is not valid :-('
|
@@ -113,24 +131,24 @@ module OrigenAppGenerators
|
|
113
131
|
|
114
132
|
def get_domain
|
115
133
|
puts
|
116
|
-
puts 'WHAT
|
134
|
+
puts 'WHAT APPLICATION DOMAIN WILL YOUR NEW APP TEMPLATE APPLY TO?'
|
117
135
|
puts
|
118
|
-
puts "Enter something like 'Test', 'Design',
|
136
|
+
puts "Enter something like 'Test Engineering', 'Design', etc."
|
119
137
|
puts
|
120
138
|
domain = get_text(single: true)
|
121
|
-
domain = domain.
|
122
|
-
@domain_summary =
|
139
|
+
domain = domain.titleize
|
140
|
+
@domain_summary = domain
|
123
141
|
@domain_namespace = @domain_summary.gsub(' ', '')
|
124
142
|
end
|
125
143
|
|
126
144
|
def filelist
|
127
145
|
@filelist ||= {
|
128
146
|
generator: { source: 'generator.rb',
|
129
|
-
dest: "lib
|
147
|
+
dest: "lib/#{Origen.app.name}/#{@domain_namespace.underscore}/#{@classname.underscore}.rb" },
|
130
148
|
templates_dir: { dest: "templates/app_generators/#{@domain_namespace.underscore}/#{@classname.underscore}",
|
131
149
|
type: :directory },
|
132
|
-
doc_info: { source: 'info.md.erb',
|
133
|
-
|
150
|
+
# doc_info: { source: 'info.md.erb',
|
151
|
+
# dest: "templates/web/#{Origen.app.name}/#{@domain_namespace.underscore}/#{@classname.underscore}.md.erb" }
|
134
152
|
}
|
135
153
|
end
|
136
154
|
end
|
@@ -0,0 +1,103 @@
|
|
1
|
+
module OrigenAppGenerators
|
2
|
+
module OrigenInfrastructure
|
3
|
+
# Generates a generic application shell
|
4
|
+
class AppGeneratorPlugin < Plugin
|
5
|
+
desc "A plugin to make your own application templates available through the 'origen new' command"
|
6
|
+
|
7
|
+
def initialize(*args)
|
8
|
+
@audience = :internal
|
9
|
+
@validate_release_tests = ['origen app_gen:test --regression']
|
10
|
+
super
|
11
|
+
end
|
12
|
+
|
13
|
+
# Any methods that are not protected will get invoked in the order that they are
|
14
|
+
# defined when the generator is run, method naming is irrelevant unless you want
|
15
|
+
# to override a method that is defined by the parent class
|
16
|
+
|
17
|
+
def get_user_input
|
18
|
+
# The methods to get the common user input that applies to all applications will
|
19
|
+
# get called at the start automatically, you have a chance here to ask any additional
|
20
|
+
# questions that are specific to the type of application being generated
|
21
|
+
end
|
22
|
+
|
23
|
+
def generate_files
|
24
|
+
@runtime_dependencies = [
|
25
|
+
['origen_app_generators', ">= #{Origen.app!.version}"]
|
26
|
+
]
|
27
|
+
@post_runtime_dependency_comments = [
|
28
|
+
'DO NOT ADD ANY ADDITIONAL RUNTIME DEPENDENCIES HERE, WHEN THESE GENERATORS',
|
29
|
+
'ARE INVOKED TO GENERATE A NEW APPLICATION IT WILL NOT BE LAUNCHED FROM WITHIN',
|
30
|
+
'A BUNDLED ENVIRONMENT.',
|
31
|
+
'',
|
32
|
+
'THEREFORE GENERATORS MUST NOT RELY ON ANY 3RD PARTY GEMS THAT ARE NOT',
|
33
|
+
'PRESENT AS PART OF A STANDARD ORIGEN INSTALLATION - I.E. YOU CAN ONLY RELY',
|
34
|
+
'ON THE GEMS THAT ORIGEN ITSELF DEPENDS ON.'
|
35
|
+
]
|
36
|
+
# Calling this will build all files, directories and symlinks contained in the
|
37
|
+
# hash returned by the filelist method
|
38
|
+
build_filelist
|
39
|
+
end
|
40
|
+
|
41
|
+
def modify_files
|
42
|
+
# If you want to modify any of the generated files you can do so now, you have access
|
43
|
+
# to all of the Thor Action methods described here:
|
44
|
+
# http://www.rubydoc.info/github/wycats/thor/Thor/Actions
|
45
|
+
# See the enable method in lib/app_generators/new.rb for some examples of using these.
|
46
|
+
end
|
47
|
+
|
48
|
+
def conclude
|
49
|
+
# Print out anything you think the user should know about their new application at the end
|
50
|
+
puts "New app created at: #{destination_root}"
|
51
|
+
puts
|
52
|
+
puts 'Create your first generator by running this command within your new app:'
|
53
|
+
puts ' origen app_gen:new'
|
54
|
+
puts
|
55
|
+
end
|
56
|
+
|
57
|
+
protected
|
58
|
+
|
59
|
+
# Defines the filelist for the generator, the default list is inherited from the
|
60
|
+
# parent class (Plugin).
|
61
|
+
# The filelist can contain references to generate files, directories or symlinks in the
|
62
|
+
# new application.
|
63
|
+
#
|
64
|
+
# Generally to make your generator more maintainable try and re-use as much as possible
|
65
|
+
# from the parent generator, this means that your generator will automatically stay up
|
66
|
+
# to date with the latest conventions
|
67
|
+
#
|
68
|
+
# The master templates live in templates/app_generators/plugin, but
|
69
|
+
# DO NOT MODIFY THESE FILES DIRECTLY.
|
70
|
+
# Either add or remove things post-generation in the modify_files method or copy the
|
71
|
+
# master file to the equivalent sub-directory of templates/app_generators/origen_infrastructure_engineering/app_generator_plugin
|
72
|
+
# which will override the version in the master directory.
|
73
|
+
#
|
74
|
+
# Additional files can be added or removed from the filelist as shown below.
|
75
|
+
def filelist
|
76
|
+
@filelist ||= begin
|
77
|
+
list = super # Always pick up the parent list
|
78
|
+
# Example of how to remove a file from the parent list
|
79
|
+
# list.delete(:web_doc_layout)
|
80
|
+
list.delete(:lib_readme)
|
81
|
+
list.delete(:lib_readme_dev)
|
82
|
+
# Example of how to add a file, in this case the file will be compiled and copied to
|
83
|
+
# the same location in the new app
|
84
|
+
# list[:config_shared_commands] = { source: 'config/shared_commands.rb' }
|
85
|
+
list[:config_load_generators] = { source: 'config/load_generators.rb' }
|
86
|
+
list[:lib_plugin] = { source: 'lib/plugin.rb', dest: "lib/#{@name}/plugin.rb" }
|
87
|
+
list[:lib_application] = { source: 'lib/application.rb', dest: "lib/#{@name}/application.rb" }
|
88
|
+
# Alternatively specifying a different destination, typically you would do this when
|
89
|
+
# the final location is dynamic
|
90
|
+
# list[:gemspec] = { source: 'gemspec.rb', dest: "#{@name}.gemspec" }
|
91
|
+
# Example of how to create a directory
|
92
|
+
# list[:pattern_dir] = { dest: "pattern", type: :directory }
|
93
|
+
# Example of how to create a symlink
|
94
|
+
# list[:target_default] = { source: 'debug.rb', # Relative to the file being linked to
|
95
|
+
# dest: 'target/default.rb', # Relative to destination_root
|
96
|
+
# type: :symlink }
|
97
|
+
# Remember to return the final list
|
98
|
+
list
|
99
|
+
end
|
100
|
+
end
|
101
|
+
end
|
102
|
+
end
|
103
|
+
end
|
@@ -27,7 +27,7 @@ module OrigenAppGenerators
|
|
27
27
|
list[:web_navbar] = { source: 'templates/web/partials/_navbar_internal.html.erb', dest: 'templates/web/partials/_navbar.html.erb' }
|
28
28
|
end
|
29
29
|
list[:lib_readme] = { source: 'lib/README', dest: "lib/#{@name}/README" }
|
30
|
-
list[:
|
30
|
+
list[:lib_readme_dev] = { source: 'lib_dev/README', dest: "lib/#{@name}_dev/README" }
|
31
31
|
list
|
32
32
|
end
|
33
33
|
end
|
@@ -1,98 +1,6 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
task :test, [:set] do |t, args|
|
8
|
-
_delete_tmp_dir
|
9
|
-
if args[:set]
|
10
|
-
vals = OrigenAppGenerators::TEST_INPUTS[args[:set].to_i]
|
11
|
-
vals.pop # Throw away the test commands
|
12
|
-
str = vals.map { |i| i == :default ? "\n" : "#{i}\n" }.join('')
|
13
|
-
result = system "echo '#{str}' | rake test"
|
14
|
-
else
|
15
|
-
result = _execute_generator(:invoke)
|
16
|
-
end
|
17
|
-
exit 1 unless result
|
18
|
-
end
|
19
|
-
|
20
|
-
desc "Test run a specific generator: rake 'run[TestEngineering::GenericTestBlock]'"
|
21
|
-
task :run, [:generator_class] do |_t, args|
|
22
|
-
_delete_tmp_dir
|
23
|
-
begin
|
24
|
-
klass = eval(args[:generator_class])
|
25
|
-
rescue
|
26
|
-
klass = eval("OrigenAppGenerators::#{args[:generator_class]}")
|
27
|
-
end
|
28
|
-
_execute_generator(klass)
|
29
|
-
end
|
30
|
-
|
31
|
-
desc 'Test that all generators build'
|
32
|
-
task :regression do
|
33
|
-
OrigenAppGenerators::TEST_INPUTS.each do |inputs|
|
34
|
-
# Default test that are run for all app builds
|
35
|
-
commands = ['origen -v',
|
36
|
-
'origen lint',
|
37
|
-
'rake new_app_tests:load_target',
|
38
|
-
'origen web compile --no-serve'
|
39
|
-
] + inputs.pop
|
40
|
-
if ENV['TRAVIS'] && ENV['CONTINUOUS_INTEGRATION']
|
41
|
-
prefix = 'bundle && bundle exec '
|
42
|
-
end
|
43
|
-
str = inputs.map { |i| i == :default ? "\n" : "#{i}\n" }.join('')
|
44
|
-
# Test the app can build
|
45
|
-
unless system "echo '#{str}' | rake test"
|
46
|
-
Origen.app.stats.report_fail
|
47
|
-
exit 1
|
48
|
-
end
|
49
|
-
# Copy the new app test rake tasks to the new app
|
50
|
-
t = File.expand_path('../new_app_tests.rake', Pathname.new(__FILE__).realpath)
|
51
|
-
FileUtils.cp t, 'tmp/lib/tasks'
|
52
|
-
# Test the app can boot
|
53
|
-
Bundler.with_clean_env do
|
54
|
-
Dir.chdir 'tmp' do
|
55
|
-
commands.each do |command|
|
56
|
-
Origen.log.info "Running command: #{command}"
|
57
|
-
unless system("#{prefix}#{command}")
|
58
|
-
Origen.app.stats.report_fail
|
59
|
-
exit 1
|
60
|
-
end
|
61
|
-
Origen.log.success "Command passed: #{command}"
|
62
|
-
end
|
63
|
-
end
|
64
|
-
end
|
65
|
-
end
|
66
|
-
Origen.app.stats.report_pass
|
67
|
-
end
|
68
|
-
|
69
|
-
def _execute_generator(klass)
|
70
|
-
# With the generator identified this now launches it in a standalone shell
|
71
|
-
# This is to emulate how it will run in real life and cause it to fail if there are
|
72
|
-
# any dependencies on running within an Origen app environment
|
73
|
-
boot = "#{File.expand_path(File.dirname(__FILE__))}/boot.rb"
|
74
|
-
origen_lib = "#{Origen.top}/lib"
|
75
|
-
origen_lib = '/proj/mem_c40tfs_testeng/r49409/origen/lib'
|
76
|
-
cmd = "#{boot} #{origen_lib} #{klass}"
|
77
|
-
cmd = "ruby #{cmd}" if Origen.running_on_windows?
|
78
|
-
# puts cmd
|
79
|
-
result = false
|
80
|
-
Bundler.with_clean_env do
|
81
|
-
result = system cmd
|
82
|
-
end
|
83
|
-
result
|
84
|
-
end
|
85
|
-
|
86
|
-
def _delete_tmp_dir
|
87
|
-
sh "rm -rf #{Origen.root}/tmp", verbose: false do |ok, _res|
|
88
|
-
# Sometimes vim can lock a dir if the file is being viewed, trying again will
|
89
|
-
# usually finish the job
|
90
|
-
unless ok
|
91
|
-
sh "rm -rf #{Origen.root}/tmp", verbose: false do |ok, _res|
|
92
|
-
unless ok
|
93
|
-
# I did my best!
|
94
|
-
end
|
95
|
-
end
|
96
|
-
end
|
97
|
-
end
|
98
|
-
end
|
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
|
@@ -1,5 +1,7 @@
|
|
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.
|
1
4
|
namespace :new_app_tests do
|
2
|
-
desc 'Test that the app and default target can load'
|
3
5
|
task :load_target do
|
4
6
|
Origen.app.target.load!
|
5
7
|
end
|
@@ -80,7 +80,17 @@ class <%= @namespace %>Application < Origen::Application
|
|
80
80
|
# system command
|
81
81
|
# end
|
82
82
|
#end
|
83
|
-
|
83
|
+
<% if @validate_release_tests %>
|
84
|
+
# Ensure that all tests pass before allowing a release to continue
|
85
|
+
def validate_release
|
86
|
+
if <%= Array(@validate_release_tests).map { |t| "!system('#{t}')" }.join(' || ') %>
|
87
|
+
puts "Sorry but you can't release with failing tests, please fix them and try again."
|
88
|
+
exit 1
|
89
|
+
else
|
90
|
+
puts "All tests passing, proceeding with release process!"
|
91
|
+
end
|
92
|
+
end
|
93
|
+
<% else %>
|
84
94
|
# Ensure that all tests pass before allowing a release to continue
|
85
95
|
#def validate_release
|
86
96
|
# if !system("origen specs") || !system("origen examples")
|
@@ -90,6 +100,7 @@ class <%= @namespace %>Application < Origen::Application
|
|
90
100
|
# puts "All tests passing, proceeding with release process!"
|
91
101
|
# end
|
92
102
|
#end
|
103
|
+
<% end -%>
|
93
104
|
|
94
105
|
# To enabled source-less pattern generation create a class (for example PatternDispatcher)
|
95
106
|
# to generate the pattern. This should return false if the requested pattern has been
|
@@ -1,4 +1,4 @@
|
|
1
|
-
module
|
1
|
+
module <%= @namespace %>
|
2
2
|
module <%= @domain_namespace %>
|
3
3
|
# Generates a generic application shell
|
4
4
|
class <%= @classname %> < <%= @parentclass %>
|
@@ -12,20 +12,33 @@ module OrigenAppGenerators
|
|
12
12
|
def get_user_input
|
13
13
|
# The methods to get the common user input that applies to all applications will
|
14
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
|
15
|
+
# questions that are specific to the type of application being generated.
|
16
|
+
# See the following links for some examples of how to ask questions:
|
17
|
+
# https://github.com/Origen-SDK/origen_app_generators/blob/master/lib/origen_app_generators/base.rb#L94
|
18
|
+
# https://github.com/Origen-SDK/origen_app_generators/blob/master/lib/origen_app_generators/plugin.rb#L44
|
16
19
|
end
|
17
20
|
|
18
21
|
def generate_files
|
19
22
|
# Calling this will build all files, directories and symlinks contained in the
|
20
|
-
# hash returned by the filelist method
|
23
|
+
# hash returned by the filelist method below
|
21
24
|
build_filelist
|
22
25
|
end
|
23
26
|
|
24
27
|
def modify_files
|
25
|
-
#
|
26
|
-
#
|
28
|
+
# Here you can add or remove things post-generation.
|
29
|
+
# Alternatively, you can copy any master file to the equivalent sub-directory of
|
30
|
+
# templates/app_generators/<%= @domain_namespace.underscore %>/<%= @classname.underscore %>
|
31
|
+
# and this will override the version in the master directory.
|
32
|
+
#
|
33
|
+
# However, post generation modification is recommended when possible since it means that your
|
34
|
+
# generated applications will automatically stay up to date with any improvements made to the
|
35
|
+
# master file.
|
36
|
+
# The downside is that creating a post-generation modification takes a bit more effort to create
|
37
|
+
# compared to simply copying and modifying the file manually.
|
38
|
+
# To help with creating modifications, you have access to all of the Thor Action methods described here:
|
27
39
|
# http://www.rubydoc.info/github/wycats/thor/Thor/Actions
|
28
|
-
# See the enable method
|
40
|
+
# See the enable method for an example of using these here:
|
41
|
+
# https://github.com/Origen-SDK/origen_app_generators/blob/master/lib/origen_app_generators/new.rb#L25
|
29
42
|
end
|
30
43
|
|
31
44
|
def conclude
|
@@ -36,38 +49,47 @@ module OrigenAppGenerators
|
|
36
49
|
protected
|
37
50
|
|
38
51
|
# Defines the filelist for the generator, the default list is inherited from the
|
39
|
-
# parent class (<%= @parentclass %>).
|
52
|
+
# parent class (<%= @namespace %>::<%= @parentclass %>).
|
53
|
+
# <% if @parentclass == 'Plugin' -%>
|
54
|
+
# Since this is a plugin generator, the default list of files comprises the application list,
|
55
|
+
# which you can see here:
|
56
|
+
# https://github.com/Origen-SDK/origen_app_generators/blob/master/lib/origen_app_generators/application.rb
|
57
|
+
# And this is then modified by the base plugin generator which you can see here:
|
58
|
+
# https://github.com/Origen-SDK/origen_app_generators/blob/master/lib/origen_app_generators/plugin.rb
|
59
|
+
# Additionally, this application could have made further modifications to the default list
|
60
|
+
# within lib/<%= @namespace.underscore %>/plugin.rb
|
61
|
+
<% else %>
|
62
|
+
# See here for the default list of files included in an application:
|
63
|
+
# https://github.com/Origen-SDK/origen_app_generators/blob/master/lib/origen_app_generators/application.rb
|
64
|
+
# Additionally, this application could have made further modifications to the default list
|
65
|
+
# within lib/<%= @namespace.underscore %>/application.rb
|
66
|
+
<% end -%>
|
67
|
+
#
|
40
68
|
# The filelist can contain references to generate files, directories or symlinks in the
|
41
69
|
# new application.
|
42
70
|
#
|
43
|
-
#
|
44
|
-
# from the parent generator, this means that your
|
45
|
-
# to date with the latest conventions
|
46
|
-
#
|
47
|
-
# The master templates live in templates/app_generators/<%= @parentclass.downcase %>, but
|
48
|
-
# DO NOT MODIFY THESE FILES DIRECTLY.
|
49
|
-
# Either add or remove things post-generation in the modify_files method or copy the
|
50
|
-
# master file to the equivalent sub-directory of templates/app_generators/<%= @domain_namespace.underscore %>/<%= @classname.underscore %>
|
51
|
-
# which will override the version in the master directory.
|
71
|
+
# To make your generator more maintainable, try and re-use as much as possible
|
72
|
+
# from the parent generator, this means that your generators will automatically stay up
|
73
|
+
# to date with the latest conventions.
|
52
74
|
#
|
53
75
|
# Additional files can be added or removed from the filelist as shown below.
|
54
76
|
def filelist
|
55
77
|
@filelist ||= begin
|
56
78
|
list = super # Always pick up the parent list
|
57
79
|
# Example of how to remove a file from the parent list
|
58
|
-
#list.delete(:web_doc_layout)
|
80
|
+
# list.delete(:web_doc_layout)
|
59
81
|
# Example of how to add a file, in this case the file will be compiled and copied to
|
60
82
|
# the same location in the new app
|
61
|
-
#list[:config_shared_commands] = { source: 'config/shared_commands.rb' }
|
83
|
+
# list[:config_shared_commands] = { source: 'config/shared_commands.rb' }
|
62
84
|
# Alternatively specifying a different destination, typically you would do this when
|
63
85
|
# the final location is dynamic
|
64
|
-
#list[:gemspec] = { source: 'gemspec.rb', dest: "#{@name}.gemspec" }
|
86
|
+
# list[:gemspec] = { source: 'gemspec.rb', dest: "#{@name}.gemspec" }
|
65
87
|
# Example of how to create a directory
|
66
|
-
#list[:pattern_dir] = { dest: "pattern", type: :directory }
|
88
|
+
# list[:pattern_dir] = { dest: "pattern", type: :directory }
|
67
89
|
# Example of how to create a symlink
|
68
|
-
#list[:target_default] = { source: 'debug.rb', # Relative to the file being linked to
|
69
|
-
#
|
70
|
-
#
|
90
|
+
# list[:target_default] = { source: 'debug.rb', # Relative to the file being linked to
|
91
|
+
# dest: 'target/default.rb', # Relative to destination_root
|
92
|
+
# type: :symlink }
|
71
93
|
# Remember to return the final list
|
72
94
|
list
|
73
95
|
end
|
@@ -0,0 +1,48 @@
|
|
1
|
+
module <%= @namespace %>
|
2
|
+
# This will be the parent class of all of your application generators, it provides a place
|
3
|
+
# to add anything that you want to be added to all of your applications
|
4
|
+
class Application < OrigenAppGenerators::Application
|
5
|
+
# Any methods added above the protected line will get automatically invoked
|
6
|
+
# at the start of *all* of your application generators.
|
7
|
+
|
8
|
+
protected
|
9
|
+
|
10
|
+
# You can add helper methods that you want to make available to all of your application
|
11
|
+
# generators here, these will not get called unless a child generator calls them.
|
12
|
+
|
13
|
+
# Here you can modify the default list of files that are included in all of your applications.
|
14
|
+
#
|
15
|
+
# See here for the default list of files:
|
16
|
+
# https://github.com/Origen-SDK/origen_app_generators/blob/master/lib/origen_app_generators/application.rb
|
17
|
+
#
|
18
|
+
# The filelist can contain references to generate files, directories or symlinks in the
|
19
|
+
# new application.
|
20
|
+
#
|
21
|
+
# To make your generators more maintainable, try and re-use as much as possible
|
22
|
+
# from the parent generator, this means that your generator will automatically stay up
|
23
|
+
# to date with the latest conventions.
|
24
|
+
#
|
25
|
+
# Additional files can be added or removed from the filelist as shown below.
|
26
|
+
def filelist
|
27
|
+
@filelist ||= begin
|
28
|
+
list = super # Always pick up the parent list
|
29
|
+
# Example of how to remove a file from the parent list
|
30
|
+
# list.delete(:web_doc_layout)
|
31
|
+
# Example of how to add a file, in this case the file will be compiled and copied to
|
32
|
+
# the same location in the new app
|
33
|
+
# list[:config_shared_commands] = { source: 'config/shared_commands.rb' }
|
34
|
+
# Alternatively specifying a different destination, typically you would do this when
|
35
|
+
# the final location is dynamic
|
36
|
+
# list[:gemspec] = { source: 'gemspec.rb', dest: "#{@name}.gemspec" }
|
37
|
+
# Example of how to create a directory
|
38
|
+
# list[:pattern_dir] = { dest: "pattern", type: :directory }
|
39
|
+
# Example of how to create a symlink
|
40
|
+
# list[:target_default] = { source: 'debug.rb', # Relative to the file being linked to
|
41
|
+
# dest: 'target/default.rb', # Relative to destination_root
|
42
|
+
# type: :symlink }
|
43
|
+
# Remember to return the final list
|
44
|
+
list
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
require 'origen_app_generators'
|
2
|
+
require '<%= @name %>/application'
|
3
|
+
require '<%= @name %>/plugin'
|
4
|
+
|
5
|
+
module <%= @namespace %>
|
6
|
+
# Define test sets of inputs to test your generators. The last item in each array is
|
7
|
+
# required and always indicates what action should be taken once the application has
|
8
|
+
# been built. nil means take no action, :default means to run a default set of test
|
9
|
+
# operations, and an array of Origen command strings gives you control of exactly
|
10
|
+
# what to run.
|
11
|
+
#
|
12
|
+
# These inputs can be executed individually by running 'origen app_gen:test -i INDEX',
|
13
|
+
# where INDEX is the index number of the set you want to execute from the TEST_INPUTS
|
14
|
+
# array.
|
15
|
+
#
|
16
|
+
# You can also execute all sets of test inputs by running: 'origen app_gen:test -r'
|
17
|
+
TEST_INPUTS = [
|
18
|
+
] # END_OF_TEST_INPUTS Don't remove this comment, it is used by the app_gen:new command!
|
19
|
+
|
20
|
+
# As you add new generators to this app they will be entered here, this enables the
|
21
|
+
# mechanism to register them with the 'origen new' command.
|
22
|
+
# You should generally not modify this by hand, instead use the 'origen app_gen:new'
|
23
|
+
# command every time you want to create a new generator, and this will be filled in
|
24
|
+
# for you.
|
25
|
+
AVAILABLE = {
|
26
|
+
}
|
27
|
+
end
|
@@ -0,0 +1,58 @@
|
|
1
|
+
module <%= @namespace %>
|
2
|
+
# This will be the parent class of all of your plugin generators, it provides a place
|
3
|
+
# to add anything that you want to be added to all of your plugins
|
4
|
+
class Plugin < OrigenAppGenerators::Plugin
|
5
|
+
def initialize(*args)
|
6
|
+
# This makes all of your plugins be configured for internal distribution, i.e. rather
|
7
|
+
# than via rubygems.org
|
8
|
+
@audience = :internal
|
9
|
+
super
|
10
|
+
end
|
11
|
+
|
12
|
+
# Any methods added above the protected line will get automatically invoked
|
13
|
+
# at the start of *all* of your plugin generators.
|
14
|
+
|
15
|
+
protected
|
16
|
+
|
17
|
+
# You can add helper methods that you want to make available to all of your plugin
|
18
|
+
# generators here, these will not get called unless a child generator calls them.
|
19
|
+
|
20
|
+
# Here you can modify the default list of files that are included in all of your plugins.
|
21
|
+
#
|
22
|
+
# Since this is a plugin genrator, the default list of files comprises the application list,
|
23
|
+
# which you can see here:
|
24
|
+
# https://github.com/Origen-SDK/origen_app_generators/blob/master/lib/origen_app_generators/application.rb
|
25
|
+
# And this is then modified by the base plugin generator which you can see here:
|
26
|
+
# https://github.com/Origen-SDK/origen_app_generators/blob/master/lib/origen_app_generators/plugin.rb
|
27
|
+
#
|
28
|
+
# The filelist can contain references to generate files, directories or symlinks in the
|
29
|
+
# new plugin.
|
30
|
+
#
|
31
|
+
# To make your generators more maintainable, try and re-use as much as possible
|
32
|
+
# from the parent generator, this means that your generators will automatically stay up
|
33
|
+
# to date with the latest conventions.
|
34
|
+
#
|
35
|
+
# Additional files can be added or removed from the filelist as shown below.
|
36
|
+
def filelist
|
37
|
+
@filelist ||= begin
|
38
|
+
list = super # Always pick up the parent list
|
39
|
+
# Example of how to remove a file from the parent list
|
40
|
+
# list.delete(:web_doc_layout)
|
41
|
+
# Example of how to add a file, in this case the file will be compiled and copied to
|
42
|
+
# the same location in the new app
|
43
|
+
# list[:config_shared_commands] = { source: 'config/shared_commands.rb' }
|
44
|
+
# Alternatively specifying a different destination, typically you would do this when
|
45
|
+
# the final location is dynamic
|
46
|
+
# list[:gemspec] = { source: 'gemspec.rb', dest: "#{@name}.gemspec" }
|
47
|
+
# Example of how to create a directory
|
48
|
+
# list[:pattern_dir] = { dest: "pattern", type: :directory }
|
49
|
+
# Example of how to create a symlink
|
50
|
+
# list[:target_default] = { source: 'debug.rb', # Relative to the file being linked to
|
51
|
+
# dest: 'target/default.rb', # Relative to destination_root
|
52
|
+
# type: :symlink }
|
53
|
+
# Remember to return the final list
|
54
|
+
list
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
@@ -3,8 +3,8 @@ source 'https://rubygems.org'
|
|
3
3
|
source '<%= Origen.site_config.gem_server %>'
|
4
4
|
<% end -%>
|
5
5
|
|
6
|
-
# Only development dependencies (things your
|
7
|
-
# be listed here in the Gemfile
|
6
|
+
# Only development dependencies (things your plugin needs only when it is running in its own workspace)
|
7
|
+
# should be listed here in the Gemfile
|
8
8
|
<% if @audience == :external -%>
|
9
9
|
# This gem provides integration with https://coveralls.io/ to monitor
|
10
10
|
# your application's test coverage
|
@@ -31,7 +31,12 @@ Gem::Specification.new do |spec|
|
|
31
31
|
spec.add_runtime_dependency "origen", ">= <%= @latest_origen_version %>"
|
32
32
|
<% if @runtime_dependencies -%>
|
33
33
|
<% @runtime_dependencies.each do |dep| -%>
|
34
|
-
|
34
|
+
spec.add_runtime_dependency <%= dep.map{ |d| "\"#{d}\"" }.join(', ') %>
|
35
|
+
<% end -%>
|
36
|
+
<% end -%>
|
37
|
+
<% if @post_runtime_dependency_comments -%>
|
38
|
+
<% @post_runtime_dependency_comments.each do |line| -%>
|
39
|
+
# <%= line %>
|
35
40
|
<% end -%>
|
36
41
|
<% end -%>
|
37
42
|
end
|
@@ -11,4 +11,10 @@ gem 'origen_debuggers'
|
|
11
11
|
|
12
12
|
gem 'origen_doc_helpers'
|
13
13
|
|
14
|
-
gem 'byebug'
|
14
|
+
gem 'byebug'
|
15
|
+
|
16
|
+
gem 'origen_updater'
|
17
|
+
|
18
|
+
# Uncomment these if you want to use a visual debugger (e.g. Visual Studio Code) to debug your app
|
19
|
+
#gem 'ruby-debug-ide'
|
20
|
+
#gem 'debase'
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: origen_app_generators
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 1.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Stephen McGinty
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-
|
11
|
+
date: 2017-08-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: origen
|
@@ -16,14 +16,14 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: 0.
|
19
|
+
version: 0.22.0
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - ">="
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: 0.
|
26
|
+
version: 0.22.0
|
27
27
|
description:
|
28
28
|
email:
|
29
29
|
- stephen.f.mcginty@gmail.com
|
@@ -31,10 +31,12 @@ executables: []
|
|
31
31
|
extensions: []
|
32
32
|
extra_rdoc_files: []
|
33
33
|
files:
|
34
|
+
- bin/boot.rb
|
34
35
|
- bin/fix_my_workspace
|
35
36
|
- config/application.rb
|
36
37
|
- config/boot.rb
|
37
38
|
- config/commands.rb
|
39
|
+
- config/shared_commands.rb
|
38
40
|
- config/version.rb
|
39
41
|
- lib/origen_app_generators.rb
|
40
42
|
- lib/origen_app_generators/application.rb
|
@@ -42,12 +44,12 @@ files:
|
|
42
44
|
- lib/origen_app_generators/empty_application.rb
|
43
45
|
- lib/origen_app_generators/empty_plugin.rb
|
44
46
|
- lib/origen_app_generators/new.rb
|
47
|
+
- lib/origen_app_generators/origen_infrastructure/app_generator_plugin.rb
|
45
48
|
- lib/origen_app_generators/plugin.rb
|
46
49
|
- lib/origen_app_generators/sub_block_parser.rb
|
47
50
|
- lib/origen_app_generators/test_engineering/stand_alone_application.rb
|
48
51
|
- lib/origen_app_generators/test_engineering/test_block.rb
|
49
52
|
- lib/tasks/app_generators.rake
|
50
|
-
- lib/tasks/boot.rb
|
51
53
|
- lib/tasks/new_app_tests.rake
|
52
54
|
- templates/app_generators/application/.gitignore
|
53
55
|
- templates/app_generators/application/.irbrc
|
@@ -76,6 +78,10 @@ files:
|
|
76
78
|
- templates/app_generators/application/templates/web/release_notes.md.erb
|
77
79
|
- templates/app_generators/new/generator.rb
|
78
80
|
- templates/app_generators/new/info.md.erb
|
81
|
+
- templates/app_generators/origen_infrastructure/app_generator_plugin/config/load_generators.rb
|
82
|
+
- templates/app_generators/origen_infrastructure/app_generator_plugin/lib/application.rb
|
83
|
+
- templates/app_generators/origen_infrastructure/app_generator_plugin/lib/module.rb
|
84
|
+
- templates/app_generators/origen_infrastructure/app_generator_plugin/lib/plugin.rb
|
79
85
|
- templates/app_generators/plugin/Gemfile
|
80
86
|
- templates/app_generators/plugin/Rakefile
|
81
87
|
- templates/app_generators/plugin/config/boot.rb
|
@@ -109,7 +115,7 @@ files:
|
|
109
115
|
- templates/app_generators/test_engineering/test_block/target/default.rb
|
110
116
|
homepage: http://origen-sdk.org/origen_app_generators
|
111
117
|
licenses:
|
112
|
-
-
|
118
|
+
- MIT
|
113
119
|
metadata: {}
|
114
120
|
post_install_message:
|
115
121
|
rdoc_options: []
|