origen 0.7.23 → 0.7.24

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 93745a8389b038130ff9ea3497ff7c20eb3b115a
4
- data.tar.gz: 91edbedad884bbbcc8752e62e05c6f96b3d5d4d3
3
+ metadata.gz: 96077b0fbaaf9abb787b9db8aa77e996da1035b9
4
+ data.tar.gz: 9c54cb2a4381a4176e683a5818660f5e69a979df
5
5
  SHA512:
6
- metadata.gz: a4e6949d31e47568c928342dde21191fd1c94beb111547d44bbd1781c0294147cde9676d8269eaafe444ebe527eb7febada8f2325a60ea4850953067c3bb7898
7
- data.tar.gz: 518c7bf4e8d3a3ffcf403eba3f93c89863e1d401f2fd62f4ae26ef5912964eed3fce4095bbe7b22b10a261fc2f98dd99aa94f46bc18d2127c4dd65eda06867c0
6
+ metadata.gz: c0a59431d8da8766af067d96397e11fb0d22b78a3e8a6f8ebb34b6b1cdd8f2f5ed21e73ea57bb0cd4a1897030e2a4aa292aa4f936afdcc166ba7cf5a7be470fe
7
+ data.tar.gz: a192b3b3d8a0982d7302570899709f70b8ad44b585ef1d2e034c0d7b3baf227a4fe2ad9bd85b4918938efddd747032e62cbed515882cc223b17e8aa355005555
data/config/version.rb CHANGED
@@ -1,7 +1,7 @@
1
1
  module Origen
2
2
  MAJOR = 0
3
3
  MINOR = 7
4
- BUGFIX = 23
4
+ BUGFIX = 24
5
5
  DEV = nil
6
6
 
7
7
  VERSION = [MAJOR, MINOR, BUGFIX].join(".") + (DEV ? ".pre#{DEV}" : '')
data/lib/origen.rb CHANGED
@@ -109,6 +109,10 @@ unless defined? RGen::ORIGENTRANSITION
109
109
  @application_loaded
110
110
  end
111
111
 
112
+ def plugins_loaded?
113
+ @plugins_loaded
114
+ end
115
+
112
116
  # Returns the current (top-level) application instance
113
117
  def app(plugin = nil, _options = {})
114
118
  plugin, options = nil, plugin if plugin.is_a?(Hash)
@@ -418,8 +422,7 @@ unless defined? RGen::ORIGENTRANSITION
418
422
  # chdir to the new app directory (to fetch it) Origen.log would try to load the partial app.
419
423
  @running_outside_an_app = true unless in_app_workspace?
420
424
  return nil if @running_outside_an_app
421
- require File.join(root, APP_CONFIG)
422
- @application = _applications_lookup[:root][root.to_s]
425
+ # Load the app's plugins and other gem requirements
423
426
  if File.exist?(File.join(root, 'Gemfile')) && !@with_boot_environment
424
427
  # Don't understand the rules here, belt and braces approach for now to make
425
428
  # sure that all Origen plugins are auto-required (otherwise Origen won't know
@@ -429,6 +432,12 @@ unless defined? RGen::ORIGENTRANSITION
429
432
  Bundler.require(:runtime)
430
433
  Bundler.require(:default)
431
434
  end
435
+ @plugins_loaded = true
436
+ # Now load the app
437
+ @loading_top_level = true
438
+ require File.join(root, APP_CONFIG)
439
+ @application = _applications_lookup[:root][root.to_s]
440
+ @loading_top_level = false
432
441
  if @with_boot_environment
433
442
  @application.plugins.disable_current
434
443
  else
@@ -447,6 +456,11 @@ unless defined? RGen::ORIGENTRANSITION
447
456
  end
448
457
  end
449
458
 
459
+ # @api private
460
+ def loading_top_level?
461
+ @loading_top_level
462
+ end
463
+
450
464
  def launch_time
451
465
  @launch_time ||= time_now
452
466
  end
@@ -35,7 +35,12 @@ module Origen
35
35
  root = Pathname.new(caller[0].sub(/(\\|\/)?config(\\|\/)application.rb.*/, '')).realpath
36
36
  app = base.instance
37
37
  app.root = root.to_s
38
- Origen.register_application(app)
38
+ if Origen.plugins_loaded? && !Origen.loading_top_level?
39
+ Origen.log.warning "The #{app.name} plugin is using a non-standard loading mechanism, upgrade to a newer version to get rid of this error (please report a bug if that does not remove this warning)"
40
+ Origen.app.plugins << app
41
+ else
42
+ Origen.register_application(app)
43
+ end
39
44
  app.add_lib_to_load_path!
40
45
  end
41
46
  end
@@ -253,13 +258,47 @@ module Origen
253
258
  # Returns true if the given application instance is the
254
259
  # current top level application
255
260
  def current?
256
- Origen.app == self
261
+ # If this is called before the plugins are loaded (i.e. by a plugin's application file), then
262
+ # it is definitely not the top-level app
263
+ if Origen.plugins_loaded?
264
+ Origen.app == self
265
+ else
266
+ false
267
+ end
257
268
  end
269
+ alias_method :standalone?, :current?
270
+ alias_method :running_standalone?, :current?
258
271
 
