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
|
# Included artefacts are also required, but will additionally
|
||||||
# update this Artefact's age.
|
# update this Artefact's age.
|
||||||
attr_reader :included_artefacts
|
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 to build this artefact.
|
||||||
# Required artefacts are needed to build this artefact, but
|
# Required artefacts are needed to build this artefact, but
|
||||||
# do not modify the artefact's age.
|
# do not modify the artefact's age.
|
||||||
|
@ -59,14 +59,15 @@ module Comfpile
|
||||||
|
|
||||||
@required_artefacts = []
|
@required_artefacts = []
|
||||||
@included_artefacts = []
|
@included_artefacts = []
|
||||||
|
@referenced_artefacts = []
|
||||||
|
|
||||||
|
|
||||||
@steps = []
|
@steps = []
|
||||||
@step_additions = nil
|
@step_additions = nil
|
||||||
|
@steps_done_ctr = 0
|
||||||
|
|
||||||
@waitlist = []
|
@waitlist = []
|
||||||
|
|
||||||
@steps_done_ctr = 0
|
|
||||||
|
|
||||||
@parameters = {}
|
@parameters = {}
|
||||||
|
|
||||||
@exit_state = nil
|
@exit_state = nil
|
||||||
|
@ -110,29 +111,48 @@ module Comfpile
|
||||||
@parent_artefact = require_artefact(stage, target)
|
@parent_artefact = require_artefact(stage, target)
|
||||||
end
|
end
|
||||||
|
|
||||||
def require_artefact(stage, target)
|
def include_artefact(stage, target)
|
||||||
artefact = @core.craft_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}!"
|
fail! "Missing artefact dependency for #{stage} #{target}!"
|
||||||
else
|
elsif(required)
|
||||||
@waitlist << {
|
@waitlist << {
|
||||||
artefact: artefact,
|
artefact: artefact,
|
||||||
required: true
|
required: true
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
@required_artefacts ||= {}
|
@referenced_artefacts << artefact
|
||||||
@required_artefacts[stage] ||= {}
|
|
||||||
@required_artefacts[stage][target] = artefact
|
|
||||||
|
|
||||||
artefact
|
artefact
|
||||||
end
|
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)
|
def craft_artefact(stage, target)
|
||||||
artefact = @core.craft_artefact(stage, target)
|
@core.craft_artefact(stage, target)
|
||||||
|
|
||||||
artefact
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def waitlist_empty?
|
def waitlist_empty?
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue