origen 0.1.3 → 0.2.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: 649e449c295842f6dcd2381fd17eb485e4932b65
4
- data.tar.gz: 136869fb9cf4ba5006e3db33e055f64c01cf23e0
3
+ metadata.gz: c03ed69b554f6d924ac5fcffe87d9c18724a9606
4
+ data.tar.gz: 8f1c2964ce925f3ccb176bd3ee9a3c0c0e6e7841
5
5
  SHA512:
6
- metadata.gz: eb114bdf1e8531c675f99b4d9f0507b13d6b7cba858e38972a3a7f78ba99d3435e47985234fb4d875de1d23c185d1450a52cc2c6a35c6aa968f78aac4ac09904
7
- data.tar.gz: 1ea70aaeca94170041b27a088b1a5933506546ae2a9b134e00ca41b2b23ed77da253936ba1854cb9e2cc81a781e297cbdb2d2baba18b311f8809e54020a298e6
6
+ metadata.gz: 254950fe29f7941f9eb65a1e2ac37e4dcac85dc141a5825c93ae96c13db1cea0d26520a5043281f664f0ca3c93ea2157801b29616fc6460bcd30aa2e14b9a194
7
+ data.tar.gz: b2aaac13da19297800d4301b275d91f201b7e92e02483fa59b852718580afa15c051da52422d73da621403c6a7d2cd0b9a067530767ada7b5dd97de461411fcb
data/config/version.rb CHANGED
@@ -1,7 +1,7 @@
1
1
  module Origen
2
2
  MAJOR = 0
3
- MINOR = 1
4
- BUGFIX = 3
3
+ MINOR = 2
4
+ BUGFIX = 0
5
5
  DEV = nil
6
6
 
7
7
  VERSION = [MAJOR, MINOR, BUGFIX].join(".") + (DEV ? ".pre#{DEV}" : '')
@@ -157,21 +157,22 @@ module Origen
157
157
  end
158
158
 
159
159
  def deploy_file(file)
160
- if deploy_to_git?
161
- fail 'File based deploy has is not support for Git yet :-('
162
- else
163
- remote_dir = live_remote_directory
164
- if remote_dir
165
- file = Origen.file_handler.clean_path_to(file)
166
- sub_dir = Origen.file_handler.sub_dir_of(file, "#{Origen.root}/templates/web") .to_s
167
- page = file.basename.to_s.sub(/\..*/, '')
168
- # Special case for the main index page
169
- if page == 'index' && sub_dir == '.'
170
- FileUtils.cp "#{Origen.root}/web/output/index.html", remote_dir
171
- else
172
- FileUtils.mkdir_p("#{remote_dir}/#{sub_dir}/#{page}")
173
- FileUtils.cp "#{Origen.root}/web/output/#{sub_dir}/#{page}/index.html", "#{remote_dir}/#{sub_dir}/#{page}"
174
- end
160
+ remote_dir = deploy_to_git? ? "#{git_repo.local}/#{git_sub_dir}" : live_remote_directory
161
+ if remote_dir
162
+ file = Origen.file_handler.clean_path_to(file)
163
+ sub_dir = Origen.file_handler.sub_dir_of(file, "#{Origen.root}/templates/web") .to_s
164
+ page = file.basename.to_s.sub(/\..*/, '')
165
+ # Special case for the main index page
166
+ if page == 'index' && sub_dir == '.'
167
+ FileUtils.cp "#{Origen.root}/web/output/index.html", remote_dir
168
+ file = "#{remote_dir}/index.html"
169
+ else
170
+ FileUtils.mkdir_p("#{remote_dir}/#{sub_dir}/#{page}")
171
+ file = "#{remote_dir}/#{sub_dir}/#{page}/index.html"
172
+ FileUtils.cp "#{Origen.root}/web/output/#{sub_dir}/#{page}/index.html", file
173
+ end
174
+ if deploy_to_git?
175
+ git_repo.checkin file, unmanaged: true, comment: @commit_message
175
176
  end
176
177
  end
177
178
  end