259
272
  # Returns true if the given application instance is
260
273
  # the current plugin
261
274
  def current_plugin?
262
- Origen.app.plugins.current == self
275
+ if Origen.plugins_loaded?
276
+ Origen.app.plugins.current == self
277
+ else
278
+ puts <<-END
279
+ current_plugin? cannot be used at this point in your code since the app is not loaded yet.
280
+
281
+ If you are calling this from config/application.rb then you can only use current_plugin? within a block:
282
+
283
+ # Not OK
284
+ if current_plugin?
285
+ config.output_directory = "#{Origen.root}/output/dir1"
286
+ else
287
+ config.output_directory = "#{Origen.root}/output/dir2"
288
+ end
289
+
290
+ # OK
291
+ config.output_directory do
292
+ if current_plugin?
293
+ "#{Origen.root}/output/dir1"
294
+ else
295
+ "#{Origen.root}/output/dir2"
296
+ end
297
+ end
298
+
299
+ END
300
+ exit 1
301
+ end
263
302
  end
264
303
 
265
304
  # Returns the current top-level object (the DUT)
@@ -464,6 +503,10 @@ module Origen
464
503
  @config ||= Configuration.new(self)
465
504
  end
466
505
 
506
+ def add_config_attribute(*args)
507
+ Application::Configuration.add_attribute(*args)
508
+ end
509
+
467
510
  # Returns the name of the given application, this is the name that will
468
511
  # be used to refer to the application when it is used as a plugin
469
512
  def name
@@ -37,11 +37,11 @@ module Origen
37
37
 
38
38
  # Any attributes that want to accept a block, but not necessarily require the target
39
39
  # can be added here
40
- ATTRS_THAT_ACCEPT_A_BLOCK = ATTRS_THAT_DEPEND_ON_TARGET +
41
- [:release_instructions, :history_file, :log_directory, :copy_command,
42
- :diff_command, :remotes,
43
- :external_app_dirs
44
- ]
40
+ ATTRS_THAT_DONT_DEPEND_ON_TARGET = [
41
+ :release_instructions, :history_file, :log_directory, :copy_command,
42
+ :diff_command, :remotes,
43
+ :external_app_dirs
44
+ ]
45
45
 
46
46
  # If a current plugin is present then its value for these attributes will be
47
47
  # used instead of that from the current application
@@ -122,7 +122,11 @@ module Origen
122
122
  # # config/application.rb
123
123
  #
124
124
  # config.output_directory = ->{ "#{Origen.root}/output/#{$dut.class}" }
125
- ATTRS_THAT_ACCEPT_A_BLOCK.each do |name|
125
+ def self.add_attribute(name, options = {})
126
+ options = {
127
+ depend_on_target: true
128
+ }.merge(options)
129
+ attr_writer name
126
130
  define_method name do |override = true, &block|
127
131
  if block # _given?
128
132
  instance_variable_set("@#{name}".to_sym, block)
@@ -131,9 +135,9 @@ module Origen
131
135
  app.current? && Origen.app.plugins.current
132
136
  var = Origen.app.plugins.current.config.send(name, override: false)
133
137
  end
134
- var ||= instance_variable_get("@#{name}".to_sym)
138
+ var ||= instance_variable_get("@#{name}".to_sym) || options[:default]
135
139
  if var.respond_to?('call')
136
- if ATTRS_THAT_DEPEND_ON_TARGET.include?(name)
140
+ if options[:depend_on_target]
137
141
  # If an attempt has been made to access this attribute before the target has
138
142
  # been instantiated raise an error
139
143
  # Note Origen.app here instead of just app to ensure we are talking to the top level application,
@@ -150,7 +154,11 @@ module Origen
150
154
  end
151
155
  end
152
156
 
153
- (ATTRS_THAT_CURRENT_PLUGIN_CAN_OVERRIDE - ATTRS_THAT_ACCEPT_A_BLOCK).each do |name|
157
+ ATTRS_THAT_DEPEND_ON_TARGET.each { |n| add_attribute(n) }
158
+
159
+ ATTRS_THAT_DONT_DEPEND_ON_TARGET.each { |n| add_attribute(n, depend_on_target: false) }
160
+
161
+ (ATTRS_THAT_CURRENT_PLUGIN_CAN_OVERRIDE - ATTRS_THAT_DEPEND_ON_TARGET - ATTRS_THAT_DONT_DEPEND_ON_TARGET).each do |name|
154
162
  if override && ATTRS_THAT_CURRENT_PLUGIN_CAN_OVERRIDE.include?(name) &&
155
163
  app.current? && Origen.app.plugins.current
156
164
  var = Origen.app.plugins.current.config.send(name, override: false)
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: origen
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.7.23
4
+ version: 0.7.24
5
5
  platform: ruby
6
6
  authors:
7
7
  - Stephen McGinty
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-08-12 00:00:00.000000000 Z
11
+ date: 2016-08-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -567,7 +567,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
567
567
  version: 1.8.11
568
568
  requirements: []
569
569
  rubyforge_project:
570
- rubygems_version: 2.2.2
570
+ rubygems_version: 2.5.1
571
571
  signing_key:
572
572
  specification_version: 4
573
573
  summary: The Semiconductor Developer's Kit