Class: MTBuild::Project

Inherits:
Object
  • Object
show all
Includes:
Rake::DSL
Defined in:
lib/mtbuild/project.rb

Overview

This is the base class for all project types.

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Rake::DSL

#application_task, #framework_task, #static_library_task, #test_application_task

Constructor Details

#initialize(project_name, project_folder, &configuration_block) ⇒ Project

If supplied, the configuration_block will be passed the newly-constructed Project object.



26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
# File 'lib/mtbuild/project.rb', line 26

def initialize(project_name, project_folder, &configuration_block)
  @configurations = []
  @project_folder = File.expand_path(project_folder)
  @output_folder = File.expand_path(File.join(@project_folder, MTBuild.default_output_folder))
  @project_name, @parent_workspace = MTBuild::BuildRegistry.enter_project(project_name, self)
  @clean_list = Rake::FileList.new

  configuration_block.call(self) if configuration_block

  namespace @project_name do
    @configurations.each do |configuration|
      configuration.configure_tasks
    end

    Cleaner.generate_clean_task_for_project(@project_name, @clean_list)
  end

  MTBuild::BuildRegistry.exit_project
end

Instance Attribute Details

#clean_listObject (readonly)

The project’s list of things to clean



22
23
24
# File 'lib/mtbuild/project.rb', line 22

def clean_list
  @clean_list
end

#output_folderObject (readonly)

The project’s output folder. Project output goes here.



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

def output_folder
  @output_folder
end

#parent_workspaceObject (readonly)

The project’s parent workspace



19
20
21
# File 'lib/mtbuild/project.rb', line 19

def parent_workspace
  @parent_workspace
end

#project_folderObject (readonly)

The project’s folder. Relative path references are interpreted as relative to this folder.



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

def project_folder
  @project_folder
end

#project_nameObject (readonly)

The project’s name



9
10
11
# File 'lib/mtbuild/project.rb', line 9

def project_name
  @project_name
end

Instance Method Details

#add_files_to_clean(*filenames) ⇒ Object

Add files to the project’s clean list.



57
58
59
60
# File 'lib/mtbuild/project.rb', line 57

def add_files_to_clean(*filenames)
  @clean_list.include(filenames)
  Cleaner.global_clean_list.include(filenames)
end

#effective_output_folderObject

Returns the effective output folder. If a workspace exists, this will return the workspace’s output folder. If not, it will return the project’s output folder.



65
66
67
68
69
70
71
# File 'lib/mtbuild/project.rb', line 65

def effective_output_folder
  if MTBuild::BuildRegistry.top_workspace.nil?
    File.join(@output_folder, @project_name.to_s.split(':'))
  else
    File.join(MTBuild::BuildRegistry.top_workspace.output_folder, @project_name.to_s.split(':'))
  end
end

#set_output_folder(output_folder) ⇒ Object

Set the project’s output folder.



52
53
54
# File 'lib/mtbuild/project.rb', line 52

def set_output_folder(output_folder)
  @output_folder = File.expand_path(File.join(@project_folder, output_folder))
end

#task_for_configuration(config_name) ⇒ Object

Get the fully-qualified task name for a configuration



47
48
49
# File 'lib/mtbuild/project.rb', line 47

def task_for_configuration(config_name)
  "#{@project_name}:#{config_name}"
end