From 94b0288aa9296dca9d247f14d0b5e96f87fd986f Mon Sep 17 00:00:00 2001 From: David Bailey Date: Tue, 11 Apr 2023 15:53:45 +0200 Subject: [PATCH] half-arsed: :shit: half implement a proper parser engine class --- lib/comfpile.rb | 5 ----- lib/comfpile/artefact.rb | 26 ++++++++++++++++++++++---- lib/comfpile/engines/parser_engine.rb | 10 ++-------- 3 files changed, 24 insertions(+), 17 deletions(-) diff --git a/lib/comfpile.rb b/lib/comfpile.rb index fb50f65..9fc96b7 100644 --- a/lib/comfpile.rb +++ b/lib/comfpile.rb @@ -5,8 +5,3 @@ require_relative "comfpile/version" require_relative 'comfpile/core.rb' require_relative 'comfpile/engines/filesource_engine.rb' - -module Comfpile - class Error < StandardError; end - # Your code goes here... -end diff --git a/lib/comfpile/artefact.rb b/lib/comfpile/artefact.rb index e29fff6..700e38f 100644 --- a/lib/comfpile/artefact.rb +++ b/lib/comfpile/artefact.rb @@ -11,7 +11,25 @@ module Comfpile attr_reader :exit_state attr_reader :stage, :target - attr_reader :linked_artefacts + + # @return [Array] List of all artefacts + # included in this artefact. + # Included artefacts are also required, but will additionally + # update this Artefact's age. + attr_reader :included_artefacts + # @return [Array] List of all artefacts + # potentially referenced by this artefact. + # Referenced artefacts are those that are potentially used + # by this artefact through e.g. function calls, but are + # not directly needed to build this artefact. Example being + # how sourcecode of a library is eventually needed for e.g. + # linking steps, but the objects can be built separately. + attr_reader :referenced_artefacts # ARTEFACT STATES # @@ -39,8 +57,8 @@ module Comfpile @parent_artefact = nil - @required_artefacts = nil - @linked_artefacts = nil + @required_artefacts = [] + @included_artefacts = [] @steps = [] @step_additions = nil @@ -132,7 +150,7 @@ module Comfpile elsif item[:artefact].succeeded? @waitlist.pop else - skip! skip! "Failed artefact dependency: #{item[:artefact]}" + skip! "Failed artefact dependency: #{item[:artefact]}" return true end diff --git a/lib/comfpile/engines/parser_engine.rb b/lib/comfpile/engines/parser_engine.rb index 024b159..104017e 100644 --- a/lib/comfpile/engines/parser_engine.rb +++ b/lib/comfpile/engines/parser_engine.rb @@ -1,14 +1,8 @@ module Compfile class ParserArtefact < Artefact - attr_reader :included_files - attr_reader :required_files - - def initialize(*args) - super(*args) - - @included_files = [] - @required_files = [] + def initialize(*args, **opts) + super(*args, **opts) parent_artefact :sourcefile, @target