Class: Ritsu::SrcFiles::TargetCmakeLists::DependenciesTemplate

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) ⇒ DependenciesTemplate

Returns a new instance of DependenciesTemplate.



88
89
90
91
# File 'lib/ritsu/src_files/target_cmake_lists.rb', line 88

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

Instance Attribute Details

#targetObject (readonly)

Returns the value of attribute target.



86
87
88
# File 'lib/ritsu/src_files/target_cmake_lists.rb', line 86

def target
  @target
end

Instance Method Details

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



93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
# File 'lib/ritsu/src_files/target_cmake_lists.rb', line 93

def update_block(block, options = {})
  block.contents.clear

  external_libraries = target.dependency_libraries.to_a
  external_libraries.sort! {|x,y| x.name <=> y.name}
  dependency_targets = target.dependency_targets.to_a
  dependency_targets.sort! {|x,y| x.name <=> y.name}

  if external_libraries.length == 0 && dependency_targets.length == 0
    return
  end

  block.contents << "TARGET_LINK_LIBRARIES(#{target.name}"

  external_libraries.each do |external_library|
    block.contents << "    " + external_library.cmake_name
  end

  dependency_targets.each do |dependency_target|
    block.contents << "    " + dependency_target.name
  end

  block.contents << ")"
end