Class: NxBuild::Target::Cpp

Inherits:
Base
  • Object
show all
Defined in:
lib/nxbuild/target/cpp.rb

Instance Attribute Summary collapse

Attributes inherited from Base

#name

Instance Method Summary collapse

Constructor Details

#initializeCpp

Returns a new instance of Cpp.



8
9
10
# File 'lib/nxbuild/target/cpp.rb', line 8

def initialize
  @sources = []
end

Instance Attribute Details

#sourcesObject (readonly)

Returns the value of attribute sources.



6
7
8
# File 'lib/nxbuild/target/cpp.rb', line 6

def sources
  @sources
end

Instance Method Details

#filter(files) ⇒ Object



17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/nxbuild/target/cpp.rb', line 17

def filter(files)
  filters = ['Mac', 'Windows']
  if OS.windows?
    filters.delete('Windows')
  end
  filters.each do |filter|
    new_files = []
    files.each_with_index do |file, i|
      s = file.split('/')
      new_files << file unless s.any? {|seg| seg == filter}
    end
    files = new_files
  end
  files
end

#source(path) ⇒ Object



12
13
14
15
# File 'lib/nxbuild/target/cpp.rb', line 12

def source(path)
  files = Dir[path + '/**/*.c'] + Dir[path + '/**/*.cpp'] + Dir[path + '/**/*.m'] + Dir[path + '/**/*.mm']
  @sources += filter(files)
end