Class: Build::Makefile

Inherits:
Object
  • Object
show all
Defined in:
lib/build/makefile.rb,
lib/build/makefile/version.rb

Overview

This parser parses just enough to correctly process dependency files generated by compilers.

Defined Under Namespace

Modules: Parser

Constant Summary collapse

VERSION =
"1.0.1"

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(rules) ⇒ Makefile

Returns a new instance of Makefile.



30
31
32
# File 'lib/build/makefile.rb', line 30

def initialize(rules)
	@rules = rules
end

Instance Attribute Details

#rulesObject (readonly)

Returns the value of attribute rules.



34
35
36
# File 'lib/build/makefile.rb', line 34

def rules
  @rules
end

Class Method Details

.load_file(path) ⇒ Object



50
51
52
53
54
# File 'lib/build/makefile.rb', line 50

def self.load_file(path)
	input = File.read(path)

	self.parse(input)
end

.parse(string) ⇒ Object



94
95
96
97
98
99
100
101
102
103
104
105
# File 'lib/build/makefile.rb', line 94

def self.parse(string)
	scanner = StringScanner.new(string)

	dependencies = {}
	Parser::parse(scanner) do |statement|
		if statement[0] == :rule
			dependencies[statement[1]] = statement[2]
		end
	end

	self.new(dependencies)
end

Instance Method Details

#[](target) ⇒ Object



36
37
38
39
40
41
42
43
44
# File 'lib/build/makefile.rb', line 36

def [] target
	dependencies = @rules[target.relative_path]
	
	if dependencies
		Files::Paths.new(
			dependencies.collect{|dep| Files::Path.new(dep).to_absolute(target.root)}
		)
	end
end

#include?(target) ⇒ Boolean

Returns:

  • (Boolean)


46
47
48
# File 'lib/build/makefile.rb', line 46

def include? target
	@rules.include? target
end