Class: Gaudi::Component

Inherits:
Object
  • Object
show all
Includes:
StandardPaths
Defined in:
lib/gaudi/helpers/components.rb

Overview

A Gaudi::Component is a logical grouping of a set of source and header files that maps to a directory structure.

Given a base directory where sources reside, the name of Component is used to map to one or more Component source directories.

By convention we define an inc/ directory where “public” headers reside. These headers form the interface of the Component and the directory is exposed by Gaudi for use in include statements.

Direct Known Subclasses

Program

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from StandardPaths

#command_file, #determine_directories, #determine_headers, #determine_interface_paths, #determine_sources, #determine_test_directories, #executable, #is_generated?, #is_unit_test?, #library, #object_file, #unit_test

Methods included from PlatformOperations

#is_assembly?, #is_exe?, #is_header?, #is_library?, #is_source?

Constructor Details

#initialize(name, system_config, platform) ⇒ Component


43
44
45
46
47
48
49
50
51
52
53
54
55
56
# File 'lib/gaudi/helpers/components.rb', line 43

def initialize name,system_config,platform
  @parent=nil
  @directories= determine_directories(name,system_config.source_directories,system_config,platform)
  @test_directories= determine_test_directories(@directories)
  @config_files= Rake::FileList[*directories.pathmap('%p/build.cfg')].existing
  if @config_files.empty? 
    @configuration = Configuration::BuildConfiguration.new(name)
  else
    @configuration = Configuration::BuildConfiguration.load(@config_files)
  end
  @system_config= system_config
  @platform= platform
  @name=@identifier= configuration.prefix
end

Instance Attribute Details

#config_filesObject (readonly)

Returns the value of attribute config_files


40
41
42
# File 'lib/gaudi/helpers/components.rb', line 40

def config_files
  @config_files
end

#configurationObject (readonly)

Returns the value of attribute configuration


40
41
42
# File 'lib/gaudi/helpers/components.rb', line 40

def configuration
  @configuration
end

#directoriesObject (readonly)

Returns the value of attribute directories


40
41
42
# File 'lib/gaudi/helpers/components.rb', line 40

def directories
  @directories
end

#identifierObject (readonly)

Returns the value of attribute identifier


40
41
42
# File 'lib/gaudi/helpers/components.rb', line 40

def identifier
  @identifier
end

#nameObject (readonly)

Returns the value of attribute name


40
41
42
# File 'lib/gaudi/helpers/components.rb', line 40

def name
  @name
end

#parentObject

This is set to the name of the program or library containing the component when building a deployment. Default is empty


42
43
44
# File 'lib/gaudi/helpers/components.rb', line 42

def parent
  @parent
end

#platformObject (readonly)

Returns the value of attribute platform


40
41
42
# File 'lib/gaudi/helpers/components.rb', line 40

def platform
  @platform
end

#test_directoriesObject (readonly)

Returns the value of attribute test_directories


40
41
42
# File 'lib/gaudi/helpers/components.rb', line 40

def test_directories
  @test_directories
end

Instance Method Details

#allObject

All files


74
75
76
# File 'lib/gaudi/helpers/components.rb', line 74

def all
  sources+headers
end

#dependenciesObject

All components upon which this Component depends on


78
79
80
# File 'lib/gaudi/helpers/components.rb', line 78

def dependencies
  configuration.dependencies.map{|dep| Component.new(dep,@system_config,platform)}
end

#external_includesObject

External (additional) include paths


82
83
84
# File 'lib/gaudi/helpers/components.rb', line 82

def external_includes
  @system_config.external_includes(@platform)+@configuration.external_includes
end

#headersObject

All headers


62
63
64
# File 'lib/gaudi/helpers/components.rb', line 62

def headers
  determine_headers(directories,@system_config,@platform).uniq
end

#include_pathsObject

List of include paths for this component

This should be a complete list of all paths to include so that the component compiles succesfully


88
89
90
91
92
93
94
# File 'lib/gaudi/helpers/components.rb', line 88

def include_paths
  incs=directories
  incs+=interface_paths
  incs+=external_includes
  dependencies.each{|dep| incs+=dep.interface_paths}
  return incs.uniq
end

#interfaceObject

The headers the component exposes


66
67
68
# File 'lib/gaudi/helpers/components.rb', line 66

def interface
  Rake::FileList[*interface_paths.pathmap("%p/**/*{#{@system_config.header_extensions(platform)}}")]
end

#interface_pathsObject

The include paths for this Component


70
71
72
# File 'lib/gaudi/helpers/components.rb', line 70

def interface_paths
  determine_interface_paths(directories).uniq
end

#sourcesObject

The components sources


58
59
60
# File 'lib/gaudi/helpers/components.rb', line 58

def sources
  determine_sources(directories,@system_config,@platform).uniq
end

#test_filesObject

Test sources


96
97
98
99
100
# File 'lib/gaudi/helpers/components.rb', line 96

def test_files
  src=@system_config.source_extensions(platform)
  hdr=@system_config.header_extensions(platform)
  Rake::FileList[*test_directories.pathmap("%p/**/*{#{src},#{hdr}}")]
end