origen 0.24.0 → 0.25.0

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: 680531e26b7e211517e36649bd3d684d5d8452ef
4
- data.tar.gz: aa8bde4fe52e7d10775eb9fc790baaf7f99a7fc7
3
+ metadata.gz: 57352a8b9560ae28fd11789e2338de6d77691e46
4
+ data.tar.gz: 41ad98388361e0e274e3d113b179e8a707f83ecb
5
5
  SHA512:
6
- metadata.gz: 933e06b3c0e4b4c4ce85a0c54ccd4e855ef1fdb9292b6d39828083bdffecc92df0434d28b4b38115c705b421922bfb43cdbc3cbd1470887f4b936189316ead83
7
- data.tar.gz: dc94a81757cb13be94012c7d9cd699842c0075d10f4abf11882531e93b8333752a176ca5d0c1a9eb09f6a31fda2675ff6e058220cb6abffbd7fc5452eaefd020
6
+ metadata.gz: dd1086933ce68c4e4218d260efda5d612c7c0a4372d4dc6a6325310e8941522d6e70b51c4f31a5a22ffbeeaceb1fdde0f450b5f1d9fceea3eb8aeac24430470c
7
+ data.tar.gz: 787cff0c13841c02c7f846005fb29bd08510bd8ddc38a49942120713494aa463542b451afade21922ff1a5e936e20346bb087fa1be82b5e8788cc4f29c8c178e
data/config/version.rb CHANGED
@@ -1,6 +1,6 @@
1
1
  module Origen
2
2
  MAJOR = 0
3
- MINOR = 24
3
+ MINOR = 25
4
4
  BUGFIX = 0
5
5
  DEV = nil
6
6
 
data/lib/origen.rb CHANGED
@@ -159,6 +159,10 @@ unless defined? RGen::ORIGENTRANSITION
159
159
  end
160
160
  alias_method :application!, :app!
161
161
 
162
+ def has_plugin?(plugin)
163
+ _applications_lookup[:name][plugin.to_sym].nil? ? false : true
164
+ end
165
+
162
166
  # @api private
163
167
  def with_source_file(file)
164
168
  @current_source_dir = Pathname.new(file).dirname
@@ -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,5 @@
1
1
  require 'optparse'
2
+ require 'origen/commands/helpers'
2
3
 
3
4
  options = {}
4
5
 
@@ -42,9 +43,8 @@ Usage: origen compile [space separated files, lists or directories] [options]
42
43
  opts.on('-n', '--name NAME', String, 'Override the default output file name') { |o| options[:output_file_name] = o }
43
44
  opts.on('-r', '--reference DIR', String, 'Override the default reference directory') { |o| options[:reference] = o }
44
45
  opts.on('-z', '--zip', 'Gzip all output files (diff checking will be skipped)') { |o| options[:zip] = o }
45
- app_options.each do |app_option|
46
- opts.on(*app_option) {}
47
- end
46
+ # Apply any application option extensions to the OptionParser
47
+ Origen::CommandHelpers.extend_options(opts, app_options, options)
48
48
  opts.separator ''
49
49
  opts.on('-h', '--help', 'Show this message') { puts opts; exit 0 }
50
50
  end
