Module: Gaudi::StandardPaths

Includes:
PlatformOperations
Included in:
Component, Tasks::Build
Defined in:
lib/custom/helpers/paths.rb,
lib/gaudi/helpers/components.rb

Overview

This is the default directory layout: src/platform

|-name/     - sources and local headers
    |-inc/  - public headers
    |-test/ - unit tests

Code can be split in several source directories and by default we will look for the files in source_directory/common/name and source_directory/platform/name for every source_directory

Instance Method Summary collapse

Methods included from PlatformOperations

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

Instance Method Details

#command_file(tgt, system_config, platform) ⇒ Object

Returns the path to the file containing the commands for the given target


15
16
17
18
19
20
21
22
23
24
25
# File 'lib/gaudi/helpers/components.rb', line 15

def command_file tgt,system_config,platform
  ext=""
  if is_library?(tgt,system_config,platform)
    ext<<"_#{platform}.library"
  elsif is_exe?(tgt,system_config,platform)
    ext<<"_#{platform}.link"
  else
      ext<<'.breadcrumb'
  end
  return tgt.pathmap("%X#{ext}")
end

#determine_directories(name, source_directories, system_config, platform) ⇒ Object

Determine which directories correspond to the given name

This method maps the repository directory structure to the component names

Raises:


16
17
18
19
20
# File 'lib/custom/helpers/paths.rb', line 16

def determine_directories name,source_directories,system_config,platform
  paths=source_directories.map{|source_dir| Rake::FileList["#{source_dir}/{#{platform},common}/#{name}"].existing}.inject(&:+)
  raise GaudiError,"Cannot find source directories for '#{name}' in #{source_directories.join(',')}" if paths.empty?
  return paths
end

#determine_headers(component_directories, system_config, platform) ⇒ Object


25
26
27
28
# File 'lib/custom/helpers/paths.rb', line 25

def determine_headers component_directories,system_config,platform
  hdr=system_config.header_extensions(platform)
  Rake::FileList[*component_directories.pathmap("%p/**/*{#{hdr}}")].exclude(*determine_test_directories(component_directories).pathmap('%p/**/*'))
end

#determine_interface_paths(component_directories) ⇒ Object


32
33
34
# File 'lib/custom/helpers/paths.rb', line 32

def determine_interface_paths component_directories
  Rake::FileList[*component_directories.pathmap('%p/inc')].existing
end

#determine_sources(component_directories, system_config, platform) ⇒ Object


21
22
23
24
# File 'lib/custom/helpers/paths.rb', line 21

def determine_sources component_directories,system_config,platform
  src=system_config.source_extensions(platform)
  Rake::FileList[*component_directories.pathmap("%p/**/*{#{src}}")].exclude(*determine_test_directories(component_directories).pathmap('%p/**/*'))
end

#determine_test_directories(component_directories) ⇒ Object


29
30
31
# File 'lib/custom/helpers/paths.rb', line 29

def determine_test_directories component_directories
  Rake::FileList[*component_directories.pathmap('%p/test')].existing
end

#executable(component, system_config) ⇒ Object

Returns the path to the executable file corresponding to the component


36
37
38
39
# File 'lib/custom/helpers/paths.rb', line 36

def executable component,system_config
  ext_obj,ext_lib,ext_exe = *system_config.extensions(component.platform)
  File.join(system_config.out,component.platform,component.name,"#{component.name}#{ext_exe}")
end

#is_generated?(filename, system_config) ⇒ Boolean

Gaudi supports code generation under the convention that all generated files are created in the output directory.


28
29
30
# File 'lib/gaudi/helpers/components.rb', line 28

def is_generated? filename,system_config
  /#{system_config.out}/=~File.expand_path(filename)
end

#is_unit_test?(filename) ⇒ Boolean

Is this a unit test or not?

If you change the StandardPaths#unit_test naming convention you should implement this accordingly.


59
60
61
# File 'lib/custom/helpers/paths.rb', line 59

def is_unit_test? filename
  filename.pathmap('%n').end_with?('Test')
end

#library(component, system_config) ⇒ Object

Returns the path to the library file corresponding to the component


41
42
43
44
# File 'lib/custom/helpers/paths.rb', line 41

def library component,system_config
  ext_obj,ext_lib,ext_exe = *system_config.extensions(component.platform)
  File.join(system_config.out,component.platform,component.name,"#{component.name}#{ext_lib}")
end

#object_file(src, component, system_config) ⇒ Object

Returns the path to the object output file corresponding to src


46
47
48
49
# File 'lib/custom/helpers/paths.rb', line 46

def object_file src,component,system_config
  ext_obj,ext_lib,ext_exe = *system_config.extensions(component.platform)
  src.pathmap("#{system_config.out}/#{component.platform}/#{component.parent ? component.parent.name : ''}/#{component.name}/%n#{ext_obj}")
end

#unit_test(component, system_config) ⇒ Object

Returns the path to the unit test binary corresponding to the component


51
52
53
54
# File 'lib/custom/helpers/paths.rb', line 51

def unit_test component,system_config
  ext_obj,ext_lib,ext_exe = *system_config.extensions(component.platform)
  File.join(system_config.out,component.platform,'tests',"#{component.name}Test#{ext_exe}")
end