origen 0.27.0 → 0.28.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 1bd96773b56519ca3c588ba06ddd2db770a6a3b8
4
- data.tar.gz: 68f3a9c05792dde205b99001d9cece88c0d1d98b
3
+ metadata.gz: de6c14abeb7969c56b039ecae7c2b8895942cc31
4
+ data.tar.gz: 6537fdfdd336093de65eb0d122902adb9ceb21aa
5
5
  SHA512:
6
- metadata.gz: 87cb67532f2c74ec3e83ba6502d527517d95a1fd96a6066a9ef11f9675cb0221c951beec990cced059914bd27a7c3e14a90c66fbc0e910b96aed77c5fb8150b5
7
- data.tar.gz: 8a1adf271a8d4f3d2f2d0f66be8e92a957ca00278ce4a9557a8b4fec015b106221469754d8dafbc2f782cd4a4728facd533985d3f5e182016b4c38f30564334f
6
+ metadata.gz: 64d3ca87c62cf25de9082e6ce7c263a504bf1bc6ed7cc06f653989e06cb053a400e194cb3a280dbf6202ee939f1eea57c4fa6cb384d5af57bd24db99971bf07f
7
+ data.tar.gz: 6c730671056c7bf5d39f04b9dfa0578a1985006d347cf4c2c4a2f19d9bfc944b419f0304b421188573843672136ef4e19c01297a8660c3c0c5d8ac18b13c2cc6
data/config/version.rb CHANGED
@@ -1,6 +1,6 @@
1
1
  module Origen
2
2
  MAJOR = 0
3
- MINOR = 27
3
+ MINOR = 28
4
4
  BUGFIX = 0
5
5
  DEV = nil
6
6
 
data/lib/origen.rb CHANGED
@@ -162,6 +162,10 @@ unless defined? RGen::ORIGENTRANSITION
162
162
  end
163
163
  alias_method :application!, :app!
164
164
 
165
+ def has_plugin?(plugin)
166
+ _applications_lookup[:name][plugin.to_sym].nil? ? false : true
167
+ end
168
+
165
169
  # @api private
166
170
  def with_source_file(file)
167
171
  @current_source_dir = Pathname.new(file).dirname
@@ -727,6 +731,15 @@ unless defined? RGen::ORIGENTRANSITION
727
731
  @lsf ||= Origen::Application::LSF.new
728
732
  end
729
733
 
734
+ # Let's Origen know about any domain specific acronyms used with an application, this will cause
735
+ # them to be translated between underscored and camel-cased versions correctly
736
+ def register_acronym(name)
737
+ require 'active_support/core_ext/string/inflections'
738
+ ActiveSupport::Inflector.inflections(:en) do |inflect|
739
+ inflect.acronym(name)
740
+ end
741
+ end
742
+
730
743
  private
731
744
 
732
745
  def current_command=(val)
