Module: Gaudi::Tasks::Build

Includes:
StandardPaths, TaskDependencies, Gaudi::ToolOperations
Defined in:
lib/gaudi/helpers/generators.rb

Overview

Tasks::Build contains all task generation methods for building source code

When building a deployment the chain of task dependencies looks like: deployment => programs => linker command files => objects => compiler command files => sources

Instance Method Summary collapse

Methods included from Gaudi::ToolOperations

#assembler_options, #command_line, #compiler_options, #librarian_options, #linker_options, #prefixed_objects

Methods included from TaskDependencies

#component_task_dependencies, #object_task_dependencies

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?

Instance Method Details

#commandfile_task(cmd_file, options, dependencies) ⇒ Object

:nodoc:


104
105
106
107
108
109
# File 'lib/gaudi/helpers/generators.rb', line 104

def commandfile_task cmd_file,options,dependencies
  file cmd_file => dependencies do |t|
    puts "Writing #{t.name}"
    write_file(t.name,options.join("\n"))
  end
end

#deployment_task(deployment, system_config) ⇒ Object

Returns a task for building a Deployment

t=deployment_task(deployment,system_config) Rake::Task.invoke


46
47
48
49
50
51
52
53
54
55
# File 'lib/gaudi/helpers/generators.rb', line 46

def deployment_task deployment,system_config
  deps=FileList.new
  deployment.platforms.each do |platform|
    deployment.programs(platform).each do |pgm| 
      deps<<program_task(pgm,system_config)
    end
  end
  deps+=system_config.configuration_files
  task deployment.name => deps
end

#library_task(component, system_config) ⇒ Object

Returns a task for building a library


78
79
80
81
82
83
84
85
86
87
# File 'lib/gaudi/helpers/generators.rb', line 78

def library_task component,system_config
  deps=component_task_dependencies(component,system_config)
  Gaudi::Configuration::PlatformConfiguration.extend(component,system_config) do
    deps+=component.sources.map{|src| object_task(src,component,system_config)}
    options= librarian_options(component,system_config)
    cmd_file=command_file(library(component,system_config),system_config,component.platform)
    write_file(cmd_file,options.join("\n"))
  end
  file library(component,system_config) => deps
end

#object_task(src, component, system_config) ⇒ Object

Returns the task to create an object file from src


89
90
91
92
93
94
95
96
97
98
99
100
101
102
# File 'lib/gaudi/helpers/generators.rb', line 89

def object_task src,component,system_config
  options=[]
  if is_source?(src)
    if is_assembly?(src)
      options= assembler_options(src,component,system_config)
    else
      options= compiler_options(src,component,system_config)
    end
  end
  t=object_file(src,component,system_config)
  cmd_file=command_file(t,system_config,component.platform)
  write_file(cmd_file,options.join("\n"))
  file t => object_task_dependencies(src,component,system_config)
end

#program_task(program, system_config) ⇒ Object

Returns a task for building a Program


57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
# File 'lib/gaudi/helpers/generators.rb', line 57

def program_task program,system_config
  deps=component_task_dependencies(program,system_config)
  Gaudi::Configuration::PlatformConfiguration.extend(program,system_config) do
    deps+=program.sources.map{|src| object_task(src,program,system_config)}
    program.dependencies.each do |dep|
      Gaudi::Configuration::PlatformConfiguration.extend(dep,system_config) do
        deps+=dep.sources.map{|src| object_task(src,dep,system_config)}
      end
    end
    program.shared_dependencies.each do |dep|
      deps<<library_task(dep,system_config)
    end
    deps+=resource_tasks(program,system_config)
    deps.uniq!
    options= linker_options(program,system_config)
    cmd_file=command_file(executable(program,system_config),system_config,program.platform)
    write_file(cmd_file,options.join("\n"))
  end
  file executable(program,system_config) => deps
end

#resource_tasks(component, system_config) ⇒ Object

A list of file tasks that copy resources to the component's build output directory.


111
112
113
114
115
116
117
118
119
# File 'lib/gaudi/helpers/generators.rb', line 111

def resource_tasks component,system_config
  component.resources.map do |resource|
    tgt=File.join(File.dirname(executable(component,system_config)),resource.pathmap('%f'))
    file tgt => [resource] do |t|
      mkdir_p(File.dirname(t.name),:verbose=>false)
      cp(resource,t.name,:verbose=>false)
    end
  end
end