origen 0.44.0 → 0.50.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/config/application.rb +2 -2
- data/config/boot.rb +0 -7
- data/config/commands.rb +3 -74
- data/config/rubocop/easy_disabled.yml +4 -0
- data/config/rubocop/easy_enabled.yml +0 -4
- data/config/rubocop/strict_disabled.yml +4 -0
- data/config/rubocop/strict_enabled.yml +0 -4
- data/config/version.rb +1 -2
- data/lib/origen/application/deployer.rb +3 -1
- data/lib/origen/application/release.rb +2 -2
- data/lib/origen/application/runner.rb +9 -2
- data/lib/origen/application.rb +91 -2
- data/lib/origen/boot/app.rb +0 -4
- data/lib/origen/boot.rb +2 -1
- data/lib/origen/code_generators/actions.rb +244 -34
- data/lib/origen/code_generators/base.rb +9 -2
- data/lib/origen/code_generators/block.rb +203 -0
- data/lib/origen/code_generators/block_common.rb +100 -0
- data/lib/origen/code_generators/dut.rb +62 -0
- data/lib/origen/code_generators/feature.rb +50 -0
- data/lib/origen/code_generators/klass.rb +41 -0
- data/lib/origen/code_generators/model.rb +60 -0
- data/lib/origen/code_generators/module.rb +92 -0
- data/lib/origen/code_generators.rb +30 -10
- data/lib/origen/commands/lint.rb +6 -1
- data/lib/origen/commands/new.rb +1 -1
- data/lib/origen/commands/new_resource.rb +41 -0
- data/lib/origen/commands/web.rb +11 -6
- data/lib/origen/commands.rb +18 -0
- data/lib/{option_parser → origen/core_ext/option_parser}/optparse.rb +0 -0
- data/lib/origen/dependencies.rb +0 -0
- data/lib/origen/file_handler.rb +8 -4
- data/lib/origen/generator/pattern_finder.rb +3 -3
- data/lib/origen/loader.rb +377 -0
- data/lib/origen/model.rb +22 -1
- data/lib/origen/model_initializer.rb +5 -1
- data/lib/origen/parameters/set.rb +2 -1
- data/lib/origen/parameters.rb +95 -3
- data/lib/origen/sub_blocks.rb +21 -7
- data/lib/origen/top_level.rb +11 -0
- data/lib/origen.rb +3 -1
- data/origen_app_generators/Gemfile +6 -2
- data/origen_app_generators/Gemfile.lock +83 -72
- data/origen_app_generators/bin/boot.rb +4 -2
- data/origen_app_generators/config/commands.rb +3 -3
- data/origen_app_generators/config/shared_commands.rb +11 -6
- data/origen_app_generators/lbin/bundle +105 -0
- data/origen_app_generators/lbin/byebug +29 -0
- data/origen_app_generators/lbin/coderay +29 -0
- data/origen_app_generators/lbin/htmldiff +29 -0
- data/origen_app_generators/lbin/httparty +29 -0
- data/origen_app_generators/lbin/httpclient +29 -0
- data/origen_app_generators/lbin/kramdown +29 -0
- data/origen_app_generators/lbin/ldiff +29 -0
- data/origen_app_generators/lbin/nanoc +29 -0
- data/origen_app_generators/lbin/nokogiri +29 -0
- data/origen_app_generators/lbin/origen +62 -0
- data/origen_app_generators/lbin/pry +29 -0
- data/origen_app_generators/lbin/rackup +29 -0
- data/origen_app_generators/lbin/rake +29 -0
- data/origen_app_generators/lbin/rspec +29 -0
- data/origen_app_generators/lbin/rubocop +29 -0
- data/origen_app_generators/lbin/ruby-parse +29 -0
- data/origen_app_generators/lbin/ruby-rewrite +29 -0
- data/origen_app_generators/lbin/thor +29 -0
- data/origen_app_generators/lbin/tilt +29 -0
- data/origen_app_generators/lbin/yard +29 -0
- data/origen_app_generators/lbin/yardoc +29 -0
- data/origen_app_generators/lbin/yri +29 -0
- data/origen_app_generators/lib/origen_app_generators/application.rb +12 -12
- data/origen_app_generators/lib/origen_app_generators/base.rb +34 -8
- data/origen_app_generators/lib/origen_app_generators/new.rb +17 -9
- data/origen_app_generators/lib/{tasks/new_app_tests.rake → origen_app_generators/new_app_tests.rb} +1 -5
- data/origen_app_generators/lib/origen_app_generators/origen_infrastructure/app_generator_plugin.rb +6 -8
- data/origen_app_generators/lib/origen_app_generators/plugin.rb +4 -7
- data/origen_app_generators/lib/origen_app_generators/test_engineering/common.rb +29 -0
- data/origen_app_generators/lib/origen_app_generators/test_engineering/stand_alone_application.rb +9 -181
- data/origen_app_generators/lib/origen_app_generators/test_engineering/test_block.rb +4 -105
- data/origen_app_generators/lib/origen_app_generators.rb +6 -4
- data/origen_app_generators/origen_app_generators.gemspec +7 -7
- data/origen_app_generators/templates/app_generators/application/Gemfile +14 -3
- data/origen_app_generators/templates/app_generators/application/{lib → app/blocks}/top_level.rb +1 -1
- data/origen_app_generators/templates/app_generators/application/app/lib/module.rb +6 -0
- data/origen_app_generators/templates/app_generators/application/{templates → app/templates}/web/index.md.erb +0 -0
- data/origen_app_generators/templates/app_generators/application/{templates → app/templates}/web/layouts/_basic.html.erb +0 -0
- data/origen_app_generators/templates/app_generators/application/{templates → app/templates}/web/partials/_navbar.html.erb +0 -0
- data/origen_app_generators/templates/app_generators/application/{templates → app/templates}/web/release_notes.md.erb +0 -0
- data/origen_app_generators/templates/app_generators/application/config/application.rb +51 -55
- data/origen_app_generators/templates/app_generators/application/{spec → test/spec}/spec_helper.rb +0 -0
- data/origen_app_generators/templates/app_generators/origen_infrastructure/app_generator_plugin/{lib → app/lib}/application.rb +0 -0
- data/origen_app_generators/templates/app_generators/origen_infrastructure/app_generator_plugin/{lib → app/lib}/base.rb +0 -0
- data/origen_app_generators/templates/app_generators/origen_infrastructure/app_generator_plugin/{lib → app/lib}/module.rb +0 -0
- data/origen_app_generators/templates/app_generators/origen_infrastructure/app_generator_plugin/{lib → app/lib}/plugin.rb +0 -0
- data/origen_app_generators/templates/app_generators/origen_infrastructure/app_generator_plugin/config/load_generators.rb +1 -1
- data/origen_app_generators/templates/app_generators/plugin/Gemfile +5 -2
- data/origen_app_generators/templates/app_generators/plugin/{templates → app/templates}/web/index.md.erb +0 -0
- data/origen_app_generators/templates/app_generators/plugin/{templates → app/templates}/web/partials/_navbar_external.html.erb +0 -0
- data/origen_app_generators/templates/app_generators/plugin/{templates → app/templates}/web/partials/_navbar_internal.html.erb +0 -0
- data/origen_app_generators/templates/app_generators/plugin/gemspec.rb +4 -3
- data/origen_app_generators/templates/app_generators/test_engineering/{stand_alone_application/environment → environment}/j750.rb +0 -0
- data/origen_app_generators/templates/app_generators/test_engineering/{stand_alone_application/environment → environment}/uflex.rb +0 -0
- data/origen_app_generators/templates/app_generators/test_engineering/{stand_alone_application/environment → environment}/v93k.rb +0 -0
- data/origen_site_config.yml +0 -7
- data/templates/code_generators/attributes.rb +20 -0
- data/templates/code_generators/class.rb +9 -0
- data/templates/code_generators/controller.rb +87 -0
- data/templates/code_generators/model.rb +21 -0
- data/templates/code_generators/module.rb +4 -0
- data/templates/code_generators/parameters.rb +19 -0
- data/templates/code_generators/pins.rb +28 -0
- data/templates/code_generators/registers.rb +20 -0
- data/templates/code_generators/sub_blocks.rb +24 -0
- data/templates/code_generators/timesets.rb +24 -0
- data/templates/code_generators/version.rb +0 -1
- metadata +66 -77
- data/lib/c99/ate_interface.rb +0 -77
- data/lib/c99/nvm.rb +0 -110
- data/lib/c99/target/mock2.rb +0 -1
- data/lib/c99/target/subdir/mock3.rb +0 -1
- data/lib/origen/code_generators/bundler.rb +0 -17
- data/lib/origen/code_generators/gem_setup.rb +0 -49
- data/lib/origen/code_generators/rake.rb +0 -13
- data/lib/origen/code_generators/rspec.rb +0 -12
- data/lib/origen/commands/add.rb +0 -12
- data/lib/tasks/private/build.rake +0 -8
- data/origen_app_generators/bin/fix_my_workspace +0 -100
- data/origen_app_generators/lib/origen_app_generators/sub_block_parser.rb +0 -81
- data/origen_app_generators/lib/tasks/app_generators.rake +0 -6
- data/origen_app_generators/spec/sub_block_spec.rb +0 -36
- data/origen_app_generators/templates/app_generators/application/lib/app.rake +0 -6
- data/origen_app_generators/templates/app_generators/application/lib/module.rb +0 -22
- data/origen_app_generators/templates/app_generators/plugin/lib/README +0 -4
- data/origen_app_generators/templates/app_generators/plugin/lib_dev/README +0 -5
- data/origen_app_generators/templates/app_generators/test_engineering/stand_alone_application/Gemfile +0 -23
- data/origen_app_generators/templates/app_generators/test_engineering/stand_alone_application/environment/jlink.rb +0 -1
- data/origen_app_generators/templates/app_generators/test_engineering/stand_alone_application/lib/ip_block.rb +0 -23
- data/origen_app_generators/templates/app_generators/test_engineering/stand_alone_application/lib/ip_block_controller.rb +0 -5
- data/origen_app_generators/templates/app_generators/test_engineering/stand_alone_application/lib/top_level.rb +0 -33
- data/origen_app_generators/templates/app_generators/test_engineering/stand_alone_application/lib/top_level_controller.rb +0 -21
- data/origen_app_generators/templates/app_generators/test_engineering/stand_alone_application/pattern/example.rb +0 -4
- data/origen_app_generators/templates/app_generators/test_engineering/stand_alone_application/target/top_level.rb +0 -4
- data/origen_app_generators/templates/app_generators/test_engineering/test_block/environment/j750.rb +0 -2
- data/origen_app_generators/templates/app_generators/test_engineering/test_block/environment/ultraflex.rb +0 -2
- data/origen_app_generators/templates/app_generators/test_engineering/test_block/environment/v93k.rb +0 -2
- data/origen_app_generators/templates/app_generators/test_engineering/test_block/lib/controller.rb +0 -12
- data/origen_app_generators/templates/app_generators/test_engineering/test_block/lib/interface.rb +0 -21
- data/origen_app_generators/templates/app_generators/test_engineering/test_block/lib/model.rb +0 -18
- data/origen_app_generators/templates/app_generators/test_engineering/test_block/lib_dev/dut.rb +0 -27
- data/origen_app_generators/templates/app_generators/test_engineering/test_block/lib_dev/dut_controller.rb +0 -26
- data/origen_app_generators/templates/app_generators/test_engineering/test_block/pattern/example.rb +0 -5
- data/origen_app_generators/templates/app_generators/test_engineering/test_block/program/prb1.rb +0 -11
- data/origen_app_generators/templates/app_generators/test_engineering/test_block/target/default.rb +0 -2
- data/templates/code_generators/gemfile_app.rb +0 -4
- data/templates/code_generators/gemfile_plugin.rb +0 -6
- data/templates/code_generators/gemspec.rb +0 -33
- data/templates/code_generators/rakefile.rb +0 -10
- data/templates/code_generators/spec_helper.rb +0 -49
@@ -0,0 +1,62 @@
|
|
1
|
+
module Origen
|
2
|
+
module CodeGenerators
|
3
|
+
class Dut < Origen::CodeGenerators::Base
|
4
|
+
include BlockCommon
|
5
|
+
|
6
|
+
def self.banner
|
7
|
+
'origen new dut NAME'
|
8
|
+
end
|
9
|
+
|
10
|
+
desc <<-END
|
11
|
+
This generator creates a top-level (DUT) block and all of the associated resources for it, e.g. a model,
|
12
|
+
controller, target, timesets, pins, etc.
|
13
|
+
|
14
|
+
The NAME of the DUT should be given in lower case, optionally prefixed by parent DUT name(s) separated
|
15
|
+
by a forward slash.
|
16
|
+
|
17
|
+
Any parent DUT(s) will be created if they don't exist, but they will not be modified if they do.
|
18
|
+
|
19
|
+
Examples:
|
20
|
+
origen new dut falcon # Creates app/blocks/dut/derivatives/falcon/...
|
21
|
+
origen new dut dsp/falcon # Creates app/blocks/dut/derivatives/dsp/derivatives/falcon/...
|
22
|
+
END
|
23
|
+
|
24
|
+
def validate_args
|
25
|
+
if args.size > 1 || args.size == 0
|
26
|
+
msg = args.size > 1 ? 'Only one' : 'One'
|
27
|
+
msg << " argument is expected by the DUT generator, e.g. 'origen new dut my_soc', 'origen new dut my_family/my_soc"
|
28
|
+
puts msg
|
29
|
+
exit 1
|
30
|
+
end
|
31
|
+
validate_args_common
|
32
|
+
end
|
33
|
+
|
34
|
+
def setup
|
35
|
+
@generate_model = true
|
36
|
+
@generate_pins = true
|
37
|
+
@generate_timesets = true
|
38
|
+
@generate_parameters = true
|
39
|
+
@top_level = true
|
40
|
+
extract_model_name
|
41
|
+
create_files
|
42
|
+
end
|
43
|
+
|
44
|
+
def create_target
|
45
|
+
contents = ''
|
46
|
+
contents << @final_namespaces.map { |n| camelcase(n) }.join('::')
|
47
|
+
contents << "::#{camelcase(@name)}.new\n"
|
48
|
+
|
49
|
+
create_file "#{Origen.root}/target/#{@name}.rb", contents
|
50
|
+
end
|
51
|
+
|
52
|
+
def completed
|
53
|
+
add_acronyms
|
54
|
+
puts
|
55
|
+
puts 'New DUT created, run the following command to target it in your workspace:'.green
|
56
|
+
puts
|
57
|
+
puts " origen t #{@name}"
|
58
|
+
puts
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
@@ -0,0 +1,50 @@
|
|
1
|
+
module Origen
|
2
|
+
module CodeGenerators
|
3
|
+
class Feature < Origen::CodeGenerators::Base
|
4
|
+
include BlockCommon
|
5
|
+
|
6
|
+
def self.banner
|
7
|
+
'origen new feature NAME'
|
8
|
+
end
|
9
|
+
|
10
|
+
desc <<-END
|
11
|
+
This generator creates a new feature block, which is similar to a regular block but with no model and controller.
|
12
|
+
Such features can then be loaded (re-used) by multiple blocks within your application code.
|
13
|
+
|
14
|
+
The name of the feature should be given in lower case, optionally prefixed by parent feature name(s) separated
|
15
|
+
by a forward slash.
|
16
|
+
|
17
|
+
Any parent features will be created if they don't exist, but they will not be modified if they do.
|
18
|
+
|
19
|
+
Examples:
|
20
|
+
origen new feature my_feature # Creates app/blocks/my_feature/...
|
21
|
+
origen new feature features/my_feature # Creates app/blocks/features/my_feature/...
|
22
|
+
|
23
|
+
The above can then be loaded to models in your application code via:
|
24
|
+
|
25
|
+
my_model.load_block('my_feature')
|
26
|
+
my_model.load_block('features/my_feature')
|
27
|
+
END
|
28
|
+
|
29
|
+
def validate_args
|
30
|
+
if args.size > 1 || args.size == 0
|
31
|
+
msg = args.size > 1 ? 'Only one' : 'One'
|
32
|
+
msg << " argument is expected by the feature generator, e.g. 'origen new feature my_feature', 'origen new feature features/my_feature"
|
33
|
+
puts msg
|
34
|
+
exit 1
|
35
|
+
end
|
36
|
+
validate_args_common
|
37
|
+
end
|
38
|
+
|
39
|
+
def setup
|
40
|
+
@generate_model = false
|
41
|
+
@generate_pins = true
|
42
|
+
@generate_timesets = true
|
43
|
+
@generate_parameters = true
|
44
|
+
extract_model_name
|
45
|
+
create_files
|
46
|
+
add_acronyms
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
@@ -0,0 +1,41 @@
|
|
1
|
+
module Origen
|
2
|
+
module CodeGenerators
|
3
|
+
class Klass < Origen::CodeGenerators::Base
|
4
|
+
def self.banner
|
5
|
+
'origen new class NAME'
|
6
|
+
end
|
7
|
+
|
8
|
+
desc <<-END
|
9
|
+
This generator creates a plain old Ruby class within your application's lib directory.
|
10
|
+
|
11
|
+
The NAME of the class should be given, in lower case, optionally indicating the presence
|
12
|
+
of any namespacing you want it to be created under.
|
13
|
+
|
14
|
+
Examples:
|
15
|
+
origen new class counter # Creates app/lib/my_application/counter.rb
|
16
|
+
origen new class helpers/counter # Creates app/lib/my_application/helpers/counter.rb
|
17
|
+
END
|
18
|
+
|
19
|
+
def validate_args
|
20
|
+
if args.size > 1 || args.size == 0
|
21
|
+
msg = args.size > 1 ? 'Only one' : 'One'
|
22
|
+
msg << " argument is expected by the class generator, e.g. 'origen new class counter', 'origen new class helpers/counter'"
|
23
|
+
puts msg
|
24
|
+
exit 1
|
25
|
+
end
|
26
|
+
validate_resource_name(args.first)
|
27
|
+
end
|
28
|
+
|
29
|
+
def create_class_file
|
30
|
+
@resource_path = args.first
|
31
|
+
klass = resource_path_to_class(args.first)
|
32
|
+
@namespaces = klass.split('::').map(&:underscore)
|
33
|
+
@name = @namespaces.pop
|
34
|
+
@namespaces = add_type_to_namespaces(@namespaces)
|
35
|
+
@root_class = true
|
36
|
+
file = class_name_to_lib_file(klass)
|
37
|
+
template 'templates/code_generators/class.rb', file
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
@@ -0,0 +1,60 @@
|
|
1
|
+
module Origen
|
2
|
+
module CodeGenerators
|
3
|
+
class Model < Origen::CodeGenerators::Base
|
4
|
+
def self.banner
|
5
|
+
'origen new model NAME'
|
6
|
+
end
|
7
|
+
|
8
|
+
desc <<-END
|
9
|
+
This generator creates a model and optionally a controller for it within your application's
|
10
|
+
app/lib directory.
|
11
|
+
|
12
|
+
The NAME of the model should be given, in lower case, optionally indicating the presence
|
13
|
+
of any namespacing you want it to be created under.
|
14
|
+
|
15
|
+
If the model is intended to represent a top-level DUT or a primary sub-block/IP (e.g. RAM,
|
16
|
+
ATD, PLL, Flash, etc) then use `origen new dut` or `origen new block` instead.
|
17
|
+
|
18
|
+
If the model is intended to represent a sub-component of an existing block then the
|
19
|
+
block generator should be used to create a nested sub-block - see the comments within
|
20
|
+
sub_blocks.rb of one of the existing block models for an example.
|
21
|
+
|
22
|
+
Otherwise, models in the app/lib directory as produced by this generator are good for when
|
23
|
+
the model is representing some abstract concept which may not map directly to hardware, or
|
24
|
+
hen you need to model a minor sub-component which needs to be shared by multuple higher level
|
25
|
+
blocks.
|
26
|
+
|
27
|
+
Examples:
|
28
|
+
origen new model sequencer # Creates app/lib/my_application/sequencer.rb
|
29
|
+
origen new model bist/sequencer # Creates app/lib/my_application/bist/sequencer.rb
|
30
|
+
END
|
31
|
+
|
32
|
+
def validate_args
|
33
|
+
if args.size > 1 || args.size == 0
|
34
|
+
msg = args.size > 1 ? 'Only one' : 'One'
|
35
|
+
msg << " argument is expected by the model generator, e.g. 'origen new model sequencer', 'origen new model bist/sequencer'"
|
36
|
+
puts msg
|
37
|
+
exit 1
|
38
|
+
end
|
39
|
+
|
40
|
+
validate_resource_name(args.first)
|
41
|
+
end
|
42
|
+
|
43
|
+
def create_model_file
|
44
|
+
@resource_path = args.first
|
45
|
+
klass = resource_path_to_class(args.first)
|
46
|
+
@namespaces = klass.split('::').map(&:underscore)
|
47
|
+
@name = @namespaces.pop
|
48
|
+
@namespaces = add_type_to_namespaces(@namespaces)
|
49
|
+
@root_class = true
|
50
|
+
file = class_name_to_lib_file(klass)
|
51
|
+
template 'templates/code_generators/model.rb', file
|
52
|
+
if yes? 'Does this model need a controller? (n):'
|
53
|
+
file = file.to_s.sub(/\.rb/, '_controller.rb')
|
54
|
+
template 'templates/code_generators/controller.rb', file
|
55
|
+
end
|
56
|
+
add_acronyms
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
@@ -0,0 +1,92 @@
|
|
1
|
+
module Origen
|
2
|
+
module CodeGenerators
|
3
|
+
class Mod < Origen::CodeGenerators::Base
|
4
|
+
def self.banner
|
5
|
+
'origen new module NAME [CLASS]'
|
6
|
+
end
|
7
|
+
|
8
|
+
desc <<-END
|
9
|
+
This generator creates a plain old Ruby module within your application's lib directory,
|
10
|
+
or if a CLASS argument is given, it will create it a child of that class in either the
|
11
|
+
lib or blocks directory as appropriate.
|
12
|
+
|
13
|
+
Where a CLASS argument is given, the new module will be automatically included in the
|
14
|
+
class.
|
15
|
+
|
16
|
+
The NAME of the module should be given, in lower case, optionally indicating the presence
|
17
|
+
of any namespacing you want it to be created under.
|
18
|
+
|
19
|
+
The CLASS argument should be a path to the Ruby file that defines the class.
|
20
|
+
|
21
|
+
Examples:
|
22
|
+
origen new module helpers # Creates app/lib/my_application/helpers.rb
|
23
|
+
origen new module helpers/math # Creates app/lib/my_application/helpers/math.rb
|
24
|
+
|
25
|
+
# Creates app/lib/blocks/dut/derivatives/falcon/model/helpers.rb
|
26
|
+
origen new module blocks/dut/derivatives/falcon/model.rb helpers
|
27
|
+
END
|
28
|
+
|
29
|
+
def validate_args
|
30
|
+
if args.size > 2 || args.size == 0
|
31
|
+
msg = args.size == 0 ? 'At least one argument is' : 'No more than two arguments are'
|
32
|
+
msg << " expected by the module generator, e.g. 'origen new module helpers', 'origen new module helpers app/lib/my_app/my_class.rb'"
|
33
|
+
puts msg
|
34
|
+
exit 1
|
35
|
+
end
|
36
|
+
|
37
|
+
if args.size == 2
|
38
|
+
@class_file = args.first
|
39
|
+
unless File.exist?(@class_file)
|
40
|
+
puts "This class file does not exist: #{@class_file}"
|
41
|
+
exit 1
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
@resource_path = validate_resource_path(args.last)
|
46
|
+
end
|
47
|
+
|
48
|
+
def create_module_file
|
49
|
+
if @class_file
|
50
|
+
@namespaces = resource_path_to_class(@class_file).split('::').map(&:underscore)
|
51
|
+
paths = resource_path_to_class(@resource_path).split('::').map(&:underscore)
|
52
|
+
@name = paths.pop
|
53
|
+
paths.shift # Lose the app namespace
|
54
|
+
@namespaces += paths
|
55
|
+
file = File.join(@class_file.sub('.rb', ''), "#{@name}.rb")
|
56
|
+
@module_name = (@namespaces + [@name]).map { |n| camelcase(n) }.join('::')
|
57
|
+
else
|
58
|
+
@module_name = resource_path_to_class(@resource_path)
|
59
|
+
@namespaces = @module_name.split('::').map(&:underscore)
|
60
|
+
@name = @namespaces.pop
|
61
|
+
file = class_name_to_lib_file(@module_name)
|
62
|
+
end
|
63
|
+
@namespaces = add_type_to_namespaces(@namespaces)
|
64
|
+
template 'templates/code_generators/module.rb', file
|
65
|
+
end
|
66
|
+
|
67
|
+
def include_module
|
68
|
+
if @class_file
|
69
|
+
klass = resource_path_to_class(@class_file)
|
70
|
+
|
71
|
+
# Does file have a nested namespace structure
|
72
|
+
snippet = File.foreach(@class_file).first(50)
|
73
|
+
if snippet.any? { |line| line =~ /\s*class #{klass.split('::').last}/ }
|
74
|
+
indent = ' ' * klass.split('::').size
|
75
|
+
lines = []
|
76
|
+
lines << indent + "include #{@module_name}"
|
77
|
+
lines << ''
|
78
|
+
inject_into_class @class_file, klass.split('::').last, lines.join("\n") + "\n"
|
79
|
+
|
80
|
+
# Else assume it is the compact style (class MyApp::DUT::Falcon)
|
81
|
+
else
|
82
|
+
lines = []
|
83
|
+
lines << " include #{@module_name}"
|
84
|
+
lines << ''
|
85
|
+
inject_into_class @class_file, klass, lines.join("\n") + "\n"
|
86
|
+
end
|
87
|
+
end
|
88
|
+
add_acronyms
|
89
|
+
end
|
90
|
+
end
|
91
|
+
end
|
92
|
+
end
|
@@ -29,13 +29,25 @@ module Origen
|
|
29
29
|
def self.load_generators
|
30
30
|
return if @generators_loaded
|
31
31
|
# Load Origen's generators
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
32
|
+
require_relative 'code_generators/block_common'
|
33
|
+
require_relative 'code_generators/dut'
|
34
|
+
require_relative 'code_generators/block'
|
35
|
+
require_relative 'code_generators/feature'
|
36
|
+
require_relative 'code_generators/model'
|
37
|
+
require_relative 'code_generators/klass'
|
38
|
+
require_relative 'code_generators/module'
|
39
|
+
# Load generators from plugins, TBD what the API will be here
|
36
40
|
@generators_loaded = true
|
37
41
|
end
|
38
42
|
|
43
|
+
# Loaded separately so as not to pollute the generated list of generators available to users
|
44
|
+
def self.load_internal_generators
|
45
|
+
return if @internal_generators_loaded
|
46
|
+
require_relative 'code_generators/semver'
|
47
|
+
require_relative 'code_generators/timever'
|
48
|
+
@internal_generators_loaded = true
|
49
|
+
end
|
50
|
+
|
39
51
|
# Receives a namespace, arguments and the behavior to invoke the generator.
|
40
52
|
# It's used as the default entry point for generate, destroy and update
|
41
53
|
# commands.
|
@@ -47,6 +59,13 @@ module Origen
|
|
47
59
|
end
|
48
60
|
end
|
49
61
|
|
62
|
+
# Like invoke, but will also make internal-use only generators available
|
63
|
+
# commands.
|
64
|
+
def self.invoke_internal(name, args = ARGV, config = {})
|
65
|
+
load_internal_generators
|
66
|
+
invoke(name, args, config)
|
67
|
+
end
|
68
|
+
|
50
69
|
def self.find_by_name(name)
|
51
70
|
names = name.split(':')
|
52
71
|
case names.size
|
@@ -61,20 +80,20 @@ module Origen
|
|
61
80
|
end
|
62
81
|
return gen if gen
|
63
82
|
end
|
64
|
-
puts "Couldn't find a
|
83
|
+
puts "Couldn't find a code generator named: #{name}"
|
65
84
|
puts
|
66
|
-
puts 'This is the list of available
|
85
|
+
puts 'This is the list of available generators:'
|
67
86
|
puts
|
68
87
|
print_generators
|
69
88
|
puts
|
70
89
|
end
|
71
90
|
|
72
91
|
# Show help message with available generators.
|
73
|
-
def self.help(command = '
|
92
|
+
def self.help(command = 'new')
|
74
93
|
puts <<-END
|
75
|
-
Add pre-built features and code snippets.
|
94
|
+
Add pre-built features and code snippets to your application.
|
76
95
|
|
77
|
-
This command will
|
96
|
+
This command will generate code for your application to implement a given feature. In some
|
78
97
|
cases this will be a complete feature and in others it will provide a starting point for you
|
79
98
|
to further customize.
|
80
99
|
|
@@ -88,7 +107,7 @@ END
|
|
88
107
|
puts ' -s, [--skip] # Skip files that already exist'
|
89
108
|
puts ' -q, [--quiet] # Suppress status output'
|
90
109
|
puts
|
91
|
-
puts "The available features are listed below, run 'origen
|
110
|
+
puts "The available features are listed below, run 'origen new <feature> -h' for more info."
|
92
111
|
puts
|
93
112
|
|
94
113
|
print_generators
|
@@ -101,6 +120,7 @@ END
|
|
101
120
|
puts name
|
102
121
|
end
|
103
122
|
plugin_generators.each do |namespace, generators|
|
123
|
+
next if namespace.to_s == 'origen_app_generators'
|
104
124
|
puts
|
105
125
|
generators.each do |_name, gen|
|
106
126
|
puts "#{namespace}:#{gen}"
|
data/lib/origen/commands/lint.rb
CHANGED
@@ -32,7 +32,12 @@ if ARGV.empty?
|
|
32
32
|
if Origen.config.lint_test[:files]
|
33
33
|
files = Origen.config.lint_test[:files].map { |f| "#{Origen.root}/#{f}" }.join(' ')
|
34
34
|
else
|
35
|
-
files =
|
35
|
+
files = []
|
36
|
+
['lib', 'app/lib', 'app/blocks'].each do |sub_dir|
|
37
|
+
dir = "#{Origen.root}/#{sub_dir}"
|
38
|
+
files << dir if File.exist?(dir)
|
39
|
+
end
|
40
|
+
files = files.join(' ')
|
36
41
|
end
|
37
42
|
else
|
38
43
|
files = ARGV.join(' ')
|
data/lib/origen/commands/new.rb
CHANGED
@@ -62,7 +62,7 @@ else
|
|
62
62
|
end
|
63
63
|
end
|
64
64
|
|
65
|
-
generators = [['https://rubygems.org', '
|
65
|
+
generators = [['https://rubygems.org', 'origen_app_generators_v2']] + Array(Origen.site_config.app_generators)
|
66
66
|
|
67
67
|
def use_packaged_generators
|
68
68
|
FileUtils.cp_r Origen.top.join('origen_app_generators').to_s, '.'
|
@@ -0,0 +1,41 @@
|
|
1
|
+
# require 'optparse'
|
2
|
+
# require 'origen/commands/helpers'
|
3
|
+
#
|
4
|
+
# options = {}
|
5
|
+
#
|
6
|
+
## App options are options that the application can supply to extend this command
|
7
|
+
# app_options = @application_options || []
|
8
|
+
# opt_parser = OptionParser.new do |opts|
|
9
|
+
# opts.banner = 'Usage: origen new RESOURCE_TYPE RESOURCE_NAME [options]'
|
10
|
+
# opts.on('-d', '--debugger', 'Enable the debugger') { options[:debugger] = true }
|
11
|
+
# # Apply any application option extensions to the OptionParser
|
12
|
+
# Origen::CommandHelpers.extend_options(opts, app_options, options)
|
13
|
+
# opts.separator ''
|
14
|
+
# opts.on('-h', '--help', 'Show this message') { puts opts; exit }
|
15
|
+
# end
|
16
|
+
#
|
17
|
+
# opt_parser.parse! ARGV
|
18
|
+
#
|
19
|
+
# command = ARGV.shift
|
20
|
+
#
|
21
|
+
# case command
|
22
|
+
# when "model"
|
23
|
+
#
|
24
|
+
#
|
25
|
+
# else
|
26
|
+
# puts "Unknown resource type, must be one of: model"
|
27
|
+
# exit 1
|
28
|
+
# end
|
29
|
+
|
30
|
+
require 'origen/code_generators'
|
31
|
+
|
32
|
+
# if no argument/-h/--help is passed to origen add command, then
|
33
|
+
# it generates the help associated.
|
34
|
+
if [nil, '-h', '--help'].include?(ARGV.first)
|
35
|
+
Origen::CodeGenerators.help 'new'
|
36
|
+
exit
|
37
|
+
end
|
38
|
+
|
39
|
+
name = ARGV.shift
|
40
|
+
|
41
|
+
Origen::CodeGenerators.invoke name, ARGV # , behavior: :invoke, destination_root: Origen.root
|
data/lib/origen/commands/web.rb
CHANGED
@@ -19,7 +19,7 @@ The following commands are available:
|
|
19
19
|
serve Start a webserver from the current directory
|
20
20
|
|
21
21
|
compile [FILE] Compile all web templates and start a server to view them, optionally supply a
|
22
|
-
file argument to only update a single page e.g. 'origen web compile templates/web/index.md.erb'
|
22
|
+
file argument to only update a single page e.g. 'origen web compile app/templates/web/index.md.erb'
|
23
23
|
Use the --remote option to copy the compiled files to a remote web server directory (the
|
24
24
|
location of which should be specified via Origen.config.web_directory). In this case when no
|
25
25
|
FILE argument is specified the entire site will be copied over to a fresh web server
|
@@ -104,7 +104,7 @@ The following options are available:
|
|
104
104
|
puts "Web server directory created at: #{dir}"
|
105
105
|
puts ''
|
106
106
|
puts "Compile any files you want to test into the #{dir}/content directory, e.g.:"
|
107
|
-
puts " origen c templates/file.md.erb -o #{dir}/content"
|
107
|
+
puts " origen c app/templates/file.md.erb -o #{dir}/content"
|
108
108
|
puts ''
|
109
109
|
puts 'To turn them into web pages:'
|
110
110
|
puts " cd #{dir}"
|
@@ -149,9 +149,12 @@ The following options are available:
|
|
149
149
|
Origen.app.listeners_for(:before_web_compile).each do |listener|
|
150
150
|
listener.before_web_compile(options)
|
151
151
|
end
|
152
|
-
|
153
|
-
|
154
|
-
|
152
|
+
templates_web_dir = 'app/templates/web'
|
153
|
+
templates_web_dir = 'templates/web' unless File.exist?("#{Origen.root}/#{templates_web_dir}")
|
154
|
+
templates_web_dir =
|
155
|
+
Origen.app.runner.launch action: :compile,
|
156
|
+
files: templates_web_dir,
|
157
|
+
output: 'web/content'
|
155
158
|
Origen.app.listeners_for(:after_web_compile).each do |listener|
|
156
159
|
listener.after_web_compile(options)
|
157
160
|
end
|
@@ -168,7 +171,9 @@ The following options are available:
|
|
168
171
|
ARGV.each do |file|
|
169
172
|
path = Origen.file_handler.clean_path_to(file)
|
170
173
|
if path.to_s =~ /origen_guides/
|
171
|
-
|
174
|
+
origen_guides_dir = 'app/templates/origen_guides'
|
175
|
+
origen_guides_dir = 'templates/origen_guides' unless File.exist?("#{Origen.root}/#{origen_guides_dir}")
|
176
|
+
output = Origen.file_handler.sub_dir_of(path, "#{Origen.root}/#{origen_guides_dir}")
|
172
177
|
else
|
173
178
|
output = Origen.file_handler.sub_dir_of(path, "#{Origen.root}/templates/web")
|
174
179
|
end
|
data/lib/origen/commands.rb
CHANGED
@@ -2,6 +2,7 @@
|
|
2
2
|
# is done here (i.e. options that apply to all commands) before handing
|
3
3
|
# over to the specific command handlers
|
4
4
|
require 'optparse'
|
5
|
+
require 'fileutils'
|
5
6
|
|
6
7
|
ARGV << '--help' if ARGV.empty?
|
7
8
|
|
@@ -29,6 +30,18 @@ ORIGEN_COMMAND_ALIASES = {
|
|
29
30
|
# Moved here so boot.rb file can know the current command
|
30
31
|
Origen.send :current_command=, @command
|
31
32
|
|
33
|
+
# Do some housekeeping, remove all .git directories in vendor/gems, this allows gems
|
34
|
+
# that have been vendored via a Git reference to be checked in as normal
|
35
|
+
if File.exist?(Origen.root.join('vendor', 'gems'))
|
36
|
+
Dir.glob("#{Origen.root}/vendor/gems/ruby/*/bundler/gems/*/.git").each do |f|
|
37
|
+
FileUtils.rm_rf(f)
|
38
|
+
end
|
39
|
+
# Also remove any nested vendor/gems folders to save space
|
40
|
+
Dir.glob("#{Origen.root}/vendor/gems/ruby/*/bundler/gems/*/vendor/gems").each do |f|
|
41
|
+
FileUtils.rm_rf(f)
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
32
45
|
# Don't log to file during the save command since we need to preserve the last log,
|
33
46
|
# this is done as early in the process as possible so any deprecation warnings during
|
34
47
|
# load don't trigger a new log
|
@@ -227,6 +240,10 @@ when 'generate', 'program', 'compile', 'merge', 'interactive', 'target', 'enviro
|
|
227
240
|
require "origen/commands/#{@command}"
|
228
241
|
exit 0 unless @command == 'interactive'
|
229
242
|
|
243
|
+
when 'new'
|
244
|
+
require 'origen/commands/new_resource'
|
245
|
+
exit 0
|
246
|
+
|
230
247
|
when 'exec'
|
231
248
|
load ARGV.first
|
232
249
|
exit 0
|
@@ -272,6 +289,7 @@ The core origen commands are:
|
|
272
289
|
lint Lint and style check (and correct) your application code
|
273
290
|
archive Create an archive of your current application state
|
274
291
|
site Monitor and manage the Origen site configuration
|
292
|
+
new Generate a new block, flow, pattern, etc. for your application
|
275
293
|
EOT
|
276
294
|
cmds.split(/\n/).each do |line|
|
277
295
|
puts Origen.clean_help_line(line)
|
File without changes
|
File without changes
|
data/lib/origen/file_handler.rb
CHANGED
@@ -100,7 +100,7 @@ module Origen
|
|
100
100
|
def clean_path_to(file, options = {})
|
101
101
|
# Allow individual calls to this method to specify additional custom load paths to consider
|
102
102
|
if options[:load_paths]
|
103
|
-
|
103
|
+
Array(options[:load_paths]).each do |root|
|
104
104
|
if File.exist?("#{root}/#{file}")
|
105
105
|
return Pathname.new("#{root}/#{file}")
|
106
106
|
end
|
@@ -222,7 +222,7 @@ module Origen
|
|
222
222
|
begin
|
223
223
|
# Allow relative references to templates/web when compiling a web template
|
224
224
|
if Origen.lsf.current_command == 'web' || web_file
|
225
|
-
clean_path_to(file, load_paths: "#{Origen.root}/templates/web")
|
225
|
+
clean_path_to(file, load_paths: ["#{Origen.root}/app/templates/web", "#{Origen.root}/templates/web"])
|
226
226
|
else
|
227
227
|
clean_path_to(file)
|
228
228
|
end
|
@@ -230,7 +230,7 @@ module Origen
|
|
230
230
|
# Try again without .erb
|
231
231
|
file = file.gsub('.erb', '')
|
232
232
|
if Origen.lsf.current_command == 'web' || web_file
|
233
|
-
clean_path_to(file, load_paths: "#{Origen.root}/templates/web")
|
233
|
+
clean_path_to(file, load_paths: ["#{Origen.root}/app/templates/web", "#{Origen.root}/templates/web"])
|
234
234
|
else
|
235
235
|
clean_path_to(file)
|
236
236
|
end
|
@@ -264,7 +264,11 @@ module Origen
|
|
264
264
|
if import_name == :origen || import_name == :origen_core
|
265
265
|
path.sub! 'origen', "#{Origen.top}/templates/shared"
|
266
266
|
else
|
267
|
-
|
267
|
+
if File.exist?("#{root}/app/templates/shared")
|
268
|
+
path.sub! Regexp.last_match[1], "#{root}/app/templates/shared"
|
269
|
+
else
|
270
|
+
path.sub! Regexp.last_match[1], "#{root}/templates/shared"
|
271
|
+
end
|
268
272
|
end
|
269
273
|
else
|
270
274
|
fail 'Unknown import path type!'
|
@@ -95,10 +95,10 @@ module Origen
|
|
95
95
|
matches = Dir.glob("#{current_plugin_pattern_path}/**/#{name}.rb").sort
|
96
96
|
# If the current plugin does not include the pattern then look into the current app
|
97
97
|
if matches.size == 0
|
98
|
-
matches = Dir.glob("#{pattern_directory}/**/#{name}.rb").sort # <= this does not include symlinks
|
98
|
+
matches = Dir.glob(["#{pattern_directory}/**/#{name}.rb", "#{Origen.root}/app/patterns/**/#{name}.rb"]).sort # <= this does not include symlinks
|
99
99
|
end
|
100
100
|
else
|
101
|
-
matches = Dir.glob("#{pattern_directory}/**/#{name}.rb").sort # <= this does not include symlinks
|
101
|
+
matches = Dir.glob(["#{pattern_directory}/**/#{name}.rb", "#{Origen.root}/app/patterns/**/#{name}.rb"]).sort # <= this does not include symlinks
|
102
102
|
end
|
103
103
|
|
104
104
|
matches
|
@@ -114,7 +114,7 @@ module Origen
|
|
114
114
|
|
115
115
|
def all_matches(name)
|
116
116
|
name = name.gsub(/\..*$/, '')
|
117
|
-
matches = Dir.glob("#{pattern_directory}/**{,/*/**}/#{name}.rb").sort # Takes symlinks into consideration
|
117
|
+
matches = Dir.glob(["#{pattern_directory}/**{,/*/**}/#{name}.rb", "#{Origen.root}/app/patterns/**{,/*/**}/#{name}.rb"]).sort # Takes symlinks into consideration
|
118
118
|
matches.flatten.uniq
|
119
119
|
end
|
120
120
|
|