class Phoenx::TargetBuilder

Attributes

framework_files[R]
project[R]
project_spec[R]
target_spec[R]

Public Class Methods

new(project, target_spec, project_spec) click to toggle source
# File lib/phoenx/use_cases/generate_target.rb, line 11
def initialize(project, target_spec, project_spec)
        @project = project
        @target_spec = target_spec
        @project_spec = project_spec
        @framework_files = []
end

Public Instance Methods

add_build_phase_scripts() click to toggle source
# File lib/phoenx/use_cases/generate_target.rb, line 41
def add_build_phase_scripts
        @target_spec.pre_build_scripts.each do |script|
                phase = self.target.new_shell_script_build_phase(script[:name])
                phase.shell_script = script[:script]
                self.target.build_phases.move(phase, 0)
        end
        @target_spec.post_build_scripts.each do |script|
                phase = self.target.new_shell_script_build_phase(script[:name])
                phase.shell_script = script[:script]
                self.target.build_phases.move(phase, self.target.build_phases.count - 1)
        end
end
add_config_files() click to toggle source
# File lib/phoenx/use_cases/generate_target.rb, line 153
def add_config_files
        # Add configuration group
        Phoenx.add_groups_for_files(@project, @target_spec.config_files.values)
        @target_spec.config_files.each do |config,file_name|
                unless file_name == nil
                        file = Phoenx.get_or_add_file(@project,file_name)
                        configuration = self.target.build_configuration_list[config]
                        unless configuration
                                abort "Config file assigned to invalid configuration '#{config}' ".red + file_name.bold
                        end
                        configuration.base_configuration_reference = file
                end
        end
end
add_frameworks_and_libraries() click to toggle source
# File lib/phoenx/use_cases/generate_target.rb, line 23
def add_frameworks_and_libraries
        # Add Framework dependencies
        frameworks_group = @project.main_group.find_subpath(FRAMEWORKS_ROOT, true)
        Phoenx.add_groups_for_files(@project,@target_spec.frameworks)
        frameworks = Phoenx.merge_files_array(@target_spec.frameworks)
        frameworks.each do |framework|
                file = Phoenx.get_or_add_file(@project,framework)
                @framework_files << file
                self.target.frameworks_build_phases.add_file_reference(file)
        end
        Phoenx.add_groups_for_files(@project, @target_spec.libraries)
        libraries = Phoenx.merge_files_array(@target_spec.libraries)
        libraries.each do |framework|
                file = Phoenx.get_or_add_file(@project,framework)
                self.target.frameworks_build_phases.add_file_reference(file)
        end
end
add_headers(header_files, excluded_header_files, attributes) click to toggle source
# File lib/phoenx/use_cases/generate_target.rb, line 128
def add_headers(header_files, excluded_header_files, attributes)
        headers = Phoenx.merge_files_array(header_files, excluded_header_files)
        unless !header_files || header_files.empty? || !headers.empty?
                puts "No #{attributes["ATTRIBUTES"].first} headers found".yellow
        end
        Phoenx.add_groups_for_files(@project, headers)
        headers.each do |header|
                file = Phoenx.get_or_add_file(@project,header)
                build_file = self.target.headers_build_phase.add_file_reference(file, true)
                build_file.settings = attributes
        end
end
add_private_headers() click to toggle source
# File lib/phoenx/use_cases/generate_target.rb, line 145
def add_private_headers
        self.add_headers(@target_spec.private_headers, @target_spec.excluded_private_headers, ATTRIBUTES_PRIVATE_HEADERS)
end
add_project_headers() click to toggle source
# File lib/phoenx/use_cases/generate_target.rb, line 149
def add_project_headers
        self.add_headers(@target_spec.project_headers, @target_spec.excluded_project_headers, ATTRIBUTES_PROJECT_HEADERS)
end
add_public_headers() click to toggle source
# File lib/phoenx/use_cases/generate_target.rb, line 141
def add_public_headers
        self.add_headers(@target_spec.public_headers, @target_spec.excluded_public_headers, ATTRIBUTES_PUBLIC_HEADERS)
end
add_resources() click to toggle source
# File lib/phoenx/use_cases/generate_target.rb, line 64
def add_resources
        # Add Resource files
        resources = Phoenx.merge_files_array(@target_spec.resources, @target_spec.excluded_resources)
        unless !@target_spec.resources || @target_spec.resources.empty? || !resources.empty?
                puts "No resources found".yellow
        end
        Phoenx.add_groups_for_files(@project, resources)
        resources.each do |source|
                file = nil
                if Phoenx.is_bundle?(source)
                        parts = source.split("/")
                        group = @project.main_group
                        parts.each do |part|
                                if Phoenx.is_bundle?(part)
                                        file = group.find_file_by_path(part)
                                        unless file != nil
                                                file = group.new_file(part)
                                                self.target.resources_build_phase.add_file_reference(file)
                                        end
                                        break
                                else
                                        group = group.find_subpath(part, false)
                                end
                        end
                elsif Phoenx.is_translation_folder?(source)
                        parts = source.split("/")
                        translation_folder_index = parts.index { |part| Phoenx.is_translation_folder?(part) }
                        parent_path = parts[0..translation_folder_index - 1].join('/')
                        parent_group = @project.main_group.find_subpath(parent_path)
                        variant_group = parent_group[File.basename(source)]
                        if variant_group == nil
                                variant_group = parent_group.new_variant_group(File.basename(source))
                                self.target.resources_build_phase.add_file_reference(variant_group)
                        end
                        variant_group.new_file(parts[translation_folder_index..parts.count].join('/'))
                else
                        group = @project.main_group.find_subpath(File.dirname(source), false)
                        unless group == nil
                                file = group.find_file_by_path(File.basename(source))
                                unless file != nil
                                        file = group.new_file(File.basename(source))
                                        self.target.resources_build_phase.add_file_reference(file)
                                end
                        end
                end
        end
end
add_sources() click to toggle source
# File lib/phoenx/use_cases/generate_target.rb, line 112
def add_sources
        # Add Source files
        sources = Phoenx.merge_files_array(@target_spec.sources, @target_spec.excluded_sources)
        unless !@target_spec.sources || @target_spec.sources.empty? || !sources.empty?
                puts "No sources found".yellow
        end
        Phoenx.add_groups_for_files(@project, sources)
        sources.each do |source|
                file = Phoenx.get_or_add_file(@project,source)
                # Add to Compile sources phase
                unless File.extname(source) == ".h" || File.extname(source) == ".pch"
                        self.target.add_file_references([file])
                end
        end
end
add_support_files() click to toggle source
# File lib/phoenx/use_cases/generate_target.rb, line 18
def add_support_files
        files = Phoenx.merge_files_array(@target_spec.support_files, @target_spec.excluded_support_files)
        Phoenx.get_or_add_files(@project, files)
end
add_system_dependencies() click to toggle source
# File lib/phoenx/use_cases/generate_target.rb, line 54
def add_system_dependencies
        # Add Framework dependencies
        @target_spec.system_frameworks.each do |framework|
                self.target.add_system_framework(framework)
        end
        @target_spec.system_libraries.each do |library|
                self.target.add_system_library(library)
        end
end
build() click to toggle source
# File lib/phoenx/use_cases/generate_target.rb, line 173
def build

end
configure_target() click to toggle source
# File lib/phoenx/use_cases/generate_target.rb, line 168
def configure_target
        Phoenx.set_target_build_settings_defaults(self.target)
        Phoenx.set_project_build_settings_defaults(@project)
end
target() click to toggle source
# File lib/phoenx/use_cases/generate_target.rb, line 177
def target
        return nil
end