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/log.rb
CHANGED
@@ -9,33 +9,24 @@ module Origen
|
|
9
9
|
# log.deprecate "Blah" # Deprecate message, always shown
|
10
10
|
class Log
|
11
11
|
require 'colored'
|
12
|
-
require '
|
13
|
-
require 'log4r/outputter/fileoutputter'
|
14
|
-
|
15
|
-
attr_accessor :msg_hash
|
16
|
-
alias_method :messages, :msg_hash
|
12
|
+
require 'logger'
|
17
13
|
|
18
14
|
LEVELS = [:normal, :verbose, :silent]
|
19
15
|
|
20
16
|
def initialize
|
21
17
|
@log_time_0 = @t0 = Time.new
|
22
18
|
self.level = :normal
|
23
|
-
@
|
19
|
+
@custom_logs = {}
|
20
|
+
@interceptors = {}
|
24
21
|
end
|
25
22
|
|
26
|
-
def
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
h[k] = []
|
32
|
-
end
|
23
|
+
def console_only?(options = {})
|
24
|
+
if options.key?(:console_only)
|
25
|
+
option = options[:console_only]
|
26
|
+
else
|
27
|
+
option = self.class.console_only?
|
33
28
|
end
|
34
|
-
|
35
|
-
end
|
36
|
-
|
37
|
-
def console_only?
|
38
|
-
self.class.console_only? || !Origen.app || Origen.running_globally?
|
29
|
+
option || !Origen.app || Origen.running_globally?
|
39
30
|
end
|
40
31
|
|
41
32
|
# Anything executed within the given block will log to the console only
|
@@ -69,16 +60,16 @@ module Origen
|
|
69
60
|
case val
|
70
61
|
when :normal
|
71
62
|
# Output everything except debug statements
|
72
|
-
console.level =
|
63
|
+
console.level = Logger::INFO
|
73
64
|
# Output everything
|
74
|
-
log_files
|
65
|
+
log_files(:level=, Logger::DEBUG) unless console_only?
|
75
66
|
when :verbose
|
76
|
-
console.level =
|
77
|
-
log_files
|
67
|
+
console.level = Logger::DEBUG
|
68
|
+
log_files(:level=, Logger::DEBUG) unless console_only?
|
78
69
|
when :silent
|
79
70
|
# We don't use any fatal messages, so this is effectively OFF
|
80
|
-
console.level =
|
81
|
-
log_files
|
71
|
+
console.level = Logger::FATAL
|
72
|
+
log_files(:level=, Logger::DEBUG) unless console_only?
|
82
73
|
end
|
83
74
|
|
84
75
|
@level = val
|
@@ -89,78 +80,106 @@ module Origen
|
|
89
80
|
@level
|
90
81
|
end
|
91
82
|
|
92
|
-
|
93
|
-
|
94
|
-
|
83
|
+
# @api private
|
84
|
+
#
|
85
|
+
# @example of an interceptor:
|
86
|
+
#
|
87
|
+
# # An interceptor ID is returned, this should be given to stop_intercepting
|
88
|
+
# @log_intercept_id = Origen.log.start_intercepting do |msg, type, options, original|
|
89
|
+
# if some_condition_is_true?
|
90
|
+
# # Handling it ourselves
|
91
|
+
# my_method(msg, type)
|
92
|
+
# else
|
93
|
+
# # Call the original Origen.log method (or the next interceptor in line)
|
94
|
+
# original.call(msg, type, options)
|
95
|
+
# end
|
96
|
+
# end
|
97
|
+
def start_intercepting(&block)
|
98
|
+
id = block.object_id
|
99
|
+
@interceptors[id] = block
|
100
|
+
id
|
95
101
|
end
|
96
102
|
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
log_files.debug msg unless console_only?
|
101
|
-
console.debug msg
|
102
|
-
@msg_hash[:debug][msg_type] << msg
|
103
|
-
nil
|
103
|
+
# @api private
|
104
|
+
def stop_intercepting(id)
|
105
|
+
@interceptors.delete(id)
|
104
106
|
end
|
105
107
|
|
106
|
-
def
|
107
|
-
string,
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
108
|
+
def debug(string = '', options = {})
|
109
|
+
string, options = sanitize_args(string, options)
|
110
|
+
PatSeq.add_thread(string) unless options[:no_thread_id]
|
111
|
+
intercept(string, :debug, options) do |msg, type, options|
|
112
|
+
msg = format_msg('DEBUG', msg)
|
113
|
+
log_files(:debug, msg) unless console_only?(options)
|
114
|
+
console.debug msg
|
115
|
+
nil
|
116
|
+
end
|
117
|
+
end
|
118
|
+
|
119
|
+
def info(string = '', options = {})
|
120
|
+
string, options = sanitize_args(string, options)
|
121
|
+
PatSeq.add_thread(string) unless options[:no_thread_id]
|
122
|
+
intercept(string, :info, options) do |msg, type, options|
|
123
|
+
msg = format_msg('INFO', msg)
|
124
|
+
log_files(:info, msg) unless console_only?(options)
|
125
|
+
console.info msg
|
126
|
+
nil
|
127
|
+
end
|
113
128
|
end
|
114
129
|
# Legacy methods
|
115
130
|
alias_method :lputs, :info
|
116
131
|
alias_method :lprint, :info
|
117
132
|
|
118
|
-
def success(string = '',
|
119
|
-
string,
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
133
|
+
def success(string = '', options = {})
|
134
|
+
string, options = sanitize_args(string, options)
|
135
|
+
PatSeq.add_thread(string) unless options[:no_thread_id]
|
136
|
+
intercept(string, :success, options) do |msg, type, options|
|
137
|
+
msg = format_msg('SUCCESS', msg)
|
138
|
+
log_files(:info, msg) unless console_only?(options)
|
139
|
+
console.info color_unless_remote(msg, :green)
|
140
|
+
nil
|
141
|
+
end
|
125
142
|
end
|
126
143
|
|
127
|
-
def deprecate(string = '',
|
128
|
-
string,
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
144
|
+
def deprecate(string = '', options = {})
|
145
|
+
string, options = sanitize_args(string, options)
|
146
|
+
PatSeq.add_thread(string) unless options[:no_thread_id]
|
147
|
+
intercept(string, :deprecate, options) do |msg, type, options|
|
148
|
+
msg = format_msg('DEPRECATED', msg)
|
149
|
+
log_files(:warn, msg) unless console_only?(options)
|
150
|
+
console.warn color_unless_remote(msg, :yellow)
|
151
|
+
nil
|
152
|
+
end
|
134
153
|
end
|
135
154
|
alias_method :deprecated, :deprecate
|
136
155
|
|
137
|
-
def warn(string = '',
|
138
|
-
string,
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
156
|
+
def warn(string = '', options = {})
|
157
|
+
string, options = sanitize_args(string, options)
|
158
|
+
PatSeq.add_thread(string) unless options[:no_thread_id]
|
159
|
+
intercept(string, :warn, options) do |msg, type, options|
|
160
|
+
msg = format_msg('WARNING', msg)
|
161
|
+
log_files(:warn, msg) unless console_only?(options)
|
162
|
+
console.warn color_unless_remote(msg, :yellow)
|
163
|
+
nil
|
164
|
+
end
|
144
165
|
end
|
145
166
|
alias_method :warning, :warn
|
146
167
|
|
147
|
-
def error(string = '',
|
148
|
-
string,
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
168
|
+
def error(string = '', options = {})
|
169
|
+
string, options = sanitize_args(string, options)
|
170
|
+
PatSeq.add_thread(string) unless options[:no_thread_id]
|
171
|
+
intercept(string, :error, options) do |msg, type, options|
|
172
|
+
msg = format_msg('ERROR', msg)
|
173
|
+
log_files(:error, msg) unless console_only?(options)
|
174
|
+
console.error color_unless_remote(msg, :red)
|
175
|
+
nil
|
176
|
+
end
|
154
177
|
end
|
155
178
|
|
156
179
|
# Made these all class methods so that they can be read without
|
157
180
|
# instantiating a new logger (mainly for use by the origen save command)
|
158
181
|
def self.log_file
|
159
|
-
|
160
|
-
end
|
161
|
-
|
162
|
-
def self.rolling_log_file
|
163
|
-
"#{log_file_directory}/rolling.txt"
|
182
|
+
File.join(log_file_directory, 'last.txt')
|
164
183
|
end
|
165
184
|
|
166
185
|
def self.log_file_directory
|
@@ -179,42 +198,169 @@ module Origen
|
|
179
198
|
level == :verbose
|
180
199
|
end
|
181
200
|
|
182
|
-
# Force logger to write any buffered output
|
201
|
+
# Force the logger to write any buffered output to the log files
|
183
202
|
def flush
|
184
|
-
|
185
|
-
|
203
|
+
@open_logs.each do |logger, file|
|
204
|
+
file.flush
|
186
205
|
end
|
187
|
-
|
206
|
+
nil
|
188
207
|
end
|
189
208
|
|
190
|
-
|
209
|
+
# Mainly intended for testing the logger, this will return the log level to the default (:normal)
|
210
|
+
# and close all log files, such that any further logging will be done to a new file(s)
|
211
|
+
def reset
|
212
|
+
self.level = :normal
|
213
|
+
flush
|
214
|
+
close_log(@last_file)
|
215
|
+
@last_file = nil
|
216
|
+
close_log(@job_file)
|
217
|
+
@job_file = nil
|
218
|
+
@custom_logs.each do |name, log|
|
219
|
+
close_log(log)
|
220
|
+
end
|
221
|
+
@custom_logs = {}
|
222
|
+
end
|
191
223
|
|
192
|
-
#
|
193
|
-
def
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
|
202
|
-
|
203
|
-
|
204
|
-
|
205
|
-
|
206
|
-
|
207
|
-
|
208
|
-
|
209
|
-
|
210
|
-
|
211
|
-
|
224
|
+
# @api private
|
225
|
+
def start_job(name, type)
|
226
|
+
dir = File.join(Origen.config.log_directory, type.to_s)
|
227
|
+
if target = Origen.try(:target).try(:name)
|
228
|
+
dir = File.join(dir, target)
|
229
|
+
end
|
230
|
+
if env = Origen.try(:environment).try(:name)
|
231
|
+
dir = File.join(dir, env)
|
232
|
+
end
|
233
|
+
FileUtils.mkdir_p dir unless File.exist?(dir)
|
234
|
+
@@job_file_paths = {} unless defined?(@@job_file_paths)
|
235
|
+
# Make sure the log name is unique in this run, duplication and overwrite can occur in cases where
|
236
|
+
# a pattern is run multiple times during a simulation
|
237
|
+
@job_file_path = File.join(dir, "#{name}.txt")
|
238
|
+
if n = @@job_file_paths[@job_file_path]
|
239
|
+
@@job_file_paths[@job_file_path] += 1
|
240
|
+
@job_file_path = File.join(dir, "#{name}_#{n}.txt")
|
241
|
+
else
|
242
|
+
@@job_file_paths[@job_file_path] = 1
|
243
|
+
end
|
244
|
+
FileUtils.rm_f(@job_file_path) if File.exist?(@job_file_path)
|
245
|
+
@job_file = open_log(@job_file_path)
|
246
|
+
end
|
247
|
+
|
248
|
+
# @api private
|
249
|
+
def stop_job
|
250
|
+
if @job_file
|
251
|
+
if tester && tester.respond_to?(:log_file_written)
|
252
|
+
tester.log_file_written @job_file_path
|
253
|
+
else
|
254
|
+
Origen.log.info "Log file written to: #{@job_file_path}"
|
255
|
+
end
|
256
|
+
flush
|
257
|
+
close_log(@job_file)
|
258
|
+
@job_file = nil
|
259
|
+
end
|
260
|
+
end
|
261
|
+
|
262
|
+
def method_missing(method, *args, &block)
|
263
|
+
@custom_logs[method.to_sym] ||= begin
|
264
|
+
log_file = File.join(Log.log_file_directory, "#{method}.txt")
|
212
265
|
unless Origen.running_remotely?
|
213
|
-
|
214
|
-
rolling_file.formatter = format
|
215
|
-
log_files.outputters << rolling_file
|
266
|
+
FileUtils.mv log_file, "#{log_file}.old" if File.exist?(log_file)
|
216
267
|
end
|
217
|
-
|
268
|
+
open_log(log_file)
|
269
|
+
end
|
270
|
+
msg = args.shift
|
271
|
+
options = args.shift || {}
|
272
|
+
if options.key?(:format) && !options[:format]
|
273
|
+
msg = "#{msg}\n"
|
274
|
+
else
|
275
|
+
msg = format_msg(method.to_s.upcase, msg)
|
276
|
+
end
|
277
|
+
@custom_logs[method.to_sym].info(msg)
|
278
|
+
end
|
279
|
+
|
280
|
+
private
|
281
|
+
|
282
|
+
def intercept(msg, type, options, &block)
|
283
|
+
if @interceptors.size > 0
|
284
|
+
call_interceptor(@interceptors.values, msg, type, options, &block)
|
285
|
+
else
|
286
|
+
yield(msg, type, options)
|
287
|
+
end
|
288
|
+
end
|
289
|
+
|
290
|
+
def call_interceptor(interceptors, msg, type, options, &original)
|
291
|
+
interceptor = interceptors.shift
|
292
|
+
if interceptors.empty?
|
293
|
+
func = -> (msg, type, options) { original.call(msg, type, options) }
|
294
|
+
else
|
295
|
+
func = -> (msg, type, options) { call_interceptor(interceptors, msg, type, options, &original) }
|
296
|
+
end
|
297
|
+
interceptor.call(msg, type, options, func)
|
298
|
+
end
|
299
|
+
|
300
|
+
def sanitize_args(*args)
|
301
|
+
message = ''
|
302
|
+
options = {}
|
303
|
+
args.each do |arg|
|
304
|
+
if arg.is_a?(String)
|
305
|
+
message = arg
|
306
|
+
elsif arg.is_a?(Hash)
|
307
|
+
options = arg
|
308
|
+
end
|
309
|
+
end
|
310
|
+
[message, options]
|
311
|
+
end
|
312
|
+
|
313
|
+
# When running on an LSF client, the console log output is captured to a file. Color codings in files just
|
314
|
+
# add noise, so inhibit them in this case since it is not providing any visual benefit to the user
|
315
|
+
def color_unless_remote(msg, color)
|
316
|
+
if Origen.running_remotely?
|
317
|
+
msg
|
318
|
+
else
|
319
|
+
msg.send(color)
|
320
|
+
end
|
321
|
+
end
|
322
|
+
|
323
|
+
# Returns a logger instance that will send to the console
|
324
|
+
def console
|
325
|
+
@console ||= open_log(STDOUT)
|
326
|
+
end
|
327
|
+
|
328
|
+
# Returns a logger instance that will send to the log/last.txt file
|
329
|
+
def last_file
|
330
|
+
@last_file ||= begin
|
331
|
+
# Preserve one prior version of the log file
|
332
|
+
FileUtils.mv Log.log_file, "#{Log.log_file}.old" if File.exist?(Log.log_file)
|
333
|
+
open_log(Log.log_file)
|
334
|
+
end
|
335
|
+
end
|
336
|
+
|
337
|
+
# Sends the given method and arguments to all file logger instances
|
338
|
+
def log_files(method, *args)
|
339
|
+
# When running remotely on an LSF client, the LSF manager will capture STDOUT (i.e. the console log output)
|
340
|
+
# and save it to a log file.
|
341
|
+
# Don't write to the last log file in that case because we would have multiple processes all vying to
|
342
|
+
# write to it at the same time.
|
343
|
+
last_file.send(method, *args) unless Origen.running_remotely?
|
344
|
+
@job_file.send(method, *args) if @job_file
|
345
|
+
end
|
346
|
+
|
347
|
+
def open_log(file)
|
348
|
+
@open_logs ||= {}
|
349
|
+
unless file.class == IO
|
350
|
+
file = File.open(file, 'w+')
|
351
|
+
end
|
352
|
+
l = Logger.new(file)
|
353
|
+
l.formatter = proc do |severity, dateime, progname, msg|
|
354
|
+
msg
|
355
|
+
end
|
356
|
+
@open_logs[l] = file
|
357
|
+
l
|
358
|
+
end
|
359
|
+
|
360
|
+
def close_log(logger)
|
361
|
+
if logger
|
362
|
+
@open_logs.delete(logger)
|
363
|
+
logger.close
|
218
364
|
end
|
219
365
|
end
|
220
366
|
|
@@ -237,13 +383,9 @@ module Origen
|
|
237
383
|
delta_t = '%0.3f' % delta_t
|
238
384
|
delta_t0 = (log_time_1.to_f - @t0.to_f).round(6)
|
239
385
|
delta_t0 = '%0.3f' % delta_t0
|
240
|
-
msg = "[#{type}]".ljust(13) + "#{delta_t0}[#{delta_t}]".ljust(16) + "|| #{msg}"
|
386
|
+
msg = "[#{type}]".ljust(13) + "#{delta_t0}[#{delta_t}]".ljust(16) + "|| #{msg}\n"
|
241
387
|
@log_time_0 = log_time_1
|
242
388
|
msg
|
243
389
|
end
|
244
|
-
|
245
|
-
def format
|
246
|
-
Log4r::PatternFormatter.new(pattern: '%m')
|
247
|
-
end
|
248
390
|
end
|
249
391
|
end
|
data/lib/origen/model.rb
CHANGED
@@ -43,6 +43,12 @@ module Origen
|
|
43
43
|
end
|
44
44
|
end
|
45
45
|
|
46
|
+
# Returns a frozen hash containing any attributes that were
|
47
|
+
# derived from a block definition
|
48
|
+
def attributes
|
49
|
+
@attributes ||= {}.freeze
|
50
|
+
end
|
51
|
+
|
46
52
|
def inspect
|
47
53
|
if controller
|
48
54
|
"<Model/Controller: #{self.class}:#{object_id}/#{controller.class}:#{controller.object_id}>"
|
@@ -63,7 +69,7 @@ module Origen
|
|
63
69
|
|
64
70
|
# Returns true if the model is the current DUT/top-level model
|
65
71
|
def is_top_level?
|
66
|
-
|
72
|
+
respond_to?(:includes_origen_top_level?)
|
67
73
|
end
|
68
74
|
alias_method :is_dut?, :is_top_level?
|
69
75
|
alias_method :top_level?, :is_top_level?
|
@@ -75,6 +81,21 @@ module Origen
|
|
75
81
|
self
|
76
82
|
end
|
77
83
|
|
84
|
+
# Returns the application instance that defines the model, often the current app but it could
|
85
|
+
# also be one of the plugins.
|
86
|
+
# Returns nil if the application cannot be resolved, usually because the model's class has
|
87
|
+
# not been correctly namespaced.
|
88
|
+
def app
|
89
|
+
@app ||= Origen::Application.from_namespace(self.class.to_s)
|
90
|
+
end
|
91
|
+
|
92
|
+
# Load the block definitions from the given path to the model.
|
93
|
+
# Returns true if a block is found and loaded, otherwise nil.
|
94
|
+
def load_block(path, options = {})
|
95
|
+
options[:path] = path
|
96
|
+
Origen::Loader.load_block(self, options)
|
97
|
+
end
|
98
|
+
|
78
99
|
def ==(obj)
|
79
100
|
if obj.is_a?(Origen::SubBlocks::Placeholder)
|
80
101
|
obj = obj.materialize
|