@@ -52,6 +52,25 @@ def portfolio_classes_matching_portfolio_kind_and_processor_kind
5252# Holds information about a Portfolio (certificate or profile).
5353# The inherited "data" member is the database of extensions, instructions, CSRs, etc.
5454class Portfolio < DatabaseObject
55+ # @param obj_yaml [Hash<String, Object>] Contains contents of Portfolio yaml file (put in @data)
56+ # @param data_path [String] Path to yaml file
57+ # @param cfg_arch [ConfiguredArchitecture] Architecture for a specific configuration
58+ def initialize ( obj_yaml , yaml_path , arch : nil )
59+ super ( obj_yaml , yaml_path , arch : arch )
60+
61+ unless arch . is_a? ( ConfiguredArchitecture )
62+ raise ArgumentError , "For #{ name } arch is a #{ arch . class } but must be a ConfiguredArchitecture"
63+ end
64+
65+ raise "For #{ name } @data[\" base\" ] is nil" if @data [ "base" ] . nil?
66+ raise "For #{ name } arch.mxlen is nil" if arch . mxlen . nil?
67+
68+ if ( obj_yaml [ "base" ] != arch . mxlen )
69+ bad_base = obj_yaml [ "base" ]
70+ raise "For #{ name } called with ConfigureArchitecture #{ arch . name } with mxlen=#{ arch . mxlen } but my base is #{ bad_base } "
71+ end
72+ end
73+
5574 # @return [ConfiguredArchitecture] The defining ConfiguredArchitecture
5675 attr_reader :cfg_arch
5776
@@ -122,6 +141,10 @@ def extension_note(ext_name)
122141 return ext_data [ "note" ] unless ext_data . nil?
123142 end
124143
144+ def mandatory_ext_reqs = in_scope_ext_reqs ( ExtensionPresence . mandatory )
145+ def optional_ext_reqs = in_scope_ext_reqs ( ExtensionPresence . optional )
146+ def optional_type_ext_reqs = in_scope_ext_reqs ( ExtensionPresence . optional )
147+
125148 # @param desired_presence [String, Hash, ExtensionPresence]
126149 # @return [Array<ExtensionRequirements>] - # Extensions with their portfolio information.
127150 # If desired_presence is provided, only returns extensions with that presence.
@@ -181,9 +204,16 @@ def in_scope_ext_reqs(desired_presence = nil)
181204 in_scope_ext_reqs
182205 end
183206
184- def mandatory_ext_reqs = in_scope_ext_reqs ( ExtensionPresence . mandatory )
185- def optional_ext_reqs = in_scope_ext_reqs ( ExtensionPresence . optional )
186- def optional_type_ext_reqs = in_scope_ext_reqs ( ExtensionPresence . optional )
207+ # @return [Array<Instruction>] Sorted list of all instructions associated with extensions listed as
208+ # mandatory or optional in portfolio. Uses minimum version of
209+ # extension version that meets extension requirement specified in portfolio.
210+ def in_scope_instructions
211+ return @in_scope_instructions unless @in_scope_instructions . nil?
212+
213+ # XXX
214+ # @in_scope_instructions = in_scope_ext_reqs.map { |ext_req| ext_req.instructions }.flatten.uniq.sort
215+ @in_scope_instructions = in_scope_extensions . map { |ext | ext . instructions } . flatten . uniq . sort
216+ end
187217
188218 # @return [Array<Extension>] List of all extensions listed in portfolio.
189219 def in_scope_extensions
@@ -196,13 +226,6 @@ def in_scope_extensions
196226 @in_scope_extensions
197227 end
198228
199- # @return [Array<Instruction>] Sorted list of all instructions associated with extensions listed as
200- # mandatory or optional in portfolio. Uses minimum version of
201- # extension version that meets extension requirement specified in portfolio.
202- def in_scope_instructions
203- in_scope_extensions . map { |ext | ext . instructions } . flatten . uniq . sort
204- end
205-
206229 # @return [Boolean] Does the profile differentiate between different types of optional.
207230 def uses_optional_types?
208231 return @uses_optional_types unless @uses_optional_types . nil?
@@ -220,7 +243,7 @@ def uses_optional_types?
220243 @uses_optional_types
221244 end
222245
223- # Called by rakefile when generating a particular portfolio instance .
246+ # Called by rakefile when generating a portfolio.
224247 # Creates an in-memory data structure used by all portfolio routines that access a cfg_arch.
225248 #
226249 # @return [ConfiguredArchitecture] A partially-configured architecture definition corresponding to this portfolio.
0 commit comments