@@ -237,8 +238,6 @@ module Origen
237
238
  FileUtils.cp_r Dir.glob("#{Origen.root}/templates/nanoc/*").sort, dir, remove_destination: true
238
239
  end
239
240
  end
240
- # Remove the .SYNCs
241
- system "find #{dir} -name \".SYNC\" | xargs rm -fr"
242
241
  @nanoc_dir = dir
243
242
  end
244
243
  end
@@ -151,7 +151,7 @@ module Origen
151
151
  printf(format, 'Origen_Name', 'Name', 'Version')
152
152
  printf(format, '---------', '----', '-------')
153
153
 
154
- Origen.plugins.each do |plugin|
154
+ Origen.plugins.sort_by { |p| p.name.to_s }.each do |plugin|
155
155
  printf(format, plugin.name, plugin.config.name, plugin.version)
156
156
  end
157
157
  puts ''
@@ -159,15 +159,47 @@ end
159
159
  # prevent Origen from then having a go.
160
160
  # This order is preferable to allowing Origen to go first since it allows
161
161
  # overloading of Origen commands by the application.
162
+ @application_options = []
163
+ @plugin_commands = []
164
+ @application_commands = []
165
+ app_id = @application_options.object_id
166
+ plugin_id = @plugin_commands.object_id
167
+ app_cmd_id = @application_commands.object_id
168
+ app_opt_err = false
169
+ plugin_opt_err = false
170
+ app_cmd_err = false
162
171
  if File.exist? "#{Origen.root}/config/commands.rb"
163
172
  require "#{Origen.root}/config/commands"
173
+ if @application_options.object_id != app_id
174
+ Origen.log.warning "Don't assign @application_options to a value in config/commands.rb!"
175
+ Origen.log.warning 'Do something like this instead:'
176
+ Origen.log.warning ' @application_options << ["-v", "--vector_comments", "Add the vector and cycle number to the vector comments"]'
177
+ app_opt_err = true
178
+ end
179
+ if @plugin_commands.object_id != plugin_id
180
+ Origen.log.warning "Don't assign @plugin_commands to a new value in config/commands.rb!"
181
+ Origen.log.warning 'Do something like this instead:'
182
+ Origen.log.warning ' @plugin_commands << " testers:build Build a test program from a collection of sub-programs"'
183
+ plugin_opt_err = true
184
+ end
164
185
  end
165
186
 
166
187
  shared_commands = Origen.import_manager.command_launcher
167
- @plugin_commands ||= []
168
188
  if shared_commands && shared_commands.size != 0
169
189
  shared_commands.each do |file|
170
190
  require file
191
+ if @application_options.object_id != app_id && !app_opt_err
192
+ Origen.log.warning "Don't assign @application_options to a new value in #{file}!"
193
+ Origen.log.warning 'Do something like this instead:'
194
+ Origen.log.warning ' @application_options << ["-v", "--vector_comments", "Add the vector and cycle number to the vector comments"]'
195
+ app_opt_err = true
196
+ end
197
+ if @plugin_commands.object_id != plugin_id && !plugin_opt_err
198
+ Origen.log.warning "Don't assign @plugin_commands to a new value in #{file}!"
199
+ Origen.log.warning 'Do something like this instead:'
200
+ Origen.log.warning ' @plugin_commands << " testers:build Build a test program from a collection of sub-programs"'
201
+ plugin_opt_err = true
202
+ end
171
203
  end
172
204
  end
173
205
 
@@ -11,9 +11,17 @@ module Origen
11
11
  # Methods available to the command line in a console session, split this to a
12
12
  # separate file if it gets large over time
13
13
  module ConsoleMethods
14
- def j750
15
- @_j750 ||= Origen::Tester::J750.new
16
- @_j750.parser
14
+ def ls
15
+ `ls`.split("\n")
16
+ end
17
+
18
+ def cd(dir)
19
+ Dir.chdir(dir)
20
+ Dir.pwd
21
+ end
22
+
23
+ def pwd
24
+ Dir.pwd
17
25
  end
18
26
  end
