Class: OrigenSim::Artifacts::Artifact

Inherits:
Object
  • Object
show all
Defined in:
lib/origen_sim/simulator/artifacts.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options) ⇒ Artifact

Returns a new instance of Artifact.



52
53
54
55
56
# File 'lib/origen_sim/simulator/artifacts.rb', line 52

def initialize(options)
  @name = options.delete(:name)
  @parent = options.delete(:parent)
  @options = options
end

Instance Attribute Details

#nameObject (readonly)

Returns the value of attribute name.



49
50
51
# File 'lib/origen_sim/simulator/artifacts.rb', line 49

def name
  @name
end

#parentObject (readonly)

Returns the value of attribute parent.



50
51
52
# File 'lib/origen_sim/simulator/artifacts.rb', line 50

def parent
  @parent
end

Instance Method Details

#cleanObject



90
91
92
93
94
95
96
97
98
# File 'lib/origen_sim/simulator/artifacts.rb', line 90

def clean
  if File.exist?(run_target)
    if File.symlink?(run_target)
      File.unlink(run_target)
    else
      FileUtils.rm_r(run_target)
    end
  end
end

#populateObject



76
77
78
79
80
81
82
83
84
85
86
87
88
# File 'lib/origen_sim/simulator/artifacts.rb', line 76

def populate
  unless Dir.exist?(run_target.dirname)
    FileUtils.mkdir_p(run_target.dirname)
  end

  if populate_method == :symlink
    File.symlink(target, run_target)
  elsif populate_method == :copy
    FileUtils.cp(target, run_target)
  else
    Origen.app.fail! "Cannot populate artifact :#{name} with populate method #{populate_method}!"
  end
end

#populate_methodObject Also known as: pop_method



71
72
73
# File 'lib/origen_sim/simulator/artifacts.rb', line 71

def populate_method
  @options[:populate_method] || parent.artifact_populate_method
end

#reconfigure(options) ⇒ Object



100
101
102
# File 'lib/origen_sim/simulator/artifacts.rb', line 100

def reconfigure(options)
  @options = options
end

#run_targetObject



62
63
64
65
66
67
68
69
# File 'lib/origen_sim/simulator/artifacts.rb', line 62

def run_target
  run_target = Pathname(@options[:run_target] || parent.artifact_run_dir)
  if run_target.absolute?
    run_target.join(target.basename)
  else
    parent.artifact_run_dir.join(run_target).join(target.basename)
  end
end

#targetObject



58
59
60
# File 'lib/origen_sim/simulator/artifacts.rb', line 58

def target
  Pathname(@options[:target] || parent.artifact_dir)
end