Class: OrigenTesters::PatternCompilers::Job

Inherits:
Object
  • Object
show all
Defined in:
lib/origen_testers/pattern_compilers/job.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(pattern, options_with_args, options) ⇒ Job

Returns a new instance of Job.



34
35
36
37
38
39
40
41
42
43
44
45
# File 'lib/origen_testers/pattern_compilers/job.rb', line 34

def initialize(pattern, options_with_args, options)
  @pattern = pattern
  @compiler = options_with_args.delete(:compiler)
  @id = options_with_args.delete(:id)
  @location = options_with_args.delete(:location)
  @clean = options_with_args.delete(:clean)
  @verbose = options_with_args.delete(:verbose)
  @output_directory = options_with_args.delete(:output_directory)
  @pinmap_workbook = options_with_args.delete(:pinmap_workbook)
  @compiler_options_with_args = options_with_args.delete_if { |k, v| v.nil? }  # Whatever's left has to be valid compiler options
  @compiler_options = options.delete_if { |k, v| v == false }
end

Instance Attribute Details

#cleanObject

Controls whether the compiler log files are kept: true/false



14
15
16
# File 'lib/origen_testers/pattern_compilers/job.rb', line 14

def clean
  @clean
end

#compilerObject (readonly)

linux compiler full path



32
33
34
# File 'lib/origen_testers/pattern_compilers/job.rb', line 32

def compiler
  @compiler
end

#compiler_optionsObject

Compiler options where only the opt has to be passed as ‘-opt’



26
27
28
# File 'lib/origen_testers/pattern_compilers/job.rb', line 26

def compiler_options
  @compiler_options
end

#compiler_options_with_argsObject

Compiler options where an opt and an arg have to be passed ‘-opt:arg’



29
30
31
# File 'lib/origen_testers/pattern_compilers/job.rb', line 29

def compiler_options_with_args
  @compiler_options_with_args
end

#idObject

Type of pattern as designated by the LinuxPatternCompiler



8
9
10
# File 'lib/origen_testers/pattern_compilers/job.rb', line 8

def id
  @id
end

#locationObject

Where the job is to be executed, either locally (‘local’) or on Linux Server Farm (‘lsf’)



11
12
13
# File 'lib/origen_testers/pattern_compilers/job.rb', line 11

def location
  @location
end

#output_directoryObject

Output directory for the .PAT file



20
21
22
# File 'lib/origen_testers/pattern_compilers/job.rb', line 20

def output_directory
  @output_directory
end

#patternObject

Pattern to be compiled, is Pathname class. Will use full path



5
6
7
# File 'lib/origen_testers/pattern_compilers/job.rb', line 5

def pattern
  @pattern
end

#pinmap_workbookObject

Pinmap file



23
24
25
# File 'lib/origen_testers/pattern_compilers/job.rb', line 23

def pinmap_workbook
  @pinmap_workbook
end

#verboseObject

Controls whether the compiler STDOUT is displayed



17
18
19
# File 'lib/origen_testers/pattern_compilers/job.rb', line 17

def verbose
  @verbose
end

Instance Method Details

#cmdObject



51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
# File 'lib/origen_testers/pattern_compilers/job.rb', line 51

def cmd
  cmd = ''
  cmd = "#{@compiler} -pinmap_workbook:#{@pinmap_workbook} -output:#{@output_directory}/#{@pattern.basename.to_s.split('.').first}.PAT #{@pattern} "
  # add in any remaining compiler options
  compiler_options.each_key { |k| cmd += "-#{k} " }
  compiler_options_with_args.each_pair { |k, v| cmd += "-#{k}:#{v} " }
  if @verbose
    cmd += ';'
  else
    cmd += '2>&1 > /dev/null;'
  end
  # If the job is to be run on the LSF add in the clean .log and mv the files if necessary
  if @location == 'lsf'
    cmd += clean_lsf if @clean == true
  end
  cmd
end

#nameObject



47
48
49
# File 'lib/origen_testers/pattern_compilers/job.rb', line 47

def name
  @pattern.basename
end

#ready?Boolean

Returns:

  • (Boolean)


69
70
71
72
73
74
75
# File 'lib/origen_testers/pattern_compilers/job.rb', line 69

def ready?
  ready = true
  ready && @output_directory.directory? &&
    @pattern.file? && @pinmap_workbook.file? &&
    [true, false].include?(@clean) &&
    [:local, :lsf].include?(@location)
end