Class: Origen::Application
- Inherits:
-
Object
show all
- Includes:
- Users
- Defined in:
- lib/origen/application.rb,
lib/origen/application/lsf.rb,
lib/origen/application/runner.rb,
lib/origen/application/target.rb,
lib/origen/application/plugins.rb,
lib/origen/application/release.rb,
lib/origen/application/deployer.rb,
lib/origen/application/statistics.rb,
lib/origen/application/environment.rb,
lib/origen/application/lsf_manager.rb,
lib/origen/application/configuration.rb,
lib/origen/application/plugins_manager.rb,
lib/origen/application/version_tracker.rb,
lib/origen/application/workspace_manager.rb,
lib/origen/application/command_dispatcher.rb
Overview
In Origen v2 this class was introduced to formally co-ordinate application level configuration of Origen.
Configuration
See Origen::Application::Configuration for the available options.
Defined Under Namespace
Classes: CommandDispatcher, Configuration, Deployer, Environment, LSF, LSFManager, Plugins, PluginsManager, RakeLoader, Release, Runner, Statistics, Target, VersionTracker, WorkspaceManager
Instance Attribute Summary collapse
-
#name ⇒ Object
Returns the name of the given application, this is the name that will be used to refer to the application when it is used as a plugin.
-
#namespace ⇒ Object
Returns the namespace used by the application as a string.
Class Method Summary
collapse
Instance Method Summary
collapse
-
#_add_block_files(files, block_dir, current_dir, sub_block = false) ⇒ Object
private
-
#add_callback_listener(obj) ⇒ Object
-
#add_config_attribute(*args) ⇒ Object
-
#add_lib_to_load_path! ⇒ Object
This method is called just after an application inherits from Origen::Application, allowing the developer to load classes in lib and use them during application configuration.
-
#add_persistant_callback_listener(obj) ⇒ Object
-
#add_pin_to_pin_map(id, pin) ⇒ Object
-
#add_pingroup_to_pingroup_map(id, pins) ⇒ Object
-
#add_toplevel_listener(obj) ⇒ Object
-
#author(version = Origen.app.version.prefixed) ⇒ Object
Returns the author (committer) for the current or given application version.
-
#blocks_files ⇒ Object
private
Returns a lookup table for all block definitions (app/blocks) that the app contains.
-
#branch(version = Origen.app.version.prefixed) ⇒ Object
(also: #selector)
Returns the branch for the current or given application version.
-
#callback_listeners ⇒ Object
-
#clear_dynamic_resources(type = :transient) ⇒ Object
-
#config ⇒ Object
-
#contributors ⇒ Object
-
#current? ⇒ Boolean
(also: #standalone?, #running_standalone?)
Returns true if the given application instance is the current top level application.
-
#current_job ⇒ Object
-
#current_jobs ⇒ Object
-
#current_plugin? ⇒ Boolean
Returns true if the given application instance is the current plugin.
-
#db ⇒ Object
-
#deployer ⇒ Object
-
#dynamic_resource(name, default, options = {}) ⇒ Object
Enable for debugging to see what the currently tracked objects are def object_store [@load_event, @static_resources, @transient_resources] end.
-
#environment ⇒ Object
-
#fail(message: nil, exception_class: RuntimeError) ⇒ Object
Prepends the application name to the fail message and throws a RuntimeError exception.
-
#fail!(message: nil, exception_class: RuntimeError, exit_status: 1) ⇒ Object
Similar to Origen.app.fail, but will instead print the message using Origen.log.error and exit the current process (using exit 1
) UNLESS –debug is used.
-
#gem_name ⇒ Object
-
#imports_directory ⇒ Object
(also: #imports_dir)
Returns a path to the imports directory (e.g. used by the remotes and similar features) for the application.
-
#inspect ⇒ Object
-
#instantiated_callback_listeners ⇒ Object
-
#listeners_for(*args) ⇒ Object
-
#load_event(type) ⇒ Object
-
#load_target!(options = {}) ⇒ Object
-
#load_tasks ⇒ Object
Load all rake tasks defined in the application’s lib/task directory.
-
#lsf ⇒ Object
-
#lsf_manager ⇒ Object
-
#mailer ⇒ Object
-
#maillist_dev ⇒ Object
Returns array of email addresses in the DEV maillist file.
-
#maillist_dev_file ⇒ Object
Returns default location of DEV maillist file (customize locally if needed).
-
#maillist_parse(file) ⇒ Object
Parses maillist file and returns an array of email address.
-
#maillist_prod ⇒ Object
Returns array of email addresses in the PROD maillist file.
-
#maillist_prod_file ⇒ Object
Returns default location of PROD maillist file (customize locally if needed).
-
#on_create_called? ⇒ Boolean
Returns true if the on_create callback has already been called during a target load.
-
#on_loaded ⇒ Object
This callback handler will fire once the main app and all of its plugins have been loaded.
-
#origen_core? ⇒ Boolean
Convenience method to check if the given application instance is Origen core.
-
#pattern_iterators ⇒ Object
-
#pin_map ⇒ Object
-
#pin_names ⇒ Object
-
#pin_pattern_exclude ⇒ Object
-
#pin_pattern_order ⇒ Object
-
#pingroup_map ⇒ Object
-
#plugins ⇒ Object
-
#plugins_manager ⇒ Object
(also: #plugin_manager, #current_plugin)
-
#previous_versions ⇒ Object
-
#release(options) ⇒ Object
-
#release_date(version = Origen.app.version.prefixed) ⇒ Object
Returns the release date for the current or given application version.
-
#release_note(version = Origen.app.version.prefixed) ⇒ Object
Returns the release note for the current or given application version.
-
#release_time(version = Origen.app.version.prefixed) ⇒ Object
Returns the release time for the current or given application version.
-
#reload_target!(options = {}) ⇒ Object
Equivalent to load_target! except that any options that were passed to load_target! the last time it was called will be re-applied when (re)loading the target.
-
#remotes_directory ⇒ Object
(also: #remotes_dir)
Returns a path to the remotes directory for the application.
-
#require_environment! ⇒ Object
-
#revision_controller(options = {}) ⇒ Object
(also: #rc)
Returns a revision controller instance (e.g. Origen::RevisionControl::Git) which has been configured to point to the local workspace and the remote repository as defined by Origen.app.config.rc_url.
-
#root ⇒ Object
Returns a full path to the root directory of the given application.
-
#root=(val) ⇒ Object
-
#runner ⇒ Object
-
#server_data ⇒ Object
Returns the server data packet available for the given application, returns nil if none is found.
-
#session(reload = false) ⇒ Object
-
#set_dynamic_resource(name, value) ⇒ Object
-
#statistics ⇒ Object
(also: #stats)
-
#subscribers_dev ⇒ Object
Returns an array of users who have subscribed for development release notifications for the given application on the website.
-
#subscribers_prod ⇒ Object
Returns an array of users who have subscribed for production release notifications for the given application on the website.
-
#target ⇒ Object
-
#target_instantiated? ⇒ Boolean
-
#target_loading? ⇒ Boolean
-
#tester ⇒ Object
-
#tester=(obj) ⇒ Object
-
#top_level ⇒ Object
Returns the current top-level object (the DUT).
-
#toplevel_listeners ⇒ Object
-
#unload_target! ⇒ Object
private
Not a clean unload, but allows objects to be re-instantiated for testing.
-
#version(options = {}) ⇒ Object
-
#version_tracker ⇒ Object
-
#versions ⇒ Object
-
#with_doc_tester(options = {}) ⇒ Object
Any attempts to instantiate a tester within the give block will be forced to instantiate an Origen::Tester::Doc instance.
-
#with_doc_tester? ⇒ Boolean
-
#with_html_doc_tester? ⇒ Boolean
-
#workspace_manager ⇒ Object
Methods included from Users
#admins, #app_users, #current_user
Instance Attribute Details
Returns the name of the given application, this is the name that will be used to refer to the application when it is used as a plugin
642
643
644
|
# File 'lib/origen/application.rb', line 642
def name
@name
end
|
#namespace ⇒ Object
Returns the namespace used by the application as a string
306
307
308
|
# File 'lib/origen/application.rb', line 306
def namespace
@namespace
end
|
Class Method Details
.from_namespace(item) ⇒ Object
Returns the application instance (i.e. main app or the plugin) that owns the given class/module (literal, string or symbol representation is accepted) or object instance. Returns nil if no matching Origen application can be found.
Origen::Application.from_namespace(MyApp) # => <my_app instance>
Origen::Application.from_namespace(MyApp::MyClass) # => <my_app instance>
Origen::Application.from_namespace('MyApp::MyClass') # => <my_app instance>
Origen::Application.from_namespace(<my_app::my_class instance>) # => <my_app instance>
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
|
# File 'lib/origen/application.rb', line 75
def from_namespace(item)
unless item.is_a?(String)
if item.is_a?(Module) || item.is_a?(Class) || item.is_a?(Symbol)
item = item.to_s
else item = item.class.to_s
end
end
namespace = item.split('::').first
@apps_by_namespace ||= {}
@apps_by_namespace[namespace] ||= begin
return Origen.app if Origen.app.namespace == namespace
Origen.app.plugins.each do |plugin|
return plugin if plugin.namespace == namespace
end
nil
end
end
|
59
60
61
|
# File 'lib/origen/application.rb', line 59
def instance
@instance ||= new
end
|
.respond_to?(*args) ⇒ Boolean
63
64
65
|
# File 'lib/origen/application.rb', line 63
def respond_to?(*args)
super || instance.respond_to?(*args)
end
|
Instance Method Details
#_add_block_files(files, block_dir, current_dir, sub_block = false) ⇒ Object
This method is part of a private API.
You should avoid using this method if possible, as it may be removed or be changed in the future.
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
|
# File 'lib/origen/application.rb', line 165
def _add_block_files(files, block_dir, current_dir, sub_block = false)
fields = current_dir.relative_path_from(block_dir).to_s.split('/')
fields.delete('derivatives')
fields.delete('sub_blocks')
path = fields.join('/')
files[path] ||= {}
files[path][:_sub_block] = true if sub_block
Dir.glob(current_dir.join('*.rb')).each do |file|
file = Pathname.new(file)
type = file.basename('.rb').to_s.to_sym
unless type == :model || type == :controller
files[path][type] ||= []
files[path][type] << file.to_s
end
end
derivatives = current_dir.join('derivatives')
if derivatives.exist?
derivatives.children.each do |item|
if item.directory?
_add_block_files(files, block_dir, item)
end
end
end
sub_blocks = current_dir.join('sub_blocks')
if sub_blocks.exist?
sub_blocks.children.each do |item|
if item.directory?
_add_block_files(files, block_dir, item, true)
end
end
end
end
|
#add_callback_listener(obj) ⇒ Object
752
753
754
|
# File 'lib/origen/application.rb', line 752
def add_callback_listener(obj)
dynamic_resource(:callback_listeners, [], adding: true) << obj
end
|
#add_config_attribute(*args) ⇒ Object
#add_lib_to_load_path! ⇒ Object
This method is called just after an application inherits from Origen::Application, allowing the developer to load classes in lib and use them during application configuration.
class MyApplication < Origen::Application
require "my_backend" config.i18n.backend = MyBackend
end
1054
1055
1056
1057
1058
|
# File 'lib/origen/application.rb', line 1054
def add_lib_to_load_path! [root.join('lib'), root.join('vendor', 'lib'), root.join('app', 'lib')].each do |path|
$LOAD_PATH.unshift(path.to_s) if File.exist?(path) && !$LOAD_PATH.include?(path.to_s)
end
end
|
#add_persistant_callback_listener(obj) ⇒ Object
756
757
758
759
760
|
# File 'lib/origen/application.rb', line 756
def add_persistant_callback_listener(obj)
@persistant_callback_listeners ||= []
@persistant_callback_listeners << obj
@persistant_callback_listeners.uniq!
end
|
#add_pin_to_pin_map(id, pin) ⇒ Object
807
808
809
810
811
812
813
814
815
|
# File 'lib/origen/application.rb', line 807
def add_pin_to_pin_map(id, pin)
if @load_event
pin_map[id] = pin
else
@transient_resources[:pin_map][id] = pin
end
end
|
#add_pingroup_to_pingroup_map(id, pins) ⇒ Object
821
822
823
824
825
826
827
828
829
|
# File 'lib/origen/application.rb', line 821
def add_pingroup_to_pingroup_map(id, pins)
if @load_event
pingroup_map[id] = pins
else
@transient_resources[:pingroup_map][id] = pins
end
end
|
#add_toplevel_listener(obj) ⇒ Object
762
763
764
765
766
767
768
769
|
# File 'lib/origen/application.rb', line 762
def add_toplevel_listener(obj)
if Origen.top_level
puts "Attempt to set an instance of #{obj.class} as the top level when there is already an instance of #{Origen.top_level.class} defined as the top-level!"
fail 'Only one object that include the Origen::TopLevel module can be instantiated per target!'
end
$dut = obj
dynamic_resource(:toplevel_listeners, [], adding: true) << obj
end
|
#author(version = Origen.app.version.prefixed) ⇒ Object
Returns the author (committer) for the current or given application version
If the user can be found in the directory then a user object will be returned, otherwise the name will be returned as a String
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
|
# File 'lib/origen/application.rb', line 560
def author(version = Origen.app.version.prefixed)
version = VersionString.new(version)
version = version.prefixed if version.semantic?
capture = false
File.readlines("#{Origen.root}/doc/history").each do |line|
line = line.strip
if capture
if capture && line =~ /^#+ by (.*) on (.*(AM|PM))/
user = Origen.fsl.find_by_name(Regexp.last_match(1))
return user if user
return Regexp.last_match(1)
end
else
if line =~ /Tag:/
line = line.gsub('\\', '')
if line =~ /^#+ Tag: #{version}$/ ||
line =~ />Tag: #{version}</
capture = true
end
end
end
end
nil
end
|
#blocks_files ⇒ Object
This method is part of a private API.
You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns a lookup table for all block definitions (app/blocks) that the app contains
149
150
151
152
153
154
155
156
157
158
159
160
161
162
|
# File 'lib/origen/application.rb', line 149
def blocks_files
@blocks_files ||= begin
files = {}
block_dir = Pathname.new(File.join(root, 'app', 'blocks'))
if block_dir.exist?
block_dir.children.each do |item|
if item.directory?
_add_block_files(files, block_dir, item)
end
end
end
files
end
end
|
#branch(version = Origen.app.version.prefixed) ⇒ Object
Also known as:
selector
Returns the branch for the current or given application version
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
|
# File 'lib/origen/application.rb', line 586
def branch(version = Origen.app.version.prefixed)
version = VersionString.new(version)
version = version.prefixed if version.semantic?
capture = false
File.readlines("#{Origen.root}/doc/history").each do |line|
line = line.strip
if capture
if capture && line =~ /^#+ .*(Selector|Branch): '(.*)'/
return Regexp.last_match(2).gsub('\\', '')
end
else
if line =~ /Tag:/
line = line.gsub('\\', '')
if line =~ /^#+ Tag: #{version}$/ ||
line =~ />Tag: #{version}</
capture = true
end
end
end
end
nil
end
|
#callback_listeners ⇒ Object
737
738
739
740
741
742
|
# File 'lib/origen/application.rb', line 737
def callback_listeners
current = Origen.app.plugins.current
applications = [self]
applications << current if current
applications + instantiated_callback_listeners
end
|
#clear_dynamic_resources(type = :transient) ⇒ Object
976
977
978
979
980
981
982
983
|
# File 'lib/origen/application.rb', line 976
def clear_dynamic_resources(type = :transient)
@top_level = nil
if type == :transient
@transient_resources = nil
else
@static_resources = nil
end
end
|
632
633
634
|
# File 'lib/origen/application.rb', line 632
def config
@config ||= Configuration.new(self)
end
|
#contributors ⇒ Object
622
623
624
625
626
627
628
629
630
|
# File 'lib/origen/application.rb', line 622
def contributors
c = []
File.readlines("#{Origen.root}/doc/history").each do |line|
if line =~ /^#+ by (.*) on /
c << Regexp.last_match(1)
end
end
c.uniq
end
|
#current? ⇒ Boolean
Also known as:
standalone?, running_standalone?
Returns true if the given application instance is the current top level application
#current_job ⇒ Object
198
199
200
|
# File 'lib/origen/application.rb', line 198
def current_job
current_jobs.last
end
|
#current_jobs ⇒ Object
202
203
204
|
# File 'lib/origen/application.rb', line 202
def current_jobs
@current_jobs ||= []
end
|
#current_plugin? ⇒ Boolean
Returns true if the given application instance is the current plugin
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
|
# File 'lib/origen/application.rb', line 400
def current_plugin?
if Origen.application_loaded?
Origen.app.plugins.current == self
else
puts <<-END
current_plugin? cannot be used at this point in your code since the app is not loaded yet.
If you are calling this from config/application.rb then you can only use current_plugin? within a block:
# Not OK
if current_plugin?
config.output_directory = "#{Origen.root}/output/dir1"
else
config.output_directory = "#{Origen.root}/output/dir2"
end
# OK
config.output_directory do
if current_plugin?
"#{Origen.root}/output/dir1"
else
"#{Origen.root}/output/dir2"
end
end
END
exit 1
end
end
|
681
682
683
|
# File 'lib/origen/application.rb', line 681
def deployer
@deployer ||= Deployer.new
end
|
#dynamic_resource(name, default, options = {}) ⇒ Object
Enable for debugging to see what the currently tracked objects are def object_store
[@load_event, @static_resources, @transient_resources]
end
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
|
# File 'lib/origen/application.rb', line 949
def dynamic_resource(name, default, options = {})
@static_resources ||= {}
@transient_resources ||= {}
if @load_event == :static ||
(!@load_event && options[:adding])
if options[:set]
@static_resources[name] = default
else
@static_resources[name] ||= default
end
elsif @load_event == :transient
if options[:set]
@transient_resources[name] = default
else
@transient_resources[name] ||= default
end
else
static = @static_resources[name] ||= default
transient = @transient_resources[name] ||= default
if static.respond_to?('+')
static + transient
else
static.merge(transient)
end
end
end
|
#environment ⇒ Object
669
670
671
|
# File 'lib/origen/application.rb', line 669
def environment
@environment ||= Environment.new
end
|
#fail(message: nil, exception_class: RuntimeError) ⇒ Object
Prepends the application name to the fail message and throws a RuntimeError exception. Very similar to the plain fail
method with the addition of prepending the application name. Prepended message: ‘Fail in app.name: ’ If no message if provided, message is set to ‘Fail in app.name’
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
|
# File 'lib/origen/application.rb', line 1006
def fail(message: nil, exception_class: RuntimeError)
message.nil? ? message = "Fail in #{name}" : message = "Fail in #{name}: #{message}"
e = exception_class.new(message)
if caller[0] =~ (/lib\/origen\/application.rb:\d+:in `fail!'/)
e.set_backtrace(caller[1..-1])
else
e.set_backtrace(caller)
end
Kernel.fail(e)
end
|
#fail!(message: nil, exception_class: RuntimeError, exit_status: 1) ⇒ Object
Similar to Origen.app.fail, but will instead print the message using Origen.log.error and exit the current process (using exit 1
) UNLESS –debug is used. In those cases, exit
will not be used and instead this will behave the same as #fail. Purpose here is to allow fail! for normal usage, but provide more details as to where fail! was used when running in debug.
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
|
# File 'lib/origen/application.rb', line 1029
def fail!(message: nil, exception_class: RuntimeError, exit_status: 1)
if Origen.debug?
self.fail(message: message, exception_class: exception_class)
else
begin
self.fail(message: message, exception_class: exception_class)
rescue exception_class => e
Origen.log.error(e.message)
exit exit_status
end
end
end
|
646
647
648
|
# File 'lib/origen/application.rb', line 646
def gem_name
(Origen.app.config.gem_name || name).to_s.underscore.symbolize
end
|
#imports_directory ⇒ Object
Also known as:
imports_dir
Returns a path to the imports directory (e.g. used by the remotes and similar features) for the application. e.g. if the app live at /home/thao/my_app, then the imports directory will typically be /home/thao/.my_app_imports_DO_NOT_HAND_MODIFY
Origen will ensure that this directory is outside of the scope of the current application’s revision control system. This prevents conflicts with the revision control system for the application and those used to import 3rd party dependencies
288
289
290
|
# File 'lib/origen/application.rb', line 288
def imports_directory
workspace_manager.imports_directory
end
|
261
262
263
|
# File 'lib/origen/application.rb', line 261
def inspect
"<Origen app (#{name}):#{object_id}>"
end
|
#instantiated_callback_listeners ⇒ Object
744
745
746
|
# File 'lib/origen/application.rb', line 744
def instantiated_callback_listeners
dynamic_resource(:callback_listeners, []) + (@persistant_callback_listeners || [])
end
|
#listeners_for(*args) ⇒ Object
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
|
# File 'lib/origen/application.rb', line 438
def listeners_for(*args)
callback = args.shift
max = args.first.is_a?(Numeric) ? args.shift : nil
options = args.shift || {}
options = {
top_level: :first
}.merge(options)
listeners = callback_listeners
if Origen.top_level
listeners -= [Origen.top_level.model]
if options[:top_level]
if options[:top_level] == :last
listeners = listeners + [Origen.top_level]
else
listeners = [Origen.top_level] + listeners
end
end
end
listeners = listeners.select { |l| l.respond_to?(callback) }.map do |l|
if l.try(:is_an_origen_model?)
l.respond_to_directly?(callback) ? l : l.controller
else
l
end
end
if max && listeners.size > max
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)}"
end
listeners
end
|
#load_event(type) ⇒ Object
985
986
987
988
989
|
# File 'lib/origen/application.rb', line 985
def load_event(type)
@load_event = type
yield
@load_event = nil
end
|
#load_target!(options = {}) ⇒ Object
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
|
# File 'lib/origen/application.rb', line 855
def load_target!(options = {})
options = {
force_debug: false
}.merge(options)
@on_create_called = false
@target_loading = true
if options[:reload]
@target_load_count = 0
else
@target_load_count ||= 0
@target_load_count += 1
end
listeners_for(:before_load_target).each(&:before_load_target)
@target_load_options = options.merge({})
clear_dynamic_resources
load_event(:transient) do
Origen.mode = Origen.app.session.origen_core[:mode] || :production begin
$_target_options = @target_load_options
Origen.target.set_signature(@target_load_options)
$dut = nil
load environment.file if environment.file
if target.proc
target.proc.call
else
load target.file!
end
ensure
$_target_options = nil
end
@target_instantiated = true
Origen.mode = :debug if options[:force_debug]
listeners_for(:on_create).each do |obj|
unless obj.is_a?(Origen::SubBlocks::Placeholder)
if obj.try(:is_a_model_and_controller?)
m = obj.model
c = obj.controller
m.on_create if m.respond_to_directly?(:on_create)
c.on_create if c.respond_to_directly?(:on_create)
else
obj.on_create
end
end
end
@on_create_called = true
listeners_for(:on_load_target).each(&:on_load_target)
end
listeners_for(:after_load_target).each(&:after_load_target)
Origen.app.plugins.validate_production_status
@target_loading = false
end
|
#load_tasks ⇒ Object
Load all rake tasks defined in the application’s lib/task directory
207
208
209
|
# File 'lib/origen/application.rb', line 207
def load_tasks
RakeLoader.new.load_tasks
end
|
673
674
675
|
# File 'lib/origen/application.rb', line 673
def lsf
@lsf ||= LSF.new
end
|
#lsf_manager ⇒ Object
685
686
687
|
# File 'lib/origen/application.rb', line 685
def lsf_manager
@lsf_manager ||= LSFManager.new
end
|
697
698
699
|
# File 'lib/origen/application.rb', line 697
def mailer
@mailer ||= Utility::Mailer.new
end
|
#maillist_dev ⇒ Object
Returns array of email addresses in the DEV maillist file
311
312
313
|
# File 'lib/origen/application.rb', line 311
def maillist_dev
maillist_parse(maillist_dev_file)
end
|
#maillist_dev_file ⇒ Object
Returns default location of DEV maillist file (customize locally if needed)
321
322
323
|
# File 'lib/origen/application.rb', line 321
def maillist_dev_file
Origen.app.root.to_s + '/config/maillist_dev.txt'
end
|
#maillist_parse(file) ⇒ Object
Parses maillist file and returns an array of email address
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
|
# File 'lib/origen/application.rb', line 331
def maillist_parse(file)
maillist = []
if File.exist?(file)
File.readlines(file).each do |line|
if index = (line =~ /\#/)
unless line[0, index].strip.empty?
maillist << Origen::Users::User.new(line[0, index].strip).email
end
else
unless line.strip.empty?
maillist << Origen::Users::User.new(line.strip).email
end
end
end
end
maillist
end
|
#maillist_prod ⇒ Object
Returns array of email addresses in the PROD maillist file
316
317
318
|
# File 'lib/origen/application.rb', line 316
def maillist_prod
maillist_parse(maillist_prod_file)
end
|
#maillist_prod_file ⇒ Object
Returns default location of PROD maillist file (customize locally if needed)
326
327
328
|
# File 'lib/origen/application.rb', line 326
def maillist_prod_file
Origen.app.root.to_s + '/config/maillist_prod.txt'
end
|
#on_create_called? ⇒ Boolean
Returns true if the on_create callback has already been called during a target load
913
914
915
|
# File 'lib/origen/application.rb', line 913
def on_create_called?
!!@on_create_called
end
|
#on_loaded ⇒ Object
This callback handler will fire once the main app and all of its plugins have been loaded
252
253
254
|
# File 'lib/origen/application.rb', line 252
def on_loaded
config.log_deprecations
end
|
#origen_core? ⇒ Boolean
Convenience method to check if the given application instance is Origen core
257
258
259
|
# File 'lib/origen/application.rb', line 257
def origen_core?
name.to_s.symbolize == :origen_core
end
|
#pattern_iterators ⇒ Object
733
734
735
|
# File 'lib/origen/application.rb', line 733
def pattern_iterators
@pattern_iterators ||= []
end
|
803
804
805
|
# File 'lib/origen/application.rb', line 803
def pin_map
dynamic_resource(:pin_map, {})
end
|
#pin_names ⇒ Object
847
848
849
850
851
852
853
|
# File 'lib/origen/application.rb', line 847
def pin_names
if @load_event
dynamic_resource(:pin_names, {})
else
@transient_resources[:pin_names] ||= {}
end
end
|
#pin_pattern_exclude ⇒ Object
839
840
841
842
843
844
845
|
# File 'lib/origen/application.rb', line 839
def pin_pattern_exclude
if @load_event
dynamic_resource(:pin_pattern_exclude, [])
else
@transient_resources[:pin_pattern_exclude] ||= []
end
end
|
#pin_pattern_order ⇒ Object
831
832
833
834
835
836
837
|
# File 'lib/origen/application.rb', line 831
def pin_pattern_order
if @load_event
dynamic_resource(:pin_pattern_order, [])
else
@transient_resources[:pin_pattern_order] ||= []
end
end
|
#pingroup_map ⇒ Object
817
818
819
|
# File 'lib/origen/application.rb', line 817
def pingroup_map
dynamic_resource(:pingroup_map, {})
end
|
650
651
652
653
654
655
656
|
# File 'lib/origen/application.rb', line 650
def plugins
if Origen.app_loaded?
@plugins ||= Plugins.new
else
Plugins.new
end
end
|
#plugins_manager ⇒ Object
Also known as:
plugin_manager, current_plugin
658
659
660
661
|
# File 'lib/origen/application.rb', line 658
def plugins_manager
Origen.deprecated 'Origen.app.plugins_manager and Origen.app.current_plugin are deprecated, use Origen.app.plugins instead'
plugins
end
|
#previous_versions ⇒ Object
610
611
612
613
614
615
616
617
618
619
620
|
# File 'lib/origen/application.rb', line 610
def previous_versions
versions = []
File.readlines("#{Origen.root}/doc/history").each do |line|
line = line.strip
if line =~ /^#+ Tag: (.*)$/ ||
line =~ />Tag: ([^<]*)</
versions << Regexp.last_match(1).gsub('\\', '')
end
end
versions.uniq
end
|
#release(options) ⇒ Object
723
724
725
726
|
# File 'lib/origen/application.rb', line 723
def release(options)
@release ||= Release.new
@release.run(options)
end
|
#release_date(version = Origen.app.version.prefixed) ⇒ Object
Returns the release date for the current or given application version
527
528
529
530
|
# File 'lib/origen/application.rb', line 527
def release_date(version = Origen.app.version.prefixed)
time = release_time(version)
time ? time.to_date : nil
end
|
#release_note(version = Origen.app.version.prefixed) ⇒ Object
Returns the release note for the current or given application version
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
|
# File 'lib/origen/application.rb', line 490
def release_note(version = Origen.app.version.prefixed)
version = VersionString.new(version)
version = version.prefixed if version.semantic?
capture = false
note_started = false
note = []
File.readlines("#{Origen.root}/doc/history").each do |line|
line = line.strip
if capture
if note_started
if line =~ /^<a class="anchor release_tag/ || line =~ /^#+ Tag/
note.pop while note.last && note.last.empty?
return note
end
if line.empty? && note.empty?
else
note << line
end
elsif line =~ /^#+ by/
note_started = true
end
else
if line =~ /Tag:/
line = line.gsub('\\', '')
if line =~ /^#+ Tag: #{version}$/ ||
line =~ />Tag: #{version}</
capture = true
end
end
end
end
note.pop while note.last && note.last.empty?
note
end
|
#release_time(version = Origen.app.version.prefixed) ⇒ Object
Returns the release time for the current or given application version
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
|
# File 'lib/origen/application.rb', line 533
def release_time(version = Origen.app.version.prefixed)
version = VersionString.new(version)
version = version.prefixed if version.semantic?
capture = false
File.readlines("#{Origen.root}/doc/history").each do |line|
line = line.strip
if capture
if capture && line =~ /^#+ by .* on (.*(AM|PM))/
return Time.parse(Regexp.last_match(1))
end
else
if line =~ /Tag:/
line = line.gsub('\\', '')
if line =~ /^#+ Tag: #{version}$/ ||
line =~ />Tag: #{version}</
capture = true
end
end
end
end
nil
end
|
#reload_target!(options = {}) ⇒ Object
Equivalent to load_target! except that any options that were passed to load_target! the last time it was called will be re-applied when (re)loading the target.
930
931
932
933
934
935
936
937
938
|
# File 'lib/origen/application.rb', line 930
def reload_target!(options = {})
old_options = @target_load_options || {}
options = (@target_load_options || {}).merge(options)
if options[:skip_first_time] && @target_load_count == 1
@target_load_count += 1
else
load_target!(options.merge(reload: true))
end
end
|
#remotes_directory ⇒ Object
Also known as:
remotes_dir
Returns a path to the remotes directory for the application. e.g. if the app live at /home/thao/my_app, then the remotes directory will typically be /home/thao/.my_app_remotes_DO_NOT_HAND_MODIFY
Origen will ensure that this directory is outside of the scope of the current application’s revision control system. This prevents conflicts with the revision control system for the application and those used to import 3rd party dependencies
300
301
302
|
# File 'lib/origen/application.rb', line 300
def remotes_directory
workspace_manager.remotes_directory
end
|
#require_environment! ⇒ Object
269
270
271
|
# File 'lib/origen/application.rb', line 269
def require_environment!
Origen.deprecate 'Calling app.require_environment! is no longer required, the app environment is now automtically loaded when Origen.app is called'
end
|
#revision_controller(options = {}) ⇒ Object
Also known as:
rc
Returns a revision controller instance (e.g. Origen::RevisionControl::Git) which has been configured to point to the local workspace and the remote repository as defined by Origen.app.config.rc_url. If the revision control URL has not been defined, or it does not resolve to a recognized revision control system, then this method will return nil.
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
|
# File 'lib/origen/application.rb', line 216
def revision_controller(options = {})
if current?
if config.rc_url
begin
if config.rc_url =~ /^sync:/
@revision_controller ||= RevisionControl::DesignSync.new(
local: root,
remote: config.rc_url
)
elsif config.rc_url =~ /git/
@revision_controller ||= RevisionControl::Git.new(
local: root,
remote: (options[:uninitialized] ? config.rc_url : (RevisionControl::Git.origin || config.rc_url)),
allow_local_adjustment: true
)
end
rescue RevisionControlUninitializedError
@revision_controller = nil
end
elsif config.vault
@revision_controller ||= RevisionControl::DesignSync.new(
local: root,
remote: config.vault
)
end
else
fail "Only the top-level application has a revision controller! #{name} is a plugin"
end
end
|
Returns a full path to the root directory of the given application
If the application instance is a plugin then this will point to where the application is installed within the imports directory
277
278
279
|
# File 'lib/origen/application.rb', line 277
def root
@root
end
|
#root=(val) ⇒ Object
265
266
267
|
# File 'lib/origen/application.rb', line 265
def root=(val)
@root = Pathname.new(val)
end
|
677
678
679
|
# File 'lib/origen/application.rb', line 677
def runner
@runner ||= Runner.new
end
|
#server_data ⇒ Object
Returns the server data packet available for the given application, returns nil if none is found
376
377
378
379
380
381
382
|
# File 'lib/origen/application.rb', line 376
def server_data
if name == :origen
@server_data ||= Origen.client.origen
else
@server_data ||= Origen.client.plugins.find { |p| p[:origen_name].downcase == name.to_s.downcase }
end
end
|
#session(reload = false) ⇒ Object
705
706
707
708
709
710
711
712
713
714
715
716
717
|
# File 'lib/origen/application.rb', line 705
def session(reload = false)
if current?
@session = nil if reload
@session ||= Database::KeyValueStores.new(self, persist: false)
else
puts "All plugins should use the top-level application's session store, i.e. use:"
puts " Origen.app.session.#{name}"
puts 'instead of:'
puts ' Origen.app!.session'
puts
exit 1
end
end
|
#set_dynamic_resource(name, value) ⇒ Object
940
941
942
|
# File 'lib/origen/application.rb', line 940
def set_dynamic_resource(name, value)
dynamic_resource(name, value, set: true)
end
|
#statistics ⇒ Object
Also known as:
stats
728
729
730
|
# File 'lib/origen/application.rb', line 728
def statistics
runner.statistics
end
|
#subscribers_dev ⇒ Object
Returns an array of users who have subscribed for development release notifications for the given application on the website
366
367
368
369
370
371
372
|
# File 'lib/origen/application.rb', line 366
def subscribers_dev
if server_data
@subscribers_dev ||= server_data[:subscribers_dev].map { |u| User.new(u[:core_id]) }
else
[]
end
end
|
#subscribers_prod ⇒ Object
Returns an array of users who have subscribed for production release notifications for the given application on the website
356
357
358
359
360
361
362
|
# File 'lib/origen/application.rb', line 356
def subscribers_prod
if server_data
@subscribers_prod ||= server_data[:subscribers_prod].map { |u| User.new(u[:core_id]) }
else
[]
end
end
|
665
666
667
|
# File 'lib/origen/application.rb', line 665
def target
@target ||= Target.new
end
|
#target_instantiated? ⇒ Boolean
991
992
993
|
# File 'lib/origen/application.rb', line 991
def target_instantiated?
@target_instantiated
end
|
#target_loading? ⇒ Boolean
995
996
997
|
# File 'lib/origen/application.rb', line 995
def target_loading?
@target_loading || false
end
|
791
792
793
|
# File 'lib/origen/application.rb', line 791
def tester
dynamic_resource(:tester, []).first
end
|
#tester=(obj) ⇒ Object
795
796
797
798
799
800
801
|
# File 'lib/origen/application.rb', line 795
def tester=(obj)
$tester = obj
set_dynamic_resource(:tester, [obj])
end
|
#top_level ⇒ Object
Returns the current top-level object (the DUT)
431
432
433
434
435
436
|
# File 'lib/origen/application.rb', line 431
def top_level
@top_level ||= begin
t = toplevel_listeners.first
t.controller ? t.controller : t if t
end
end
|
#toplevel_listeners ⇒ Object
748
749
750
|
# File 'lib/origen/application.rb', line 748
def toplevel_listeners
dynamic_resource(:toplevel_listeners, [])
end
|
#unload_target! ⇒ Object
This method is part of a private API.
You should avoid using this method if possible, as it may be removed or be changed in the future.
Not a clean unload, but allows objects to be re-instantiated for testing
919
920
921
922
923
924
925
|
# File 'lib/origen/application.rb', line 919
def unload_target!
listeners_for(:before_load_target).each(&:before_load_target)
clear_dynamic_resources
clear_dynamic_resources(:static)
Origen::Pins.clear_pin_aliases
$dut = nil
end
|
#version(options = {}) ⇒ Object
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
|
# File 'lib/origen/application.rb', line 469
def version(options = {})
@version = nil if options[:refresh]
return @version if @version
if Origen.running_globally?
@version = Origen.version
else
load File.join(root, 'config', 'version.rb')
if defined? eval(namespace)::VERSION
@version = Origen::VersionString.new(eval(namespace)::VERSION)
else
@version = Origen::VersionString.new(eval(self.class.to_s)::VERSION)
end
end
@version
end
|
#version_tracker ⇒ Object
689
690
691
|
# File 'lib/origen/application.rb', line 689
def version_tracker
@version_tracker ||= VersionTracker.new
end
|
719
720
721
|
# File 'lib/origen/application.rb', line 719
def versions
version_tracker.versions
end
|
#with_doc_tester(options = {}) ⇒ Object
Any attempts to instantiate a tester within the give block will be forced to instantiate an Origen::Tester::Doc instance
773
774
775
776
777
778
779
780
781
|
# File 'lib/origen/application.rb', line 773
def with_doc_tester(options = {})
@with_doc_tester = true
if options[:html]
@with_html_doc_tester = true
end
yield
@with_doc_tester = false
@with_html_doc_tester = false
end
|
#with_doc_tester? ⇒ Boolean
783
784
785
|
# File 'lib/origen/application.rb', line 783
def with_doc_tester?
@with_doc_tester
end
|
#with_html_doc_tester? ⇒ Boolean
787
788
789
|
# File 'lib/origen/application.rb', line 787
def with_html_doc_tester?
@with_html_doc_tester
end
|
#workspace_manager ⇒ Object
693
694
695
|
# File 'lib/origen/application.rb', line 693
def workspace_manager
@workspace_manager ||= WorkspaceManager.new
end
|