class MTBuild::Project
This is the base class for all project types.
Attributes
clean_list[R]
The project's list of things to clean
output_folder[R]
The project's output folder. Project
output goes here.
parent_workspace[R]
The project's parent workspace
project_folder[R]
The project's folder. Relative path references are interpreted as relative to this folder.
project_name[R]
The project's name
Public Class Methods
new(project_name, project_folder, &configuration_block)
click to toggle source
If supplied, the configuration_block will be passed the newly-constructed Project
object.
# File lib/mtbuild/project.rb, line 26 def initialize(project_name, project_folder, &configuration_block) @default_configuration = nil @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 generate_implicit_workspace_configurations namespace @project_name do @configurations.each_value do |configuration| configuration.configure_tasks end Cleaner.generate_clean_task_for_project(@project_name, @clean_list) end MTBuild::BuildRegistry.exit_project end
Public Instance Methods
add_configuration(configuration_name, configuration)
click to toggle source
# File lib/mtbuild/project.rb, line 81 def add_configuration(configuration_name, configuration) merged_configuration = {} unless @default_configuration.nil? merged_configuration = @default_configuration end unless @parent_workspace.nil? configuration_defaults = @parent_workspace.configuration_defaults.fetch(configuration_name, {}) merged_configuration = Utils.merge_configurations(configuration_defaults, merged_configuration) end merged_configuration = Utils.merge_configurations(merged_configuration, configuration) cfg = create_configuration(configuration_name, merged_configuration) @configurations[configuration_name] = cfg cfg end
add_files_to_clean(*filenames)
click to toggle source
Add files to the project's clean list.
# File lib/mtbuild/project.rb, line 65 def add_files_to_clean(*filenames) @clean_list.include(filenames) Cleaner.global_clean_list.include(filenames) end
effective_output_folder()
click to toggle source
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.
# File lib/mtbuild/project.rb, line 73 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_default_configuration(configuration)
click to toggle source
# File lib/mtbuild/project.rb, line 96 def set_default_configuration(configuration) @default_configuration = configuration end
set_output_folder(output_folder)
click to toggle source
Set the project's output folder.
# File lib/mtbuild/project.rb, line 60 def set_output_folder(output_folder) @output_folder = File.expand_path(File.join(@project_folder, output_folder)) end
task_for_configuration(config_name)
click to toggle source
Get the fully-qualified task name for a configuration
# File lib/mtbuild/project.rb, line 50 def task_for_configuration(config_name) "#{@project_name}:#{config_name}" end
tasks_for_all_configurations()
click to toggle source
Get the list of fully-qualified task names for all configurations
# File lib/mtbuild/project.rb, line 55 def tasks_for_all_configurations @configurations.keys.collect{ |name| "#{@project_name}:#{name}"} end
Private Instance Methods
create_configuration(configuration_name, configuration)
click to toggle source
# File lib/mtbuild/project.rb, line 102 def create_configuration(configuration_name, configuration) nil end
generate_implicit_workspace_configurations()
click to toggle source
# File lib/mtbuild/project.rb, line 106 def generate_implicit_workspace_configurations if not @default_configuration.nil? and not @parent_workspace.nil? @parent_workspace.configuration_defaults.each do |configuration_name, configuration| add_configuration(configuration_name, configuration) unless @configurations.has_key? configuration_name end end end