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
data/lib/origen/application.rb
CHANGED
@@ -50,6 +50,8 @@ module Origen
|
|
50
50
|
Origen.register_application(app)
|
51
51
|
end
|
52
52
|
app.add_lib_to_load_path!
|
53
|
+
# Also blow this cache as a new app has just been added
|
54
|
+
@apps_by_namespace = nil
|
53
55
|
end
|
54
56
|
end
|
55
57
|
end
|
@@ -62,6 +64,33 @@ module Origen
|
|
62
64
|
super || instance.respond_to?(*args)
|
63
65
|
end
|
64
66
|
|
67
|
+
# Returns the application instance (i.e. main app or the plugin) that owns the given class/module
|
68
|
+
# (literal, string or symbol representation is accepted) or object instance.
|
69
|
+
# Returns nil if no matching Origen application can be found.
|
70
|
+
#
|
71
|
+
# Origen::Application.from_namespace(MyApp) # => <my_app instance>
|
72
|
+
# Origen::Application.from_namespace(MyApp::MyClass) # => <my_app instance>
|
73
|
+
# Origen::Application.from_namespace('MyApp::MyClass') # => <my_app instance>
|
74
|
+
# Origen::Application.from_namespace(<my_app::my_class instance>) # => <my_app instance>
|
75
|
+
def from_namespace(item)
|
76
|
+
unless item.is_a?(String)
|
77
|
+
if item.is_a?(Module) || item.is_a?(Class) || item.is_a?(Symbol)
|
78
|
+
item = item.to_s
|
79
|
+
else # Assume to be an object instance in this case
|
80
|
+
item = item.class.to_s
|
81
|
+
end
|
82
|
+
end
|
83
|
+
namespace = item.split('::').first
|
84
|
+
@apps_by_namespace ||= {}
|
85
|
+
@apps_by_namespace[namespace] ||= begin
|
86
|
+
return Origen.app if Origen.app.namespace == namespace
|
87
|
+
Origen.app.plugins.each do |plugin|
|
88
|
+
return plugin if plugin.namespace == namespace
|
89
|
+
end
|
90
|
+
nil
|
91
|
+
end
|
92
|
+
end
|
93
|
+
|
65
94
|
protected
|
66
95
|
|
67
96
|
def method_missing(*args, &block)
|
@@ -104,6 +133,58 @@ module Origen
|
|
104
133
|
end
|
105
134
|
end
|
106
135
|
|
136
|
+
# @api private
|
137
|
+
#
|
138
|
+
# Returns a lookup table for all block definitions (app/blocks) that the app contains
|
139
|
+
def blocks_files
|
140
|
+
@blocks_files ||= begin
|
141
|
+
files = {}
|
142
|
+
block_dir = Pathname.new(File.join(root, 'app', 'blocks'))
|
143
|
+
if block_dir.exist?
|
144
|
+
block_dir.children.each do |item|
|
145
|
+
if item.directory?
|
146
|
+
_add_block_files(files, block_dir, item)
|
147
|
+
end
|
148
|
+
end
|
149
|
+
end
|
150
|
+
files
|
151
|
+
end
|
152
|
+
end
|
153
|
+
|
154
|
+
# @api private
|
155
|
+
def _add_block_files(files, block_dir, current_dir, sub_block = false)
|
156
|
+
fields = current_dir.relative_path_from(block_dir).to_s.split('/')
|
157
|
+
fields.delete('derivatives')
|
158
|
+
fields.delete('sub_blocks')
|
159
|
+
path = fields.join('/')
|
160
|
+
files[path] ||= {}
|
161
|
+
files[path][:_sub_block] = true if sub_block
|
162
|
+
Dir.glob(current_dir.join('*.rb')).each do |file|
|
163
|
+
file = Pathname.new(file)
|
164
|
+
type = file.basename('.rb').to_s.to_sym
|
165
|
+
unless type == :model || type == :controller
|
166
|
+
files[path][type] ||= []
|
167
|
+
files[path][type] << file.to_s
|
168
|
+
end
|
169
|
+
end
|
170
|
+
derivatives = current_dir.join('derivatives')
|
171
|
+
if derivatives.exist?
|
172
|
+
derivatives.children.each do |item|
|
173
|
+
if item.directory?
|
174
|
+
_add_block_files(files, block_dir, item)
|
175
|
+
end
|
176
|
+
end
|
177
|
+
end
|
178
|
+
sub_blocks = current_dir.join('sub_blocks')
|
179
|
+
if sub_blocks.exist?
|
180
|
+
sub_blocks.children.each do |item|
|
181
|
+
if item.directory?
|
182
|
+
_add_block_files(files, block_dir, item, true)
|
183
|
+
end
|
184
|
+
end
|
185
|
+
end
|
186
|
+
end
|
187
|
+
|
107
188
|
def current_job
|
108
189
|
current_jobs.last
|
109
190
|
end
|
@@ -766,6 +847,7 @@ END
|
|
766
847
|
force_debug: false
|
767
848
|
}.merge(options)
|
768
849
|
@on_create_called = false
|
850
|
+
@target_loading = true
|
769
851
|
if options[:reload]
|
770
852
|
@target_load_count = 0
|
771
853
|
else
|
@@ -814,7 +896,7 @@ END
|
|
814
896
|
end
|
815
897
|
listeners_for(:after_load_target).each(&:after_load_target)
|
816
898
|
Origen.app.plugins.validate_production_status
|
817
|
-
|
899
|
+
@target_loading = false
|
818
900
|
end
|
819
901
|
|
820
902
|
# Returns true if the on_create callback has already been called during a target load
|
@@ -900,6 +982,10 @@ END
|
|
900
982
|
@target_instantiated
|
901
983
|
end
|
902
984
|
|
985
|
+
def target_loading?
|
986
|
+
@target_loading || false
|
987
|
+
end
|
988
|
+
|
903
989
|
# Prepends the application name to the fail message and throws a RuntimeError exception.
|
904
990
|
# Very similar to the plain <code>fail</code> method with the addition of prepending the application name.
|
905
991
|
# Prepended message: 'Fail in app.name: '
|
@@ -956,7 +1042,7 @@ END
|
|
956
1042
|
# config.i18n.backend = MyBackend
|
957
1043
|
# end
|
958
1044
|
def add_lib_to_load_path! #:nodoc:
|
959
|
-
[root.join('lib'), root.join('vendor', 'lib')].each do |path|
|
1045
|
+
[root.join('lib'), root.join('vendor', 'lib'), root.join('app', 'lib')].each do |path|
|
960
1046
|
$LOAD_PATH.unshift(path.to_s) if File.exist?(path) && !$LOAD_PATH.include?(path.to_s)
|
961
1047
|
end
|
962
1048
|
end
|
@@ -224,7 +224,9 @@ module Origen
|
|
224
224
|
end
|
225
225
|
|
226
226
|
def create_web_server_dir
|
227
|
-
|
227
|
+
templates_web_dir = 'app/templates/web'
|
228
|
+
templates_web_dir = 'templates/web' unless File.exist?("#{Origen.root}/#{templates_web_dir}")
|
229
|
+
if File.exist?("#{Origen.root}/#{templates_web_dir}")
|
228
230
|
dir = web_server_dir
|
229
231
|
FileUtils.rm_rf dir if File.exist?(dir)
|
230
232
|
FileUtils.mkdir_p dir
|
@@ -328,9 +328,9 @@ Your workspace has local modifications that are preventing the requested action
|
|
328
328
|
# Sets the version number in the file store
|
329
329
|
def write_version(version)
|
330
330
|
if version.semantic?
|
331
|
-
Origen::CodeGenerators.
|
331
|
+
Origen::CodeGenerators.invoke_internal 'semver', [], config: { change: version }
|
332
332
|
else
|
333
|
-
Origen::CodeGenerators.
|
333
|
+
Origen::CodeGenerators.invoke_internal 'timever', [], config: { change: version }
|
334
334
|
end
|
335
335
|
system 'origen -v' # Invoke Origen under the new version, this updates Gemfile.lock
|
336
336
|
end
|
@@ -46,7 +46,9 @@ module Origen
|
|
46
46
|
Origen.log.info 'Monitor status of remote jobs via:'
|
47
47
|
Origen.log.info ' origen l'
|
48
48
|
else
|
49
|
-
|
49
|
+
unless tester && tester.try(:sim?)
|
50
|
+
Origen.log.info '*' * 70 unless options[:quiet]
|
51
|
+
end
|
50
52
|
Origen.app.listeners_for(:before_generate).each do |listener|
|
51
53
|
if listener.class.instance_method(:before_generate).arity == 0
|
52
54
|
listener.before_generate
|
@@ -82,29 +84,35 @@ module Origen
|
|
82
84
|
Origen.app.listeners_for(:program_generated).each(&:program_generated)
|
83
85
|
else
|
84
86
|
temporary_plugin_from_options = options[:current_plugin]
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
end
|
89
|
-
case options[:action]
|
90
|
-
when :compile
|
91
|
-
Origen.generator.compile_file_or_directory(file, options)
|
92
|
-
when :merge
|
93
|
-
Origen.generator.merge_file_or_directory(file, options)
|
94
|
-
when :import_test_time
|
95
|
-
Origen.time.import_test_time(file, options)
|
96
|
-
when :import_test_flow
|
97
|
-
Origen.time.import_test_flow(file, options)
|
98
|
-
else
|
99
|
-
Origen.generator.generate_pattern(file, options)
|
100
|
-
end
|
87
|
+
if options[:action] == :pattern && options[:sequence]
|
88
|
+
patterns = expand_lists_and_directories(options[:files], options.merge(preserve_duplicates: true))
|
89
|
+
Origen.generator.generate_pattern(patterns, options)
|
101
90
|
Origen.app.plugins.temporary = nil if temporary_plugin_from_options
|
91
|
+
else
|
92
|
+
expand_lists_and_directories(options[:files], options).each do |file|
|
93
|
+
if temporary_plugin_from_options
|
94
|
+
Origen.app.plugins.temporary = temporary_plugin_from_options
|
95
|
+
end
|
96
|
+
case options[:action]
|
97
|
+
when :compile
|
98
|
+
Origen.generator.compile_file_or_directory(file, options)
|
99
|
+
when :merge
|
100
|
+
Origen.generator.merge_file_or_directory(file, options)
|
101
|
+
when :import_test_time
|
102
|
+
Origen.time.import_test_time(file, options)
|
103
|
+
when :import_test_flow
|
104
|
+
Origen.time.import_test_flow(file, options)
|
105
|
+
else
|
106
|
+
Origen.generator.generate_pattern(file, options)
|
107
|
+
end
|
108
|
+
Origen.app.plugins.temporary = nil if temporary_plugin_from_options
|
109
|
+
end
|
102
110
|
end
|
103
111
|
end
|
104
112
|
end
|
105
113
|
end
|
106
114
|
|
107
|
-
unless options[:quiet]
|
115
|
+
unless options[:quiet] || (tester && tester.try(:sim?))
|
108
116
|
Origen.log.info '*' * 70
|
109
117
|
stats.print_summary unless options[:action] == :merge
|
110
118
|
end
|
@@ -255,8 +263,15 @@ module Origen
|
|
255
263
|
if Origen.mode.production? && Origen.app.rc
|
256
264
|
unless Origen.app.rc.local_modifications.empty?
|
257
265
|
puts <<-EOT
|
258
|
-
Your workspace has local modifications
|
259
|
-
|
266
|
+
Your workspace is running in production mode and it has local modifications which are preventing
|
267
|
+
the requested action, run the following command to see what files have been modified:
|
268
|
+
|
269
|
+
origen rc mods
|
270
|
+
|
271
|
+
If you are currently developing this application and are not ready to check everything in yet,
|
272
|
+
then run the following command to switch your workspace to debug/development mode:
|
273
|
+
|
274
|
+
origen m debug
|
260
275
|
EOT
|
261
276
|
exit 1
|
262
277
|
end
|
data/lib/origen/boot.rb
ADDED
@@ -0,0 +1,302 @@
|
|
1
|
+
$VERBOSE = nil # Don't care about world writable dir warnings and the like
|
2
|
+
|
3
|
+
require 'pathname'
|
4
|
+
require 'fileutils'
|
5
|
+
|
6
|
+
class OrigenBootError < StandardError
|
7
|
+
end
|
8
|
+
|
9
|
+
# Keep a note of the pwd at the time when Origen was first loaded, this is initially used
|
10
|
+
# by the site_config lookup.
|
11
|
+
$_origen_invocation_pwd ||= Pathname.pwd
|
12
|
+
|
13
|
+
# This will be referenced later in ruby_version_check, the origen used to launch
|
14
|
+
# the process is different than the one that actually runs under bundler
|
15
|
+
$origen_launch_root = Pathname.new(File.dirname(__FILE__)).parent
|
16
|
+
|
17
|
+
# Override any influence from $LANG in the users environment
|
18
|
+
Encoding.default_external = Encoding::UTF_8
|
19
|
+
Encoding.default_internal = Encoding::UTF_8
|
20
|
+
ENV['LC_ALL'] = nil
|
21
|
+
ENV['LANG'] = nil
|
22
|
+
ENV['LANG'] = 'en_US.UTF-8'
|
23
|
+
|
24
|
+
load File.expand_path('../operating_systems.rb', __FILE__)
|
25
|
+
|
26
|
+
# Are we inside an Origen application workspace?
|
27
|
+
# If ORIGEN_ROOT is defined it means that we were launched within an app from the new style Origen binstub,
|
28
|
+
# so all is well
|
29
|
+
if defined?(ORIGEN_ROOT)
|
30
|
+
origen_root = ORIGEN_ROOT
|
31
|
+
else
|
32
|
+
app_config = File.join('config', 'application.rb')
|
33
|
+
if File.exist?(app_config)
|
34
|
+
origen_root = Dir.pwd
|
35
|
+
else
|
36
|
+
path = Pathname.new(Dir.pwd)
|
37
|
+
until path.root? || origen_root
|
38
|
+
if File.exist?(File.join(path, app_config))
|
39
|
+
origen_root = path.to_s
|
40
|
+
else
|
41
|
+
path = path.parent
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
45
|
+
# If we are in an app and we have not been invoked through a Bundler binstub, then check if one exists and
|
46
|
+
# if so re-launch through it, otherwise create one and then re-launch through that
|
47
|
+
if origen_root && !ENV['BUNDLE_BIN_PATH']
|
48
|
+
binstub = File.join(origen_root, 'lbin', 'origen')
|
49
|
+
unless File.exist?(binstub)
|
50
|
+
require_relative 'boot/app'
|
51
|
+
Origen::Boot.create_origen_binstub(origen_root)
|
52
|
+
end
|
53
|
+
exec Gem.ruby, binstub, *ARGV
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
# Defer loading these until we have re-launched above to save time
|
58
|
+
load File.expand_path('../site_config.rb', __FILE__)
|
59
|
+
load File.expand_path('../loader.rb', __FILE__)
|
60
|
+
|
61
|
+
warnings = nil
|
62
|
+
|
63
|
+
########################################################################################################################
|
64
|
+
########################################################################################################################
|
65
|
+
## If running inside an application workspace
|
66
|
+
########################################################################################################################
|
67
|
+
########################################################################################################################
|
68
|
+
if origen_root
|
69
|
+
require_relative 'boot/app'
|
70
|
+
|
71
|
+
if ARGV.first == 'setup'
|
72
|
+
Origen::Boot.setup(origen_root)
|
73
|
+
puts
|
74
|
+
puts 'Your application has been setup successfully'
|
75
|
+
exit 0
|
76
|
+
else
|
77
|
+
warnings = Origen::Boot.app!(origen_root)
|
78
|
+
boot_app = true
|
79
|
+
end
|
80
|
+
|
81
|
+
########################################################################################################################
|
82
|
+
########################################################################################################################
|
83
|
+
## If running outside an application and a user or central tool Origen bundle is to be used
|
84
|
+
##
|
85
|
+
## Note that there is a lot of duplication of the above code, however this is a copy of the original code
|
86
|
+
## to boot up outside an app when a tool Origen bundle is present. It has been maintained separately to
|
87
|
+
## ensure that the changes to how an application boots up do not affect the global tool installation functionality.
|
88
|
+
########################################################################################################################
|
89
|
+
########################################################################################################################
|
90
|
+
elsif Origen.site_config.gem_manage_bundler && (Origen.site_config.user_install_enable || Origen.site_config.tool_repo_install_dir)
|
91
|
+
# Force everyone to have a consistent way of installing gems with bundler.
|
92
|
+
# In this case, we aren't running from an Origen application, so build everything at Origen.home instead
|
93
|
+
# Have two options here: if user_install_enable is true, use user_install_dir. Otherwise, use the tool_repo_install_dir
|
94
|
+
install_dir = Origen.site_config.user_install_enable ? File.expand_path(Origen.site_config.user_install_dir) : File.expand_path(Origen.site_config.tool_repo_install_dir)
|
95
|
+
unless Dir.exist?(install_dir)
|
96
|
+
load File.expand_path('../../lib/origen/utility/input_capture.rb', __FILE__)
|
97
|
+
include Origen::Utility::InputCapture
|
98
|
+
|
99
|
+
puts "Root directory '#{install_dir}' does not exist. Would you like to create it?"
|
100
|
+
if get_text(confirm: :return_boolean)
|
101
|
+
FileUtils.mkdir(install_dir)
|
102
|
+
else
|
103
|
+
puts 'Exiting with creating Origen install'
|
104
|
+
exit!
|
105
|
+
end
|
106
|
+
end
|
107
|
+
|
108
|
+
gemfile = File.join(install_dir, 'Gemfile')
|
109
|
+
unless File.exist?(gemfile)
|
110
|
+
# Create a default Gemfile that can be further customized by the user.
|
111
|
+
# Initial Gemfile only requires Origen. Nothing else. Essentially a blank installation.
|
112
|
+
Dir.chdir(install_dir) do
|
113
|
+
`bundle init`
|
114
|
+
end
|
115
|
+
# The above will give a general Gemfile from Bundler. We'll just append "gem 'origen' to the end.
|
116
|
+
File.open(gemfile, 'a') do |f|
|
117
|
+
f << "gem 'origen'\n"
|
118
|
+
end
|
119
|
+
end
|
120
|
+
ENV['BUNDLE_GEMFILE'] = gemfile
|
121
|
+
ENV['BUNDLE_PATH'] = File.expand_path(Origen.site_config.gem_install_dir)
|
122
|
+
ENV['BUNDLE_BIN'] = File.join(install_dir, 'lbin')
|
123
|
+
|
124
|
+
origen_exec = File.join(ENV['BUNDLE_BIN'], 'origen')
|
125
|
+
|
126
|
+
# If the user/tool bundle already exists but we have not been invoked through that, abort this thread
|
127
|
+
# and re-launch under the required bundler environment
|
128
|
+
if File.exist?(origen_exec) && !ENV['BUNDLE_BIN_PATH'] && File.exist?(ENV['BUNDLE_PATH'])
|
129
|
+
exec Gem.ruby, origen_exec, *ARGV
|
130
|
+
exit 0
|
131
|
+
else
|
132
|
+
boot_app = false
|
133
|
+
end
|
134
|
+
|
135
|
+
if File.exist?(ENV['BUNDLE_GEMFILE'])
|
136
|
+
# Overriding bundler here so that bundle install can be automated as required
|
137
|
+
require 'bundler/shared_helpers'
|
138
|
+
if Bundler::SharedHelpers.in_bundle?
|
139
|
+
require 'bundler'
|
140
|
+
if STDOUT.tty?
|
141
|
+
begin
|
142
|
+
fail OrigenBootError unless File.exist?(ENV['BUNDLE_BIN'])
|
143
|
+
Bundler.setup
|
144
|
+
fail OrigenBootError unless File.exist?(ENV['BUNDLE_BIN'])
|
145
|
+
rescue Gem::LoadError, Bundler::BundlerError, OrigenBootError => e
|
146
|
+
cmd = "bundle install --gemfile #{ENV['BUNDLE_GEMFILE']} --binstubs #{ENV['BUNDLE_BIN']} --path #{ENV['BUNDLE_PATH']}"
|
147
|
+
# puts cmd
|
148
|
+
puts 'Installing required gems...'
|
149
|
+
puts
|
150
|
+
`chmod o-w #{install_dir}` # Stops some annoying world writable warnings during install
|
151
|
+
`chmod o-w #{install_dir}/bin` if File.exist?("#{install_dir}/bin")
|
152
|
+
`chmod o-w #{install_dir}/.bin` if File.exist?("#{install_dir}/.bin")
|
153
|
+
result = false
|
154
|
+
|
155
|
+
Bundler.with_clean_env do
|
156
|
+
if Origen.os.unix?
|
157
|
+
if Origen.site_config.gem_build_switches
|
158
|
+
Origen.site_config.gem_build_switches.each do |switches|
|
159
|
+
`bundle config build.#{switches}`
|
160
|
+
end
|
161
|
+
end
|
162
|
+
end
|
163
|
+
result = system(cmd)
|
164
|
+
end
|
165
|
+
`chmod o-w #{ENV['BUNDLE_BIN']}`
|
166
|
+
# Make .bat versions of all executables, Bundler should really be doing this when running
|
167
|
+
# on windows
|
168
|
+
if Origen.os.windows?
|
169
|
+
bat_present = File.exist? "#{install_dir}/lbin/origen.bat"
|
170
|
+
Dir.glob("#{install_dir}/lbin/*").each do |bin|
|
171
|
+
unless bin =~ /.bat$/
|
172
|
+
bat = "#{bin}.bat"
|
173
|
+
unless File.exist?(bat)
|
174
|
+
File.open(bat, 'w') { |f| f.write('@"ruby.exe" "%~dpn0" %*') }
|
175
|
+
end
|
176
|
+
end
|
177
|
+
end
|
178
|
+
if !bat_present && !result
|
179
|
+
puts 'Some Windows specific updates to your workspace were required, please re-run the last command'
|
180
|
+
exit 0
|
181
|
+
end
|
182
|
+
end
|
183
|
+
if result
|
184
|
+
exec "origen #{ARGV.join(' ')}"
|
185
|
+
exit 0
|
186
|
+
else
|
187
|
+
puts
|
188
|
+
puts "If you have just updated a gem version and are now getting an error that Bundler cannot find compatible versions for it then first try running 'bundle update <gemname>'."
|
189
|
+
puts "For example if you have just changed the version of origen_core run 'bundle update origen_core'."
|
190
|
+
exit 1
|
191
|
+
end
|
192
|
+
end
|
193
|
+
else
|
194
|
+
Bundler.setup
|
195
|
+
end
|
196
|
+
end
|
197
|
+
require 'bundler/setup'
|
198
|
+
require 'origen'
|
199
|
+
else
|
200
|
+
$LOAD_PATH.unshift "#{File.expand_path(File.dirname(__FILE__))}/../lib"
|
201
|
+
require 'origen'
|
202
|
+
end
|
203
|
+
|
204
|
+
########################################################################################################################
|
205
|
+
########################################################################################################################
|
206
|
+
## We are running outside of an app and no-special global Origen tool setup is present
|
207
|
+
########################################################################################################################
|
208
|
+
########################################################################################################################
|
209
|
+
else
|
210
|
+
$LOAD_PATH.unshift "#{File.expand_path(File.dirname(__FILE__))}/../lib"
|
211
|
+
require 'origen'
|
212
|
+
end
|
213
|
+
|
214
|
+
########################################################################################################################
|
215
|
+
########################################################################################################################
|
216
|
+
|
217
|
+
begin
|
218
|
+
# Now that the runtime Origen version is loaded, we need to re-load the site config.
|
219
|
+
# This is because the version of the site_config that was originally loaded above has instantiated
|
220
|
+
# a site_config object, whereas earlier versions of Origen (which could now be loaded), instantiated
|
221
|
+
# a simple hash instead.
|
222
|
+
# Reloading now will ensure consistency between the site config object and the version of
|
223
|
+
# Origen that is now live.
|
224
|
+
Origen.instance_variable_set(:@site_config, nil)
|
225
|
+
load 'origen/site_config.rb'
|
226
|
+
require 'colored'
|
227
|
+
# Emit all broadcast messages before executing all commands
|
228
|
+
if Origen.site_config.broadcast_info
|
229
|
+
puts
|
230
|
+
Array(Origen.site_config.broadcast_info).each { |line| puts line }
|
231
|
+
puts
|
232
|
+
end
|
233
|
+
if Origen.site_config.broadcast_warning
|
234
|
+
puts
|
235
|
+
Array(Origen.site_config.broadcast_warning).each { |line| puts line.yellow }
|
236
|
+
puts
|
237
|
+
end
|
238
|
+
if Origen.site_config.broadcast_danger
|
239
|
+
puts
|
240
|
+
Array(Origen.site_config.broadcast_danger).each { |line| puts line.red }
|
241
|
+
puts
|
242
|
+
end
|
243
|
+
if Origen.site_config.broadcast_success
|
244
|
+
puts
|
245
|
+
Array(Origen.site_config.broadcast_success).each { |line| puts line.green }
|
246
|
+
puts
|
247
|
+
end
|
248
|
+
|
249
|
+
# If this script has been invoked from within an Origen application then open
|
250
|
+
# up all commands, if not then only allow the command to create a new Origen
|
251
|
+
# application.
|
252
|
+
if origen_root && boot_app
|
253
|
+
puts warnings if warnings && Origen.version >= '0.40.0'
|
254
|
+
require 'origen/commands'
|
255
|
+
else
|
256
|
+
require 'origen/commands_global'
|
257
|
+
end
|
258
|
+
rescue Exception => e
|
259
|
+
# A formatted stack dump will not be printed if the application ends via 'exit 0' or 'exit 1'. In that
|
260
|
+
# case the application code is responsible for printing a helpful error message.
|
261
|
+
# This will intercept all other exits, e.g. via 'fail "Something has done wrong"', and split the stack
|
262
|
+
# dump to separate all in-application references from Origen core/plugin references.
|
263
|
+
if e.is_a?(SystemExit)
|
264
|
+
exit e.status
|
265
|
+
else
|
266
|
+
puts
|
267
|
+
if Origen.app_loaded?
|
268
|
+
puts 'COMPLETE CALL STACK'
|
269
|
+
puts '-------------------'
|
270
|
+
puts e.message unless e.is_a?(SystemExit)
|
271
|
+
puts e.backtrace
|
272
|
+
|
273
|
+
puts
|
274
|
+
puts 'APPLICATION CALL STACK'
|
275
|
+
puts '----------------------'
|
276
|
+
puts e.message unless e.is_a?(SystemExit)
|
277
|
+
# Only print out the application stack trace by default, if verbose logging is
|
278
|
+
# enabled then output the full thing
|
279
|
+
e.backtrace.each do |line|
|
280
|
+
path = Pathname.new(line)
|
281
|
+
if path.absolute?
|
282
|
+
if line =~ /^#{Origen.root}/ && line !~ /^#{Origen.root}\/lbin/
|
283
|
+
puts line
|
284
|
+
end
|
285
|
+
else
|
286
|
+
puts line unless line =~ /^.\/lbin/
|
287
|
+
end
|
288
|
+
end
|
289
|
+
else
|
290
|
+
puts 'COMPLETE CALL STACK'
|
291
|
+
puts '-------------------'
|
292
|
+
puts e.message unless e.is_a?(SystemExit)
|
293
|
+
puts e.backtrace
|
294
|
+
end
|
295
|
+
exit 1
|
296
|
+
end
|
297
|
+
ensure
|
298
|
+
if Origen.app_loaded?
|
299
|
+
Origen.app.listeners_for(:on_origen_shutdown).each(&:on_origen_shutdown)
|
300
|
+
Origen.app.runner.shutdown
|
301
|
+
end
|
302
|
+
end
|