origen 0.3.0 → 0.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/config/version.rb +1 -1
- data/lib/origen.rb +528 -524
- data/lib/origen/application.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: cdf7248a1c3000a7ea31e2721bf61b28693c9222
|
4
|
+
data.tar.gz: b264bd5d9bd97000e7a8d33d5231c90b858caad9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 38b82c90dbba93819b9ea1aa8a02b383101e81a1e620fb54f388fdb64b26e8fc3674a00e73f6d57ae0a774aa133aa38fec2b80917ad7af80a7756214ee8c4a36
|
7
|
+
data.tar.gz: 3aaedb9dcfb7f5c9dea81c494955bf5ed0c192c1eaa10d3d5212c3d3cab7791e6c6bed88c7ca6769a1bb91dea5f4c58504ce950bac38e440651ba39371f1db43
|
data/config/version.rb
CHANGED
data/lib/origen.rb
CHANGED
@@ -1,632 +1,636 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
require '
|
10
|
-
require 'origen/
|
11
|
-
require 'origen/
|
12
|
-
require 'origen/
|
13
|
-
require 'origen/
|
14
|
-
require 'origen/
|
15
|
-
require 'origen/
|
16
|
-
require 'origen/
|
17
|
-
require 'origen/
|
18
|
-
require 'origen/
|
19
|
-
require '
|
20
|
-
require '
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
1
|
+
# This guard is temporary to help Freescale transition to Origen from
|
2
|
+
# our original internal version (RGen)
|
3
|
+
unless defined? RGen::ORIGENTRANSITION
|
4
|
+
require 'English'
|
5
|
+
require 'pathname'
|
6
|
+
# Keep a note of the pwd at the time when Origen was first loaded, this is initially used
|
7
|
+
# by the site_config lookup.
|
8
|
+
$_origen_invocation_pwd ||= Pathname.pwd
|
9
|
+
require 'fileutils'
|
10
|
+
require 'origen/site_config'
|
11
|
+
require 'origen/operating_systems'
|
12
|
+
require 'origen/core_ext'
|
13
|
+
require 'origen/acronyms'
|
14
|
+
require 'origen/callbacks'
|
15
|
+
require 'origen/top_level'
|
16
|
+
require 'origen/model'
|
17
|
+
require 'origen/ruby_version_check'
|
18
|
+
require 'origen/application'
|
19
|
+
require 'origen/remote_manager'
|
20
|
+
require 'origen/utility'
|
21
|
+
require 'origen/logger_methods'
|
22
|
+
require 'option_parser/optparse'
|
23
|
+
require 'bundler'
|
24
|
+
|
25
|
+
module Origen
|
26
|
+
autoload :Features, 'origen/features'
|
27
|
+
autoload :Bugs, 'origen/bugs'
|
28
|
+
autoload :Generator, 'origen/generator'
|
29
|
+
autoload :Pins, 'origen/pins'
|
30
|
+
autoload :Registers, 'origen/registers'
|
31
|
+
autoload :Users, 'origen/users'
|
32
|
+
autoload :FileHandler, 'origen/file_handler'
|
33
|
+
autoload :RegressionManager, 'origen/regression_manager'
|
34
|
+
autoload :Location, 'origen/location'
|
35
|
+
autoload :VersionString, 'origen/version_string'
|
36
|
+
autoload :Mode, 'origen/mode'
|
37
|
+
autoload :ChipMode, 'origen/chip_mode'
|
38
|
+
autoload :ChipPackage, 'origen/chip_package'
|
39
|
+
autoload :Client, 'origen/client'
|
40
|
+
autoload :SubBlocks, 'origen/sub_blocks'
|
41
|
+
autoload :SubBlock, 'origen/sub_blocks'
|
42
|
+
autoload :ModelInitializer, 'origen/model_initializer'
|
43
|
+
autoload :Controller, 'origen/controller'
|
44
|
+
autoload :Database, 'origen/database'
|
45
|
+
autoload :Parameters, 'origen/parameters'
|
46
|
+
autoload :RevisionControl, 'origen/revision_control'
|
47
|
+
autoload :Specs, 'origen/specs'
|
48
|
+
autoload :CodeGenerators, 'origen/code_generators'
|
49
|
+
autoload :Encodings, 'origen/encodings'
|
50
|
+
autoload :Log, 'origen/log'
|
51
|
+
autoload :Chips, 'origen/chips'
|
52
|
+
|
53
|
+
APP_CONFIG = File.join('config', 'application.rb')
|
54
|
+
|
55
|
+
class OrigenError < StandardError
|
56
|
+
def self.status_code(code)
|
57
|
+
define_method(:status_code) { code }
|
58
|
+
end
|
55
59
|
end
|
56
|
-
end
|
57
60
|
|
58
|
-
|
59
|
-
|
61
|
+
class GitError < OrigenError; status_code(11); end
|
62
|
+
class DesignSyncError < OrigenError; status_code(12); end
|
60
63
|
|
61
|
-
|
62
|
-
|
64
|
+
class << self
|
65
|
+
include Origen::Utility::TimeAndDate
|
63
66
|
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
+
def enable_profiling
|
68
|
+
@profiling = true
|
69
|
+
end
|
67
70
|
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
+
def disable_profiling
|
72
|
+
@profiling = false
|
73
|
+
end
|
71
74
|
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
75
|
+
def profile(message)
|
76
|
+
if @profiling
|
77
|
+
caller[0] =~ /.*\/(\w+\.rb):(\d+).*/
|
78
|
+
if block_given?
|
79
|
+
start = Time.now
|
80
|
+
yield
|
81
|
+
duration_in_ms = ((Time.now - start) * 1000).round
|
82
|
+
puts "#{duration_in_ms}ms".ljust(10) + "#{Regexp.last_match[1]}:#{Regexp.last_match[2]} '#{message}'"
|
83
|
+
else
|
84
|
+
puts "#{Time.now} - #{Regexp.last_match[1]}:#{Regexp.last_match[2]} #{message}"
|
85
|
+
end
|
80
86
|
else
|
81
|
-
|
87
|
+
yield if block_given?
|
82
88
|
end
|
83
|
-
else
|
84
|
-
yield if block_given?
|
85
89
|
end
|
86
|
-
end
|
87
90
|
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
91
|
+
def register_application(app)
|
92
|
+
_applications_lookup[:name][app.name] = app
|
93
|
+
_applications_lookup[:root][app.root.to_s] = app
|
94
|
+
@plugins = nil
|
95
|
+
end
|
93
96
|
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
97
|
+
def plugins
|
98
|
+
Origen.deprecate 'Origen.plugins is deprecated, use Origen.app.plugins instead'
|
99
|
+
Origen.app.plugins
|
100
|
+
end
|
98
101
|
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
+
def app_loaded?
|
103
|
+
@application_loaded
|
104
|
+
end
|
102
105
|
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
106
|
+
# Returns the current (top-level) application instance
|
107
|
+
def app(plugin = nil, _options = {})
|
108
|
+
plugin, options = nil, plugin if plugin.is_a?(Hash)
|
109
|
+
if plugin
|
110
|
+
load_application
|
111
|
+
app = _applications_lookup[:name][plugin.to_sym]
|
112
|
+
if app
|
113
|
+
app
|
114
|
+
else
|
115
|
+
puts "Couldn't find application instance called #{plugin}, known names are:"
|
116
|
+
puts " #{_applications_lookup[:name].keys.join(', ')}"
|
117
|
+
puts
|
118
|
+
fail 'Origen.root lookup error!'
|
119
|
+
end
|
111
120
|
else
|
112
|
-
|
113
|
-
puts " #{_applications_lookup[:name].keys.join(', ')}"
|
114
|
-
puts
|
115
|
-
fail 'Origen.root lookup error!'
|
121
|
+
load_application
|
116
122
|
end
|
117
|
-
else
|
118
|
-
load_application
|
119
123
|
end
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
124
|
+
alias_method :application, :app
|
125
|
+
|
126
|
+
# Equivalent to application except that if called from code in a plugin this
|
127
|
+
# will return that plugin's application instance
|
128
|
+
def app!
|
129
|
+
file = caller[0]
|
130
|
+
path = @current_source_dir || Pathname.new(file).dirname
|
131
|
+
until File.exist?(File.join(path, APP_CONFIG)) || path.root?
|
132
|
+
path = path.parent
|
133
|
+
end
|
134
|
+
if path.root?
|
135
|
+
fail "Something went wrong resoving Origen.app! from: #{caller[0]}"
|
136
|
+
end
|
137
|
+
find_app_by_root(path)
|
133
138
|
end
|
134
|
-
|
135
|
-
end
|
136
|
-
alias_method :application!, :app!
|
139
|
+
alias_method :application!, :app!
|
137
140
|
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
141
|
+
# @api private
|
142
|
+
def with_source_file(file)
|
143
|
+
@current_source_dir = Pathname.new(file).dirname
|
144
|
+
yield
|
145
|
+
@current_source_dir = nil
|
146
|
+
end
|
144
147
|
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
148
|
+
# Validates that when the current app is OrigenCore then the
|
149
|
+
# origen executable is coming from the same workspace
|
150
|
+
#
|
151
|
+
# @api private
|
152
|
+
def validate_origen_dev_configuration!
|
153
|
+
if Origen.app.name == :origen_core
|
154
|
+
if Origen.root != Origen.top
|
155
|
+
puts 'It looks like you are trying to develop Origen core, but you are running an Origen'
|
156
|
+
puts 'executable from another workspace!'
|
157
|
+
if Origen.running_on_windows?
|
158
|
+
puts 'To resolve this error you must add the following directory to your Windows PATH:'
|
159
|
+
puts " #{Origen.root}\\bin"
|
160
|
+
else
|
161
|
+
puts 'To resolve this error run:'
|
162
|
+
puts " cd #{Origen.root}"
|
163
|
+
puts ' source source_setup'
|
164
|
+
end
|
165
|
+
exit 1
|
161
166
|
end
|
162
|
-
exit 1
|
163
167
|
end
|
164
168
|
end
|
165
|
-
end
|
166
169
|
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
170
|
+
# @api private
|
171
|
+
def _applications_lookup
|
172
|
+
@_applications_lookup ||= { name: {}, root: {} }
|
173
|
+
end
|
171
174
|
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
175
|
+
# Returns an instance of Origen::Users::LDAP which provides
|
176
|
+
# methods to query and authorize users against a company's LDAP-based employee directory
|
177
|
+
def ldap
|
178
|
+
@ldap ||= Origen::Users::LDAP.new
|
179
|
+
end
|
177
180
|
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
|
181
|
+
# Return the application instance from the given path
|
182
|
+
# to an Origen application workspace, i.e. Origen.app conventionally
|
183
|
+
# returns the current application instance, this method returns the
|
184
|
+
# same thing that would be returned from the given remote workspace.
|
185
|
+
#
|
186
|
+
# @api private
|
187
|
+
def find_app_by_root(path_to_origen_root, options = {})
|
188
|
+
app = _applications_lookup[:root][Pathname.new(path_to_origen_root).realpath.to_s]
|
189
|
+
if !app || options[:reload]
|
190
|
+
# If the application is already defined then un-define it, this is to allow it to
|
191
|
+
# be reloaded.
|
192
|
+
# This option feels like it doesn't belong here, but is part of the legacy import
|
193
|
+
# require system. When that has been removed in future so can this reload system, under
|
194
|
+
# bundler app versions will be resolved before loading them so there will be no need
|
195
|
+
# for this
|
196
|
+
if app
|
197
|
+
begin
|
198
|
+
Object.send(:remove_const, app.class.to_s)
|
199
|
+
rescue
|
200
|
+
# Nothing to do here
|
201
|
+
end
|
198
202
|
end
|
203
|
+
require File.join(path_to_origen_root, APP_CONFIG)
|
204
|
+
app = _applications_lookup[:root][Pathname.new(path_to_origen_root).realpath.to_s]
|
199
205
|
end
|
200
|
-
|
201
|
-
|
202
|
-
|
203
|
-
|
204
|
-
|
205
|
-
|
206
|
-
|
206
|
+
return app if app
|
207
|
+
puts "Couldn't find application instance with root #{path_to_origen_root}, known roots are:"
|
208
|
+
_applications_lookup[:root].keys.each do |key|
|
209
|
+
puts " #{key}"
|
210
|
+
end
|
211
|
+
puts
|
212
|
+
fail 'Application lookup error!'
|
207
213
|
end
|
208
|
-
|
209
|
-
|
210
|
-
end
|
211
|
-
alias_method :application_instance, :find_app_by_root
|
212
|
-
alias_method :app_instance, :find_app_by_root
|
214
|
+
alias_method :application_instance, :find_app_by_root
|
215
|
+
alias_method :app_instance, :find_app_by_root
|
213
216
|
|
214
|
-
|
215
|
-
|
216
|
-
|
217
|
+
def command_dispatcher
|
218
|
+
@command_dispatcher ||= Application::CommandDispatcher.new
|
219
|
+
end
|
217
220
|
|
218
|
-
|
219
|
-
|
220
|
-
|
221
|
-
|
221
|
+
def configuration
|
222
|
+
app.config
|
223
|
+
end
|
224
|
+
alias_method :config, :configuration
|
222
225
|
|
223
|
-
|
224
|
-
|
225
|
-
|
226
|
+
def mailer
|
227
|
+
application.mailer
|
228
|
+
end
|
226
229
|
|
227
|
-
|
228
|
-
|
229
|
-
|
230
|
+
def target
|
231
|
+
application.target
|
232
|
+
end
|
230
233
|
|
231
|
-
|
232
|
-
|
233
|
-
|
234
|
-
|
235
|
-
|
234
|
+
def load_target(t, options = {})
|
235
|
+
target.temporary = t
|
236
|
+
application.load_target!(options)
|
237
|
+
application.runner.prepare_and_validate_workspace
|
238
|
+
end
|
236
239
|
|
237
|
-
|
238
|
-
|
239
|
-
|
240
|
+
def environment
|
241
|
+
application.environment
|
242
|
+
end
|
240
243
|
|
241
|
-
|
242
|
-
|
243
|
-
|
244
|
-
|
245
|
-
|
244
|
+
# Returns true if Origen is running in an application workspace
|
245
|
+
def in_app_workspace?
|
246
|
+
path = Pathname.new(Dir.pwd)
|
247
|
+
until path.root? || File.exist?(File.join(path, APP_CONFIG))
|
248
|
+
path = path.parent
|
249
|
+
end
|
250
|
+
!path.root?
|
246
251
|
end
|
247
|
-
!path.root?
|
248
|
-
end
|
249
252
|
|
250
|
-
|
251
|
-
|
252
|
-
|
253
|
-
else
|
254
|
-
if @root_fudge_active
|
255
|
-
app.root
|
253
|
+
def root(plugin = nil)
|
254
|
+
if plugin
|
255
|
+
app(plugin).root
|
256
256
|
else
|
257
|
-
@
|
258
|
-
|
259
|
-
|
260
|
-
|
261
|
-
|
262
|
-
|
263
|
-
|
257
|
+
if @root_fudge_active
|
258
|
+
app.root
|
259
|
+
else
|
260
|
+
@root ||= begin
|
261
|
+
path = Pathname.new(Dir.pwd)
|
262
|
+
until path.root? || File.exist?(File.join(path, APP_CONFIG))
|
263
|
+
path = path.parent
|
264
|
+
end
|
265
|
+
if path.root?
|
266
|
+
fail 'Something went wrong resolving the application root!'
|
267
|
+
end
|
268
|
+
path
|
264
269
|
end
|
265
|
-
path
|
266
270
|
end
|
267
271
|
end
|
268
272
|
end
|
269
|
-
|
270
|
-
|
271
|
-
|
272
|
-
|
273
|
-
|
274
|
-
|
275
|
-
|
276
|
-
|
277
|
-
|
278
|
-
|
279
|
-
|
280
|
-
|
273
|
+
alias_method :app_root, :root
|
274
|
+
|
275
|
+
# Like Origen.root but this will return the plugin root if called by plugin code
|
276
|
+
def root!
|
277
|
+
file = caller[0]
|
278
|
+
path = Pathname.new(file).dirname
|
279
|
+
until path.root? || File.exist?(File.join(path, APP_CONFIG))
|
280
|
+
path = path.parent
|
281
|
+
end
|
282
|
+
if path.root?
|
283
|
+
fail "Something went wrong resolving Origen.root! from: #{caller[0]}"
|
284
|
+
end
|
285
|
+
path.realpath
|
281
286
|
end
|
282
|
-
path.realpath
|
283
|
-
end
|
284
287
|
|
285
|
-
|
286
|
-
|
287
|
-
|
288
|
-
|
289
|
-
|
290
|
-
|
291
|
-
|
292
|
-
|
293
|
-
|
294
|
-
|
295
|
-
|
296
|
-
|
297
|
-
|
298
|
-
|
299
|
-
|
300
|
-
|
301
|
-
# Turns off bundler and all plugins if the app is loaded within this block
|
302
|
-
# @api private
|
303
|
-
def with_boot_environment
|
304
|
-
@with_boot_environment = true
|
305
|
-
yield
|
306
|
-
@with_boot_environment = false
|
307
|
-
end
|
288
|
+
# Ugly hack to force Origen.root references to the plugin's top-level when loading
|
289
|
+
# the environment.rb of the plugin
|
290
|
+
#
|
291
|
+
# References to Origen.root in a plugin environment.rb is deprecated and this will be
|
292
|
+
# removed in future once all plugins load through bundler
|
293
|
+
#
|
294
|
+
# @api private
|
295
|
+
def with_origen_root(path)
|
296
|
+
orig = app.root
|
297
|
+
@root_fudge_active = true
|
298
|
+
app.root = Pathname.new(path)
|
299
|
+
yield
|
300
|
+
app.root = orig
|
301
|
+
@root_fudge_active = false
|
302
|
+
end
|
308
303
|
|
309
|
-
|
310
|
-
|
311
|
-
|
312
|
-
|
313
|
-
|
314
|
-
|
315
|
-
|
316
|
-
# (yes we need to make the API more obvious).
|
317
|
-
def listeners_for(*args)
|
318
|
-
callback = args.shift
|
319
|
-
max = args.first.is_a?(Numeric) ? args.shift : nil
|
320
|
-
listeners = [Origen.app] + Origen.plugins +
|
321
|
-
Origen.app.instantiated_callback_listeners
|
322
|
-
listeners = listeners.select { |l| l.respond_to?(callback) }
|
323
|
-
if max && listeners.size > max
|
324
|
-
fail "You can only define a #{callback} callback #{max > 1 ? (max.to_s + 'times') : 'once'}, however you have declared it #{listeners.size} times for instances of: #{listeners.map(&:class)}"
|
325
|
-
end
|
326
|
-
listeners
|
327
|
-
end
|
304
|
+
# Turns off bundler and all plugins if the app is loaded within this block
|
305
|
+
# @api private
|
306
|
+
def with_boot_environment
|
307
|
+
@with_boot_environment = true
|
308
|
+
yield
|
309
|
+
@with_boot_environment = false
|
310
|
+
end
|
328
311
|
|
329
|
-
|
330
|
-
|
331
|
-
|
312
|
+
# This is the application-facing API for implementing custom callbacks,
|
313
|
+
# the top-level application, all plugin application instances, and any
|
314
|
+
# application objects that include the Origen::Callbacks module will be
|
315
|
+
# returned
|
316
|
+
#
|
317
|
+
# Origen system callbacks should use Origen.app.listeners_for instead, that
|
318
|
+
# version will return only the current plugin instance instead of them all
|
319
|
+
# (yes we need to make the API more obvious).
|
320
|
+
def listeners_for(*args)
|
321
|
+
callback = args.shift
|
322
|
+
max = args.first.is_a?(Numeric) ? args.shift : nil
|
323
|
+
listeners = [Origen.app] + Origen.app.plugins +
|
324
|
+
Origen.app.instantiated_callback_listeners
|
325
|
+
listeners = listeners.select { |l| l.respond_to?(callback) }
|
326
|
+
if max && listeners.size > max
|
327
|
+
fail "You can only define a #{callback} callback #{max > 1 ? (max.to_s + 'times') : 'once'}, however you have declared it #{listeners.size} times for instances of: #{listeners.map(&:class)}"
|
328
|
+
end
|
329
|
+
listeners
|
330
|
+
end
|
332
331
|
|
333
|
-
|
334
|
-
|
335
|
-
|
332
|
+
def generator
|
333
|
+
@generator ||= Generator.new
|
334
|
+
end
|
336
335
|
|
337
|
-
|
338
|
-
|
339
|
-
|
336
|
+
def client
|
337
|
+
@client ||= Client.new
|
338
|
+
end
|
340
339
|
|
341
|
-
|
342
|
-
|
343
|
-
|
340
|
+
def tester
|
341
|
+
application && application.tester
|
342
|
+
end
|
344
343
|
|
345
|
-
|
346
|
-
|
347
|
-
|
344
|
+
def pin_bank
|
345
|
+
@pin_bank ||= Pins::PinBank.new
|
346
|
+
end
|
348
347
|
|
349
|
-
|
350
|
-
|
351
|
-
|
348
|
+
def file_handler
|
349
|
+
@file_handler ||= FileHandler.new
|
350
|
+
end
|
352
351
|
|
353
|
-
|
354
|
-
|
355
|
-
|
356
|
-
end
|
357
|
-
alias_method :imports_manager, :import_manager
|
352
|
+
def regression_manager
|
353
|
+
@regression_manager ||= RegressionManager.new
|
354
|
+
end
|
358
355
|
|
359
|
-
|
360
|
-
|
361
|
-
|
362
|
-
|
363
|
-
|
364
|
-
alias_method :current_plugin, :plugins_manager
|
356
|
+
def import_manager
|
357
|
+
Origen.deprecated 'Origen.import_manager is deprecated, use Origen.app.plugins instead'
|
358
|
+
app.plugins
|
359
|
+
end
|
360
|
+
alias_method :imports_manager, :import_manager
|
365
361
|
|
366
|
-
|
367
|
-
|
368
|
-
|
369
|
-
|
362
|
+
def plugins_manager
|
363
|
+
Origen.deprecated 'Origen.plugins_manager and Origen.current_plugin are deprecated, use Origen.app.plugins instead'
|
364
|
+
app.plugins
|
365
|
+
end
|
366
|
+
alias_method :plugin_manager, :plugins_manager
|
367
|
+
alias_method :current_plugin, :plugins_manager
|
370
368
|
|
371
|
-
|
372
|
-
|
373
|
-
|
369
|
+
def remote_manager
|
370
|
+
@remote_manager ||= RemoteManager.new
|
371
|
+
end
|
372
|
+
alias_method :remotes_manager, :remote_manager
|
374
373
|
|
375
|
-
|
376
|
-
|
377
|
-
|
374
|
+
def pattern
|
375
|
+
generator.pattern
|
376
|
+
end
|
378
377
|
|
379
|
-
|
380
|
-
|
381
|
-
|
378
|
+
def flow
|
379
|
+
generator.flow
|
380
|
+
end
|
382
381
|
|
383
|
-
|
384
|
-
|
385
|
-
|
382
|
+
def resources
|
383
|
+
generator.resources
|
384
|
+
end
|
386
385
|
|
387
|
-
|
388
|
-
|
389
|
-
|
386
|
+
def time
|
387
|
+
@time ||= Origen::Tester::Time.new
|
388
|
+
end
|
390
389
|
|
391
|
-
|
392
|
-
|
393
|
-
return @version if @version && !options[:refresh]
|
394
|
-
if options[:refresh] || !defined?(Origen::VERSION)
|
395
|
-
load File.join(Pathname.new(File.dirname(__FILE__)).parent, 'config', 'version.rb')
|
390
|
+
def controllers
|
391
|
+
@controllers ||= []
|
396
392
|
end
|
397
|
-
@version = Origen::VersionString.new(Origen::VERSION)
|
398
|
-
end
|
399
393
|
|
400
|
-
|
401
|
-
|
402
|
-
|
403
|
-
|
404
|
-
|
405
|
-
@application ||= begin
|
406
|
-
# This flag is set so that when a thread starts with no app it remains with no app. This
|
407
|
-
# was an issue when building a new app with the fetch command and when the thread did a
|
408
|
-
# chdir to the new app directory (to fetch it) Origen.log would try to load the partial app.
|
409
|
-
@running_outside_an_app = true unless in_app_workspace?
|
410
|
-
return nil if @running_outside_an_app
|
411
|
-
require File.join(root, APP_CONFIG)
|
412
|
-
@application = _applications_lookup[:root][root.to_s]
|
413
|
-
if File.exist?(File.join(root, 'Gemfile')) && !@with_boot_environment
|
414
|
-
# Don't understand the rules here, belt and braces approach for now to make
|
415
|
-
# sure that all Origen plugins are auto-required (otherwise Origen won't know
|
416
|
-
# about them to plug them into the application)
|
417
|
-
Bundler.require
|
418
|
-
Bundler.require(:development)
|
419
|
-
Bundler.require(:runtime)
|
420
|
-
Bundler.require(:default)
|
394
|
+
def version(options = {})
|
395
|
+
@version = nil if options[:refresh]
|
396
|
+
return @version if @version && !options[:refresh]
|
397
|
+
if options[:refresh] || !defined?(Origen::VERSION)
|
398
|
+
load File.join(Pathname.new(File.dirname(__FILE__)).parent, 'config', 'version.rb')
|
421
399
|
end
|
422
|
-
|
423
|
-
|
424
|
-
|
425
|
-
|
400
|
+
@version = Origen::VersionString.new(Origen::VERSION)
|
401
|
+
end
|
402
|
+
|
403
|
+
# Loads the top-level application and all of its plugins, but not the target
|
404
|
+
#
|
405
|
+
# In most cases this should never need to be called directly and will be called
|
406
|
+
# automatically the first time the application is referenced via Origen.app
|
407
|
+
def load_application(options = {})
|
408
|
+
@application ||= begin
|
409
|
+
# This flag is set so that when a thread starts with no app it remains with no app. This
|
410
|
+
# was an issue when building a new app with the fetch command and when the thread did a
|
411
|
+
# chdir to the new app directory (to fetch it) Origen.log would try to load the partial app.
|
412
|
+
@running_outside_an_app = true unless in_app_workspace?
|
413
|
+
return nil if @running_outside_an_app
|
414
|
+
require File.join(root, APP_CONFIG)
|
415
|
+
@application = _applications_lookup[:root][root.to_s]
|
416
|
+
if File.exist?(File.join(root, 'Gemfile')) && !@with_boot_environment
|
417
|
+
# Don't understand the rules here, belt and braces approach for now to make
|
418
|
+
# sure that all Origen plugins are auto-required (otherwise Origen won't know
|
419
|
+
# about them to plug them into the application)
|
420
|
+
Bundler.require
|
421
|
+
Bundler.require(:development)
|
422
|
+
Bundler.require(:runtime)
|
423
|
+
Bundler.require(:default)
|
424
|
+
end
|
425
|
+
if @with_boot_environment
|
426
|
+
@application.plugins.disable_current
|
427
|
+
else
|
428
|
+
Origen.remote_manager.require!
|
429
|
+
end
|
430
|
+
boot = File.join(root, 'config', 'boot.rb')
|
431
|
+
require boot if File.exist?(boot)
|
432
|
+
env = File.join(root, 'config', 'environment.rb')
|
433
|
+
require env if File.exist?(env)
|
434
|
+
dev = File.join(root, 'config', 'development.rb')
|
435
|
+
require dev if File.exist?(dev)
|
436
|
+
validate_origen_dev_configuration!
|
437
|
+
([@application] + Origen.app.plugins).each(&:on_loaded)
|
438
|
+
@application_loaded = true
|
439
|
+
@application
|
426
440
|
end
|
427
|
-
boot = File.join(root, 'config', 'boot.rb')
|
428
|
-
require boot if File.exist?(boot)
|
429
|
-
env = File.join(root, 'config', 'environment.rb')
|
430
|
-
require env if File.exist?(env)
|
431
|
-
dev = File.join(root, 'config', 'development.rb')
|
432
|
-
require dev if File.exist?(dev)
|
433
|
-
validate_origen_dev_configuration!
|
434
|
-
([@application] + Origen.app.plugins).each(&:on_loaded)
|
435
|
-
@application_loaded = true
|
436
|
-
@application
|
437
441
|
end
|
438
|
-
end
|
439
442
|
|
440
|
-
|
441
|
-
|
442
|
-
|
443
|
+
def launch_time
|
444
|
+
@launch_time ||= time_now
|
445
|
+
end
|
443
446
|
|
444
|
-
|
445
|
-
|
446
|
-
|
447
|
-
|
447
|
+
# Returns the full path to the Origen core top-level directory
|
448
|
+
def top
|
449
|
+
@origen_top ||= Pathname.new(File.dirname(__FILE__)).parent
|
450
|
+
end
|
448
451
|
|
449
|
-
|
450
|
-
|
451
|
-
|
452
|
-
|
452
|
+
# Compile the given file and return the result as a string
|
453
|
+
def compile(file, options = {})
|
454
|
+
Origen::Generator::Compiler.new.compile_inline(file, options)
|
455
|
+
end
|
453
456
|
|
454
|
-
|
455
|
-
|
456
|
-
|
457
|
+
def interfaces
|
458
|
+
@interfaces ||= []
|
459
|
+
end
|
457
460
|
|
458
|
-
|
459
|
-
|
460
|
-
|
461
|
+
def add_interface(interface_class)
|
462
|
+
interfaces << interface_class
|
463
|
+
end
|
461
464
|
|
462
|
-
|
463
|
-
|
464
|
-
|
465
|
-
|
466
|
-
|
467
|
-
|
468
|
-
|
469
|
-
else
|
470
|
-
int = interfaces.find { |i| i.supports?(Origen.tester) }
|
471
|
-
if int
|
472
|
-
@interface = int.new(options)
|
465
|
+
# Resets the tester interface (instantiates a new one). Any supplied options
|
466
|
+
# are passed to the interface initialization.
|
467
|
+
def reset_interface(options = {})
|
468
|
+
# The doc interface should in future be phased out, but for now assume that an explicitly
|
469
|
+
# declared interface is for the non-doc case
|
470
|
+
if options[:interface] && !Origen.tester.doc?
|
471
|
+
@interface = eval(options[:interface]).new(options)
|
473
472
|
else
|
474
|
-
|
475
|
-
|
473
|
+
int = interfaces.find { |i| i.supports?(Origen.tester) }
|
474
|
+
if int
|
475
|
+
@interface = int.new(options)
|
476
|
+
else
|
477
|
+
unless options.delete(:silence_no_interface_error)
|
478
|
+
fail "No interface has been defined for tester: #{Origen.tester.class}"
|
479
|
+
end
|
476
480
|
end
|
477
481
|
end
|
482
|
+
@interface._load_generator if @interface.respond_to?(:_load_generator)
|
483
|
+
if @interface.respond_to?(:at_flow_start)
|
484
|
+
@interface.at_flow_start
|
485
|
+
else
|
486
|
+
@interface.reset_globals if @interface.respond_to?(:reset_globals)
|
487
|
+
end
|
488
|
+
@interface
|
478
489
|
end
|
479
|
-
@interface._load_generator if @interface.respond_to?(:_load_generator)
|
480
|
-
if @interface.respond_to?(:at_flow_start)
|
481
|
-
@interface.at_flow_start
|
482
|
-
else
|
483
|
-
@interface.reset_globals if @interface.respond_to?(:reset_globals)
|
484
|
-
end
|
485
|
-
@interface
|
486
|
-
end
|
487
490
|
|
488
|
-
|
489
|
-
|
490
|
-
|
491
|
+
def interface_loaded?
|
492
|
+
!!@interface
|
493
|
+
end
|
491
494
|
|
492
|
-
|
493
|
-
|
494
|
-
|
495
|
-
|
496
|
-
|
495
|
+
# Returns the (application defined) test program interface for the given tester
|
496
|
+
# if one has been defined, otherwise returns nil
|
497
|
+
def interface(options = {})
|
498
|
+
@interface || reset_interface(options)
|
499
|
+
end
|
497
500
|
|
498
|
-
|
499
|
-
|
500
|
-
|
501
|
-
|
501
|
+
# Returns true if an interface is defined for the current tester
|
502
|
+
def interface_present?
|
503
|
+
!!interface(silence_no_interface_error: true)
|
504
|
+
end
|
502
505
|
|
503
|
-
|
504
|
-
|
505
|
-
|
506
|
-
|
507
|
-
|
508
|
-
|
509
|
-
|
510
|
-
|
506
|
+
# Use User.current to retrieve the current user, this is an internal API that will
|
507
|
+
# be cleaned up (removed) in future
|
508
|
+
# @api private
|
509
|
+
def current_user
|
510
|
+
if app_loaded? || in_app_workspace?
|
511
|
+
application.current_user
|
512
|
+
else
|
513
|
+
User.new(User.current_user_id)
|
514
|
+
end
|
511
515
|
end
|
512
|
-
end
|
513
516
|
|
514
|
-
|
515
|
-
|
516
|
-
|
517
|
+
def lsf
|
518
|
+
application.lsf_manager
|
519
|
+
end
|
517
520
|
|
518
|
-
|
519
|
-
|
520
|
-
|
521
|
+
def running_on_windows?
|
522
|
+
Origen.os.windows?
|
523
|
+
end
|
521
524
|
|
522
|
-
|
523
|
-
|
524
|
-
|
525
|
+
def running_on_linux?
|
526
|
+
!running_on_windows?
|
527
|
+
end
|
525
528
|
|
526
|
-
|
527
|
-
|
528
|
-
|
529
|
-
|
529
|
+
def running_remotely?
|
530
|
+
@running_remotely
|
531
|
+
end
|
532
|
+
alias_method :running_remotely, :running_remotely?
|
530
533
|
|
531
|
-
|
532
|
-
|
533
|
-
|
534
|
+
def running_locally?
|
535
|
+
!running_remotely?
|
536
|
+
end
|
534
537
|
|
535
|
-
|
536
|
-
|
537
|
-
|
538
|
+
def running_remotely=(val)
|
539
|
+
@running_remotely = val
|
540
|
+
end
|
538
541
|
|
539
|
-
|
540
|
-
|
541
|
-
|
542
|
-
|
543
|
-
|
542
|
+
# Returns true if Origen is running with the -d or --debug switches enabled
|
543
|
+
def debug?
|
544
|
+
@debug || false
|
545
|
+
end
|
546
|
+
alias_method :debugger?, :debug?
|
544
547
|
|
545
|
-
|
546
|
-
|
547
|
-
|
548
|
+
def enable_debugger
|
549
|
+
@debug = true
|
550
|
+
end
|
548
551
|
|
549
|
-
|
550
|
-
|
551
|
-
|
552
|
+
def debugger_enabled?
|
553
|
+
@debug
|
554
|
+
end
|
552
555
|
|
553
|
-
|
554
|
-
|
555
|
-
|
556
|
-
|
556
|
+
def development?
|
557
|
+
# This should be integrated with Origen.config.mode in the future
|
558
|
+
@development
|
559
|
+
end
|
557
560
|
|
558
|
-
|
559
|
-
|
560
|
-
|
561
|
+
def set_development_mode
|
562
|
+
@development = true
|
563
|
+
end
|
561
564
|
|
562
|
-
|
563
|
-
|
564
|
-
|
565
|
-
|
566
|
-
|
565
|
+
# Returns an object tracking the Origen execution mode/configuration, an
|
566
|
+
# instance of Origen::Mode
|
567
|
+
def mode
|
568
|
+
application.config.mode
|
569
|
+
end
|
567
570
|
|
568
|
-
|
569
|
-
|
570
|
-
|
571
|
+
def mode=(val)
|
572
|
+
application.config.mode = val
|
573
|
+
end
|
571
574
|
|
572
|
-
|
573
|
-
|
574
|
-
|
575
|
-
|
576
|
-
|
575
|
+
# Returns the current top-level (DUT) object if one has been defined (by
|
576
|
+
# instantiating an object that includes Origen::TopLevel).
|
577
|
+
def top_level
|
578
|
+
application.top_level
|
579
|
+
end
|
577
580
|
|
578
|
-
|
579
|
-
|
580
|
-
|
581
|
-
|
582
|
-
|
583
|
-
|
584
|
-
|
581
|
+
def deprecate(*msgs)
|
582
|
+
_deprecate(*msgs)
|
583
|
+
if Origen.app
|
584
|
+
# If an app deprecation return the caller who called the deprecated method
|
585
|
+
if caller[0] =~ /#{Origen.root}/
|
586
|
+
c = caller[1]
|
587
|
+
# If an Origen deprecation then return the first caller from the current app
|
588
|
+
else
|
589
|
+
c = caller.find { |line| line =~ /#{Origen.root}/ }
|
590
|
+
end
|
585
591
|
else
|
586
|
-
c = caller
|
592
|
+
c = caller[1]
|
593
|
+
end
|
594
|
+
c =~ /(.*):(\d+):.*/
|
595
|
+
begin
|
596
|
+
_deprecate "Called by #{Regexp.last_match[1]}:#{Regexp.last_match[2]}", options
|
597
|
+
rescue
|
598
|
+
# For this to fail it means the deprecated method was called by IRB or similar
|
599
|
+
# and in that case there is no point advising who called anyway
|
587
600
|
end
|
588
|
-
else
|
589
|
-
c = caller[1]
|
590
|
-
end
|
591
|
-
c =~ /(.*):(\d+):.*/
|
592
|
-
begin
|
593
|
-
_deprecate "Called by #{Regexp.last_match[1]}:#{Regexp.last_match[2]}", options
|
594
|
-
rescue
|
595
|
-
# For this to fail it means the deprecated method was called by IRB or similar
|
596
|
-
# and in that case there is no point advising who called anyway
|
597
601
|
end
|
598
|
-
|
599
|
-
alias_method :deprecated, :deprecate
|
602
|
+
alias_method :deprecated, :deprecate
|
600
603
|
|
601
|
-
|
602
|
-
|
603
|
-
|
604
|
+
def log
|
605
|
+
@log ||= Log.new
|
606
|
+
end
|
604
607
|
|
605
|
-
|
606
|
-
|
607
|
-
|
608
|
-
|
609
|
-
|
608
|
+
# Returns the name of the currently executing Origen command (a String),
|
609
|
+
# e.g. 'generate', 'program', 'compile', etc.
|
610
|
+
def current_command
|
611
|
+
@current_command
|
612
|
+
end
|
610
613
|
|
611
|
-
|
614
|
+
private
|
612
615
|
|
613
|
-
|
614
|
-
|
615
|
-
|
616
|
+
def current_command=(val)
|
617
|
+
@current_command = val
|
618
|
+
end
|
616
619
|
|
617
|
-
|
618
|
-
|
619
|
-
|
620
|
-
|
621
|
-
|
620
|
+
def _deprecate(*lines)
|
621
|
+
options = lines.last.is_a?(Hash) ? lines.pop : {}
|
622
|
+
lines.flatten.each do |line|
|
623
|
+
line.split(/\n/).each do |line|
|
624
|
+
log.deprecate line
|
625
|
+
end
|
622
626
|
end
|
623
627
|
end
|
624
628
|
end
|
625
629
|
end
|
626
|
-
end
|
627
630
|
|
628
|
-
# This is already required by commands.rb, but also necessary here so
|
629
|
-
# that is included whenever rspec (or another 3rd party) loads Origen
|
630
|
-
# outside the scope of an Origen command
|
631
|
-
require 'origen/global_methods'
|
632
|
-
include Origen::GlobalMethods
|
631
|
+
# This is already required by commands.rb, but also necessary here so
|
632
|
+
# that is included whenever rspec (or another 3rd party) loads Origen
|
633
|
+
# outside the scope of an Origen command
|
634
|
+
require 'origen/global_methods'
|
635
|
+
include Origen::GlobalMethods
|
636
|
+
end
|
data/lib/origen/application.rb
CHANGED
@@ -81,7 +81,7 @@ module Origen
|
|
81
81
|
end
|
82
82
|
end
|
83
83
|
# Finally those that the plugin's have given us
|
84
|
-
([Origen.app] + Origen.plugins).each do |plugin|
|
84
|
+
([Origen.app] + Origen.app.plugins).each do |plugin|
|
85
85
|
namespace plugin.name do
|
86
86
|
Dir.glob("#{plugin.root}/lib/tasks/shared/*.rake").sort.each do |file|
|
87
87
|
load file
|