Module: Build::Dependency::Provider

Defined in:
lib/build/dependency/provider.rb

Instance Method Summary collapse

Instance Method Details

#dependenciesIdentitySet<Dependency>

Returns:


148
149
150
# File 'lib/build/dependency/provider.rb', line 148

def dependencies
	@dependencies ||= Set.new
end

#depends(*names, **options) ⇒ Object

Add one or more dependencies to the provider.

Examples:

A named dependency.

target.depends "Compiler/clang"

A symbolic dependency.

target.depends :compiler

Parameters:

  • names (Array<String>)

    the dependency names to add.


194
195
196
197
198
# File 'lib/build/dependency/provider.rb', line 194

def depends(*names, **options)
	names.each do |name|
		dependencies << Depends.new(name, **options)
	end
end

#depends?(name) ⇒ Boolean

Returns:

  • (Boolean)

200
201
202
# File 'lib/build/dependency/provider.rb', line 200

def depends?(name)
	dependencies.include?(name)
end

#filter(dependency) ⇒ Object


152
153
154
# File 'lib/build/dependency/provider.rb', line 152

def filter(dependency)
	provisions.select{|name, provision| dependency.match?(name)}
end

#freezeObject


123
124
125
126
127
128
129
130
# File 'lib/build/dependency/provider.rb', line 123

def freeze
	return unless frozen?
	
	provisions.freeze
	dependencies.freeze
	
	super
end

#priorityObject

The default priority.


138
139
140
# File 'lib/build/dependency/provider.rb', line 138

def priority
	@priority ||= 0
end

#priority=(value) ⇒ Object

Assign a priority.


133
134
135
# File 'lib/build/dependency/provider.rb', line 133

def priority= value
	@priority = value
end

#provides(*names, **aliases, &block) ⇒ Object

Add one or more provisions to the provider.

Examples:

A named provision.

target.provides "Compiler/clang" do
	cxx "clang"
end

A symbolic provision.

target.provides compiler: "Compiler/clang"

Parameters:

  • names (Array<String>)

    the named provisions to add.

  • aliases (Hash<Symbol, Array>)

    the aliases to add.


178
179
180
181
182
183
184
185
186
# File 'lib/build/dependency/provider.rb', line 178

def provides(*names, **aliases, &block)
	names.each do |name|
		provisions[name] = Provision.new(name, self, block)
	end
	
	aliases.each do |name, dependencies|
		provisions[name] = Alias.new(name, self, Array(dependencies))
	end
end

#provides?(dependency) ⇒ Boolean

Does this unit provide the named thing?

Returns:

  • (Boolean)

157
158
159
# File 'lib/build/dependency/provider.rb', line 157

def provides?(dependency)
	provisions.key?(dependency.name)
end

#provision_for(dependency) ⇒ Object


161
162
163
# File 'lib/build/dependency/provider.rb', line 161

def provision_for(dependency)
	return provisions[dependency.name]
end

#provisionsObject


143
144
145
# File 'lib/build/dependency/provider.rb', line 143

def provisions
	@provisions ||= {}
end

#resolution_for(dependency) ⇒ Object


165
166
167
# File 'lib/build/dependency/provider.rb', line 165

def resolution_for(dependency)
	return Resolution.new(provision_for(dependency), dependency)
end