feat: ✨ properly implement artefact dependency addition
This commit is contained in:
parent
08bb5ac67f
commit
f908eb1e22
1 changed files with 33 additions and 13 deletions
|
@ -17,7 +17,7 @@ module Comfpile
|
|||
# Included artefacts are also required, but will additionally
|
||||
# update this Artefact's age.
|
||||
attr_reader :included_artefacts
|
||||
# @return [Array<Comfpile::Artefact] List of all artefacts
|
||||
# @return [Array<Comfpile::Artefact>] List of all artefacts
|
||||
# required to build this artefact.
|
||||
# Required artefacts are needed to build this artefact, but
|
||||
# do not modify the artefact's age.
|
||||
|
@ -59,14 +59,15 @@ module Comfpile
|
|||
|
||||
@required_artefacts = []
|
||||
@included_artefacts = []
|
||||
@referenced_artefacts = []
|
||||
|
||||
|
||||
@steps = []
|
||||
@step_additions = nil
|
||||
@steps_done_ctr = 0
|
||||
|
||||
@waitlist = []
|
||||
|
||||
@steps_done_ctr = 0
|
||||
|
||||
@parameters = {}
|
||||
|
||||
@exit_state = nil
|
||||
|
@ -110,29 +111,48 @@ module Comfpile
|
|||
@parent_artefact = require_artefact(stage, target)
|
||||
end
|
||||
|
||||
def require_artefact(stage, target)
|
||||
artefact = @core.craft_artefact(stage, target)
|
||||
def include_artefact(stage, target)
|
||||
artefact = require_artefact(stage, target)
|
||||
@included_artefacts << artefact
|
||||
end
|
||||
|
||||
if(artefact.nil?)
|
||||
def require_artefact(stage, target)
|
||||
artefact = reference_artefact(stage, target, required: true)
|
||||
@required_artefacts << artefact
|
||||
end
|
||||
|
||||
def reference_artefact(stage, target, required: false)
|
||||
artefact = craft_artefact(stage, target)
|
||||
|
||||
if(artefact.nil? and required)
|
||||
fail! "Missing artefact dependency for #{stage} #{target}!"
|
||||
else
|
||||
elsif(required)
|
||||
@waitlist << {
|
||||
artefact: artefact,
|
||||
required: true
|
||||
}
|
||||
end
|
||||
|
||||
@required_artefacts ||= {}
|
||||
@required_artefacts[stage] ||= {}
|
||||
@required_artefacts[stage][target] = artefact
|
||||
@referenced_artefacts << artefact
|
||||
|
||||
artefact
|
||||
end
|
||||
|
||||
#
|
||||
# Find or create a new artefact
|
||||
#
|
||||
# @param [Symbol] stage The type of item to create.
|
||||
# can either be a stage for file processing (e.g. :parsed,
|
||||
# :sourcefile, :x86_debug_compiled), or an action (:clean)
|
||||
# @param [String] target Target file. Usually expressed
|
||||
# as path relative to Comfpile's resource locations.
|
||||
#
|
||||
# @return [nil, Artefact] Returns nil if no engine was
|
||||
# found that can craft this, else returns the
|
||||
# created or looked-up artefact.
|
||||
#
|
||||
def craft_artefact(stage, target)
|
||||
artefact = @core.craft_artefact(stage, target)
|
||||
|
||||
artefact
|
||||
@core.craft_artefact(stage, target)
|
||||
end
|
||||
|
||||
def waitlist_empty?
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue