origen 0.2.6 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/bin/origen +3 -1
- data/config/boot.rb +1 -7
- data/config/commands.rb +0 -1
- data/config/version.rb +2 -2
- data/lib/c99/{j750_interface.rb → ate_interface.rb} +3 -11
- data/lib/c99/doc_interface.rb +1 -1
- data/lib/origen.rb +9 -30
- data/lib/origen/application.rb +10 -8
- data/lib/origen/application/configuration.rb +13 -26
- data/lib/origen/application/plugins.rb +122 -0
- data/lib/origen/application/plugins_manager.rb +16 -254
- data/lib/origen/application/release.rb +2 -2
- data/lib/origen/application/runner.rb +2 -4
- data/lib/origen/chips.rb +0 -0
- data/lib/origen/chips/chip.rb +0 -0
- data/lib/origen/chips/design_entry.rb +0 -0
- data/lib/origen/chips/doc_entry.rb +0 -0
- data/lib/origen/chips/note.rb +0 -0
- data/lib/origen/commands.rb +4 -44
- data/lib/origen/commands/compile.rb +1 -2
- data/lib/origen/commands/generate.rb +1 -1
- data/lib/origen/commands/interactive.rb +1 -2
- data/lib/origen/commands/plugin.rb +49 -56
- data/lib/origen/commands/program.rb +1 -1
- data/lib/origen/commands/rc.rb +2 -2
- data/lib/origen/commands/version.rb +2 -17
- data/lib/origen/commands_global.rb +3 -0
- data/lib/origen/file_handler.rb +10 -10
- data/lib/origen/generator.rb +1 -1
- data/lib/origen/generator/job.rb +1 -1
- data/lib/origen/generator/pattern.rb +2 -2
- data/lib/origen/generator/pattern_finder.rb +10 -9
- data/lib/origen/pins/pin.rb +0 -0
- data/lib/origen/regression_manager.rb +0 -0
- data/lib/origen/remote_manager.rb +2 -8
- data/lib/origen/revision_control/design_sync.rb +0 -0
- data/lib/origen/revision_control/git.rb +0 -0
- data/lib/origen/specs.rb +0 -0
- data/lib/origen/specs/checkers.rb +0 -0
- data/lib/origen/specs/creation_info.rb +0 -0
- data/lib/origen/specs/exhibit.rb +0 -0
- data/lib/origen/specs/spec.rb +0 -0
- data/lib/origen/utility.rb +0 -1
- data/lib/origen/utility/diff.rb +0 -0
- metadata +42 -119
- data/lib/origen/import_manager.rb +0 -596
- data/lib/origen/nvm.rb +0 -6
- data/lib/origen/nvm/block_array.rb +0 -72
- data/lib/origen/tester.rb +0 -56
- data/lib/origen/tester/api.rb +0 -277
- data/lib/origen/tester/bdm/bdm.rb +0 -25
- data/lib/origen/tester/doc/doc.rb +0 -226
- data/lib/origen/tester/doc/generator.rb +0 -126
- data/lib/origen/tester/doc/generator/flow.rb +0 -71
- data/lib/origen/tester/doc/generator/flow_line.rb +0 -203
- data/lib/origen/tester/doc/generator/test.rb +0 -68
- data/lib/origen/tester/doc/generator/test_group.rb +0 -66
- data/lib/origen/tester/doc/generator/tests.rb +0 -47
- data/lib/origen/tester/doc/model.rb +0 -162
- data/lib/origen/tester/generator.rb +0 -271
- data/lib/origen/tester/generator/flow_control_api.rb +0 -606
- data/lib/origen/tester/generator/identity_map.rb +0 -25
- data/lib/origen/tester/generator/placeholder.rb +0 -13
- data/lib/origen/tester/generator/test_numberer.rb +0 -25
- data/lib/origen/tester/interface.rb +0 -154
- data/lib/origen/tester/j750/files.rb +0 -45
- data/lib/origen/tester/j750/generator.rb +0 -203
- data/lib/origen/tester/j750/generator/flow.rb +0 -123
- data/lib/origen/tester/j750/generator/flow_line.rb +0 -288
- data/lib/origen/tester/j750/generator/patgroup.rb +0 -111
- data/lib/origen/tester/j750/generator/patgroups.rb +0 -41
- data/lib/origen/tester/j750/generator/patset.rb +0 -111
- data/lib/origen/tester/j750/generator/patsets.rb +0 -41
- data/lib/origen/tester/j750/generator/templates/flow.txt.erb +0 -9
- data/lib/origen/tester/j750/generator/templates/instances.txt.erb +0 -16
- data/lib/origen/tester/j750/generator/templates/patgroups.txt.erb +0 -8
- data/lib/origen/tester/j750/generator/templates/patsets.txt.erb +0 -10
- data/lib/origen/tester/j750/generator/test_instance.rb +0 -846
- data/lib/origen/tester/j750/generator/test_instance_group.rb +0 -60
- data/lib/origen/tester/j750/generator/test_instances.rb +0 -182
- data/lib/origen/tester/j750/j750.rb +0 -845
- data/lib/origen/tester/j750/j750_hpt.rb +0 -35
- data/lib/origen/tester/j750/parser.rb +0 -104
- data/lib/origen/tester/j750/parser/ac_spec.rb +0 -11
- data/lib/origen/tester/j750/parser/ac_specs.rb +0 -0
- data/lib/origen/tester/j750/parser/dc_spec.rb +0 -36
- data/lib/origen/tester/j750/parser/dc_specs.rb +0 -50
- data/lib/origen/tester/j750/parser/descriptions.rb +0 -340
- data/lib/origen/tester/j750/parser/flow.rb +0 -111
- data/lib/origen/tester/j750/parser/flow_line.rb +0 -207
- data/lib/origen/tester/j750/parser/flows.rb +0 -23
- data/lib/origen/tester/j750/parser/pattern_set.rb +0 -94
- data/lib/origen/tester/j750/parser/pattern_sets.rb +0 -33
- data/lib/origen/tester/j750/parser/test_instance.rb +0 -322
- data/lib/origen/tester/j750/parser/test_instances.rb +0 -26
- data/lib/origen/tester/j750/parser/timeset.rb +0 -15
- data/lib/origen/tester/j750/parser/timesets.rb +0 -0
- data/lib/origen/tester/jlink/jlink.rb +0 -33
- data/lib/origen/tester/parser.rb +0 -24
- data/lib/origen/tester/parser/description_lookup.rb +0 -64
- data/lib/origen/tester/parser/searchable_array.rb +0 -32
- data/lib/origen/tester/parser/searchable_hash.rb +0 -32
- data/lib/origen/tester/time.rb +0 -338
- data/lib/origen/tester/timing.rb +0 -253
- data/lib/origen/tester/ultraflex/files.rb +0 -45
- data/lib/origen/tester/ultraflex/generator.rb +0 -200
- data/lib/origen/tester/ultraflex/generator/flow.rb +0 -119
- data/lib/origen/tester/ultraflex/generator/flow_line.rb +0 -269
- data/lib/origen/tester/ultraflex/generator/patgroup.rb +0 -111
- data/lib/origen/tester/ultraflex/generator/patgroups.rb +0 -41
- data/lib/origen/tester/ultraflex/generator/patset.rb +0 -111
- data/lib/origen/tester/ultraflex/generator/patsets.rb +0 -41
- data/lib/origen/tester/ultraflex/generator/templates/flow.txt.erb +0 -9
- data/lib/origen/tester/ultraflex/generator/templates/instances.txt.erb +0 -16
- data/lib/origen/tester/ultraflex/generator/templates/patgroups.txt.erb +0 -8
- data/lib/origen/tester/ultraflex/generator/templates/patsets.txt.erb +0 -10
- data/lib/origen/tester/ultraflex/generator/test_instance.rb +0 -622
- data/lib/origen/tester/ultraflex/generator/test_instance_group.rb +0 -60
- data/lib/origen/tester/ultraflex/generator/test_instances.rb +0 -174
- data/lib/origen/tester/ultraflex/parser.rb +0 -104
- data/lib/origen/tester/ultraflex/parser/ac_spec.rb +0 -11
- data/lib/origen/tester/ultraflex/parser/ac_specs.rb +0 -0
- data/lib/origen/tester/ultraflex/parser/dc_spec.rb +0 -36
- data/lib/origen/tester/ultraflex/parser/dc_specs.rb +0 -50
- data/lib/origen/tester/ultraflex/parser/descriptions.rb +0 -342
- data/lib/origen/tester/ultraflex/parser/flow.rb +0 -111
- data/lib/origen/tester/ultraflex/parser/flow_line.rb +0 -207
- data/lib/origen/tester/ultraflex/parser/flows.rb +0 -23
- data/lib/origen/tester/ultraflex/parser/pattern_set.rb +0 -94
- data/lib/origen/tester/ultraflex/parser/pattern_sets.rb +0 -33
- data/lib/origen/tester/ultraflex/parser/test_instance.rb +0 -262
- data/lib/origen/tester/ultraflex/parser/test_instances.rb +0 -26
- data/lib/origen/tester/ultraflex/parser/timeset.rb +0 -15
- data/lib/origen/tester/ultraflex/parser/timesets.rb +0 -0
- data/lib/origen/tester/ultraflex/ultraflex.rb +0 -759
- data/lib/origen/tester/v93k/generator.rb +0 -80
- data/lib/origen/tester/v93k/generator/flow.rb +0 -63
- data/lib/origen/tester/v93k/generator/flow_node.rb +0 -17
- data/lib/origen/tester/v93k/generator/flow_node/print.rb +0 -10
- data/lib/origen/tester/v93k/generator/pattern.rb +0 -16
- data/lib/origen/tester/v93k/generator/pattern_master.rb +0 -54
- data/lib/origen/tester/v93k/generator/templates/_test_method.txt.erb +0 -6
- data/lib/origen/tester/v93k/generator/templates/_test_suite.txt.erb +0 -11
- data/lib/origen/tester/v93k/generator/templates/template.flow.erb +0 -121
- data/lib/origen/tester/v93k/generator/templates/template.pmfl.erb +0 -9
- data/lib/origen/tester/v93k/generator/test_function.rb +0 -103
- data/lib/origen/tester/v93k/generator/test_functions.rb +0 -79
- data/lib/origen/tester/v93k/generator/test_method.rb +0 -46
- data/lib/origen/tester/v93k/generator/test_methods.rb +0 -75
- data/lib/origen/tester/v93k/generator/test_suite.rb +0 -54
- data/lib/origen/tester/v93k/generator/test_suites.rb +0 -65
- data/lib/origen/tester/v93k/v93k.rb +0 -420
- data/lib/origen/tester/vector.rb +0 -86
- data/lib/origen/tester/vector_generator.rb +0 -637
- data/lib/origen/tester/vector_pipeline.rb +0 -150
- data/lib/origen/utility/design_sync.rb +0 -494
- data/lib/origen/version_checker.rb +0 -117
@@ -1,150 +0,0 @@
|
|
1
|
-
module Origen
|
2
|
-
module Tester
|
3
|
-
class VectorPipeline
|
4
|
-
attr_reader :group_size, :pipeline
|
5
|
-
|
6
|
-
def initialize(group_size)
|
7
|
-
@group_size = group_size
|
8
|
-
@pipeline = []
|
9
|
-
end
|
10
|
-
|
11
|
-
# Add a vector/comment to the pipeline
|
12
|
-
def <<(vector)
|
13
|
-
if vector.is_a?(Vector)
|
14
|
-
consume_comments(vector)
|
15
|
-
if vector.repeat > 1
|
16
|
-
add_repeat_vector(vector)
|
17
|
-
else
|
18
|
-
pipeline << vector
|
19
|
-
end
|
20
|
-
else
|
21
|
-
comments << vector
|
22
|
-
end
|
23
|
-
end
|
24
|
-
|
25
|
-
# If there are complete groups sitting at the top of the pipeline
|
26
|
-
# then this will yield them back line by line, stopping when after the last
|
27
|
-
# complete group and leaving any remaining single vectors in the pipeline
|
28
|
-
# If there are no complete groups present then it will just return
|
29
|
-
def flush
|
30
|
-
while lead_group_finalized?
|
31
|
-
lead_group.each do |vector|
|
32
|
-
vector.comments.each do |comment|
|
33
|
-
yield comment
|
34
|
-
end
|
35
|
-
yield vector
|
36
|
-
end
|
37
|
-
pipeline.shift(group_size)
|
38
|
-
end
|
39
|
-
end
|
40
|
-
|
41
|
-
# Call at the end to force a flush out of any remaining vectors
|
42
|
-
def empty
|
43
|
-
if !pipeline.empty? || !comments.empty?
|
44
|
-
pipeline.each do |vector|
|
45
|
-
vector.comments.each do |comment|
|
46
|
-
yield comment
|
47
|
-
end
|
48
|
-
yield vector
|
49
|
-
end
|
50
|
-
comments.each do |comment|
|
51
|
-
yield comment
|
52
|
-
end
|
53
|
-
@pipeline = []
|
54
|
-
@comments = []
|
55
|
-
end
|
56
|
-
end
|
57
|
-
|
58
|
-
private
|
59
|
-
|
60
|
-
# Pushes a duplicate of the given vector with its repeat set to 1
|
61
|
-
# Also clears any comments associated with the vector with the rationale that we only
|
62
|
-
# want to see them the first time
|
63
|
-
def push_duplicate(vector)
|
64
|
-
v = vector.dup
|
65
|
-
v.repeat = 1
|
66
|
-
pipeline << v
|
67
|
-
vector.comments = []
|
68
|
-
end
|
69
|
-
|
70
|
-
def add_repeat_vector(vector)
|
71
|
-
count = vector.repeat
|
72
|
-
# Align to the start of a new group by splitting off single vectors
|
73
|
-
# to complete the current group
|
74
|
-
while !aligned? && count > 0
|
75
|
-
push_duplicate(vector)
|
76
|
-
count -= 1
|
77
|
-
end
|
78
|
-
if count > group_size
|
79
|
-
remainder = count % group_size
|
80
|
-
# Create a group with the required repeat
|
81
|
-
group_size.times do
|
82
|
-
push_duplicate(vector)
|
83
|
-
end
|
84
|
-
pipeline.last.repeat = (count - remainder) / group_size
|
85
|
-
# Then expand out any leftover
|
86
|
-
remainder.times do
|
87
|
-
push_duplicate(vector)
|
88
|
-
end
|
89
|
-
# For small repeats that fit within the group just expand them
|
90
|
-
else
|
91
|
-
while count > 0
|
92
|
-
push_duplicate(vector)
|
93
|
-
count -= 1
|
94
|
-
end
|
95
|
-
end
|
96
|
-
end
|
97
|
-
|
98
|
-
# Returns true of the next vector to be added to the pipeline will
|
99
|
-
# be at the start of a new group
|
100
|
-
def aligned?
|
101
|
-
(pipeline.size % group_size) == 0
|
102
|
-
end
|
103
|
-
|
104
|
-
def consume_comments(vector)
|
105
|
-
vector.comments = comments
|
106
|
-
@comments = []
|
107
|
-
end
|
108
|
-
|
109
|
-
def comments
|
110
|
-
@comments ||= []
|
111
|
-
end
|
112
|
-
|
113
|
-
# When true the lead group is complete and a further repeat of it is not possible
|
114
|
-
# Calling this will compress the 2nd group into the 1st if possible
|
115
|
-
def lead_group_finalized?
|
116
|
-
if lead_group.size == group_size
|
117
|
-
if second_group_present?
|
118
|
-
i = -1
|
119
|
-
if second_group.all? do |vector|
|
120
|
-
i += 1
|
121
|
-
pipeline[i] == vector
|
122
|
-
end
|
123
|
-
pipeline[group_size - 1].repeat += 1
|
124
|
-
group_size.times { pipeline.delete_at(group_size) }
|
125
|
-
false
|
126
|
-
else
|
127
|
-
true
|
128
|
-
end
|
129
|
-
else
|
130
|
-
false
|
131
|
-
end
|
132
|
-
else
|
133
|
-
false
|
134
|
-
end
|
135
|
-
end
|
136
|
-
|
137
|
-
def second_group_present?
|
138
|
-
second_group.size == group_size
|
139
|
-
end
|
140
|
-
|
141
|
-
def lead_group
|
142
|
-
pipeline[0..group_size - 1]
|
143
|
-
end
|
144
|
-
|
145
|
-
def second_group
|
146
|
-
pipeline[group_size..(group_size * 2) - 1]
|
147
|
-
end
|
148
|
-
end
|
149
|
-
end
|
150
|
-
end
|
@@ -1,494 +0,0 @@
|
|
1
|
-
module Origen
|
2
|
-
module Utility
|
3
|
-
# Ruby API to interface with Design Sync
|
4
|
-
class DesignSync
|
5
|
-
# Tag the target which is an absolute path to a file or directory.
|
6
|
-
#
|
7
|
-
# ==== Options
|
8
|
-
#
|
9
|
-
# * :rec # Recursive, false by default
|
10
|
-
# * :delete # Delete the given tag from the target, false by default
|
11
|
-
# * :replace # Replace any existing version of the given tag, false by default
|
12
|
-
# * :exclude # Supply filenames to exclude or wildcard, e.g. "*.lst,*.S19"
|
13
|
-
#
|
14
|
-
# ==== Example
|
15
|
-
#
|
16
|
-
# tag(Origen.root, "my_release_001", :rec => true)
|
17
|
-
# tag("#{Origen.root}/top/top_block.rb", "my_release_001")
|
18
|
-
def tag(target, tag, options = {})
|
19
|
-
options = { rec: false, # Set true to tag recursively
|
20
|
-
delete: false,
|
21
|
-
replace: false
|
22
|
-
}.merge(options)
|
23
|
-
cmd = "dssc tag #{tag} #{exclude(options)} #{options[:replace] ? '-replace' : ''} #{rec(options)} #{options[:delete] ? '-delete' : ''} #{target}"
|
24
|
-
if options[:debug]
|
25
|
-
puts '**** DesignSync Debug ****'
|
26
|
-
puts cmd
|
27
|
-
else
|
28
|
-
system(cmd)
|
29
|
-
end
|
30
|
-
end
|
31
|
-
|
32
|
-
# Import a file to the local workspace from another vault, where the vault
|
33
|
-
# argument must include the full path to the requested file. You can optionally
|
34
|
-
# supply a destination for where you want the file to end up, if no destination
|
35
|
-
# is supplied the file will end up in the PWD.
|
36
|
-
#
|
37
|
-
# ==== Example
|
38
|
-
#
|
39
|
-
# # Import this file and save it in Origen.root
|
40
|
-
# file = "design_sync.rb"
|
41
|
-
# vault = "sync://sync-15088:15088/Projects/common_tester_blocks/origen/lib/sys"
|
42
|
-
# version = "v0.1.0" # Version can be any valid DS identifier, e.g. a version number or tag
|
43
|
-
#
|
44
|
-
# import(file, vault, version, Origen.root)
|
45
|
-
def import(file, vault, version, destination = false)
|
46
|
-
puts 'Importing from DesignSync...'
|
47
|
-
puts "#{vault}/#{file} #{version}"
|
48
|
-
unless sys("dssc import -version #{version} -force #{vault} #{file}")[0] =~ /Success/
|
49
|
-
fail "Error importing #{file} from Design Sync"
|
50
|
-
end
|
51
|
-
if Origen.running_on_windows?
|
52
|
-
sys("move /Y #{file} #{destination}/.") if destination
|
53
|
-
else
|
54
|
-
sys("mv -f #{file} #{destination}/.") if destination
|
55
|
-
end
|
56
|
-
end
|
57
|
-
|
58
|
-
# Check out a specific target which should be an absolute path to the target file, or
|
59
|
-
# wildcard expression.
|
60
|
-
#
|
61
|
-
# ==== Options:
|
62
|
-
#
|
63
|
-
# * :rec # Do a recursive checkout, false by default
|
64
|
-
# * :lock # Check out with a lock (overrides get option due to DesignSync get/lock incompatibility)
|
65
|
-
# * :version # Specific tag or version number, will get latest by default
|
66
|
-
# * :force # Force check out, false by default
|
67
|
-
# * :verbose # Display output to terminal, false by default
|
68
|
-
# * :get # Fetch locally editable copies, true by default (unless lock is set)
|
69
|
-
#
|
70
|
-
# ==== Example
|
71
|
-
#
|
72
|
-
# # Checkout everything in Origen.root
|
73
|
-
# check_out("#{Origen.root}/*", :rec => true)
|
74
|
-
def check_out(target, options = {})
|
75
|
-
options = {
|
76
|
-
get: true
|
77
|
-
}.merge(options)
|
78
|
-
cmd = "dssc co #{rec(options)} #{get(options)} #{loc(options)} #{ver(options)} #{force(options)} -nocomment #{target}"
|
79
|
-
launch(cmd, options[:verbose])
|
80
|
-
end
|
81
|
-
|
82
|
-
# Check in a specific target which should be an absolute path to the target file, or
|
83
|
-
# wildcard expression.
|
84
|
-
#
|
85
|
-
# ==== Options:
|
86
|
-
#
|
87
|
-
# * :rec # Do a recursive check-in, false by default
|
88
|
-
# * :comment # Supply a comment to go with the check-in
|
89
|
-
# * :new # Allow check in of new files (i.e. add the file to revision control)
|
90
|
-
# * :verbose # Display output to terminal, false by default
|
91
|
-
# * :skip # Allow check in to skip over a newer version of the file if it exists
|
92
|
-
# * :keep # Keep editable copy of the files post check-in, false by default
|
93
|
-
#
|
94
|
-
# ==== Example
|
95
|
-
#
|
96
|
-
# # Check-in everything in Origen.root
|
97
|
-
# check_in("#{Origen.root}/*", :rec => true, :com => "Periodic checkin, still in development")
|
98
|
-
def check_in(target, options = {})
|
99
|
-
options = {
|
100
|
-
keep: true
|
101
|
-
}.merge(options)
|
102
|
-
# FYI: for debug use '-dryrun' option to 'dssc ci' command
|
103
|
-
cmd = "dssc ci #{keep(options)} #{rec(options)} #{new(options)} #{com(options)} #{branch(options)} #{options[:skip] ? '-skip' : ''} #{target}"
|
104
|
-
launch(cmd, options[:verbose])
|
105
|
-
end
|
106
|
-
|
107
|
-
# Check in the contents of the given directory to a remote vault location, that is a vault location
|
108
|
-
# that is not associated with the workspace that the given files are in.
|
109
|
-
#
|
110
|
-
# Anything found in the given directory will be checked in, even files which are not currently under
|
111
|
-
# revision control.
|
112
|
-
#
|
113
|
-
# No attempt will be made to merge the current vault contents with the local data, the local data
|
114
|
-
# will always be checked in as lastest.
|
115
|
-
#
|
116
|
-
# A tag can be optionally supplied and if present will be applied to the files post check in.
|
117
|
-
#
|
118
|
-
# @example
|
119
|
-
#
|
120
|
-
# ds.remote_check_in("#{Origen.root}/output/j750", :vault => "sync://sync-15088:15088/Projects/common_tester_blocks/origen_training/j750", :tag => Origen.app.version)
|
121
|
-
def remote_check_in(dir, options = {})
|
122
|
-
Origen.deprecate 'Use Origen::RevisionControl::DesignSync.remote_check_in instead'
|
123
|
-
options = {
|
124
|
-
verbose: true,
|
125
|
-
rec: true,
|
126
|
-
keep: true,
|
127
|
-
new: true,
|
128
|
-
skip: true,
|
129
|
-
replace: true
|
130
|
-
}.merge(options)
|
131
|
-
|
132
|
-
dir = Pathname.new(dir)
|
133
|
-
fail "Directory does not exist: #{dir}" unless dir.exist?
|
134
|
-
fail "Only directories are supported by remote_check_in, this is not a directory: #{dir}" unless dir.directory?
|
135
|
-
fail 'No vault option supplied to remote_check_in!' unless options[:vault]
|
136
|
-
scratch = Pathname.new("#{Origen.app.workspace_manager.imports_directory}/design_sync/scratch")
|
137
|
-
FileUtils.rm_rf(scratch) if scratch.exist?
|
138
|
-
FileUtils.mkdir_p(scratch)
|
139
|
-
FileUtils.cp_r("#{dir}/.", scratch)
|
140
|
-
remove_dot_syncs!(scratch)
|
141
|
-
launch("dssc setvault #{options[:vault]} #{scratch}", options[:verbose])
|
142
|
-
check_in(scratch, options)
|
143
|
-
tag(scratch, options[:tag], options) if options[:tag]
|
144
|
-
FileUtils.rm_rf(scratch)
|
145
|
-
end
|
146
|
-
|
147
|
-
# Recursively remove all .SYNC directories from the given directory
|
148
|
-
def remove_dot_syncs!(dir, _options = {})
|
149
|
-
Origen.deprecate 'Use Origen::RevisionControl::DesignSync.remove_dot_syncs! instead'
|
150
|
-
dir = Pathname.new(dir)
|
151
|
-
fail "Directory does not exist: #{dir}" unless dir.exist?
|
152
|
-
fail "Only directories are supported by remove_dot_syncs, this is not a directory: #{dir}" unless dir.directory?
|
153
|
-
Dir.glob("#{dir}/**/.SYNC").sort.each do |dot_sync|
|
154
|
-
FileUtils.rm_rf(dot_sync)
|
155
|
-
end
|
156
|
-
end
|
157
|
-
|
158
|
-
# Cancel a checkout of a specific target which should be an absolute path to the target file,
|
159
|
-
# or wildcard expression
|
160
|
-
#
|
161
|
-
# ==== Options:
|
162
|
-
#
|
163
|
-
# * :rec # Do a recursive cancel, false by default
|
164
|
-
# * :force # Force cancel (overwrite local edits), false by default
|
165
|
-
# * :exclude # Supply filenames to exclude or wildcard, e.g. "*.lst,*.S19"
|
166
|
-
# * :keep # Keep editable copy of the files post cancel, false by default
|
167
|
-
#
|
168
|
-
# ==== Example
|
169
|
-
#
|
170
|
-
# # Cancel every checkout in Origen.root
|
171
|
-
# cancel("#{Origen.root}/*", :rec => true, :force => true)
|
172
|
-
def cancel(_target, options = {})
|
173
|
-
# Note "-verbose" is not a valid option for dssc cancel
|
174
|
-
cmd = "dssc cancel #{keep(options)} #{rec(options)} #{force(options)} #{exclude(options)}"
|
175
|
-
launch(cmd)
|
176
|
-
end
|
177
|
-
|
178
|
-
# Almost the same as DesignSync#check_out but accepts some different options.
|
179
|
-
#
|
180
|
-
# ==== Options:
|
181
|
-
#
|
182
|
-
# * :rec # Do a recursive populate, false by default
|
183
|
-
# * :version # Specific tag or version number, will get latest by default
|
184
|
-
# * :force # Force populate (overwrite local edits), false by default
|
185
|
-
# * :unify # Unify the workspace (remove any retired files you currently have checked out)
|
186
|
-
# * :exclude # Supply filenames to exclude or wildcard, e.g. "*.lst,*.S19"
|
187
|
-
# * :verbose # Display output to terminal, false by default
|
188
|
-
# * :get # Fetch locally editable copies, true by default
|
189
|
-
# * :merge # Merge local edits into latest files, false by default
|
190
|
-
def populate(target, options = {})
|
191
|
-
options = { unify: true,
|
192
|
-
incremental: false,
|
193
|
-
replace: false,
|
194
|
-
get: true,
|
195
|
-
merge: false
|
196
|
-
}.merge(options)
|
197
|
-
inc = options[:incremental] ? '-inc' : ''
|
198
|
-
replace = options[:replace] ? '-replace' : ''
|
199
|
-
cmd = "dssc pop #{inc} #{replace} #{rec(options)} #{force(options)} #{merge(options)} #{get(options)} #{ver(options)} #{uni(options)} #{exclude(options)} #{target}"
|
200
|
-
successful = launch(cmd, options[:verbose])
|
201
|
-
unless successful
|
202
|
-
fail "Something went wrong when populating #{target} from DesignSync!"
|
203
|
-
end
|
204
|
-
end
|
205
|
-
|
206
|
-
# Check if the supplied directory has any modified objects, will reflect the result from the
|
207
|
-
# last call unless :refresh => true. Returns true or false.
|
208
|
-
# See DesignSync#modified_objects for available options.
|
209
|
-
#
|
210
|
-
# ==== Example
|
211
|
-
#
|
212
|
-
# modified_objects? # Takes a while to run while the workspace is queried
|
213
|
-
# modified_objects? # Runs very quickly and returns the cached answer
|
214
|
-
# modified_objects?(:refresh => true) # Takes a while to run while the workspace is queried
|
215
|
-
def modified_objects?(*args)
|
216
|
-
modified_objects(*args).size > 0
|
217
|
-
end
|
218
|
-
|
219
|
-
# Returns the selector for the given object, which should be an absolute path to a
|
220
|
-
# file or directory
|
221
|
-
def selector(target)
|
222
|
-
sys("dssc url selector #{target}")[0]
|
223
|
-
end
|
224
|
-
|
225
|
-
# Returns an array of paths to modified files, caches result for performance, set :refresh => true
|
226
|
-
# to clear cache. The target should be an absolute path to the directory you want to query.
|
227
|
-
#
|
228
|
-
# ==== Options:
|
229
|
-
#
|
230
|
-
# * :rec # Do a recursive search, false by default
|
231
|
-
# * :exclude # Supply filenames to exclude or wildcard, e.g. "*.lst,*.S19"
|
232
|
-
# * :refresh # Force a new search, false by default
|
233
|
-
#
|
234
|
-
# ==== Example
|
235
|
-
#
|
236
|
-
# # Get all modified files in my project workspace
|
237
|
-
# files = modified_objects(Origen.root, :rec => true)
|
238
|
-
#
|
239
|
-
# NOTE: -unmanaged and -managed are mutually exclusive, specifying both does neither!
|
240
|
-
# -unmanaged : show only objects not under revision control
|
241
|
-
# -managed : show only objects under revision control
|
242
|
-
# -modified : show locally modified files in workspace (includes unmanaged objects)
|
243
|
-
# -changed : shows not up-to-date files. Includes both locally modified and newer verions in vault.
|
244
|
-
# Overrides -modified.
|
245
|
-
|
246
|
-
def modified_objects(target, options = {})
|
247
|
-
options = {
|
248
|
-
managed: true, # by default handle managed (to permit for unmanaged case)
|
249
|
-
remote: false, # includes files possibly modified by others in repository
|
250
|
-
}.merge(options)
|
251
|
-
# The result of this method is cached for future calls (method called twice actually)
|
252
|
-
@objects = nil if options[:refresh]
|
253
|
-
@needs_update_objects = nil if options[:refresh]
|
254
|
-
|
255
|
-
if options[:remote]
|
256
|
-
return @needs_update_objects if @needs_update_objects
|
257
|
-
else
|
258
|
-
return @objects if @objects
|
259
|
-
end
|
260
|
-
|
261
|
-
# Since DesignSync does not supply an option to only list files that need update (!), have to run with
|
262
|
-
# -changed option then again without and difference the 2 arrays!
|
263
|
-
if options[:remote]
|
264
|
-
all_objects = sys("dssc ls #{rec(options)} #{exclude(options)} #{managed(options)} #{dssc_path(options)} -report N -modified #{unmanaged(options)} -changed -format text #{target}").reject do |item|
|
265
|
-
# removes extraneous lines
|
266
|
-
item =~ /^(Name|Directory|---)/
|
267
|
-
end
|
268
|
-
all_objects.map! do |object|
|
269
|
-
object.strip! # Strip off any whitespace from all objects
|
270
|
-
object.sub!(/^#{full_path_prefix}/, '')
|
271
|
-
object.sub('|', ':')
|
272
|
-
end
|
273
|
-
end
|
274
|
-
|
275
|
-
@objects = sys("dssc ls #{rec(options)} #{exclude(options)} #{managed(options)} #{dssc_path(options)} -report N -modified #{unmanaged(options)} -format text #{target}").reject do |item|
|
276
|
-
# removes extraneous lines
|
277
|
-
item =~ /^(Name|Directory|---)/
|
278
|
-
end
|
279
|
-
@objects.map! do |object|
|
280
|
-
object.strip! # Strip off any whitespace from all objects
|
281
|
-
object.sub!(/^#{full_path_prefix}/, '')
|
282
|
-
object.sub('|', ':')
|
283
|
-
end
|
284
|
-
|
285
|
-
# Now difference the lists if remote desired
|
286
|
-
if options[:remote]
|
287
|
-
return @needs_update_objects = all_objects - @objects
|
288
|
-
else
|
289
|
-
return @objects
|
290
|
-
end
|
291
|
-
end
|
292
|
-
|
293
|
-
def full_path_prefix
|
294
|
-
@full_path_prefix ||= begin
|
295
|
-
if Origen.running_on_windows?
|
296
|
-
'file:///'
|
297
|
-
else
|
298
|
-
'file://'
|
299
|
-
end
|
300
|
-
end
|
301
|
-
end
|
302
|
-
|
303
|
-
# Check if the supplied directory has any changed objects vs the previous tag
|
304
|
-
# See DesignSync#changed_objects for available options.
|
305
|
-
def changed_objects?(*args)
|
306
|
-
objects = changed_objects(*args)
|
307
|
-
objects[:added].size > 0 || objects[:removed].size > 0 || objects[:changed].size > 0
|
308
|
-
end
|
309
|
-
|
310
|
-
# Returns a hash containing files that have changed vs. the previous tag, this is
|
311
|
-
# organized as follows:
|
312
|
-
#
|
313
|
-
# {
|
314
|
-
# :added => [], # Paths to files that have been added since the previous tag
|
315
|
-
# :removed => [], # Paths to files that have been removed since the previous tag
|
316
|
-
# :changed => [], # Paths to files that have changed since the previous tag
|
317
|
-
# }
|
318
|
-
def changed_objects(target, previous_tag, options = {})
|
319
|
-
options = {
|
320
|
-
}.merge(options)
|
321
|
-
# We need to parse the following data from the output, ignore everything else
|
322
|
-
# which will mostly refer to un-managed files.
|
323
|
-
#
|
324
|
-
# Added since previous version...
|
325
|
-
# 1.12 First only source_setup
|
326
|
-
# Removed since previous version...
|
327
|
-
# 1.13 Second only lib/history
|
328
|
-
# Modified since previous version...
|
329
|
-
# 1.32 1.31 Different versions lib/origen/application.rb
|
330
|
-
# Modified since previous version including a local edit...
|
331
|
-
# 1.7 (Locally Modified) 1.7 Different states lib/origen/commands/rc.rb
|
332
|
-
objects = {
|
333
|
-
added: [], removed: [], changed: []
|
334
|
-
}
|
335
|
-
sys("dssc compare -rec -path -report silent -selector #{previous_tag} #{target}").each do |line|
|
336
|
-
unless line =~ /Unmanaged/
|
337
|
-
# http://www.rubular.com/r/GoNYB75upB
|
338
|
-
if line =~ /\s*(\S+)\s+First only\s+(\S+)\s*/
|
339
|
-
objects[:added] << Regexp.last_match[2]
|
340
|
-
# http://www.rubular.com/r/Xvh32Lm4hS
|
341
|
-
elsif line =~ /\s*(\S+)\s+Second only\s+(\S+)\s*/
|
342
|
-
objects[:removed] << Regexp.last_match[2]
|
343
|
-
# http://www.rubular.com/r/tvTHod9Mye
|
344
|
-
elsif line =~ /\s*\S+\s+(\(Locally Modified\))?\s*(\S+)\s+Different (versions|states)\s+(\S+)\s*/
|
345
|
-
objects[:changed] << Regexp.last_match[4]
|
346
|
-
end
|
347
|
-
end
|
348
|
-
end
|
349
|
-
objects
|
350
|
-
end
|
351
|
-
|
352
|
-
def diff_cmd(options = {})
|
353
|
-
if options[:version]
|
354
|
-
"dssc diff -gui -ver #{options[:version]}"
|
355
|
-
else
|
356
|
-
'dssc diff -gui'
|
357
|
-
end
|
358
|
-
end
|
359
|
-
|
360
|
-
# Returns true if the given file is known to Design Sync
|
361
|
-
#
|
362
|
-
# ==== Example
|
363
|
-
#
|
364
|
-
# managed_by_design_sync?("#{Origen.root}/config/application.rb")
|
365
|
-
def managed_by_design_sync?(path, _options = {})
|
366
|
-
res = sys "dssc url vault #{path}"
|
367
|
-
if res.empty?
|
368
|
-
false
|
369
|
-
else
|
370
|
-
if res.first =~ /^file:/ || res.first =~ /There is no object with that name/
|
371
|
-
false
|
372
|
-
else
|
373
|
-
true
|
374
|
-
end
|
375
|
-
end
|
376
|
-
end
|
377
|
-
|
378
|
-
# Will recursively move back up the directory tree from the given
|
379
|
-
# directory and return the first one that is not part of a Design Sync
|
380
|
-
# workspace.
|
381
|
-
#
|
382
|
-
# The supplied pathname should be an absolute Pathname instance.
|
383
|
-
def container_directory(pathname)
|
384
|
-
if managed_by_design_sync?(pathname)
|
385
|
-
container_directory(pathname.parent)
|
386
|
-
else
|
387
|
-
pathname
|
388
|
-
end
|
389
|
-
end
|
390
|
-
|
391
|
-
# Initializes the given directory with the given vault reference
|
392
|
-
def initialize_dir(dir, vault)
|
393
|
-
Dir.chdir dir do
|
394
|
-
sys "dssc setvault #{vault} ."
|
395
|
-
end
|
396
|
-
end
|
397
|
-
|
398
|
-
# Returns the vault reference to give local file or directory
|
399
|
-
def vault(file_or_dir)
|
400
|
-
(sys "dssc url vault #{file_or_dir}").first
|
401
|
-
end
|
402
|
-
|
403
|
-
private
|
404
|
-
|
405
|
-
# This will return true if the command has run successfully without errors
|
406
|
-
def launch(cmd, verbose = false) # :nodoc:
|
407
|
-
if verbose
|
408
|
-
$stdout.sync = true
|
409
|
-
puts cmd
|
410
|
-
system cmd
|
411
|
-
else
|
412
|
-
`#{cmd}`
|
413
|
-
$CHILD_STATUS.success?
|
414
|
-
end
|
415
|
-
end
|
416
|
-
|
417
|
-
# Make a sys call, returning the output in an array
|
418
|
-
def sys(call) # :nodoc:
|
419
|
-
output = `#{call}`.split("\n")
|
420
|
-
# Screen out some common redundant DS output before handing back
|
421
|
-
output.reject do |item|
|
422
|
-
item =~ /^Logging/ || item == '' ||
|
423
|
-
item =~ /V(\d+\.\d+-\d+|\d.\d+)/ # Screen out something like "V5.1-1205" or "V6R2010"
|
424
|
-
end
|
425
|
-
end
|
426
|
-
|
427
|
-
def exclude(options) # :nodoc:
|
428
|
-
options[:exclude] ? "-exclude '#{options[:exclude]}'" : ''
|
429
|
-
end
|
430
|
-
|
431
|
-
def rec(options) # :nodoc:
|
432
|
-
options[:rec] ? '-rec' : ''
|
433
|
-
end
|
434
|
-
|
435
|
-
def force(options) # :nodoc:
|
436
|
-
options[:force] ? '-force' : ''
|
437
|
-
end
|
438
|
-
|
439
|
-
def uni(options) # :nodoc:
|
440
|
-
(options[:uni] || options[:unify]) ? '-uni' : ''
|
441
|
-
end
|
442
|
-
|
443
|
-
def get(options) # :nodoc:
|
444
|
-
# lock option overrides get option
|
445
|
-
# due to incompatibility in DesignSync
|
446
|
-
if !(options[:lock] || options[:loc])
|
447
|
-
options[:get] ? '-get' : ''
|
448
|
-
else
|
449
|
-
''
|
450
|
-
end
|
451
|
-
end
|
452
|
-
|
453
|
-
def loc(options) # :nodoc:
|
454
|
-
(options[:lock] || options[:loc]) ? '-loc' : '-get'
|
455
|
-
end
|
456
|
-
|
457
|
-
def keep(options) # :nodoc:
|
458
|
-
(options[:keep]) ? '-keep' : ''
|
459
|
-
end
|
460
|
-
|
461
|
-
def merge(options) # :nodoc:
|
462
|
-
(options[:merge]) ? '-merge' : ''
|
463
|
-
end
|
464
|
-
|
465
|
-
def ver(options) # :nodoc:
|
466
|
-
options[:version] ? "-ver #{options[:version]}" : ''
|
467
|
-
end
|
468
|
-
|
469
|
-
def branch(options) # :nodoc:
|
470
|
-
options[:branch] ? "-branch #{options[:branch]}" : ''
|
471
|
-
end
|
472
|
-
|
473
|
-
def new(options) # :nodoc:
|
474
|
-
options[:new] ? '-new' : ''
|
475
|
-
end
|
476
|
-
|
477
|
-
def com(options) # :nodoc:
|
478
|
-
options[:comment] ? "-com \"#{options[:comment]}\"" : '-comment /null'
|
479
|
-
end
|
480
|
-
|
481
|
-
def unmanaged(options) # :nodoc:
|
482
|
-
options[:unmanaged] ? '-unmanaged' : ''
|
483
|
-
end
|
484
|
-
|
485
|
-
def managed(options) # :nodoc:
|
486
|
-
options[:managed] ? '-managed' : ''
|
487
|
-
end
|
488
|
-
|
489
|
-
def dssc_path(options) # :nodoc:
|
490
|
-
options[:fullpath] ? '-fullpath' : '-path'
|
491
|
-
end
|
492
|
-
end
|
493
|
-
end
|
494
|
-
end
|