19
27
 
@@ -350,7 +350,11 @@ The following options are available:
350
350
  else
351
351
  puts 'The following files have been modified:'
352
352
  changes.flatten.each do |file|
353
- puts " #{Origen.app.rc.diff_cmd(file, Origen.app.version)}"
353
+ if Origen.app.rc.git?
354
+ puts " #{Origen.app.rc.diff_cmd(file)}"
355
+ else
356
+ puts " #{Origen.app.rc.diff_cmd(file, Origen.app.version)}"
357
+ end
354
358
  end
355
359
  end
356
360
  end
@@ -197,6 +197,7 @@ The following options are available:
197
197
  when 'deploy'
198
198
  Origen.app.load_target!
199
199
  _require_web_directory
200
+ _deployer.prepare!(options)
200
201
  if ARGV.empty?
201
202
  _deployer.deploy_site
202
203
  else
@@ -211,6 +212,7 @@ The following options are available:
211
212
  when 'archive'
212
213
  Origen.app.load_target!
213
214
  _require_web_directory
215
+ _deployer.prepare!(options)
214
216
  unless ARGV[0]
215
217
  puts 'You must supply an ID argument to create an archive'
216
218
  end
@@ -224,13 +224,36 @@ module Origen
224
224
  c2 '*' * 75
225
225
  c2 'ENVIRONMENT:'
226
226
  c2 ' Application'
227
- c2 " Source: #{Origen.config.rc_url}"
227
+ if Origen.app.rc.git?
228
+ c2 " Source: #{Origen.config.rc_url}"
229
+ else
230
+ c2 " Vault: #{Origen.config.vault}"
231
+ end
228
232
  c2 " Version: #{Origen.app.version}"
229
233
  c2 " Workspace: #{Origen.root}"
234
+ if Origen.app.rc.git?
235
+ begin
236
+ status = "#{Origen.app.rc.current_branch}(#{Origen.app.rc.current_commit})"
237
+ status += ' (+local edits)' unless Origen.app.rc.local_modifications.empty?
238
+ c2 " Branch: #{status}"
239
+ rescue
240
+ # No problem, we did our best
241
+ end
242
+ end
230
243
  c2 ' Origen'
231
- c2 ' Source: https://github.com/Origen-SDK/origen'
244
+ if Origen.app.rc.git?
245
+ c2 ' Source: https://github.com/Origen-SDK/origen'
246
+ else
247
+ c2 " Vault: #{Origen.config.vault}"
248
+ end
232
249
  c2 " Version: #{Origen.version}"
233
250
  c2 " Workspace: #{Origen.top}"
251
+ unless Origen.plugins.empty?
252
+ c2 ' Plugins'
253
+ Origen.plugins.sort_by { |p| p.name.to_s }.each do |plugin|
254
+ c2 " #{plugin.name}:".ljust(30) + plugin.version
255
+ end
256
+ end
234
257
  c2 '*' * 75
235
258
  if Origen.config.pattern_header
236
259
  c2 '*' * 75
@@ -219,7 +219,11 @@ module Origen
219
219
  puts ''
220
220
  puts 'WHAT VERSION DO YOU WANT TO COMPARE AGAINST?'
221
221
  puts ''
222
- puts "Valid values are 'latest', 'last' (production release), or a tag."
222
+ if Origen.app.rc.git?
223
+ puts "Valid values are 'latest', 'last' (production release), a tag, a commit or a branch."
224
+ else
225
+ puts "Valid values are 'latest', 'last' (production release), or a tag."
226
+ end
223
227
  puts ''
224
228
  get_text(default: Origen.app.version, single: true)
225
229
  end
@@ -230,11 +234,8 @@ module Origen
230
234
  Origen.app.version_tracker.versions.last
231
235
  elsif version.downcase == 'latest'
232
236
  version
233
- elsif VersionString.new(version).valid?
234
- version
235
237
  else
236
- puts 'Sorry but that version tag looks to be invalid!'
237
- exit 1
238
+ version
238
239
  end
239
240
  end
