origen_app_generators 0.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/config/application.rb +146 -0
- data/config/commands.rb +75 -0
- data/config/environment.rb +1 -0
- data/config/users.rb +19 -0
- data/config/version.rb +8 -0
- data/lib/origen_app_generators/application.rb +62 -0
- data/lib/origen_app_generators/base.rb +201 -0
- data/lib/origen_app_generators/generic_application.rb +15 -0
- data/lib/origen_app_generators/generic_plugin.rb +15 -0
- data/lib/origen_app_generators/new.rb +137 -0
- data/lib/origen_app_generators/plugin.rb +39 -0
- data/lib/origen_app_generators/test_engineering/generic_test_block.rb +68 -0
- data/lib/origen_app_generators.rb +67 -0
- data/lib/tasks/app_generators.rake +50 -0
- data/lib/tasks/boot.rb +42 -0
- data/templates/app_generators/application/Gemfile +12 -0
- data/templates/app_generators/application/Rakefile +10 -0
- data/templates/app_generators/application/config/application.rb +110 -0
- data/templates/app_generators/application/config/commands.rb +76 -0
- data/templates/app_generators/application/config/environment.rb +4 -0
- data/templates/app_generators/application/config/users.rb +29 -0
- data/templates/app_generators/application/config/version.rb +8 -0
- data/templates/app_generators/application/doc/history +0 -0
- data/templates/app_generators/application/lib/app.rake +6 -0
- data/templates/app_generators/application/lib/module.rb +17 -0
- data/templates/app_generators/application/lib/top_level.rb +12 -0
- data/templates/app_generators/application/spec/spec_helper.rb +98 -0
- data/templates/app_generators/application/target/debug.rb +8 -0
- data/templates/app_generators/application/target/production.rb +9 -0
- data/templates/app_generators/application/templates/web/archive.md.erb +11 -0
- data/templates/app_generators/application/templates/web/contact.md.erb +36 -0
- data/templates/app_generators/application/templates/web/docs/environment/definitions.md.erb +17 -0
- data/templates/app_generators/application/templates/web/docs/environment/installation.md.erb +22 -0
- data/templates/app_generators/application/templates/web/docs/environment/introduction.md.erb +5 -0
- data/templates/app_generators/application/templates/web/index.md.erb +12 -0
- data/templates/app_generators/application/templates/web/layouts/_basic.html.erb +14 -0
- data/templates/app_generators/application/templates/web/layouts/_doc.html.erb +35 -0
- data/templates/app_generators/application/templates/web/partials/_navbar.html.erb +23 -0
- data/templates/app_generators/application/templates/web/references.md.erb +39 -0
- data/templates/app_generators/application/templates/web/release_notes.md.erb +5 -0
- data/templates/app_generators/new/generator.rb +78 -0
- data/templates/app_generators/new/info.md.erb +9 -0
- data/templates/app_generators/plugin/Gemfile +12 -0
- data/templates/app_generators/plugin/config/development.rb +12 -0
- data/templates/app_generators/plugin/gemspec.rb +36 -0
- data/templates/app_generators/plugin/templates/web/index.md.erb +60 -0
- data/templates/app_generators/plugin/templates/web/partials/_navbar.html.erb +22 -0
- data/templates/app_generators/test_engineering/generic_test_block/lib/interface.rb +6 -0
- data/templates/app_generators/test_engineering/generic_test_block/program/prb1.rb +9 -0
- data/templates/app_generators/test_engineering/generic_test_block/target/j750.rb +10 -0
- data/templates/app_generators/test_engineering/generic_test_block/target/ultraflex.rb +10 -0
- data/templates/app_generators/test_engineering/generic_test_block/target/v93k.rb +10 -0
- data/templates/web/_history.md +166 -0
- data/templates/web/archive.md.erb +11 -0
- data/templates/web/contact.md.erb +36 -0
- data/templates/web/docs/developers/creating.md.erb +290 -0
- data/templates/web/docs/environment/installation.md.erb +12 -0
- data/templates/web/docs/environment/introduction.md.erb +10 -0
- data/templates/web/example.md.erb +73 -0
- data/templates/web/index.md.erb +48 -0
- data/templates/web/layouts/_basic.html.erb +18 -0
- data/templates/web/layouts/_doc.html.erb +37 -0
- data/templates/web/origen_app_generators/application.md.erb +116 -0
- data/templates/web/origen_app_generators/plugin.md.erb +29 -0
- data/templates/web/origen_app_generators/test_engineering/generic_test_block.md.erb +16 -0
- data/templates/web/partials/_navbar.html.erb +22 -0
- data/templates/web/release_notes.md.erb +5 -0
- metadata +126 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: b62097b0a52eb5b3b37d8861518f5673c23bc609
|
4
|
+
data.tar.gz: 53dba9b5c337583764bb55fd591bdd82091cd4fe
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 4054a7da719c69903d3f00e3623e6f9404698e3d71c81324aa55dc83cf92308c2e6055e22131102219001084ab79a73082af4b43348e7ef85843bce2c6c73e08
|
7
|
+
data.tar.gz: ff3a36f08acdadb8dff73c87b9c6426d36bc1825829cec4bab95632a4bea9b0885242e71f6ce112f9edb7aa4e683f2212c3f0062a2f73d58b25dde281fcd6629
|
@@ -0,0 +1,146 @@
|
|
1
|
+
require 'origen'
|
2
|
+
class OrigenAppGeneratorsApplication < Origen::Application
|
3
|
+
# This information is used in headers and email templates, set it specific
|
4
|
+
# to your application
|
5
|
+
config.name = "Origen App Generators"
|
6
|
+
config.initials = "Origen_App_Generators"
|
7
|
+
config.rc_url = "ssh://git@github.com:Origen-SDK/origen_app_generators.git"
|
8
|
+
config.release_externally = true
|
9
|
+
|
10
|
+
# To enable deployment of your documentation to a web server (via the 'origen web'
|
11
|
+
# command) fill in these attributes. The example here is configured to deploy to
|
12
|
+
# the origen.freescale.net domain, which is an easy option if you don't have another
|
13
|
+
# server already in mind. To do this you will need an account on CDE and to be a member
|
14
|
+
# of the 'origen' group.
|
15
|
+
config.web_directory = "/proj/.web_origen/html/origen_app_generators"
|
16
|
+
config.web_domain = "http://origen-sdk.org/origen_app_generators"
|
17
|
+
|
18
|
+
# When false Origen will be less strict about checking for some common coding errors,
|
19
|
+
# it is recommended that you leave this to true for better feedback and easier debug.
|
20
|
+
# This will be the default setting in Origen v3.
|
21
|
+
config.strict_errors = true
|
22
|
+
|
23
|
+
# See: http://origen.freescale.net/origen/latest/guides/utilities/lint/
|
24
|
+
config.lint_test = {
|
25
|
+
# Require the lint tests to pass before allowing a release to proceed
|
26
|
+
run_on_tag: true,
|
27
|
+
# Auto correct violations where possible whenever 'origen lint' is run
|
28
|
+
auto_correct: true,
|
29
|
+
# Limit the testing for large legacy applications
|
30
|
+
#level: :easy,
|
31
|
+
# Run on these directories/files by default
|
32
|
+
#files: ["lib", "config/application.rb"],
|
33
|
+
}
|
34
|
+
|
35
|
+
# Versioning is based on a timestamp by default, if you would rather use semantic
|
36
|
+
# versioning, i.e. v1.0.0 format, then set this to true.
|
37
|
+
# In parallel go and edit config/version.rb to enable the semantic version code.
|
38
|
+
config.semantically_version = true
|
39
|
+
|
40
|
+
# An example of how to set application specific LSF parameters
|
41
|
+
#config.lsf.project = "msg.te"
|
42
|
+
|
43
|
+
# An example of how to specify a prefix to add to all generated patterns
|
44
|
+
#config.pattern_prefix = "nvm"
|
45
|
+
|
46
|
+
# An example of how to add header comments to all generated patterns
|
47
|
+
#config.pattern_header do
|
48
|
+
# cc "This is a pattern created by the example origen application"
|
49
|
+
#end
|
50
|
+
|
51
|
+
# By default all generated output will end up in ./output.
|
52
|
+
# Here you can specify an alternative directory entirely, or make it dynamic such that
|
53
|
+
# the output ends up in a setup specific directory.
|
54
|
+
#config.output_directory do
|
55
|
+
# "#{Origen.root}/output/#{$dut.class}"
|
56
|
+
#end
|
57
|
+
|
58
|
+
# Similary for the reference files, generally you want to setup the reference directory
|
59
|
+
# structure to mirror that of your output directory structure.
|
60
|
+
#config.reference_directory do
|
61
|
+
# "#{Origen.root}/.ref/#{$dut.class}"
|
62
|
+
#end
|
63
|
+
|
64
|
+
# This will automatically deploy your documentation after every tag
|
65
|
+
#def after_release_email(tag, note, type, selector, options)
|
66
|
+
# deployer = Origen.app.deployer
|
67
|
+
# if deployer.running_on_cde? && deployer.user_belongs_to_origen?
|
68
|
+
# command = "origen web compile --remote --api"
|
69
|
+
# if Origen.app.version.production?
|
70
|
+
# command += " --archive #{Origen.app.version}"
|
71
|
+
# end
|
72
|
+
# Dir.chdir Origen.root do
|
73
|
+
# system command
|
74
|
+
# end
|
75
|
+
# end
|
76
|
+
#end
|
77
|
+
|
78
|
+
# Ensure that all tests pass before allowing a release to continue
|
79
|
+
#def validate_release
|
80
|
+
# if !system("origen specs") || !system("origen examples")
|
81
|
+
# puts "Sorry but you can't release with failing tests, please fix them and try again."
|
82
|
+
# exit 1
|
83
|
+
# else
|
84
|
+
# puts "All tests passing, proceeding with release process!"
|
85
|
+
# end
|
86
|
+
#end
|
87
|
+
|
88
|
+
# To enabled source-less pattern generation create a class (for example PatternDispatcher)
|
89
|
+
# to generate the pattern. This should return false if the requested pattern has been
|
90
|
+
# dispatched, otherwise Origen will proceed with looking up a pattern source as normal.
|
91
|
+
#def before_pattern_lookup(requested_pattern)
|
92
|
+
# PatternDispatcher.new.dispatch_or_return(requested_pattern)
|
93
|
+
#end
|
94
|
+
|
95
|
+
# If you use pattern iterators you may come accross the case where you request a pattern
|
96
|
+
# like this:
|
97
|
+
# origen g example_pat_b0.atp
|
98
|
+
#
|
99
|
+
# However it cannot be found by Origen since the pattern name is actually example_pat_bx.atp
|
100
|
+
# In the case where the pattern cannot be found Origen will pass the name to this translator
|
101
|
+
# if it exists, and here you can make any substitutions to help Origen find the file you
|
102
|
+
# want. In this example any instances of _b\d, where \d means a number, are replaced by
|
103
|
+
# _bx.
|
104
|
+
#config.pattern_name_translator do |name|
|
105
|
+
# name.gsub(/_b\d/, "_bx")
|
106
|
+
#end
|
107
|
+
|
108
|
+
# If you want to use pattern iterators, that is the ability to generate multiple pattern
|
109
|
+
# variants from a single source file, then you can define the required behavior here.
|
110
|
+
# The examples below implement some of the iterators that were available in Origen 1,
|
111
|
+
# you can remove them if you don't want to use them, or of course modify or add new
|
112
|
+
# iterators specific to your application logic.
|
113
|
+
|
114
|
+
# By setting iterator
|
115
|
+
config.pattern_iterator do |iterator|
|
116
|
+
# Define a key that you will use to enable this in a pattern, here the iterator
|
117
|
+
# can be enabled like this: Pattern.create(by_setting: [1,2,3]) do
|
118
|
+
iterator.key = :by_setting
|
119
|
+
|
120
|
+
# The value passed from the pattern via the key comes in here as the first
|
121
|
+
# argument, the name applied here can be anything, but settings seem reasonable since
|
122
|
+
# an array of setting values is expected.
|
123
|
+
# The last argument &pattern is mandatory and represents the pattern block (the bit contained
|
124
|
+
# within Pattern.create do ... end)
|
125
|
+
iterator.loop do |settings, &pattern|
|
126
|
+
# Implement the loop however you like, here we loop for each value in the array
|
127
|
+
settings.each do |setting|
|
128
|
+
# Now call the pattern passing in the setting argument, this would be captured
|
129
|
+
# in the pattern like this:
|
130
|
+
# Pattern.create do |setting|
|
131
|
+
pattern.call(setting)
|
132
|
+
end
|
133
|
+
end
|
134
|
+
|
135
|
+
# Each pattern iteration needs a unique name, otherwise Origen will simply overwrite
|
136
|
+
# the same output file each time.
|
137
|
+
# The base pattern name and the pattern argument, in this case the setting, will be
|
138
|
+
# passed in here and whatever is returned is what will be used as the name.
|
139
|
+
iterator.pattern_name do |name, setting|
|
140
|
+
# Substiture _x in the name with the setting, _1, _2, etc.
|
141
|
+
name.gsub("_x", "_#{setting}")
|
142
|
+
end
|
143
|
+
end
|
144
|
+
|
145
|
+
|
146
|
+
end
|
data/config/commands.rb
ADDED
@@ -0,0 +1,75 @@
|
|
1
|
+
# This file should be used to extend the origen command line tool with tasks
|
2
|
+
# specific to your application.
|
3
|
+
# The comments below should help to get started and you can also refer to
|
4
|
+
# lib/origen/commands.rb in your Origen core workspace for more examples and
|
5
|
+
# inspiration.
|
6
|
+
#
|
7
|
+
# Also see the official docs on adding commands:
|
8
|
+
# http://origen.freescale.net/origen/latest/guides/custom/commands/
|
9
|
+
|
10
|
+
# Map any command aliases here, for example to allow origen -x to refer to a
|
11
|
+
# command called execute you would add a reference as shown below:
|
12
|
+
aliases ={
|
13
|
+
# "-x" => "execute",
|
14
|
+
}
|
15
|
+
|
16
|
+
# The requested command is passed in here as @command, this checks it against
|
17
|
+
# the above alias table and should not be removed.
|
18
|
+
@command = aliases[@command] || @command
|
19
|
+
|
20
|
+
## Now branch to the specific task code
|
21
|
+
#case @command
|
22
|
+
#
|
23
|
+
## Run the unit tests
|
24
|
+
#when "specs"
|
25
|
+
# ARGV.unshift "spec"
|
26
|
+
# require "rspec"
|
27
|
+
# # For some unidentified reason Rspec does not autorun on this version
|
28
|
+
# if RSpec::Core::Version::STRING && RSpec::Core::Version::STRING == "2.11.1"
|
29
|
+
# RSpec::Core::Runner.run ARGV
|
30
|
+
# else
|
31
|
+
# require "rspec/autorun"
|
32
|
+
# end
|
33
|
+
# exit 0 # This will never be hit on a fail, RSpec will automatically exit 1
|
34
|
+
#
|
35
|
+
## Run the example-based (diff) tests
|
36
|
+
#when "examples"
|
37
|
+
# Origen.load_application
|
38
|
+
# status = 0
|
39
|
+
#
|
40
|
+
# # Compiler tests
|
41
|
+
# ARGV = %w(templates/example.txt.erb -t debug -r approved)
|
42
|
+
# load "origen/commands/compile.rb"
|
43
|
+
# # Pattern generator tests
|
44
|
+
# #ARGV = %w(some_pattern -t debug -r approved)
|
45
|
+
# #load "#{Origen.top}/lib/origen/commands/generate.rb"
|
46
|
+
#
|
47
|
+
# if Origen.app.stats.changed_files == 0 &&
|
48
|
+
# Origen.app.stats.new_files == 0 &&
|
49
|
+
# Origen.app.stats.changed_patterns == 0 &&
|
50
|
+
# Origen.app.stats.new_patterns == 0
|
51
|
+
#
|
52
|
+
# Origen.app.stats.report_pass
|
53
|
+
# else
|
54
|
+
# Origen.app.stats.report_fail
|
55
|
+
# status = 1
|
56
|
+
# end
|
57
|
+
# puts
|
58
|
+
# exit status # Exit with a 1 on the event of a failure per std unix result codes
|
59
|
+
#
|
60
|
+
## Always leave an else clause to allow control to fall back through to the
|
61
|
+
## Origen command handler.
|
62
|
+
## You probably want to also add the command details to the help shown via
|
63
|
+
## origen -h, you can do this be assigning the required text to @application_commands
|
64
|
+
## before handing control back to Origen. Un-comment the example below to get started.
|
65
|
+
#else
|
66
|
+
# @application_commands = <<-EOT
|
67
|
+
# specs Run the specs (tests), -c will enable coverage
|
68
|
+
# examples Run the examples (tests), -c will enable coverage
|
69
|
+
# EOT
|
70
|
+
#
|
71
|
+
# # Uncomment the following and update the path with the file
|
72
|
+
# # that handles the commands that are shared from this plugin
|
73
|
+
# #require "#{Origen.app_root}/config/shared_commands"
|
74
|
+
#
|
75
|
+
#end
|
@@ -0,0 +1 @@
|
|
1
|
+
require "origen_app_generators"
|
data/config/users.rb
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
# This file defines the users associated with your project, it is basically the
|
2
|
+
# mailing list for release notes.
|
3
|
+
#
|
4
|
+
# You can split your users into "admin" and "user" groups, the main difference
|
5
|
+
# between the two is that admin users will get all tag emails, users will get
|
6
|
+
# emails on external/official releases only.
|
7
|
+
#
|
8
|
+
# Users are also prohibited from running the "origen tag" task, but this is
|
9
|
+
# really just to prevent a casual user from executing it inadvertently and is
|
10
|
+
# not intended to be a serious security gate.
|
11
|
+
module Origen
|
12
|
+
module Users
|
13
|
+
def users
|
14
|
+
@users ||= [
|
15
|
+
|
16
|
+
]
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
data/config/version.rb
ADDED
@@ -0,0 +1,62 @@
|
|
1
|
+
module OrigenAppGenerators
|
2
|
+
# The base generator class that should be used by all application generators
|
3
|
+
class Application < Base
|
4
|
+
# Any methods that are not protected will get invoked in the order they are
|
5
|
+
# defined when the generator is run
|
6
|
+
|
7
|
+
protected
|
8
|
+
|
9
|
+
def type
|
10
|
+
:application
|
11
|
+
end
|
12
|
+
|
13
|
+
# This is the default list of files that will get generated for a new application
|
14
|
+
# when you call the compile_filelist method.
|
15
|
+
# To customize this for a domain specific application generator you can either
|
16
|
+
# delete an entry:
|
17
|
+
#
|
18
|
+
# filelist.delete(:config_application)
|
19
|
+
# compile_filelist
|
20
|
+
#
|
21
|
+
# Or point it to a different template, the supplied path is relative to templates/app_generators
|
22
|
+
#
|
23
|
+
# filelist[:config_application][:source] = "dng_test_app/config/application.rb"
|
24
|
+
# compile_filelist
|
25
|
+
def filelist
|
26
|
+
fail '@name must be defined before calling filelist for the first time' unless @name
|
27
|
+
@filelist ||= {
|
28
|
+
config_application: { source: 'config/application.rb' },
|
29
|
+
config_version: { source: 'config/version.rb' },
|
30
|
+
config_users: { source: 'config/users.rb' },
|
31
|
+
config_environment: { source: 'config/environment.rb' },
|
32
|
+
config_commands: { source: 'config/commands.rb' },
|
33
|
+
doc_history: { source: 'doc/history' },
|
34
|
+
target_debug: { source: 'target/debug.rb' },
|
35
|
+
target_production: { source: 'target/production.rb' },
|
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
|
+
lib_module: { source: 'lib/module.rb',
|
40
|
+
dest: "lib/#{@name}.rb" },
|
41
|
+
lib_top_level: { source: 'lib/top_level.rb',
|
42
|
+
dest: "lib/#{@name}/top_level.rb" },
|
43
|
+
lib_tasks: { source: 'lib/app.rake',
|
44
|
+
dest: "lib/tasks/#{@name}.rake" },
|
45
|
+
spec_helper: { source: 'spec/spec_helper.rb' },
|
46
|
+
web_index: { source: 'templates/web/index.md.erb' },
|
47
|
+
web_basic_layout: { source: 'templates/web/layouts/_basic.html.erb' },
|
48
|
+
web_doc_layout: { source: 'templates/web/layouts/_doc.html.erb' },
|
49
|
+
web_navbar: { source: 'templates/web/partials/_navbar.html.erb' },
|
50
|
+
web_references: { source: 'templates/web/references.md.erb' },
|
51
|
+
web_archive: { source: 'templates/web/archive.md.erb' },
|
52
|
+
web_contact: { source: 'templates/web/contact.md.erb' },
|
53
|
+
web_release_notes: { source: 'templates/web/release_notes.md.erb' },
|
54
|
+
web_defintions: { source: 'templates/web/docs/environment/definitions.md.erb' },
|
55
|
+
web_installation: { source: 'templates/web/docs/environment/installation.md.erb' },
|
56
|
+
web_introduction: { source: 'templates/web/docs/environment/introduction.md.erb' },
|
57
|
+
rakefile: { source: 'Rakefile' },
|
58
|
+
gemfile: { source: 'Gemfile' }
|
59
|
+
}
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
@@ -0,0 +1,201 @@
|
|
1
|
+
module OrigenAppGenerators
|
2
|
+
# This is the base generator used by all generators in this application
|
3
|
+
class Base < Origen::CodeGenerators::Base
|
4
|
+
include Origen::Utility::InputCapture
|
5
|
+
|
6
|
+
require 'gems'
|
7
|
+
|
8
|
+
def set_source_paths
|
9
|
+
# The base Origen generator puts the Origen core directory on the source path, in retrospect this
|
10
|
+
# was a bad idea and makes for hard to debug errors if an app generator resolves a template from
|
11
|
+
# outside of this app.
|
12
|
+
# So to keep things sane remove any inherited source paths.
|
13
|
+
self.class.source_paths.pop until self.class.source_paths.empty?
|
14
|
+
klass = self.class
|
15
|
+
until klass == OrigenAppGenerators::Base
|
16
|
+
dir = klass.to_s.sub('OrigenAppGenerators::', '').split('::').map(&:underscore).join('/')
|
17
|
+
dir = File.expand_path("../../../templates/app_generators/#{dir}", __FILE__)
|
18
|
+
self.class.source_paths << dir if File.exist?(dir)
|
19
|
+
klass = klass.superclass
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
# Just makes the type (:plugin or :application) available to all templates
|
24
|
+
def set_type
|
25
|
+
@type = type
|
26
|
+
end
|
27
|
+
|
28
|
+
def get_common_user_input
|
29
|
+
get_name_and_namespace
|
30
|
+
get_revision_control
|
31
|
+
end
|
32
|
+
|
33
|
+
def get_lastest_origen_version
|
34
|
+
(Gems.info 'origen')['version']
|
35
|
+
end
|
36
|
+
|
37
|
+
protected
|
38
|
+
|
39
|
+
def self.title
|
40
|
+
desc.sub(/^An? /, '').titleize
|
41
|
+
end
|
42
|
+
|
43
|
+
def get_revision_control
|
44
|
+
puts ''
|
45
|
+
puts 'IS THIS FOR TRAINING?'
|
46
|
+
puts ''
|
47
|
+
training = get_text(confirm: :return_boolean, default: 'no')
|
48
|
+
if type == :plugin && !training
|
49
|
+
puts ''
|
50
|
+
puts 'WHAT CATEGORY BEST DESCRIBES YOUR PLUGIN??'
|
51
|
+
puts ''
|
52
|
+
cats = {
|
53
|
+
dut: 'Top-level SoC/DUT models',
|
54
|
+
helper: 'Helper methods and code snippets',
|
55
|
+
physical: 'Physical interface drivers (e.g. JTAG)',
|
56
|
+
protocol: 'Protocol driver providing read/write register APIs (e.g. JTAG2IPS)',
|
57
|
+
module: 'A module to support testing a specific silicon block',
|
58
|
+
tester: 'Any Origen tester model, could be an ATE or a debugger or testbench stimulus generator ',
|
59
|
+
misc: 'Anything else'
|
60
|
+
}
|
61
|
+
cats.each do |key, val|
|
62
|
+
puts "#{key} - #{val}"
|
63
|
+
end
|
64
|
+
puts ''
|
65
|
+
category = get_text(single: true, accept: cats.keys).downcase.to_sym
|
66
|
+
end
|
67
|
+
@vault = 'sync://sync-15088:15088/Projects/common_tester_blocks/'
|
68
|
+
if training
|
69
|
+
@vault += 'origen_training/'
|
70
|
+
elsif type == :plugin
|
71
|
+
@vault += "origen_blocks/#{category}/"
|
72
|
+
else
|
73
|
+
@vault += 'blocks/'
|
74
|
+
end
|
75
|
+
@vault += "#{@name}/tool_data/origen"
|
76
|
+
end
|
77
|
+
|
78
|
+
# Calling this will compile all files in filelist against the current instance
|
79
|
+
# variable values
|
80
|
+
def build_filelist
|
81
|
+
symlink_cmds = []
|
82
|
+
self.destination_root = args.first
|
83
|
+
filelist.each do |_name, file|
|
84
|
+
if file[:type] == :symlink
|
85
|
+
if Origen.running_on_windows?
|
86
|
+
dest = Pathname.new("#{destination_root}/#{file[:dest]}")
|
87
|
+
source = dest.dirname.to_s + "/#{file[:source]}"
|
88
|
+
symlink_cmds << "call mklink /h #{dest.to_s.gsub('/', '\\')} #{source.to_s.gsub('/', '\\')}"
|
89
|
+
else
|
90
|
+
create_link file[:dest], file[:source]
|
91
|
+
end
|
92
|
+
elsif file[:type] == :dir || file[:type] == :directory
|
93
|
+
empty_directory(file[:dest] || file[:source])
|
94
|
+
else
|
95
|
+
dest = file[:dest] || file[:source]
|
96
|
+
if file[:copy] || dest =~ /.erb$/
|
97
|
+
copy_file(file[:source], dest)
|
98
|
+
else
|
99
|
+
template(file[:source], dest)
|
100
|
+
end
|
101
|
+
end
|
102
|
+
end
|
103
|
+
symlink_cmds.each { |cmd| system(cmd) }
|
104
|
+
end
|
105
|
+
|
106
|
+
# Convenience method that is equivalent to calling get_name and then get_namespace
|
107
|
+
def get_name_and_namespace
|
108
|
+
get_name
|
109
|
+
get_namespace
|
110
|
+
end
|
111
|
+
|
112
|
+
# Prompts the user to confirm or enter the Ruby namespace to be used in the app.
|
113
|
+
#
|
114
|
+
# If @name is already defined a proposal will be generated from that, alternatively a proposal
|
115
|
+
# can be supplied. If not proposal is resolved the user will be prompted to input from scratch.
|
116
|
+
def get_namespace(proposal = nil)
|
117
|
+
puts
|
118
|
+
puts "SELECT YOUR #{type.to_s.upcase}'S NAMESPACE"
|
119
|
+
puts
|
120
|
+
puts "All #{type} code needs to reside in a unique namespace, this prevents naming collisions with 3rd party plugins."
|
121
|
+
puts 'By Ruby conventions this must start with a capital letter and should ideally be CamelCased and not use underscores'
|
122
|
+
puts 'Some examples:: C40TFSNVMTester, CAPIOrigen, LS2080, ApacheOrigen'
|
123
|
+
puts
|
124
|
+
if !proposal && @name
|
125
|
+
proposal = @name.to_s.camelize
|
126
|
+
end
|
127
|
+
proposal = nil if proposal.length < 3
|
128
|
+
proposal.gsub(/Rgen/i, 'Origen') if proposal
|
129
|
+
|
130
|
+
valid = false
|
131
|
+
until valid
|
132
|
+
@namespace = get_text(single: true, default: proposal)
|
133
|
+
proposal = nil
|
134
|
+
unless @namespace.empty?
|
135
|
+
if @namespace.length >= 3
|
136
|
+
valid = valid_constant?(@namespace)
|
137
|
+
end
|
138
|
+
unless valid
|
139
|
+
puts 'That namespace is not valid :-('
|
140
|
+
puts
|
141
|
+
end
|
142
|
+
end
|
143
|
+
end
|
144
|
+
@namespace
|
145
|
+
end
|
146
|
+
|
147
|
+
# Returns true if the given string can be converted to a valid Ruby constant and one that
|
148
|
+
# does not already exist within the scope of this application and Origen Core
|
149
|
+
def valid_constant?(string)
|
150
|
+
valid = false
|
151
|
+
# Try and convert this to a constant to test for validity, this will also screen things
|
152
|
+
# like Origen since that will not trigger an error
|
153
|
+
begin
|
154
|
+
string.constantize
|
155
|
+
rescue NameError => e
|
156
|
+
if e.message =~ /^uninitialized constant/
|
157
|
+
valid = true
|
158
|
+
end
|
159
|
+
else
|
160
|
+
# Something else is wrong with it
|
161
|
+
end
|
162
|
+
valid
|
163
|
+
end
|
164
|
+
|
165
|
+
# Prompts the user to input a name for the new application, this will be screened to ensure
|
166
|
+
# that it can cleanly cast to a symbol for use in Origen.
|
167
|
+
#
|
168
|
+
# This should be unique within the whole Origen ecosystem, in future this method will be enhanced
|
169
|
+
# to check with the Origen server which will in future maintain a database of known app names.
|
170
|
+
#
|
171
|
+
# The final name is returned at the end and assigned to variable @name for use in templates.
|
172
|
+
def get_name
|
173
|
+
proposal = args.first.symbolize.to_s
|
174
|
+
proposal = nil if proposal.length < 3
|
175
|
+
puts
|
176
|
+
puts "WHAT DO YOU WANT TO CALL YOUR NEW #{type.to_s.upcase}?"
|
177
|
+
puts
|
178
|
+
puts "This should be lowercased and underscored and will be used to uniquely identify your #{type} within the Origen ecosystem."
|
179
|
+
puts 'Some examples: c40tfs_nvm_tester, capi_origen, ls2080, apache_origen'
|
180
|
+
puts
|
181
|
+
valid = false
|
182
|
+
until valid
|
183
|
+
name = get_text(single: true, default: proposal)
|
184
|
+
proposal = nil
|
185
|
+
unless name.empty?
|
186
|
+
if name == name.symbolize.to_s
|
187
|
+
if name.symbolize.to_s.length >= 3
|
188
|
+
valid = true
|
189
|
+
@name = name
|
190
|
+
end
|
191
|
+
else
|
192
|
+
puts
|
193
|
+
puts 'That name is not valid, how about this?'
|
194
|
+
proposal = name.symbolize.to_s
|
195
|
+
end
|
196
|
+
end
|
197
|
+
end
|
198
|
+
@name
|
199
|
+
end
|
200
|
+
end
|
201
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
module OrigenAppGenerators
|
2
|
+
# Generates a generic application shell
|
3
|
+
class GenericApplication < Application
|
4
|
+
# Any methods that are not protected will get invoked in the order they are
|
5
|
+
# defined when the generator is run
|
6
|
+
|
7
|
+
def generate_files
|
8
|
+
build_filelist
|
9
|
+
end
|
10
|
+
|
11
|
+
def conclude
|
12
|
+
puts "New app created at: #{destination_root}"
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
module OrigenAppGenerators
|
2
|
+
# Generates a generic plugin shell
|
3
|
+
class GenericPlugin < Plugin
|
4
|
+
# Any methods that are not protected will get invoked in the order they are
|
5
|
+
# defined when the generator is run
|
6
|
+
|
7
|
+
def generate_files
|
8
|
+
build_filelist
|
9
|
+
end
|
10
|
+
|
11
|
+
def conclude
|
12
|
+
puts "New app created at: #{destination_root}"
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|