Sha256: 791bc7615ca6a16081c912215b449a2c2ba281c795126d874497eafbd076a49d

Contents?: true

Size: 1.66 KB

Versions: 12

Compression:

Stored size: 1.66 KB

Contents

module Xcake
  module Generator
    # This generator handles adding nodes
    # to the project and creating a build phase
    # for it.
    #
    class BuildPhase

      include Visitor

      # @return [Project] the xcode project
      #
      attr_accessor :project

      # This should be overidden
      # by subclasses.
      #
      # @param [Node] the node
      #
      # @return [Boolean] true if build phase can handle the node.
      #
      def self.can_install_node(node)
        true
      end

      # @return [Project] the xcode project
      #
      def initialize(project)
        @project = project
      end

      # Find the group which this node
      # should be added to.
      #
      # This dictates where it shows up
      # in the groups structure.
      #
      # @param [Node] the node
      #
      # @return [PBXGroup] the group
      #
      def group_for_node(node)
        return @project.main_group unless node.parent

        @project.main_group.find_subpath(node.parent.path, true)
      end

      # Adds file reference to the target.
      #
      # This should be overidden in subclasses
      # to add the file reference the correct
      # build phase.
      #
      # @param [PBXFileReference] the file reference
      #
      # @param [PBXTarget] the xcode target
      #
      def add_file_reference_to_target(_file_reference, _target)
      end

      protected

      def visit_node(node)

        group = group_for_node(node)
        file_reference = group.new_reference(node.path)

        node.targets.each do |t|
           add_file_reference_to_target(file_reference, t)
        end
      end

      def leave_node(node)
      end

    end
  end
end

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
xcake-0.5.3 lib/xcake/generator/build_phase.rb
xcake-0.5.2 lib/xcake/generator/build_phase.rb
xcake-0.5.1 lib/xcake/generator/build_phase.rb
xcake-0.5.0 lib/xcake/generator/build_phase.rb
xcake-0.4.8 lib/xcake/generator/build_phase.rb
xcake-0.4.7 lib/xcake/generator/build_phase.rb
xcake-0.4.6 lib/xcake/generator/build_phase.rb
xcake-0.4.5 lib/xcake/generator/build_phase.rb
xcake-0.4.4 lib/xcake/generator/build_phase.rb
xcake-0.4.3 lib/xcake/generator/build_phase.rb
xcake-0.4.2 lib/xcake/generator/build_phase.rb
xcake-0.4.1 lib/xcake/generator/build_phase.rb