Class: MTBuild::CompiledConfiguration

Inherits:
Configuration show all
Includes:
Rake::DSL
Defined in:
lib/mtbuild/compiled_configuration.rb

Overview

This is the base class for configurations representing compiled objects (libraries, applications, etc.)

Instance Attribute Summary collapse

Attributes inherited from Configuration

#configuration_name, #output_folder, #parent_project, #project_folder

Instance Method Summary collapse

Methods included from Rake::DSL

#application_task, #framework_task, #static_library_task, #test_application_task

Constructor Details

#initialize(parent_project, output_folder, configuration_name, configuration) ⇒ CompiledConfiguration

Returns a new instance of CompiledConfiguration.



18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/mtbuild/compiled_configuration.rb', line 18

def initialize(parent_project, output_folder, configuration_name, configuration)
  super
  @dependencies = expand_configuration_wildcards(namespace_tasks(configuration.fetch(:dependencies, [])))
  @dependencies |= configuration.fetch(:rake_dependencies, [])
  @default_toolchain_config = configuration[:toolchain]
  @default_toolchain = Toolchain.create_toolchain(self, @default_toolchain_config)

  @source_files = Utils.expand_file_list(configuration.fetch(:sources, []), configuration.fetch(:excluded_sources, []), @project_folder)
  @toolchains = {@default_toolchain => @source_files}

  @tests = namespace_tasks(Utils.ensure_array(configuration.fetch(:tests, [])))
end

Instance Attribute Details

#dependenciesObject (readonly)

A list of Rake tasks that this configuration depends upon



10
11
12
# File 'lib/mtbuild/compiled_configuration.rb', line 10

def dependencies
  @dependencies
end

#source_filesObject (readonly)

A list of source files that will be compiled



13
14
15
# File 'lib/mtbuild/compiled_configuration.rb', line 13

def source_files
  @source_files
end

#testsObject (readonly)

A list of Rake test tasks that will execute after this configuration builds



16
17
18
# File 'lib/mtbuild/compiled_configuration.rb', line 16

def tests
  @tests
end

Instance Method Details

#add_sources(sources, excludes = [], toolchain_configuration) ⇒ Object

This method adds source files with their own toolchains. Use this method to add any source files that need special toolchain settings.



33
34
35
36
37
# File 'lib/mtbuild/compiled_configuration.rb', line 33

def add_sources(sources, excludes=[], toolchain_configuration)
  merged_configuration = Utils.merge_configurations(@default_toolchain_config, toolchain_configuration)
  toolchain = Toolchain.create_toolchain(self, merged_configuration)
  @toolchains[toolchain] = Utils.expand_file_list(sources, excludes, @project_folder)
end

#configure_tasksObject

Create the actual Rake tasks that will perform the configuration’s work



40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
# File 'lib/mtbuild/compiled_configuration.rb', line 40

def configure_tasks
  super
  all_sources = []
  @toolchains.each do |toolchain, sources|
    all_sources |= sources
    toolchain.output_folder = @output_folder
    toolchain.project_folder = @project_folder
    toolchain.output_decorator = "-#{@configuration_name}"
    CompiledConfiguration.add_framework_dependencies_to_toolchain(toolchain, @dependencies)
  end
  # Give the default toolchain an opportunity to scan all source files for
  # any special needs. For example, a toolchain might look for .cpp files
  # to determine that it should link a project with the "g++" vs "gcc".
  @default_toolchain.scan_sources(all_sources)
end