origen 0.34.3 → 0.52.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/bin/origen +1 -231
- data/config/application.rb +12 -3
- data/config/boot.rb +2 -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 +2 -3
- data/lib/origen.rb +27 -14
- data/lib/origen/application.rb +88 -2
- data/lib/origen/application/deployer.rb +3 -1
- data/lib/origen/application/release.rb +2 -2
- data/lib/origen/application/runner.rb +35 -20
- data/lib/origen/boot.rb +302 -0
- data/lib/origen/boot/api.rb +13 -0
- data/lib/origen/boot/app.rb +284 -0
- data/lib/origen/code_generators.rb +30 -10
- 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/commands.rb +30 -13
- data/lib/origen/commands/archive.rb +175 -0
- data/lib/origen/commands/extract.rb +43 -0
- data/lib/origen/commands/generate.rb +1 -0
- data/lib/origen/commands/lint.rb +6 -1
- data/lib/origen/commands/new.rb +48 -24
- data/lib/origen/commands/new_resource.rb +41 -0
- data/lib/origen/commands/site.rb +52 -0
- data/lib/origen/commands/web.rb +11 -6
- data/lib/origen/commands_global.rb +9 -7
- data/lib/origen/core_ext/numeric.rb +20 -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 +18 -6
- data/lib/origen/generator.rb +19 -10
- data/lib/origen/generator/comparator.rb +2 -1
- data/lib/origen/generator/flow.rb +3 -1
- data/lib/origen/generator/job.rb +60 -16
- data/lib/origen/generator/pattern.rb +132 -72
- data/lib/origen/generator/pattern_finder.rb +3 -3
- data/lib/origen/generator/pattern_sequence.rb +201 -0
- data/lib/origen/generator/pattern_sequencer.rb +99 -0
- data/lib/origen/generator/pattern_thread.rb +175 -0
- data/lib/origen/loader.rb +381 -0
- data/lib/origen/log.rb +250 -108
- data/lib/origen/model.rb +22 -1
- data/lib/origen/model/exporter.rb +50 -10
- data/lib/origen/model_initializer.rb +5 -1
- data/lib/origen/operating_systems.rb +4 -0
- data/lib/origen/parameters.rb +96 -4
- data/lib/origen/parameters/set.rb +4 -3
- data/lib/origen/pins.rb +10 -8
- data/lib/origen/pins/pin.rb +61 -46
- data/lib/origen/ports/port.rb +5 -0
- data/lib/origen/registers.rb +5 -0
- data/lib/origen/registers/bit.rb +57 -53
- data/lib/origen/registers/bit_collection.rb +100 -43
- data/lib/origen/registers/msb0_delegator.rb +47 -0
- data/lib/origen/registers/reg.rb +114 -99
- data/lib/origen/revision_control.rb +1 -1
- data/lib/origen/revision_control/git.rb +23 -3
- data/lib/origen/site_config.rb +251 -60
- data/lib/origen/site_config/config.rb +217 -0
- data/lib/origen/sub_blocks.rb +106 -31
- data/lib/origen/top_level.rb +11 -0
- data/lib/origen/users/user.rb +3 -2
- data/lib/origen/utility/mailer.rb +42 -9
- data/lib/origen/value/bin_str_val.rb +1 -1
- data/lib/origen/value/hex_str_val.rb +1 -1
- data/lib/origen/version_string.rb +6 -1
- data/lib/tasks/gem.rake +6 -1
- data/origen_app_generators/Gemfile +19 -0
- data/origen_app_generators/Gemfile.lock +152 -0
- data/origen_app_generators/LICENSE +21 -0
- data/origen_app_generators/README.md +368 -0
- data/{templates/code_generators/rakefile.rb → origen_app_generators/Rakefile} +0 -0
- data/origen_app_generators/bin/boot.rb +39 -0
- data/origen_app_generators/config/application.rb +153 -0
- data/origen_app_generators/config/boot.rb +1 -0
- data/origen_app_generators/config/commands.rb +63 -0
- data/origen_app_generators/config/shared_commands.rb +177 -0
- data/origen_app_generators/config/version.rb +8 -0
- data/origen_app_generators/doc/history +223 -0
- 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.rb +125 -0
- data/origen_app_generators/lib/origen_app_generators/application.rb +62 -0
- data/origen_app_generators/lib/origen_app_generators/base.rb +257 -0
- data/origen_app_generators/lib/origen_app_generators/empty_application.rb +15 -0
- data/origen_app_generators/lib/origen_app_generators/empty_plugin.rb +15 -0
- data/origen_app_generators/lib/origen_app_generators/new.rb +170 -0
- data/origen_app_generators/lib/origen_app_generators/new_app_tests.rb +4 -0
- data/origen_app_generators/lib/origen_app_generators/origen_infrastructure/app_generator_plugin.rb +107 -0
- data/origen_app_generators/lib/origen_app_generators/plugin.rb +55 -0
- 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 +64 -0
- data/origen_app_generators/lib/origen_app_generators/test_engineering/test_block.rb +61 -0
- data/origen_app_generators/origen_app_generators.gemspec +33 -0
- data/{templates/code_generators → origen_app_generators/spec}/spec_helper.rb +0 -0
- data/origen_app_generators/target/debug.rb +8 -0
- data/origen_app_generators/target/default.rb +8 -0
- data/origen_app_generators/target/production.rb +0 -0
- data/origen_app_generators/templates/app_generators/application/.gitignore +37 -0
- data/origen_app_generators/templates/app_generators/application/.irbrc +9 -0
- data/origen_app_generators/templates/app_generators/application/.rspec +1 -0
- data/origen_app_generators/templates/app_generators/application/.travis.yml +11 -0
- data/origen_app_generators/templates/app_generators/application/Gemfile +34 -0
- data/origen_app_generators/templates/app_generators/application/Rakefile +7 -0
- data/origen_app_generators/templates/app_generators/application/app/blocks/top_level.rb +12 -0
- data/origen_app_generators/templates/app_generators/application/app/lib/module.rb +6 -0
- data/origen_app_generators/templates/app_generators/application/app/templates/web/index.md.erb +19 -0
- data/origen_app_generators/templates/app_generators/application/app/templates/web/layouts/_basic.html.erb +13 -0
- data/origen_app_generators/templates/app_generators/application/app/templates/web/partials/_navbar.html.erb +20 -0
- data/origen_app_generators/templates/app_generators/application/app/templates/web/release_notes.md.erb +5 -0
- data/origen_app_generators/templates/app_generators/application/config/application.rb +121 -0
- data/origen_app_generators/templates/app_generators/application/config/boot.rb +4 -0
- data/origen_app_generators/templates/app_generators/application/config/commands.rb +79 -0
- data/origen_app_generators/templates/app_generators/application/config/maillist_dev.txt +4 -0
- data/origen_app_generators/templates/app_generators/application/config/maillist_prod.txt +3 -0
- data/origen_app_generators/templates/app_generators/application/config/version.rb +8 -0
- data/origen_app_generators/templates/app_generators/application/doc/history +0 -0
- data/origen_app_generators/templates/app_generators/application/dot_keep +0 -0
- data/origen_app_generators/templates/app_generators/application/origen_core_session +2 -0
- data/origen_app_generators/templates/app_generators/application/spec/spec_helper.rb +44 -0
- data/origen_app_generators/templates/app_generators/application/target/debug.rb +8 -0
- data/origen_app_generators/templates/app_generators/application/target/default.rb +1 -0
- data/origen_app_generators/templates/app_generators/application/target/production.rb +4 -0
- data/origen_app_generators/templates/app_generators/new/generator.rb +102 -0
- data/origen_app_generators/templates/app_generators/new/info.md.erb +9 -0
- data/origen_app_generators/templates/app_generators/origen_infrastructure/app_generator_plugin/app/lib/application.rb +54 -0
- data/origen_app_generators/templates/app_generators/origen_infrastructure/app_generator_plugin/app/lib/base.rb +55 -0
- data/origen_app_generators/templates/app_generators/origen_infrastructure/app_generator_plugin/app/lib/module.rb +28 -0
- data/origen_app_generators/templates/app_generators/origen_infrastructure/app_generator_plugin/app/lib/plugin.rb +64 -0
- data/origen_app_generators/templates/app_generators/origen_infrastructure/app_generator_plugin/config/load_generators.rb +6 -0
- data/origen_app_generators/templates/app_generators/plugin/Gemfile +32 -0
- data/origen_app_generators/templates/app_generators/plugin/Rakefile +10 -0
- data/origen_app_generators/templates/app_generators/plugin/app/templates/web/index.md.erb +37 -0
- data/origen_app_generators/templates/app_generators/plugin/app/templates/web/partials/_navbar_external.html.erb +20 -0
- data/origen_app_generators/templates/app_generators/plugin/app/templates/web/partials/_navbar_internal.html.erb +20 -0
- data/origen_app_generators/templates/app_generators/plugin/config/boot.rb +24 -0
- data/origen_app_generators/templates/app_generators/plugin/gemspec.rb +43 -0
- data/origen_app_generators/templates/app_generators/test_engineering/environment/j750.rb +1 -0
- data/origen_app_generators/templates/app_generators/test_engineering/environment/uflex.rb +1 -0
- data/origen_app_generators/templates/app_generators/test_engineering/environment/v93k.rb +1 -0
- data/origen_app_generators/templates/app_generators/test_engineering/stand_alone_application/.keep +0 -0
- data/origen_app_generators/templates/app_generators/test_engineering/test_block/.keep +0 -0
- data/origen_site_config.yml +55 -5
- 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
- data/templates/git/gitignore.erb +0 -1
- data/vendor/lib/models/origen/export1.rb +77 -0
- data/vendor/lib/models/origen/export1/block1.rb +13 -0
- data/vendor/lib/models/origen/export1/block1/x.rb +36 -0
- data/vendor/lib/models/origen/non_origen_meta_data.md +1 -0
- metadata +149 -68
- data/bin/fix_my_workspace +0 -100
- 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/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
@@ -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
|
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,10 +30,22 @@ 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
|
35
|
-
Origen::Log.console_only =
|
48
|
+
Origen::Log.console_only = %w(save target environment version).include?(@command)
|
36
49
|
|
37
50
|
if ARGV.delete('--coverage') ||
|
38
51
|
((@command == 'specs' || @command == 'examples' || @command == 'test') && (ARGV.delete('-c') || ARGV.delete('--coverage')))
|
@@ -97,22 +110,13 @@ Origen.lsf.current_command = @command
|
|
97
110
|
|
98
111
|
if ARGV.delete('-d') || ARGV.delete('--debug')
|
99
112
|
begin
|
100
|
-
|
101
|
-
require 'byebug'
|
102
|
-
else
|
103
|
-
require 'rubygems'
|
104
|
-
require 'ruby-debug'
|
105
|
-
end
|
113
|
+
require 'byebug'
|
106
114
|
rescue LoadError
|
107
115
|
def debugger
|
108
116
|
caller[0] =~ /.*\/(\w+\.rb):(\d+).*/
|
109
117
|
puts 'The debugger gem is not installed, add the following to your Gemfile:'
|
110
118
|
puts
|
111
|
-
puts "
|
112
|
-
puts " gem 'byebug', '~>3.5'"
|
113
|
-
puts 'else'
|
114
|
-
puts " gem 'debugger', '~>1.6'"
|
115
|
-
puts 'end'
|
119
|
+
puts " gem 'byebug', '~>8'"
|
116
120
|
puts
|
117
121
|
end
|
118
122
|
end
|
@@ -230,11 +234,16 @@ end.compact
|
|
230
234
|
|
231
235
|
case @command
|
232
236
|
when 'generate', 'program', 'compile', 'merge', 'interactive', 'target', 'environment',
|
233
|
-
'save', 'lsf', 'web', 'time', 'dispatch', 'rc', 'lint', 'plugin', 'fetch', 'mode', 'gem'
|
237
|
+
'save', 'lsf', 'web', 'time', 'dispatch', 'rc', 'lint', 'plugin', 'fetch', 'mode', 'gem',
|
238
|
+
'archive'
|
234
239
|
|
235
240
|
require "origen/commands/#{@command}"
|
236
241
|
exit 0 unless @command == 'interactive'
|
237
242
|
|
243
|
+
when 'new'
|
244
|
+
require 'origen/commands/new_resource'
|
245
|
+
exit 0
|
246
|
+
|
238
247
|
when 'exec'
|
239
248
|
load ARGV.first
|
240
249
|
exit 0
|
@@ -244,6 +253,10 @@ when 'version'
|
|
244
253
|
require 'origen/commands/version'
|
245
254
|
exit 0
|
246
255
|
|
256
|
+
when 'site'
|
257
|
+
require 'origen/commands/site'
|
258
|
+
exit 0
|
259
|
+
|
247
260
|
else
|
248
261
|
if ['-h', '--help'].include?(@command)
|
249
262
|
status = 0
|
@@ -267,12 +280,16 @@ The core origen commands are:
|
|
267
280
|
compile Compile a template file or directory (short-cut alias: "c")
|
268
281
|
exec Execute any Ruby file with access to your app environment
|
269
282
|
|
283
|
+
setup Setup an app workspace for the first time, or fix if it can't boot
|
270
284
|
rc Revision control commands, see -h for details
|
271
285
|
save Save the new or changed files from the last run or a given log file
|
272
286
|
lsf Monitor and manage LSF jobs (short-cut alias: "l")
|
273
287
|
web Web page tools, see -h for details
|
274
288
|
time Tools for test time analysis and forecasting
|
275
289
|
lint Lint and style check (and correct) your application code
|
290
|
+
archive Create an archive of your current application state
|
291
|
+
site Monitor and manage the Origen site configuration
|
292
|
+
new Generate a new block, flow, pattern, etc. for your application
|
276
293
|
EOT
|
277
294
|
cmds.split(/\n/).each do |line|
|
278
295
|
puts Origen.clean_help_line(line)
|
@@ -0,0 +1,175 @@
|
|
1
|
+
require 'optparse'
|
2
|
+
require 'fileutils'
|
3
|
+
require 'find'
|
4
|
+
require 'bundler'
|
5
|
+
|
6
|
+
options = {}
|
7
|
+
options[:exclude] = []
|
8
|
+
|
9
|
+
opt_parser = OptionParser.new do |opts|
|
10
|
+
opts.banner = 'Usage: origen archive [options]'
|
11
|
+
opts.on('--local', 'Install gems within your app so that it can run completely standalone, no archive is created') { options[:local] = true }
|
12
|
+
opts.on('--no-local', "Reverses a previously executed 'origen archive --local' operation, returning the app to use a conventional gem installation") { options[:no_local] = true }
|
13
|
+
opts.on('-e', '--exclude DIR', 'Exclude the given directory from the archive, e.g. --exclude simulation') { |dir| options[:exclude] << dir }
|
14
|
+
end
|
15
|
+
opt_parser.parse! ARGV
|
16
|
+
|
17
|
+
origen_binstub = File.join(Origen.root, 'lbin', 'origen')
|
18
|
+
|
19
|
+
unless File.exist?(origen_binstub) && File.read(origen_binstub) =~ /This file was generated by Origen/
|
20
|
+
puts 'An archive can only be created after your application is running the latest Origen boot system,'
|
21
|
+
puts 'run the following command to update your application and then try again:'
|
22
|
+
puts
|
23
|
+
puts ' origen setup'
|
24
|
+
puts
|
25
|
+
exit 1
|
26
|
+
end
|
27
|
+
|
28
|
+
if options[:no_local]
|
29
|
+
Dir.chdir Origen.root do
|
30
|
+
dir = File.join('vendor', 'gems')
|
31
|
+
FileUtils.rm_rf(dir) if File.exist?(dir)
|
32
|
+
end
|
33
|
+
passed = true
|
34
|
+
Bundler.with_clean_env do
|
35
|
+
passed = system('origen -v')
|
36
|
+
end
|
37
|
+
if passed
|
38
|
+
Origen.log.success 'Local gems have been removed and your application has been restored to use a conventional gem installation.'
|
39
|
+
exit 0
|
40
|
+
else
|
41
|
+
Origen.log.error 'A problem was encountered when trying to boot your application after removing local gems!'
|
42
|
+
exit 1
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
Origen.log.info 'Preparing the workspace' unless options[:local]
|
47
|
+
tmp1 = File.join(Origen.root, '..', "#{Origen.app.name}_copy")
|
48
|
+
name = "#{Origen.app.name}-#{Origen.app.version}"
|
49
|
+
tmpdir = File.join(Origen.root, 'tmp')
|
50
|
+
tmp = File.join(tmpdir, name)
|
51
|
+
archive = File.join(Origen.root, 'tmp', "#{name}.origen")
|
52
|
+
unless options[:local]
|
53
|
+
FileUtils.rm_rf(tmp1) if File.exist?(tmp1)
|
54
|
+
FileUtils.rm_rf(tmp) if File.exist?(tmp)
|
55
|
+
FileUtils.rm_rf(archive) if File.exist?(archive)
|
56
|
+
end
|
57
|
+
|
58
|
+
exclude_dirs = ['.bundle', 'output', 'tmp', 'web', 'waves', '.git', '.ref', 'dist', 'log', '.lsf', '.session'] + options[:exclude]
|
59
|
+
|
60
|
+
unless options[:local]
|
61
|
+
begin
|
62
|
+
Origen.log.info 'Creating a copy of the application'
|
63
|
+
if Origen.os.linux?
|
64
|
+
Dir.chdir Origen.root do
|
65
|
+
cmd = "rsync -av --progress . tmp/#{name} --exclude tmp"
|
66
|
+
exclude_dirs.each do |dir|
|
67
|
+
cmd += " --exclude #{dir}"
|
68
|
+
end
|
69
|
+
passed = system cmd
|
70
|
+
unless passed
|
71
|
+
Origen.log.error 'A problem was encountered when creating a copy of your application, archive aborted!'
|
72
|
+
exit 1
|
73
|
+
end
|
74
|
+
end
|
75
|
+
else
|
76
|
+
FileUtils.mkdir_p(tmp1)
|
77
|
+
FileUtils.cp_r "#{Origen.root}/.", tmp1
|
78
|
+
FileUtils.mv tmp1, tmp
|
79
|
+
end
|
80
|
+
# Remove all .svn or .SYNC directories
|
81
|
+
Find.find(tmp) do |path|
|
82
|
+
n = File.basename(path)
|
83
|
+
if FileTest.directory?(path) && (n == '.svn' || n == '.SYNC')
|
84
|
+
puts "Removing: #{path}"
|
85
|
+
FileUtils.remove_dir(path)
|
86
|
+
end
|
87
|
+
end
|
88
|
+
ensure
|
89
|
+
FileUtils.rm_rf(tmp1) if File.exist?(tmp1)
|
90
|
+
end
|
91
|
+
end
|
92
|
+
|
93
|
+
Origen.log.info 'Fetching all required gems' unless options[:local]
|
94
|
+
dir = options[:local] ? Origen.root : tmp
|
95
|
+
Dir.chdir dir do
|
96
|
+
# When archiving, also include copies of all gem packages for other platforms, this will help if the
|
97
|
+
# archive needs to run on a different platform to the one used to create it in the future
|
98
|
+
unless options[:local]
|
99
|
+
Bundler.with_clean_env do
|
100
|
+
FileUtils.rm_rf('.bundle') if File.exist?('.bundle')
|
101
|
+
system 'hash -r' # Ignore fail if not on bash
|
102
|
+
|
103
|
+
passed = system "GEM_HOME=#{File.expand_path(Origen.site_config.gem_install_dir)} bundle package --all --all-platforms --no-install"
|
104
|
+
unless passed
|
105
|
+
Origen.log.error 'A problem was encountered when packaging the gems, archive aborted!'
|
106
|
+
exit 1
|
107
|
+
end
|
108
|
+
FileUtils.rm_rf('.bundle') if File.exist?('.bundle')
|
109
|
+
end
|
110
|
+
end
|
111
|
+
|
112
|
+
Origen.log.info 'Installing gems into the application (this could take a while)'
|
113
|
+
FileUtils.mkdir_p(File.join('vendor', 'gems'))
|
114
|
+
require 'origen/boot/app'
|
115
|
+
begin
|
116
|
+
Origen::Boot.setup(dir)
|
117
|
+
Origen::Boot.setup_bundler(dir)
|
118
|
+
rescue Exception => e
|
119
|
+
Origen.log.error e.to_s
|
120
|
+
Origen.log.error 'A problem was encountered setting up the workspace, archive aborted!'
|
121
|
+
exit 1
|
122
|
+
end
|
123
|
+
FileUtils.touch('.origen_archive') unless options[:local]
|
124
|
+
|
125
|
+
Bundler.with_clean_env do
|
126
|
+
passed = system('bundle') && system('origen -v')
|
127
|
+
unless passed
|
128
|
+
Origen.log.error 'A problem was encountered installing the gem bundle, archive aborted!'
|
129
|
+
exit 1
|
130
|
+
end
|
131
|
+
end
|
132
|
+
|
133
|
+
unless options[:local]
|
134
|
+
Origen.log.info 'Removing all temporary and output files'
|
135
|
+
exclude_dirs.each do |dir|
|
136
|
+
if File.exist?(dir)
|
137
|
+
if File.symlink?(dir)
|
138
|
+
FileUtils.rm(dir)
|
139
|
+
else
|
140
|
+
FileUtils.rm_rf(dir)
|
141
|
+
end
|
142
|
+
end
|
143
|
+
end
|
144
|
+
end
|
145
|
+
end
|
146
|
+
|
147
|
+
if options[:local]
|
148
|
+
Origen.log.success 'Gems have been successfully installed to your application'
|
149
|
+
Origen.log.success ''
|
150
|
+
Origen.log.success 'If you ran this in error or otherwise want to undo it, run the following command:'
|
151
|
+
Origen.log.success ' origen archive --no-local'
|
152
|
+
Origen.log.success ''
|
153
|
+
else
|
154
|
+
Origen.log.info 'Creating archive'
|
155
|
+
Dir.chdir tmpdir do
|
156
|
+
FileUtils.rm_rf('.bundle') if File.exist?('.bundle')
|
157
|
+
passed = system "tar -cvzf #{name}.origen ./#{name}"
|
158
|
+
unless passed
|
159
|
+
Origen.log.error 'A problem was encountered creating the tarball, archive aborted!'
|
160
|
+
exit 1
|
161
|
+
end
|
162
|
+
|
163
|
+
Origen.log.info 'Cleaning up'
|
164
|
+
FileUtils.rm_rf(name)
|
165
|
+
end
|
166
|
+
|
167
|
+
puts
|
168
|
+
begin
|
169
|
+
size = `du -sh tmp/#{name}.origen`.split(/\s+/).first
|
170
|
+
Origen.log.success "Your application archive is complete and is #{size}B in size"
|
171
|
+
rescue
|
172
|
+
Origen.log.success 'Your application archive is complete'
|
173
|
+
end
|
174
|
+
Origen.log.success archive
|
175
|
+
end
|
@@ -0,0 +1,43 @@
|
|
1
|
+
require 'optparse'
|
2
|
+
require 'fileutils'
|
3
|
+
require 'bundler'
|
4
|
+
|
5
|
+
options = {}
|
6
|
+
|
7
|
+
opt_parser = OptionParser.new do |opts|
|
8
|
+
opts.banner = 'Usage: origen extract FILE [options]'
|
9
|
+
end
|
10
|
+
opt_parser.parse! ARGV
|
11
|
+
|
12
|
+
archive = ARGV.first
|
13
|
+
|
14
|
+
unless File.exist?(archive)
|
15
|
+
Origen.log.error "File not found: #{archive}"
|
16
|
+
exit 1
|
17
|
+
end
|
18
|
+
|
19
|
+
dirname = Pathname.new(archive).basename('.origen').to_s
|
20
|
+
|
21
|
+
if File.exist?(dirname)
|
22
|
+
Origen.log.error "The application directory already exists (#{dirname}), delete it and then try again if you want to overwrite it"
|
23
|
+
exit 1
|
24
|
+
end
|
25
|
+
|
26
|
+
passed = system "tar -xvzf #{archive}"
|
27
|
+
unless passed
|
28
|
+
Origen.log.error 'A problem was encountered extracting the tarball, extraction aborted!'
|
29
|
+
exit 1
|
30
|
+
end
|
31
|
+
|
32
|
+
Dir.chdir dirname do
|
33
|
+
Bundler.with_clean_env do
|
34
|
+
Origen.log.info 'Trying to boot the application...'
|
35
|
+
|
36
|
+
passed = system "#{File.join('lbin', 'origen')} -v"
|
37
|
+
if passed
|
38
|
+
Origen.log.success 'Your application has been extracted and can boot up'
|
39
|
+
else
|
40
|
+
Origen.log.error 'Something went wrong at the final hurdle, your application has been extracted but cannot boot'
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|