240
241
 
@@ -25,9 +25,14 @@ module Origen
25
25
  end
26
26
 
27
27
  if options[:force]
28
- git 'reset HEAD'
29
- git 'pull', options
30
- git "checkout #{version} #{paths.join(' ')}", options
28
+ version = "origin/#{version}" if remote_branch?(version)
29
+ if paths == [local.to_s]
30
+ git "reset --hard #{version}"
31
+ else
32
+ git 'reset HEAD'
33
+ git 'pull', options
34
+ git "checkout #{version} #{paths.join(' ')}", options
35
+ end
31
36
  else
32
37
  if paths.size > 1 || paths.first != local.to_s
33
38
  fail 'The Git driver does not support partial merge checkout, it has to be the whole workspace'
@@ -63,8 +68,8 @@ module Origen
63
68
  # Can't check in unless we have the latest
64
69
  if options[:force] && !options[:initial]
65
70
  # Locally check in the given files
66
- checkin(paths.join(' '), local: true, verbose: false, comment: options[:comment])
67
- local_rev = current_commit
71
+ checkin(paths.join(' '), no_push: true, verbose: false, comment: options[:comment])
72
+ local_rev = current_commit(short: false)
68
73
  # Pull latest
69
74
  checkout
70
75
  # Restore the given files to our previous version
@@ -103,7 +108,7 @@ module Origen
103
108
  end
104
109
  git cmd, options
105
110
  end
106
- git "push origin #{current_branch}" unless options[:local]
111
+ git "push origin #{current_branch}" unless options[:no_push]
107
112
  paths
108
113
  end
109
114
 
@@ -161,8 +166,12 @@ module Origen
161
166
  git(cmd, options).map(&:strip)
162
167
  end
163
168
 
164
- def diff_cmd(file, version)
165
- "git difftool --tool tkdiff -y #{prefix_tag(version)} #{file}"
169
+ def diff_cmd(file, version = nil)
170
+ if version
171
+ "git difftool --tool tkdiff -y #{prefix_tag(version)} #{file}"
172
+ else
173
+ "git difftool --tool tkdiff -y #{file}"
174
+ end
166
175
  end
167
176
 
168
177
  def tag(id, options = {})
@@ -184,6 +193,18 @@ module Origen
184
193
  git('rev-parse --abbrev-ref HEAD', verbose: false).first
185
194
  end
186
195
 
196
+ def current_commit(options = {})
197
+ options = {
198
+ short: true
199
+ }.merge(options)
200
+ commit = git('rev-parse HEAD', verbose: false).first
201
+ if options[:short]
202
+ commit[0, 11]
203
+ else
204
+ commit
205
+ end
206
+ end
207
+
187
208
  # Returns true if the given tag already exists
188
209
  def tag_exists?(tag)
189
210
  git('fetch', verbose: false) unless @all_tags_fetched
@@ -191,9 +212,24 @@ module Origen
191
212
  git('tag', verbose: false).include?(tag.to_s)
192
213
  end
193
214
 
215
+ # Returns true if the given string matches a branch name in the remote repo
216
+ # Origen.app.rc.remote_branch?("master") # => true
217
+ # Origen.app.rc.remote_branch?("feature/exists") # => true
218
+ # Origen.app.rc.remote_branch?("feature/does_not_exist") # => false
219
+ def remote_branch?(str)
220
+ # Github doesn't like the ssh:// for this command, whereas Stash seems
221
+ # to require it.
222
+ if github?
223
+ rem = remote_without_protocol
224
+ else
225
+ rem = remote
226
+ end
227
+ !git("ls-remote --heads #{rem} #{str}", verbose: false).empty?
228
+ end
229
+
194
230
  def initialized?
195
231
  File.exist?("#{local}/.git") &&
