require "pathname" require "command/runner" require "take/project/file" require "take/project/actionable" require "take/project/target" require "take/project/convert" require "take/project/definition" require "take/project/requirement" module Take # Handles project information for a specific project. Tends to # represent an entire directory. class Project # The name of the project. This is normally guessed from the # directory name. # # @return [String] attr_accessor :name # Creates a new project with the block, and calls {#call}. # Returns the created project. A name is not required. # # @param [String?] name the name of the project. If it is not # given, it is assumed from the directory name. # @return [Project] # @todo FIX def self.create(name = nil, path = nil, &block) project = new(name, path, &block) project.call project end # Initialize the project. def initialize(name = nil, path = nil, &block) @block = block @name = name @groups = {} @files = {} @targets = [] if path @_path = Pathname.new(path) end end # Set the project name. def project(name) @name = name end # The path to the project. # # @return [Pathname] def path @_path ||= Pathname.new("/home/homer/projects/dash") end def call @definition = Definition.new(self) @definition.instance_exec(&@block) p @definition @definition end # Creates a Makefile syntax-based string of the project. # # @return [String] def to_makefile out = "" out << @targets. map { |target| target.to_makefile(self) }.join("\n\n") out end def file(name) index = File.normalize(name, path) @files[index] ||= File.new(index) end def env { cc: "gcc" } end end end