Module: Flak::Template::Cpp::Settings

Extended by:
MergeEngine
Defined in:
lib/flak/rake/templates/cpp.rb

Class Method Summary collapse

Instance Method Summary collapse

Methods included from MergeEngine

flatten_yaml, flatten_yaml_file, infuse, settings_modifications

Class Method Details

.extended(target) ⇒ Object



8
9
10
# File 'lib/flak/rake/templates/cpp.rb', line 8

def self.extended target
  infuse target
end

Instance Method Details

#build_filenameObject

these methods will become instance methods of the target and as such will have access to te @settings instance variable



18
19
20
21
22
23
24
# File 'lib/flak/rake/templates/cpp.rb', line 18

def build_filename
  bind = binding()
  Flak::Errors.assert("@settings[:build_directory]", "String", bind,__FILE__)
  Flak::Errors.assert("@settings[:name]", "String", bind,__FILE__)
  Flak::Errors.assert("@settings[:target_extension]", "String", bind,__FILE__)
  File.join(@settings[:build_directory],'products',@settings[:name].ext(@settings[:target_extension])) 
end

#c_clean_cmdObject



86
87
88
89
# File 'lib/flak/rake/templates/cpp.rb', line 86

def c_clean_cmd
  object_str = object_files.collect { |el| "\"#{el.to_s}\"" }.join(" ")
  "rm -f \"#{build_filename}\" #{object_str}"
end

#c_compile_cmd(source) ⇒ Object



45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
# File 'lib/flak/rake/templates/cpp.rb', line 45

def c_compile_cmd(source)
  bind = binding()
  Flak::Errors.assert("@settings[:compiler]", "String", bind,__FILE__)
  Flak::Errors.assert("@settings[:object_flag]", "String", bind,__FILE__)
  Flak::Errors.assert("@settings[:include_flag]", "String", bind,__FILE__)

  compiler = "\"#{@settings[:compiler]}\""
  object = "#{@settings[:object_flag]}\"#{object_file(source)}\""
  source = "\"#{source}\""
  inc_path = (@settings[:source_files].collect {|f| f.pathmap('%d')}.uniq | ( @settings[:include_paths] || [] )).collect { |el| "#{@settings[:include_flag]}\"#{el.to_s}\"" }.join(" ")
  includes = ( @settings[:includes] || [] ).collect { |el| "-include  \"#{el.to_s}\"" }.join(" ")
  compiler_options = (@settings[:compiler_options] || [] ).collect { |el| el.to_s }.join(" ")
  # puts "*" * 80
  # puts @settings[:compiler_options]
  # puts "*" * 80
  "#{compiler} #{compiler_options}  #{source} #{object}  #{inc_path} #{includes}"
end


64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
# File 'lib/flak/rake/templates/cpp.rb', line 64

def c_link_cmd
  bind = binding()
  Flak::Errors.assert("@settings[:linker]", "String", bind,__FILE__)
  Flak::Errors.assert("@settings[:lib_flag]", "String", bind,__FILE__)
  Flak::Errors.assert("@settings[:lib_ext]", "String", bind,__FILE__)
  Flak::Errors.assert("@settings[:libpath_flag]", "String", bind,__FILE__)
  Flak::Errors.assert("@settings[:framework_flag]", "String", bind,__FILE__)
  Flak::Errors.assert("@settings[:outputfile_flag]", "String", bind,__FILE__)


  linker = "\"#{@settings[:linker]}\""
  objects = object_files.collect { |el| "\"#{el.to_s}\"" }.join(" ")
  #  libstr =  ((@settings[:libs] || []).collect { |el| "-l#{el.to_s}" } |  (@settings[:static_libs] || []).collect { |el| "#{@settings[:static_prefix_flag]} -l#{el.to_s}" }).join(" ")
  libstr =  (@settings[:libs] || []).collect { |el| "#{@settings[:lib_flag]}#{el.to_s}#{@settings[:lib_ext]}" }.join(" ")
  libpathstr = (@settings[:lib_paths] || []).collect { |el| "#{@settings[:libpath_flag]}\"#{el.to_s}\"" }.join(" ")
  linkflagstr = ( @settings[:linker_options]  || [] ).collect { |el| el.to_s }.join(" ")
  dso_flagstr = (@settings[:dso_options] || [] ).collect { |el| el.to_s }.join(" ")
  fwrk = (@settings[:frameworks] || [] ).collect { |el| "#{@settings[:framework_flag]} #{el.to_s}" }.join(" ")
  "#{linker}  #{dso_flagstr} #{linkflagstr}  #{libpathstr} #{libstr} #{fwrk}   #{@settings[:outputfile_flag]}\"#{build_filename}\" #{objects}"
end

#object_file(source) ⇒ Object

generate path to object file from source: e.g. /hq/dev/jtools/build/2009.3/darwin/debug/animal/sensor.o“



33
34
35
36
37
38
# File 'lib/flak/rake/templates/cpp.rb', line 33

def object_file(source)
  bind = binding()
  Flak::Errors.assert("@settings[:build_directory]", "String", bind,__FILE__)
  Flak::Errors.assert("@settings[:object_extension]", "String", bind,__FILE__)
  File.join(@settings[:build_directory], source.gsub("/src/","/").ext( @settings[:object_extension] ))
end

#object_filesObject

collect all object files for this target



41
42
43
# File 'lib/flak/rake/templates/cpp.rb', line 41

def object_files
  @settings[:source_files].collect { |s| object_file(s) }
end

#release_filenameObject



26
27
28
29
30
# File 'lib/flak/rake/templates/cpp.rb', line 26

def release_filename 
  bind = binding()
  Flak::Errors.assert("@settings[:revision_directory]", "String", bind,__FILE__)
  File.join( @settings[:revision_directory], 'bin', build_filename.pathmap('%f'))   
end