196
- git('remote -v', verbose: false).any? { |r| r =~ /#{remote_without_protocol}/ } &&
232
+ git('remote -v', verbose: false).any? { |r| r =~ /#{remote_without_protocol_and_user}/ || r =~ /#{remote_without_protocol_and_user.to_s.gsub(':', "\/")}/ } &&
197
233
  !git('status', verbose: false).any? { |l| l =~ /^#? ?Initial commit$/ }
198
234
  end
199
235
 
@@ -204,12 +240,45 @@ module Origen
204
240
  FileUtils.rm_f files
205
241
  end
206
242
 
243
+ # A class method is provided to fetch the user name since it is useful to have access
244
+ # to this when outside of an application workspace, e.g. when creating a new app
245
+ def self.user_name
246
+ git('config user.name', verbose: false).first
247
+ rescue
248
+ nil
249
+ end
250
+
251
+ # A class method is provided to fetch the user email since it is useful to have access
252
+ # to this when outside of an application workspace, e.g. when creating a new app
253
+ def self.user_email
254
+ git('config user.email', verbose: false).first
255
+ rescue
256
+ nil
257
+ end
258
+
259
+ def user_name
260
+ self.class.user_name
261
+ end
262
+
263
+ def user_email
264
+ self.class.user_email
265
+ end
266
+
267
+ # Returns true if the remote points to a github url
268
+ def github?
269
+ !!(remote.to_s =~ /github.com/)
270
+ end
271
+
207
272
  private
208
273
 
209
274
  def remote_without_protocol
210
275
  Pathname.new(remote.sub(/^.*:\/\//, ''))
211
276
  end
212
277
 
278
+ def remote_without_protocol_and_user
279
+ Pathname.new(remote_without_protocol.to_s.sub(/^.*@/, ''))
280
+ end
281
+
213
282
  def create_gitignore
214
283
  c = Origen::Generator::Compiler.new
215
284
  c.compile "#{Origen.top}/templates/git/gitignore.erb",
@@ -223,10 +292,6 @@ module Origen
223
292
  !(git('status --verbose', verbose: false).last =~ /^(no changes|nothing to commit)/)
224
293
  end
225
294
 
226
- def current_commit
227
- git('rev-parse HEAD', verbose: false).first
228
- end
229
-
230
295
  def initialize_local_dir
231
296
  super
232
297
  unless initialized?
@@ -236,8 +301,13 @@ module Origen
236
301
  end
237
302
  end
238
303
 
239
- # Execute a git operation, the resultant output is returned in an array
240
304
  def git(command, options = {})
305
+ options[:local] = local
306
+ self.class.git(command, options)
307
+ end
308
+
309
+ # Execute a git operation, the resultant output is returned in an array
310
+ def self.git(command, options = {})
241
311
  options = {
242
312
  check_errors: true,
243
313
  verbose: true
@@ -247,7 +317,7 @@ module Origen
247
317
  Origen.log.info "git #{command}"
248
318
  Origen.log.info ''
249
319
  end
250
- Dir.chdir local do
320
+ chdir options[:local] do
251
321
  Open3.popen2e("git #{command}") do |_stdin, stdout_err, wait_thr|
252
322
  while line = stdout_err.gets
253
323
  Origen.log.info line.strip if options[:verbose]
@@ -266,6 +336,16 @@ module Origen
266
336
  end
267
337
  output
268
338
  end
339
+
340
+ def self.chdir(dir)
341
+ if dir
342
+ Dir.chdir dir do
343
+ yield
344
+ end
345
+ else
346
+ yield
347
+ end
348
+ end
269
349
  end
270
350
  end
271
351
  end
data/lib/origen/specs.rb CHANGED
@@ -9,7 +9,8 @@ module Origen
9
9
  autoload :Mode_Select, 'origen/specs/mode_select.rb'
10
10
  autoload :Version_History, 'origen/specs/version_history.rb'
11
11
  autoload :Creation_Info, 'origen/specs/creation_info.rb'
12
- require_relative 'specs/checkers'
12
+ require 'origen/specs/checkers'
13
+ include Checkers
13
14
 
14
15
  attr_accessor :_specs, :_notes, :_exhibits, :_doc_resources, :_overrides, :_power_supplies, :_mode_selects, :_version_history, :_creation_info
15
16
 
@@ -19,6 +20,14 @@ module Origen
19
20
 
20
21
  SpecTableAttr = Struct.new(:table_text, :show, :padding)
21
22
 
23
+ # A regular Array but print specs to the console via their ID for brevity and
24
+ # consistency with other APIs (e.g. $dut.regs # => [:reg1, :reg2])
25
+ class SpecArray < Array
26
+ def inspect
27
+ map(&:name).inspect
28
+ end
29
+ end
30
+
22
31
  # Returns a hash of hash containing all specs/modes
23
32
  # If no spec is specified then all specs are returned via inspect
24
33
  # If a spec is specified, a spec object will be returned if found
@@ -31,9 +40,8 @@ module Origen
31
40
  sub_type: nil,
32
41
  mode: current_mode.nil? ? nil : current_mode.name,
33
42
  spec: nil,
34
- verbose: false,
35
43
  creating_spec: false
36
- }.update(options)
44
+ }.update(options || {})
37
45
  _specs
38
46
  if s.nil?
39
47
  return show_specs(options)
@@ -47,7 +55,9 @@ module Origen
47
55
  end
48
56
 
49
57
  # Define and instantiate a Spec object
50
- def spec(name, type, mode = nil, &block)
58
+ def spec(name, type = nil, mode = nil, &block)
59
+ return specs(name, type) unless block_given?
60
+ fail 'A type argument is required when defining a spec!' unless type
51
61
  _specs
52
62
  name = name_audit(name)
53
63
  fail 'Specification names must be of SPEC_TYPES Symbol or String and cannot start with a number' if name.nil?
@@ -80,7 +90,6 @@ module Origen
80
90
  sub_type: nil,
81
91
  mode: current_mode.nil? ? nil : current_mode.name,
82
92
  spec: nil,
83
- verbose: false,
84
93
  creating_spec: false
85
94
  }.update(options)
86
95
  if @_specs.nil? || @_specs == {}
@@ -102,7 +111,6 @@ module Origen
102
111
  sub_type: nil,
103
112
  mode: current_mode.nil? ? nil : current_mode.name,
104
113
  spec: nil,
105
- verbose: false,
106
114
  creating_spec: false
107
115
  }.update(options)
108
116
  options[:spec] = s
@@ -157,8 +165,8 @@ module Origen
157
165
  end
158
166
  end
159
167
 
160
- def creation_info(author, date, src_info = {}, tool_info = {})
161
- @_creation_info = Creation_Info.new(author, date, src_info, tool_info)
168
+ def creation_info(author, date, version, src_info = {}, tool_info = {})
169
+ @_creation_info = Creation_Info.new(author, date, version, src_info, tool_info)
162
170
  end
163
171
 
164
172
  # Returns a Note object from the notes hash
@@ -434,8 +442,7 @@ module Origen
434
442
  spec: nil,
435
443
  type: nil,
436
444
  sub_type: nil,
437
- verbose: false,
438
- specs_to_be_shown: [],
445
+ specs_to_be_shown: SpecArray.new,
439
446
  owner: nil,
440
447
  creating_spec: false
441
448
  }.update(options)
@@ -476,13 +483,12 @@ module Origen
476
483
  return specs_to_be_shown.first
477
484
  else
478
485
  Origen.log.debug "returning an array of specs during initial search: #{specs_to_be_shown}"
479
- print_to_console(specs_to_be_shown) if options[:verbose] == true
480
486
  return specs_to_be_shown
481
487
  end
482
488
  end
483
489
 
484
490
  # Method to print a spec table to the console
485
- def print_to_console(specs_to_be_shown)
491
+ def specs_to_table_string(specs_to_be_shown)
486
492
  whitespace_padding = 3
487
493
  table = []
488
494
  attrs_to_be_shown = {
@@ -543,7 +549,7 @@ module Origen
543
549
  table << data += '|'
544
550
  end
545
551
  table << '-' * header.length
546
- puts table.flatten.join("\n")
552
+ table.flatten.join("\n")
547
553
  end
548
554
  end
549
555
  end