@@ -21,6 +21,9 @@ module Origen
21
21
  if line =~ /^\s*gem\s+(("|')\w+("|')),.*(:path\s*=>|path:)/
22
22
  fail "The following gem is defined as a path in your Gemfile, but that is not allowed in production: #{Regexp.last_match[1]}"
23
23
  end
24
+ if line =~ /ORIGEN PLUGIN AUTO-GENERATED/
25
+ fail 'Fetched gems are currently being used in your Gemfile, but that is not allowed in production!'
26
+ end
24
27
  end
25
28
  end
26
29
  end
@@ -228,7 +228,7 @@ end.compact
228
228
 
229
229
  case @command
230
230
  when 'generate', 'program', 'compile', 'merge', 'interactive', 'target', 'environment',
231
- 'save', 'lsf', 'web', 'time', 'dispatch', 'rc', 'lint', 'plugin', 'fetch', 'mode' # , 'add'
231
+ 'save', 'lsf', 'web', 'time', 'dispatch', 'rc', 'lint', 'plugin', 'fetch', 'mode', 'gem' # , 'add'
232
232
 
233
233
  require "origen/commands/#{@command}"
234
234
  exit 0 unless @command == 'interactive'
@@ -1,4 +1,9 @@
1
1
  require 'optparse'
2
+ require 'fileutils'
3
+ require 'rubygems'
4
+ require 'origen/version_string'
5
+
6
+ include Origen::Utility::InputCapture
2
7
 
3
8
  options = {}
4
9
 
@@ -12,22 +17,110 @@ Usage: origen pl
12
17
 
13
18
  Quickstart Examples:
14
19
  origen pl # Displays the current plugin
15
- origen pl added # Lists the included plugins
16
20
  origen pl [plugin_name] # Sets the specified plugin as current plugin
17
21
  origen pl reset # Resets the current plugin to none
22
+ origen pl added # Lists the included Origen plugins
23
+ origen pl added --all # Lists the included Origen plugins and external gem dependencies
24
+ origen pl fetch [plugin_name] # Populates plugin/gem source to a local repo (<app_root>/tmp/gems/)
25
+ origen pl clean [plugin_name|all] # Removes the local copy of the plugin/gem source
26
+ origen pl info [plugin_name] # Get additional details of the plugin
18
27
 
19
28
  The following commands are available:
20
29
 
21
30
  added Displays all plugins that are currently included in this app locally
31
+ reset Resets the current plugin to none
32
+ fetch Populates plugin/gem source to a local repo (<app_root>/tmp/gems/)
33
+ clean Removes the local copy of the plugin/gem source
34
+ info Displays detailed information about the plugin/gem
22
35
 
23
36
  The following options are available:
24
37
  EOT
38
+ opts.on('-a', '--allr', 'List all plugins/gems (including external)') { options[:debugger] = true }
25
39
  opts.on('-d', '--debugger', 'Enable the debugger') { options[:debugger] = true }
26
40
  opts.on('-h', '--help', 'Show this message') { puts opts; exit }
27
41
  end
28
42
 
29
43
  opt_parser.parse! ARGV
30
44
 
45
+ QUIET_ATTRS = %w(
46
+ files test_files signing_key licenses rdoc_options
47
+ autorequire cert_chain post_install_message
48
+ )
49
+
50
+ def self._local_gems
51
+ gems = {}
52
+ Gem::Specification.sort_by { |g| [g.name.downcase, g.version] }.group_by(&:name).map do |name, specs|
53
+ gems[name.to_sym] = {
54
+ name: name,
55
+ version: specs.map(&:version).join(','),
56
+ location: specs.map(&:full_gem_path).join(','),
57
+ authors: specs.map(&:authors).join(',')
58
+ }
59
+ end
60
+ gems
61
+ end
62
+
63
+ def self._local_gems_orig
64
+ Gem::Specification.sort_by { |g| [g.name.downcase, g.version] }.group_by(&:name)
65
+ end
66
+
67
+ def self._session_gem_path
68
+ "#{Origen.app.root}/tmp/gems"
69
+ end
70
+
71
+ def self._application_gemfile
72
+ "#{Origen.app.root}/Gemfile"
73
+ end
74
+
75
+ def self._local_path_to_gem(gem)
76
+ "#{_session_gem_path}/#{Pathname(gem[:location]).basename}"
77
+ end
78
+
79
+ def self._gem_basename(gem)
80
+ "#{Pathname(gem[:location]).basename}"
81
+ end
82
+
83
+ def self._gem_rc_version(gem)
84
+ gem[:version]
85
+ end
86
+
87
+ def self._update_gemfile
88
+ content = File.read(_application_gemfile)
89
+
90
+ search_regexp = "# ORIGEN PLUGIN AUTO-GENERATED.*# /ORIGEN PLUGIN AUTO-GENERATED.*?\n"
91
+
92
+ if Origen.app.session.gems.keys.empty?
93
+ new_contents = content.gsub(/#{search_regexp}/m, '')
94
+ else
95
+ replacement_string = "# ORIGEN PLUGIN AUTO-GENERATED---------------DO NOT REMOVE THIS LINE-------------\n"
96
+ replacement_string += "# -- DO NOT CHECK IN WITH THIS SECTION!\n"
97
+ replacement_string += "# -- DO NOT HAND MODIFY!\n"
98
+ replacement_string += "# -- USE 'origen pl clean all' to reset\n"
99
+ replacement_string += "\n"
100
+
101
+ Origen.app.session.gems.keys.sort.each do |g|
102
+ replacement_string += "gem '#{g}', path: '#{Origen.app.session.gems[g.to_sym]}'\n"
103
+ replacement_string += "puts \"\\e[1;93;40mWARNING: Using session gem for '#{g}'\\e[0m\"\n"
104
+ end
105
+
106
+ replacement_string += "def gem(*args)\n"
107
+ replacement_string += " return if [#{Origen.app.session.gems.keys.sort.map { |e| "'" + e.to_s + "'" }.join(',')}].include? args[0]\n"
108
+ replacement_string += " super(*args)\n"
109
+ replacement_string += "end\n"
110
+ replacement_string += "#\n"
111
+ replacement_string += "# /ORIGEN PLUGIN AUTO-GENERATED---------------DO NOT REMOVE THIS LINE------------\n"
112
+
113
+ if content =~ /#{search_regexp}/m
114
+ new_contents = content.gsub(/#{search_regexp}/m, replacement_string)
115
+ else
116
+ new_contents = replacement_string + content
117
+ end
118
+ end
119
+ File.open(_application_gemfile, 'w') { |file| file.puts new_contents }
120
+ end
121
+
122
+ gems = _local_gems
123
+
31
124
  if !ARGV[0]
32
125
  if Origen.app.plugins.current
33
126
  puts "Current plugin is: #{Origen.app.plugins.current.name}"
@@ -64,8 +157,153 @@ else
64
157
  end
65
158
  puts
66
159
  exit 0
160
+ when 'fetch'
161
+ gem = ARGV[0]
162
+ if gem
163
+ if gems.key?(gem.to_sym)
164
+ # Initialize ./tmp/gems/
165
+ FileUtils.mkdir_p(_session_gem_path) unless Dir.exist? _session_gem_path
166
+
167
+ if Dir.exist? _local_path_to_gem(gems[gem.to_sym])
168
+ # check if already exists, ask for permission to blow away
169
+ puts ''
170
+ puts "Plugin/Gem '#{_gem_basename(gems[gem.to_sym])}' already exists locally, would you like to replace?"
171
+ puts "(This will delete and replace the exising copy at #{_local_path_to_gem(gems[gem.to_sym])})"
172
+ puts ''
173
+ get_text confirm: true
174
+ Origen::Log.console_only do
175
+ Dir.chdir Origen.root do
176
+ # Blow away these temporary files
177
+ system("rm -fr #{_local_path_to_gem(gems[gem.to_sym])}")
178
+ end
179
+ end
180
+ end
181
+
182
+ if Origen.has_plugin?(gem)
183
+ # Set up the requested plugin workspace
184
+ rc_url = Origen.app(gem.to_sym).config.rc_url || Origen.app(gem.to_sym).config.vault
185
+ if rc_url =~ /git/
186
+ Origen::RevisionControl::Git.git("clone #{rc_url} #{_gem_basename(gems[gem.to_sym])}", local: _session_gem_path, verbose: true)
187
+ else
188
+ # Use Origen::RevisionControl for DesignSync
189
+ rc = Origen::RevisionControl.new remote: rc_url, local: _local_path_to_gem(gems[gem.to_sym])
190
+ tag = Origen::VersionString.new(_gem_rc_version(gems[gem.to_sym]))
191
+ tag = tag.prefixed if tag.semantic?
192
+ rc.build version: tag
193
+ end
194
+ else
195
+ puts 'Not an Origen plugin, only COPYING source.'
196
+ FileUtils.cp_r(gems[gem.to_sym][:location], _session_gem_path)
197
+ end
198
+
199
+ # FileUtils.cp_r(gems[gem.to_sym][:location], _session_gem_path)
200
+ unless options[:dont_use]
201
+ Origen.app.session.gems[gem.to_sym] = "#{_local_path_to_gem(gems[gem.to_sym])}"
202
+ end
67
203
 
68
- # when 'list'
204
+ _update_gemfile
205
+
206
+ puts "Fetched #{gem} to tmp/gems/#{_gem_basename(gems[gem.to_sym])}"
207
+ puts ''
208
+ else
209
+ puts "Error: '#{gem}' is not a currently used plugin/gem. Use 'origen pl list' for gem list."
210
+ end
211
+ else
212
+ puts "Error: Must specify plugin/gem to be fetched. Use 'origen pl -h' for usage"
213
+ end
214
+ when 'clean'
215
+ gem = ARGV[0]
216
+ if gem
217
+ if gem == 'all'
218
+ if Dir.exist? _session_gem_path
219
+ puts ''
220
+ puts 'You are about to delete all local plugin/gems (tmp/gems/). IS THAT CORRECT?'
221
+ puts ''
222
+ get_text confirm: true
223
+ Origen::Log.console_only do
224
+ Dir.chdir Origen.root do
225
+ system("rm -fr #{_session_gem_path}")
226
+ end
227
+ end
228
+ unless Origen.app.session.gems.keys.empty?
229
+ Origen.app.session.gems.keys.sort.each do |g|
230
+ Origen.app.session.gems.delete_key(g)
231
+ end
232
+ _update_gemfile
233
+ end
234
+ else
235
+ puts 'There are no local plugins/gems present, nothing to clean.'
236
+ end
237
+ elsif gems.key?(gem.to_sym)
238
+ if Dir.exist? _local_path_to_gem(gems[gem.to_sym])
239
+ # check if already exists, ask for permission to blow away
240
+ puts ''
241
+ puts "You are about to delete the local copy of '#{gem}' (tmp/gems/#{_gem_basename(gems[gem.to_sym])}). IS THAT CORRECT?"
242
+ puts ''
243
+ get_text confirm: true
244
+ Origen::Log.console_only do
245
+ Dir.chdir Origen.root do
246
+ system("rm -fr #{_local_path_to_gem(gems[gem.to_sym])}")
247
+ end
248
+ end
249
+ Origen.app.session.gems.delete_key(gem.to_sym)
250
+ _update_gemfile
251
+ else
252
+ puts "Plugin/Gem '#{gem}' is not locally present, nothing to clean."
253
+ end
254
+ end
255
+ else
256
+ puts "Error: Must specify plugin/gem to be cleaned or 'all'. Use 'origen pl -h' for usage"
257
+ end
258
+ when 'info'
259
+ gem = ARGV[0]
260
+ if gem
261
+ if gems.key?(gem.to_sym)
262
+ a = _local_gems_orig[gem].to_yaml.split(/\n+/)
263
+ skip = true
264
+
265
+ if options[:gem_location] || options[:gem_version]
266
+ puts '================================================================================='
267
+ puts "Gem Name: #{gems[gem.to_sym][:name]}"
268
+ puts "Version: #{gems[gem.to_sym][:version]}" if options[:gem_version]
269
+ puts "Location: #{gems[gem.to_sym][:location]}" if options[:gem_location]
270
+ puts '================================================================================='
271
+ else
272
+ puts '================================================================================='
273
+ puts "Gem Name: #{gems[gem.to_sym][:name]}"
274
+ puts "Version: #{gems[gem.to_sym][:version]}"
275
+ puts "Location: #{gems[gem.to_sym][:location]}"
276
+ puts '---------------------------------------------------------------------------------'
277
+ puts 'Details:'
278
+ a.each do |line|
279
+ if line =~ /^ (\w+):(.*)$/
280
+ topic = Regexp.last_match(1)
281
+ if QUIET_ATTRS.include? topic
282
+ skip = true
283
+ else
284
+ skip = false
285
+ end
286
+ end
287
+ puts " #{line}" unless skip
288
+ end
289
+ puts '---------------------------------------------------------------------------------'
290
+ puts '================================================================================='
291
+ end
292
+ else
293
+ puts "Error: '#{gem}' not a valid command or plugin/gem. Use 'origen pl -h' for usage or 'origen pl list' for plugin/gem list."
294
+ end
295
+ else
296
+ puts "Error: Must specify plugin/gem for the info command. Use 'origen pl -h' for usage"
297
+ end
298
+ when 'list'
299
+ longest_key = gems.keys.max_by(&:length)
300
+ puts ''
301
+ printf "%-#{longest_key.length}s %-15s %s\n", 'Gem', 'Version', 'Location'
302
+ puts '--------------------------------------------------------------------------------------------------------------'
303
+ gems.each do |k, v|
304
+ printf "%-#{longest_key.length}s %-15s %s\n", k, v[:version], v[:location]
305
+ end
306
+ puts ''
69
307
  # Origen.plugins_manager.list
70
308
  # when 'describe'
71
309
  # puts Origen.plugins_manager.describe(ARGV.shift)
@@ -86,7 +324,6 @@ else
86
324
  # end
87
325
 
88
326
  else
89
-
90
327
  Origen.app.plugins.current = input.to_sym
91
328
  if Origen.app.plugins.current
92
329
  puts "#{Origen.app.plugins.current.name} is now set as the current plugin."
@@ -9,3 +9,4 @@ require 'origen/core_ext/array'
9
9
  require 'origen/core_ext/range'
10
10
  require 'origen/core_ext/enumerable'
11
11
  require 'origen/core_ext/regexp'
12
+ require 'origen/core_ext/symbol'
@@ -57,7 +57,7 @@ class Numeric
57
57
  end
58
58
  end
59
59
 
60
- %w(Hz hz Ts ts bps sps ohm Ohm a A v V s S).each do |m|
60
+ %w(Hz hz Ts ts bps sps ohm Ohm a A v V s S f F).each do |m|
61
61
  define_method "as_#{m}" do
62
62
  as_units(m)
63
63
  end
@@ -134,31 +134,31 @@ class Numeric
134
134
  end
135
135
  end
136
136
 
137
- %w(v V s S a A Hz Ts Ohm ohm O o).each do |m|
137
+ %w(v V s S a A Hz Ts Ohm ohm O o f F).each do |m|
138
138
  define_method m do
139
139
  self
140
140
  end
141
141
  end
142
142
 
143
- %w(mv mV ms mS ma mA mo mO mOhm mohm).each do |m|
143
+ %w(mv mV ms mS ma mA mo mO mOhm mohm mf mF).each do |m|
144
144
  define_method m do
145
145
  self / 1_000.0
146
146
  end
147
147
  end
148
148
 
149
- %w(uv uV us uS ua uA).each do |m|
149
+ %w(uv uV us uS ua uA uf uF).each do |m|
150
150
  define_method m do
151
151
  self / 1_000_000.0
152
152
  end
153
153
  end
154
154
 
155
- %w(nv nV ns nS na nA).each do |m|
155
+ %w(nv nV ns nS na nA nf nF).each do |m|
156
156
  define_method m do
157
157
  self / 1_000_000_000.0
158
158
  end
159
159
  end
160
160
 
161
- %w(pv pV ps pS pa pA).each do |m|
161
+ %w(pv pV ps pS pa pA pf pF).each do |m|
162
162
  define_method m do
163
163
  self / 1_000_000_000_000.0
164
164
  end
@@ -141,6 +141,30 @@ class String
141
141
  end
142
142
  end
143
143
 
144
+ # Boolean if the string is uppercase
145
+ # Will not work with odd character sets
146
+ def is_upcase?
147
+ self == upcase
148
+ end
149
+ alias_method :is_uppercase?, :is_upcase?
150
+
151
+ # Boolean if the string is uppercase
152
+ # Will not work with odd character sets
153
+ def is_downcase?
154
+ self == downcase
155
+ end
156
+ alias_method :is_lowercase?, :is_downcase?
157
+
158
+ # Convert Excel/Spreadsheet column to integer
159
+ def excel_col_index
160
+ str = split('').map(&:upcase).join('')
161
+ offset = 'A'.ord - 1
162
+ str.chars.inject(0) { |x, c| x * 26 + c.ord - offset }
163
+ end
164
+ alias_method :xls_col_index, :excel_col_index
165
+ alias_method :xlsx_col_index, :excel_col_index
166
+ alias_method :spreadsheet_col_index, :excel_col_index
167
+
144
168
  private
145
169
 
146
170
  # Convert a verilog number string to an integer
@@ -0,0 +1,5 @@
1
+ class Symbol
2
+ def smatch(regexp)
3
+ to_s.match(regexp)
4
+ end
5
+ end
data/lib/origen/model.rb CHANGED
@@ -7,6 +7,8 @@ module Origen
7
7
  module Model
8
8
  extend ActiveSupport::Concern
9
9
 
10
+ autoload :Exporter, 'origen/model/exporter'
11
+
10
12
  included do
11
13
  attr_writer :ip_name
12
14
  attr_accessor :version
@@ -29,6 +31,7 @@ module Origen
29
31
  include Origen::Tests
30
32
  include Origen::PowerDomains
31
33
  include Origen::Clocks
34
+ include Origen::Model::Exporter
32
35
  end
33
36
 
34
37
  module ClassMethods