Class: Ritsu::SrcFiles::TargetCmakeLists::CudaCompileTemplate

Inherits:
Template
  • Object
show all
Defined in:
lib/ritsu/ext/cuda/src_files/target_cmake_lists.rb

Instance Attribute Summary collapse

Attributes included from BlockMixin

#contents, #id, #indent_length, #indent_level, #local_indentation

Instance Method Summary collapse

Methods inherited from Template

#add_content, #add_template, #child_template_with_id, #child_template_with_id_position, #child_templates, #create_block

Methods included from BlockMixin

#add_line, #add_new_line, #block_structure?, #clear_contents, #indent, #initialize_block_mixin, #outdent

Constructor Details

#initialize(target) ⇒ CudaCompileTemplate

Returns a new instance of CudaCompileTemplate.



46
47
48
49
# File 'lib/ritsu/ext/cuda/src_files/target_cmake_lists.rb', line 46

def initialize(target)
  super("TargetCmakeLists -- #{target.name} -- CudaCompile")
  @target = target
end

Instance Attribute Details

#targetObject (readonly)

Returns the value of attribute target.



44
45
46
# File 'lib/ritsu/ext/cuda/src_files/target_cmake_lists.rb', line 44

def target
  @target
end

Instance Method Details

#cuda_generate_files_var_nameObject



51
52
53
# File 'lib/ritsu/ext/cuda/src_files/target_cmake_lists.rb', line 51

def cuda_generate_files_var_name
  "#{target.name.upcase}_CUDA_GENERATED_FILES"
end

#update_block(block, options = {}) ⇒ Object



55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
# File 'lib/ritsu/ext/cuda/src_files/target_cmake_lists.rb', line 55

def update_block(block, options = {})
  block.clear_contents
  
  cu_files = target.src_files.select { |x| x.respond_to?(:cu_file?) && x.cu_file? }
  if cu_files.length == 0
    return
  end
  cu_files.sort! {|x,y| x.src_path <=> y.src_path}
  
  block.add_line "CUDA_COMPILE(#{cuda_generate_files_var_name}"
  block.indent
  cu_files.each do |cu_file|
    block.add_line("${CMAKE_SOURCE_DIR}/#{cu_file.src_path}")
  end
  block.outdent
  block.add_line ")"
  block.add_new_line
  block.add_line "SET(#{target.name.upcase}_SRC_FILES ${#{target.name.upcase}_SRC_FILES} ${#{cuda_generate_files_var_name}})"
end