Sha256: a63148aee5fdf1528c7b6979dca1eb4779d19e320a374a3a353ad6162d0388e7

Contents?: true

Size: 1.72 KB

Versions: 7

Compression:

Stored size: 1.72 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)
        if node.parent
          @project.main_group.find_subpath(node.parent.path, true)
        else
          @project.main_group
        end
      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|
           puts "Added to #{t}"
           add_file_reference_to_target(file_reference, t)
        end
      end

      def leave_node(node)
      end

    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
xcake-0.3.1 lib/xcake/generator/build_phase.rb
xcake-0.3.0 lib/xcake/generator/build_phase.rb
xcake-0.1.9 lib/xcake/generator/build_phase.rb
xcake-0.1.8 lib/xcake/generator/build_phase.rb
xcake-0.1.7 lib/xcake/generator/build_phase.rb
xcake-0.1.6 lib/xcake/generator/build_phase.rb
xcake-0.1.5 lib/xcake/generator/build_phase.rb