Class: Ritsu::SrcFiles::TargetCmakeLists::SourceFilesTemplate

Inherits:
Template
  • Object
show all
Defined in:
lib/ritsu/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) ⇒ SourceFilesTemplate

Returns a new instance of SourceFilesTemplate.



62
63
64
65
# File 'lib/ritsu/src_files/target_cmake_lists.rb', line 62

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

Instance Attribute Details

#targetObject

Returns the value of attribute target.



60
61
62
# File 'lib/ritsu/src_files/target_cmake_lists.rb', line 60

def target
  @target
end

Instance Method Details

#src_files_var_nameObject



67
68
69
# File 'lib/ritsu/src_files/target_cmake_lists.rb', line 67

def src_files_var_name
  target.name.upcase + "_SRC_FILES"
end

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



71
72
73
74
75
76
77
78
79
80
81
82
# File 'lib/ritsu/src_files/target_cmake_lists.rb', line 71

def update_block(block, options = {})
  block.contents.clear
  block.contents << "SET(#{src_files_var_name}"

  src_files = target.src_files.to_a
  src_files.sort! {|x,y| x.src_path <=> y.src_path}
  src_files.each do |src_file|
    block.contents << "    ${CMAKE_SOURCE_DIR}/#{src_file.src_path}" if src_file.include_in_source_files?
  end

  block.contents << ")"
end