@@ -0,0 +1,270 @@
1
+ require 'optparse'
2
+ require 'fileutils'
3
+ require 'rubygems'
4
+ require 'origen/version_string'
5
+
6
+ include Origen::Utility::InputCapture
7
+
8
+ options = {}
9
+
10
+ opt_parser = OptionParser.new do |opts|
11
+ opts.banner = <<-END
12
+ Usage: origen gem
13
+ origen gem gem_name [option]
14
+ origen gem fetch gem_name
15
+ origen gem clean (gem_name|all)
16
+
17
+ Quickstart Examples:
18
+ origen gem # Displays the list of currently used gems
19
+ origen gem gem_name # Displays details of specified gem
20
+ origen gem fetch gem name # Poluates/copies gem source to a local repo (<application_top_level_path>/tmp/gems)
21
+ # and updates Gemfile to use local copy
22
+ origen gem clean (gem_name|all) # Removes/deletes the local copy of the gem source and updated Gemfile to
23
+ # use originally specified version/path
24
+
25
+ The following options are available:
26
+ END
27
+ opts.on('--location', 'Display the location of the specified gem') { options[:gem_location] = true }
28
+ opts.on('--version', 'Display the version of the specified gem') { options[:gem_version] = true }
29
+ opts.on('-h', '--help', 'Show this message') { puts opts; exit }
30
+ end
31
+
32
+ opt_parser.parse! ARGV
33
+
34
+ QUIET_ATTRS = %w(
35
+ files test_files signing_key licenses rdoc_options
36
+ autorequire cert_chain post_install_message
37
+ )
38
+
39
+ def self._local_gems
40
+ gems = {}
41
+ Gem::Specification.sort_by { |g| [g.name.downcase, g.version] }.group_by(&:name).map do |name, specs|
42
+ gems[name.to_sym] = {
43
+ name: name,
44
+ version: specs.map(&:version).join(','),
45
+ location: specs.map(&:full_gem_path).join(','),
46
+ authors: specs.map(&:authors).join(',')
47
+ }
48
+ end
49
+ gems
50
+ end
51
+
52
+ def self._local_gems_orig
53
+ Gem::Specification.sort_by { |g| [g.name.downcase, g.version] }.group_by(&:name)
54
+ end
55
+
56
+ def self._session_gem_path
57
+ "#{Origen.app.root}/tmp/gems"
58
+ end
59
+
60
+ def self._application_gemfile
61
+ "#{Origen.app.root}/Gemfile"
62
+ end
63
+
64
+ def self._local_path_to_gem(gem)
65
+ "#{_session_gem_path}/#{Pathname(gem[:location]).basename}"
66
+ end
67
+
68
+ def self._gem_basename(gem)
69
+ "#{Pathname(gem[:location]).basename}"
70
+ end
71
+
72
+ def self._gem_rc_version(gem)
73
+ gem[:version]
74
+ end
75
+
76
+ def self._update_gemfile
77
+ content = File.read(_application_gemfile)
78
+
79
+ search_regexp = "# ORIGEN GEM AUTO-GENERATED.*# /ORIGEN GEM AUTO-GENERATED.*?\n"
80
+
81
+ if Origen.app.session.gems.keys.empty?
82
+ new_contents = content.gsub(/#{search_regexp}/m, '')
83
+ else
84
+ replacement_string = "# ORIGEN GEM AUTO-GENERATED---------------DO NOT REMOVE THIS LINE-------------\n"
85
+ replacement_string += "# -- DO NOT CHECK IN WITH THIS SECTION!\n"
86
+ replacement_string += "# -- DO NOT HAND MODIFY!\n"
87
+ replacement_string += "# -- USE 'origen gem clean all' to reset\n"
88
+ replacement_string += "\n"
89
+
90
+ Origen.app.session.gems.keys.sort.each do |g|
91
+ replacement_string += "gem '#{g}', path: '#{Origen.app.session.gems[g.to_sym]}'\n"
92
+ replacement_string += "puts \"\\e[1;93;40mWARNING: Using session gem for '#{g}'\\e[0m\"\n"
93
+ end
94
+
95
+ replacement_string += "def gem(*args)\n"
96
+ replacement_string += " return if [#{Origen.app.session.gems.keys.sort.map { |e| "'" + e.to_s + "'" }.join(',')}].include? args[0]\n"
97
+ replacement_string += " super(*args)\n"
98
+ replacement_string += "end\n"
99
+ replacement_string += "#\n"
100
+ replacement_string += "# /ORIGEN GEM AUTO-GENERATED---------------DO NOT REMOVE THIS LINE------------\n"
101
+
102
+ if content =~ /#{search_regexp}/m
103
+ new_contents = content.gsub(/#{search_regexp}/m, replacement_string)
104
+ else
105
+ new_contents = replacement_string + content
106
+ end
107
+ end
108
+ File.open(_application_gemfile, 'w') { |file| file.puts new_contents }
109
+ end
110
+
111
+ gems = _local_gems
112
+
113
+ if !ARGV[0]
114
+ longest_key = gems.keys.max_by(&:length)
115
+ puts ''
116
+ printf "%-#{longest_key.length}s %-15s %s\n", 'Gem', 'Version', 'Location'
117
+ puts '--------------------------------------------------------------------------------------------------------------'
118
+ gems.each do |k, v|
119
+ printf "%-#{longest_key.length}s %-15s %s\n", k, v[:version], v[:location]
120
+ end
121
+ puts ''
122
+ else
123
+ case input = ARGV.shift
124
+ when 'clean'
125
+ gem = ARGV[0]
126
+ if gem
127
+ if gem == 'all'
128
+ if Dir.exist? _session_gem_path
129
+ puts ''
130
+ puts 'You are about to delete all local gems (tmp/gems/). IS THAT CORRECT?'
131
+ puts ''
132
+ get_text confirm: true
133
+ Origen::Log.console_only do
134
+ Dir.chdir Origen.root do
135
+ system("rm -fr #{_session_gem_path}")
136
+ end
137
+ end
138
+ unless Origen.app.session.gems.keys.empty?
139
+ Origen.app.session.gems.keys.sort.each do |g|
140
+ Origen.app.session.gems.delete_key(g)
141
+ end
142
+ _update_gemfile
143
+ end
144
+ else
145
+ puts 'There are no local gems present, nothing to clean.'
146
+ end
147
+ elsif gems.key?(gem.to_sym)
148
+ if Dir.exist? _local_path_to_gem(gems[gem.to_sym])
149
+ # check if already exists, ask for permission to blow away
150
+ puts ''
151
+ puts "You are about to delete the local copy of '#{gem}' (tmp/gems/#{_gem_basename(gems[gem.to_sym])}). IS THAT CORRECT?"
152
+ puts ''
153
+ get_text confirm: true
154
+ Origen::Log.console_only do
155
+ Dir.chdir Origen.root do
156
+ system("rm -fr #{_local_path_to_gem(gems[gem.to_sym])}")
157
+ end
158
+ end
159
+ Origen.app.session.gems.delete_key(gem.to_sym)
160
+ _update_gemfile
161
+ else
162
+ puts "Gem '#{gem}' is not locally present, nothing to clean."
163
+ end
164
+ end
165
+ else
166
+ puts "Error: Must specify gem to be cleaned or 'all'. Use 'origen gem -h' for usage"
167
+ end
168
+ when 'fetch'
169
+ gem = ARGV[0]
170
+ if gem
171
+ if gems.key?(gem.to_sym)
172
+ # Initialize ./tmp/gems/
173
+ FileUtils.mkdir_p(_session_gem_path) unless Dir.exist? _session_gem_path
174
+
175
+ if Dir.exist? _local_path_to_gem(gems[gem.to_sym])
176
+ # check if already exists, ask for permission to blow away
177
+ puts ''
178
+ puts "Gem '#{_gem_basename(gems[gem.to_sym])}' already exists locally, would you like to replace?"
179
+ puts "(This will delete and replace the exising copy at #{_local_path_to_gem(gems[gem.to_sym])})"
180
+ puts ''
181
+ get_text confirm: true
182
+ Origen::Log.console_only do
183
+ Dir.chdir Origen.root do
184
+ # Blow away these temporary files
185
+ system("rm -fr #{_local_path_to_gem(gems[gem.to_sym])}")
186
+ end
187
+ end
188
+ end
189
+
190
+ if Origen.has_plugin?(gem)
191
+ # Set up the requested plugin workspace
192
+ rc_url = Origen.app(gem.to_sym).config.rc_url || Origen.app(gem.to_sym).config.vault
193
+ if rc_url =~ /git/
194
+ Origen::RevisionControl::Git.git("clone #{rc_url} #{_gem_basename(gems[gem.to_sym])}", local: _session_gem_path, verbose: true)
195
+ else
196
+ # Use Origen::RevisionControl for DesignSync
197
+ rc = Origen::RevisionControl.new remote: rc_url, local: _local_path_to_gem(gems[gem.to_sym])
198
+ tag = Origen::VersionString.new(_gem_rc_version(gems[gem.to_sym]))
199
+ tag = tag.prefixed if tag.semantic?
200
+ rc.build version: tag
201
+ end
202
+ else
203
+ puts 'Not an Origen plugin gem, only COPYING source.'
204
+ FileUtils.cp_r(gems[gem.to_sym][:location], _session_gem_path)
205
+ end
206
+
207
+ # FileUtils.cp_r(gems[gem.to_sym][:location], _session_gem_path)
208
+ unless options[:dont_use]
209
+ Origen.app.session.gems[gem.to_sym] = "#{_local_path_to_gem(gems[gem.to_sym])}"
210
+ end
211
+
212
+ _update_gemfile
213
+
214
+ puts "Fetched #{gem} to tmp/gems/#{_gem_basename(gems[gem.to_sym])}"
215
+ puts ''
216
+ # puts 'Please add the following to your Gemfile:'
217
+ # puts ''
218
+ # puts "gem '#{gem}', path: '#{_local_path_to_gem(gems[gem.to_sym])}'"
219
+ # puts ''
220
+ else
221
+ puts "Error: '#{gem}' is not a currently used gem. Use 'origen gem' for gem list."
222
+ end
223
+ else
224
+ puts "Error: Must specify gem to be fetched. Use 'origen gem -h' for usage"
225
+ end
226
+ # when 'reset'
227
+ # gem = ARGV[0]
228
+ # if gem
229
+ # puts "Resetting #{gem} to Gemfile/gemspec"
230
+ # else
231
+ # puts "Error: Must specify gem to be cleaned or 'all'"
232
+ # end
233
+ else
234
+ gem = input
235
+ if gems.key?(gem.to_sym)
236
+ a = _local_gems_orig[gem].to_yaml.split(/\n+/)
237
+ skip = true
238
+
239
+ if options[:gem_location] || options[:gem_version]
240
+ puts '================================================================================='
241
+ puts "Gem Name: #{gems[gem.to_sym][:name]}"
242
+ puts "Version: #{gems[gem.to_sym][:version]}" if options[:gem_version]
243
+ puts "Location: #{gems[gem.to_sym][:location]}" if options[:gem_location]
244
+ puts '================================================================================='
245
+ else
246
+ puts '================================================================================='
247
+ puts "Gem Name: #{gems[gem.to_sym][:name]}"
248
+ puts "Version: #{gems[gem.to_sym][:version]}"
249
+ puts "Location: #{gems[gem.to_sym][:location]}"
250
+ puts '---------------------------------------------------------------------------------'
251
+ puts 'Details:'
252
+ a.each do |line|
253
+ if line =~ /^ (\w+):(.*)$/
254
+ topic = Regexp.last_match(1)
255
+ if QUIET_ATTRS.include? topic
256
+ skip = true
257
+ else
258
+ skip = false
259
+ end
260
+ end
261
+ puts " #{line}" unless skip
262
+ end
263
+ puts '---------------------------------------------------------------------------------'
264
+ puts '================================================================================='
265
+ end
266
+ else
267
+ puts "Error: '#{gem}' not a valid command or gem. Use 'origen gem -h' for usage or 'origen gem' for gem list."
268
+ end
269
+ end
270
+ end
@@ -1,4 +1,5 @@
1
1
  require 'optparse'
2
+ require 'origen/commands/helpers'
2
3
 
3
4
  options = {}
4
5
 
@@ -22,9 +23,8 @@ opt_parser = OptionParser.new do |opts|
22
23
  opts.on('--nocom', 'No comments in the generated pattern') { options[:no_comments] = true }
23
24
  opts.on('-d', '--debugger', 'Enable the debugger') { options[:debugger] = true }
24
25
  opts.on('-m', '--mode MODE', Origen::Mode::MODES, 'Force the Origen operating mode:', ' ' + Origen::Mode::MODES.join(', ')) { |_m| }
25
- app_options.each do |app_option|
26
- opts.on(*app_option) {}
27
- end
26
+ # Apply any application option extensions to the OptionParser
27
+ Origen::CommandHelpers.extend_options(opts, app_options, options)
28
28
  opts.separator ''
29
29
  opts.on('-h', '--help', 'Show this message') { puts opts; exit }
30
30
  end
@@ -0,0 +1,18 @@
1
+ module Origen
2
+ module CommandHelpers
3
+ def self.extend_options(opts, app_opts, options)
4
+ app_opts.each do |app_option|
5
+ if app_option.last.is_a?(Proc)
6
+ ao_proc = app_option.pop
7
+ if ao_proc.arity == 1
8
+ opts.on(*app_option) { ao_proc.call(options) }
9
+ else
10
+ opts.on(*app_option) { |arg| ao_proc.call(options, arg) }
11
+ end
12
+ else
13
+ opts.on(*app_option) {}
14
+ end
15
+ end
16
+ end
17
+ end
18
+ end
@@ -6,6 +6,7 @@ begin
6
6
  rescue LoadError
7
7
  # If not installed simply not available
8
8
  end
9
+ require 'origen/commands/helpers'
9
10
 
10
11
  module Origen
11
12
  # Methods available to the command line in a console session, split this to a
@@ -39,9 +40,8 @@ Usage: origen i [options]
39
40
  opts.on('-p', '--pry', 'Use Pry for the session (instead of IRB)') { options[:pry] = true }
40
41
  opts.on('-d', '--debugger', 'Enable the debugger') { options[:debugger] = true }
41
42
  opts.on('-m', '--mode MODE', Origen::Mode::MODES, 'Force the Origen operating mode:', ' ' + Origen::Mode::MODES.join(', ')) { |_m| }
42
- app_options.each do |app_option|
43
- opts.on(*app_option) {}
44
- end
43
+ # Apply any application option extensions to the OptionParser
44
+ Origen::CommandHelpers.extend_options(opts, app_options, options)
45
45
  opts.separator ''
46
46
  opts.on('-h', '--help', 'Show this message') { puts opts; exit }
47
47
  end
@@ -1,3 +1,5 @@
1
+ require 'origen/commands/helpers'
2
+
1
3
  options = {}
2
4
 
3
5
  # App options are options that the application can supply to extend this command
@@ -19,9 +21,8 @@ http://origen.freescale.net/origen/latest/guides/utilities/lint/
19
21
  opts.on('-e', '--easy', 'Be less strict, most checks run with this flag enabled can be corrected automatically') { options[:easy] = true }
20
22
  opts.on('-m', '--mode MODE', Origen::Mode::MODES, 'Force the Origen operating mode:', ' ' + Origen::Mode::MODES.join(', ')) { |_m| }
21
23
  opts.on('-d', '--debugger', 'Enable the debugger') { options[:debugger] = true }
22
- app_options.each do |app_option|
23
- opts.on(*app_option) {}
24
- end
24
+ # Apply any application option extensions to the OptionParser
25
+ Origen::CommandHelpers.extend_options(opts, app_options, options)
25
26
  opts.separator ''
26
27
  opts.on('-h', '--help', 'Show this message') { puts opts; exit }
27
28
  end
@@ -1,4 +1,5 @@
1
1
  require 'optparse'
2
+ require 'origen/commands/helpers'
2
3
 
3
4
  options = {}
4
5
 
@@ -55,9 +56,8 @@ Usage: origen lsf [options]
55
56
  # opts.on("-e", "--execute", "Execute....") { options[:execute] = true }
56
57
  opts.on('-m', '--mode MODE', Origen::Mode::MODES, 'Force the Origen operating mode:', ' ' + Origen::Mode::MODES.join(', ')) { |_m| }
57
58
  opts.on('-d', '--debugger', 'Enable the debugger') { options[:debugger] = true }
58
- app_options.each do |app_option|
59
- opts.on(*app_option) {}
60
- end
59
+ # Apply any application option extensions to the OptionParser
60
+ Origen::CommandHelpers.extend_options(opts, app_options, options)
61
61
  opts.separator ''
62
62
  opts.on('-h', '--help', 'Show this message') { puts opts; exit }
63
63
  end
@@ -1,4 +1,5 @@
1
1
  require 'optparse'
2
+ require 'origen/commands/helpers'
2
3
 
3
4
  options = {}
4
5
 
@@ -22,9 +23,8 @@ opt_parser = OptionParser.new do |opts|
22
23
  opts.on('-p', '--project NAME', String, 'Specify the LSF project, default is msg.te') { |o| options[:project] = o }
23
24
  opts.on('-d', '--debugger', 'Enable the debugger') { options[:debugger] = true }
24
25
  opts.on('-m', '--mode MODE', Origen::Mode::MODES, 'Force the Origen operating mode:', ' ' + Origen::Mode::MODES.join(', ')) { |_m| }
25
- app_options.each do |app_option|
26
- opts.on(*app_option) {}
27
- end
26
+ # Apply any application option extensions to the OptionParser
27
+ Origen::CommandHelpers.extend_options(opts, app_options, options)
28
28
  opts.separator ''
29
29
  opts.on('-h', '--help', 'Show this message') { puts opts; exit }
30
30
  end
@@ -1,4 +1,5 @@
1
1
  require 'optparse'
2
+ require 'origen/commands/helpers'
2
3
 
3
4
  include Origen::Utility::InputCapture
4
5
 
@@ -127,9 +128,8 @@ The following commands are available:
127
128
  The following options are available:
128
129
  EOT
129
130
  opts.on('-h', '--help', 'Show this message') { puts opts; exit }
130
- app_options.each do |app_option|
131
- opts.on(*app_option) {}
132
- end
131
+ # Apply any application option extensions to the OptionParser
132
+ Origen::CommandHelpers.extend_options(opts, app_options, options)
133
133
  opts.separator ''
134
134
  opts.on('-d', '--debugger', 'Enable the debugger') { options[:debugger] = true }
135
135
  opts.on('-m', '--mode MODE', Origen::Mode::MODES, 'Force the Origen operating mode:', ' ' + Origen::Mode::MODES.join(', ')) { |_m| }
@@ -1,4 +1,5 @@
1
1
  require 'optparse'
2
+ require 'origen/commands/helpers'
2
3
 
3
4
  options = {}
4
5
 
@@ -14,9 +15,8 @@ Usage: origen save TYPE [options]
14
15
  opts.on('-f', '--file FILE', String, 'Override the default log file') { |o| options[:log_file] = o }
15
16
  opts.on('-d', '--debugger', 'Enable the debugger') { options[:debugger] = true }
16
17
  opts.on('-m', '--mode MODE', Origen::Mode::MODES, 'Force the Origen operating mode:', ' ' + Origen::Mode::MODES.join(', ')) { |_m| }
17
- app_options.each do |app_option|
18
- opts.on(*app_option) {}
19
- end
18
+ # Apply any application option extensions to the OptionParser
19
+ Origen::CommandHelpers.extend_options(opts, app_options, options)
20
20
  opts.separator ''
21
21
  opts.on('-h', '--help', 'Show this message') { puts opts; exit }
22
22
  end
@@ -1,5 +1,6 @@
1
1
  require 'optparse'
2
2
  require 'pathname'
3
+ require 'origen/commands/helpers'
3
4
 
4
5
  options = {}
5
6
 
@@ -28,9 +29,8 @@ Usage: origen time CMD [args] [options]
28
29
  opts.on('-d', '--debugger', 'Enable the debugger') { options[:debugger] = true }
29
30
  opts.on('-m', '--mode MODE', Origen::Mode::MODES, 'Force the Origen operating mode:', ' ' + Origen::Mode::MODES.join(', ')) { |_m| }
30
31
  opts.on('-f', '--file FILE', String, 'Override the default log file') { |o| options[:log_file] = o }
31
- app_options.each do |app_option|
32
- opts.on(*app_option) {}
33
- end
32
+ # Apply any application option extensions to the OptionParser
33
+ Origen::CommandHelpers.extend_options(opts, app_options, options)
34
34
  opts.separator ''
35
35
  opts.on('-h', '--help', 'Show this message') { puts opts; exit }
36
36
  end
@@ -1,5 +1,6 @@
1
1
  require 'optparse'
2
2
  require 'pathname'
3
+ require 'origen/commands/helpers'
3
4
 
4
5
  module Origen
5
6
  options = {}
@@ -49,9 +50,8 @@ The following options are available:
49
50
  opts.on('-m', '--mode MODE', Origen::Mode::MODES, 'Force the Origen operating mode:', ' ' + Origen::Mode::MODES.join(', ')) { |_m| }
50
51
  opts.on('--no-serve', "Don't serve the website after compiling without the remote option") { options[:no_serve] = true }
51
52
  opts.on('-c', '--comment COMMENT', String, 'Supply a commit comment when deploying to Git') { |o| options[:comment] = o }
52
- app_options.each do |app_option|
53
- opts.on(*app_option) {}
54
- end
53
+ # Apply any application option extensions to the OptionParser
54
+ Origen::CommandHelpers.extend_options(opts, app_options, options)
55
55
  opts.separator ''
56
56
  opts.on('-h', '--help', 'Show this message') { puts opts; exit }
57
57
  end
@@ -107,10 +107,21 @@ module Origen
107
107
  # next time, this should be faster for repeated lookups of the same method, e.g. reg
108
108
  def method_missing(method, *args, &block)
109
109
  if model.respond_to?(method)
110
- define_singleton_method(method) do |*args, &block|
111
- model.send(method, *args, &block)
110
+ # This method is handled separately since it is important to produce a proxy method
111
+ # that takes no arguments, otherwise the register address lookup system mistakes it
112
+ # for a legacy way of calculating the base address whereby the register itself was
113
+ # given as an argument.
114
+ if method.to_sym == :base_address
115
+ define_singleton_method(method) do
116
+ model.send(method)
117
+ end
118
+ base_address
119
+ else
120
+ define_singleton_method(method) do |*args, &block|
121
+ model.send(method, *args, &block)
122
+ end
123
+ send(method, *args, &block)
112
124
  end
113
- send(method, *args, &block)
114
125
  else
115
126
  super
116
127
  end
@@ -20,4 +20,18 @@ class Array
20
20
  hash.delete_if { |_k, v| v.size == 1 }
21
21
  hash
22
22
  end
23
+
24
+ def include_hash?
25
+ each { |e| return true if e.is_a? Hash }
26
+ false
27
+ end
28
+
29
+ def include_hash_with_key?(key)
30
+ each do |e|
31
+ if e.is_a? Hash
32
+ return e if e.key?(key)
33
+ end
34
+ end
35
+ nil
36
+ end
23
37
  end
@@ -4,12 +4,14 @@ module Origen
4
4
  class Job # :nodoc: all
5
5
  attr_accessor :output_file_body, :pattern
6
6
  attr_reader :split_counter
7
+ attr_reader :options
7
8
 
8
9
  def initialize(pattern, options)
9
10
  @testing = options[:testing]
10
11
  @options = options
11
12
  @requested_pattern = pattern
12
13
  @no_comments = options[:no_comments]
14
+ @output_opt = options[:output]
13
15
  end
14
16
 
15
17
  # Returns true if the job is a test job, will only be true in a test scenario
@@ -66,7 +68,7 @@ module Origen
66
68
 
67
69
  def output_pattern_directory
68
70
  @output_pattern_directory ||= begin
69
- dir = Origen.app.config.pattern_output_directory
71
+ dir = output_override || Origen.app.config.pattern_output_directory
70
72
  if tester.respond_to?(:subdirectory)
71
73
  dir = File.join(dir, tester.subdirectory)
72
74
  end
@@ -100,6 +102,17 @@ module Origen
100
102
  '.' + Origen.tester.pat_extension
101
103
  end
102
104
 
105
+ def output_override
106
+ if @output_opt
107
+ if @output_opt =~ /#{Origen.root}/
108
+ return @output_opt
109
+ else
110
+ return "#{Origen.root}/#{@output_opt}"
111
+ end
112
+ end
113
+ nil
114
+ end
115
+
103
116
  def split_number
104
117
  if split_counter
105
118
  "_part#{split_counter}"
@@ -368,7 +368,11 @@ module Origen
368
368
 
369
369
  if Origen.tester.generate?
370
370
  Origen.app.listeners_for(:pattern_generated).each do |listener|
371
- listener.pattern_generated(Pathname.new(job.output_pattern))
371
+ if listener.class.instance_method(:pattern_generated).arity == 1
372
+ listener.pattern_generated(Pathname.new(job.output_pattern))
373
+ else
374
+ listener.pattern_generated(Pathname.new(job.output_pattern), job.options)
375
+ end
372
376
  end
373
377
  end
374
378
  end
@@ -153,6 +153,34 @@ module Origen
153
153
  owner._request_live_parameter
154
154
  self
155
155
  end
156
+
157
+ def to_flat_hash(options = {})
158
+ options = {
159
+ delimiter: '.'
160
+ }.update(options)
161
+ flatten_params(self, options[:delimiter]).first
162
+ end
163
+
164
+ private
165
+
166
+ def flatten_params(param_hash, delimiter, name = nil, results_hash = {})
167
+ param_hash.each do |k, v|
168
+ if v.is_a? Origen::Parameters::Set
169
+ name.nil? ? name = k.to_s : name << "#{delimiter}#{k}"
170
+ (results_hash, name) = flatten_params(v, delimiter, name, results_hash)
171
+ else
172
+ if name.nil?
173
+ results_hash[k] = v
174
+ else
175
+ results_hash["#{name}#{delimiter}#{k}"] = v
176
+ if k == param_hash.keys.last
177
+ name = nil
178
+ end
179
+ end
180
+ end
181
+ end
182
+ [results_hash, name]
183
+ end
156
184
  end
157
185
  end
158
186
  end
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.24.0
4
+ version: 0.25.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Stephen McGinty
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-09-02 00:00:00.000000000 Z
11
+ date: 2017-09-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -421,7 +421,9 @@ files:
421
421
  - lib/origen/commands/compile.rb
422
422
  - lib/origen/commands/environment.rb
423
423
  - lib/origen/commands/fetch.rb
424
+ - lib/origen/commands/gem.rb
424
425
  - lib/origen/commands/generate.rb
426
+ - lib/origen/commands/helpers.rb
425
427
  - lib/origen/commands/interactive.rb
426
428
  - lib/origen/commands/lint.rb
427
429
  - lib/origen/commands/lsf.rb
@@ -603,7 +605,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
603
605
  version: 1.8.11
604
606
  requirements: []
605
607
  rubyforge_project:
606
- rubygems_version: 2.6.11
608
+ rubygems_version: 2.5.2
607
609
  signing_key:
608
610
  specification_version: 4
609
611
  summary: The Semiconductor Developer's Kit