diff --git a/.github/workflows/regress.yml b/.github/workflows/regress.yml index 9c2a03bf7..6cb36ab50 100755 --- a/.github/workflows/regress.yml +++ b/.github/workflows/regress.yml @@ -93,24 +93,28 @@ jobs: runs-on: ubuntu-latest env: SINGULARITY: 1 + MODEL: MockProcessor + CONFIG: mocks steps: - name: Clone Github Repo Action uses: actions/checkout@v4 - name: singularity setup uses: ./.github/actions/singularity-setup - name: Generate extension PDF - run: ./do gen:proc_crd_pdf[MockProcessor] + run: ./do gen:proc_crd_pdf regress-gen-profile: runs-on: ubuntu-latest env: SINGULARITY: 1 + RELEASE: Mock + CONFIG: mocks steps: - name: Clone Github Repo Action uses: actions/checkout@v4 - name: singularity setup uses: ./.github/actions/singularity-setup - name: Generate extension PDF - run: ./do gen:profile_release_pdf[Mock] + run: ./do gen:profile_release_pdf build-llvm: runs-on: ubuntu-latest steps: diff --git a/Rakefile b/Rakefile index 7d27e9ca8..6454bb36f 100755 --- a/Rakefile +++ b/Rakefile @@ -121,8 +121,14 @@ namespace :gen do end end - desc "Resolve the standard in arch/, and write it to gen/resolved_arch/_" - task "resolved_arch" => "#{$root}/.stamps/resolve-_.stamp" + desc <<~DESC + Resolve the architecture files, and write it to gen/resolved_arch/ + + By default, resolves the standard architecture ("_") under arch. + + To resolve an overlay, set the CONFIG enviornment variable to a config name that uses the overlay + DESC + task "resolved_arch" => "#{$root}/.stamps/resolve-#{ENV.key?('CONFIG') ? ENV['CONFIG'] : '_'}.stamp" end # rule to generate standard for any configurations with an overlay @@ -496,12 +502,18 @@ namespace :test do Rake::Task["gen:html"].invoke("example_rv64_with_overlay") $logger.info "Generating MockProcessor-CRD.pdf" + ENV["CONFIG"] = "mocks" + ENV["MODEL"] = "MockProcessor" Rake::Task["#{$root}/gen/proc_crd/pdf/MockProcessor-CRD.pdf"].invoke $logger.info "Generating MockProcessor-CTP.pdf" + ENV["CONFIG"] = "mocks" + ENV["MODEL"] = "MockProcessor" Rake::Task["#{$root}/gen/proc_ctp/pdf/MockProcessor-CTP.pdf"].invoke $logger.info "Generating MockProfileRelease.pdf" + ENV["CONFIG"] = "mocks" + ENV["RELEASE"] = "Mock" Rake::Task["#{$root}/gen/profile/pdf/MockProfileRelease.pdf"].invoke $logger.info "Generating Go Language Support" @@ -528,38 +540,55 @@ desc <<~DESC DESC task :portfolios do portfolio_start_msg("MockProcessor-CRD") + ENV["CONFIG"] = "mocks" Rake::Task["#{$root}/gen/proc_crd/pdf/MockProcessor-CRD.pdf"].invoke portfolio_start_msg("MockProcessor-CTP") + ENV["CONFIG"] = "mocks" Rake::Task["#{$root}/gen/proc_ctp/pdf/MockProcessor-CTP.pdf"].invoke portfolio_start_msg("MockProfileRelease") + ENV["CONFIG"] = "mocks" Rake::Task["#{$root}/gen/profile/pdf/MockProfileRelease.pdf"].invoke portfolio_start_msg("MC100-32-CTP") + ENV["CONFIG"] = "_" Rake::Task["#{$root}/gen/proc_ctp/pdf/MC100-32-CTP.pdf"].invoke portfolio_start_msg("MC100-32-CRD") + ENV["CONFIG"] = "_" Rake::Task["#{$root}/gen/proc_crd/pdf/MC100-32-CRD.pdf"].invoke portfolio_start_msg("MC100-64-CRD") + ENV["CONFIG"] = "_" Rake::Task["#{$root}/gen/proc_crd/pdf/MC100-64-CRD.pdf"].invoke portfolio_start_msg("MC200-32-CRD") + ENV["CONFIG"] = "_" Rake::Task["#{$root}/gen/proc_crd/pdf/MC200-32-CRD.pdf"].invoke portfolio_start_msg("MC200-64-CRD") + ENV["CONFIG"] = "_" Rake::Task["#{$root}/gen/proc_crd/pdf/MC200-64-CRD.pdf"].invoke portfolio_start_msg("MC300-32-CRD") + ENV["CONFIG"] = "_" Rake::Task["#{$root}/gen/proc_crd/pdf/MC300-32-CRD.pdf"].invoke portfolio_start_msg("MC300-64-CRD") + ENV["CONFIG"] = "_" Rake::Task["#{$root}/gen/proc_crd/pdf/MC300-64-CRD.pdf"].invoke portfolio_start_msg("AC100-CRD") + ENV["CONFIG"] = "_" Rake::Task["#{$root}/gen/proc_crd/pdf/AC100-CRD.pdf"].invoke portfolio_start_msg("AC200-CRD") + ENV["CONFIG"] = "_" Rake::Task["#{$root}/gen/proc_crd/pdf/AC200-CRD.pdf"].invoke portfolio_start_msg("RVI20ProfileRelease") + ENV["CONFIG"] = "_" Rake::Task["#{$root}/gen/profile/pdf/RVI20ProfileRelease.pdf"].invoke portfolio_start_msg("RVA20ProfileRelease") + ENV["CONFIG"] = "_" Rake::Task["#{$root}/gen/profile/pdf/RVA20ProfileRelease.pdf"].invoke portfolio_start_msg("RVA22ProfileRelease") + ENV["CONFIG"] = "_" Rake::Task["#{$root}/gen/profile/pdf/RVA22ProfileRelease.pdf"].invoke portfolio_start_msg("RVA23ProfileRelease") + ENV["CONFIG"] = "_" Rake::Task["#{$root}/gen/profile/pdf/RVA23ProfileRelease.pdf"].invoke portfolio_start_msg("RVB23ProfileRelease") + ENV["CONFIG"] = "_" Rake::Task["#{$root}/gen/profile/pdf/RVB23ProfileRelease.pdf"].invoke end diff --git a/arch/ext/Xmock.yaml b/arch_overlay/mocks/ext/Xmock.yaml similarity index 98% rename from arch/ext/Xmock.yaml rename to arch_overlay/mocks/ext/Xmock.yaml index 19850b209..85faba589 100644 --- a/arch/ext/Xmock.yaml +++ b/arch_overlay/mocks/ext/Xmock.yaml @@ -1,4 +1,4 @@ -# yaml-language-server: $schema=../../schemas/ext_schema.json +# yaml-language-server: $schema=../../../schemas/ext_schema.json $schema: "ext_schema.json#" kind: extension diff --git a/arch/inst/mock.yaml b/arch_overlay/mocks/inst/mock.yaml similarity index 100% rename from arch/inst/mock.yaml rename to arch_overlay/mocks/inst/mock.yaml diff --git a/arch/proc_cert_class/MockProcessor.yaml b/arch_overlay/mocks/proc_cert_class/MockProcessor.yaml similarity index 100% rename from arch/proc_cert_class/MockProcessor.yaml rename to arch_overlay/mocks/proc_cert_class/MockProcessor.yaml diff --git a/arch/proc_cert_model/MockProcessor.yaml b/arch_overlay/mocks/proc_cert_model/MockProcessor.yaml similarity index 100% rename from arch/proc_cert_model/MockProcessor.yaml rename to arch_overlay/mocks/proc_cert_model/MockProcessor.yaml diff --git a/arch/profile/MP-S-64.yaml b/arch_overlay/mocks/profile/MP-S-64.yaml similarity index 100% rename from arch/profile/MP-S-64.yaml rename to arch_overlay/mocks/profile/MP-S-64.yaml diff --git a/arch/profile/MP-U-64.yaml b/arch_overlay/mocks/profile/MP-U-64.yaml similarity index 100% rename from arch/profile/MP-U-64.yaml rename to arch_overlay/mocks/profile/MP-U-64.yaml diff --git a/arch/profile_class/Mock.yaml b/arch_overlay/mocks/profile_class/Mock.yaml similarity index 100% rename from arch/profile_class/Mock.yaml rename to arch_overlay/mocks/profile_class/Mock.yaml diff --git a/arch/profile_release/Mock.yaml b/arch_overlay/mocks/profile_release/Mock.yaml similarity index 100% rename from arch/profile_release/Mock.yaml rename to arch_overlay/mocks/profile_release/Mock.yaml diff --git a/backends/portfolio/tasks.rake b/backends/portfolio/tasks.rake index 474360882..aa34f2838 100644 --- a/backends/portfolio/tasks.rake +++ b/backends/portfolio/tasks.rake @@ -5,23 +5,11 @@ require "pathname" require_relative "#{$lib}/idl/passes/gen_adoc" -# @return [Architecture] -def pf_create_arch - # Ensure that unconfigured resolved architecture called "_" exists. - Rake::Task["#{$root}/.stamps/resolve-_.stamp"].invoke - - # Create architecture object using the unconfigured resolved architecture called "_". - Architecture.new($root / "gen" / "resolved_arch" / "_") -end - # @param portfolio_grp_with_arch [PortfolioGroup] Contains one or more Portfolio objects that have an arch (not a cfg_arch). # @return [ConfiguredArchitecture] -def pf_create_cfg_arch(portfolio_grp_with_arch) +def pf_create_cfg_arch(portfolio_grp_with_arch, config_name) raise ArgumentError, "portfolio_grp_with_arch is a #{portfolio_grp_with_arch.class} but must be a PortfolioGroup" unless portfolio_grp_with_arch.is_a?(PortfolioGroup) - # Ensure that unconfigured resolved architecture called "_" exists. - Rake::Task["#{$root}/.stamps/resolve-_.stamp"].invoke - # Create a ConfiguredArchitecture object and provide it a PortfolioGroupConfig object to implement the AbstractConfig API. # The DatabaseObjects in PortfolioGroup only have an Architecture object and not a ConfiguredArchitecture object # otherwise there would be a circular dependency. To avoid this circular dependency, none of the routines @@ -30,7 +18,7 @@ def pf_create_cfg_arch(portfolio_grp_with_arch) ConfiguredArchitecture.new( portfolio_grp_with_arch.name, PortfolioGroupConfig.new(portfolio_grp_with_arch), - $root / "gen" / "resolved_arch" / "_" + $root / "gen" / "resolved_arch" / config_name ) end diff --git a/backends/proc_cert/tasks.rake b/backends/proc_cert/tasks.rake index e841e4158..1f8c2643a 100644 --- a/backends/proc_cert/tasks.rake +++ b/backends/proc_cert/tasks.rake @@ -7,20 +7,22 @@ require "pathname" # @param erb_template_pname [String] Path to ERB template file # @param target_pname [String] Full name of adoc file being generated # @param model_name [String] Name of the processor certificate model -def proc_cert_create_adoc(erb_template_pname, target_pname, model_name) +def proc_cert_create_adoc(erb_template_pname, target_pname, model_name, config_locator) # Create Architecture object without any knowledge of certificate model. - $logger.info "Creating Architecture object for #{model_name}" - arch = pf_create_arch + $logger.info "Creating Architecture object for #{model_name}, config #{config_locator}" + bootstrap_cfg_arch = cfg_arch_for(config_locator) # Create ProcCertModel for specific processor certificate model as specified in its arch YAML file. # The Architecture object also creates all other portfolio-related class instances from their arch YAML files. # None of these objects are provided with a AbstractConfig or Design object when created. $logger.info "Creating ProcCertModel with only an Architecture object for #{model_name}" - proc_cert_model_with_arch = arch.proc_cert_model(model_name) + proc_cert_model_with_arch = bootstrap_cfg_arch.proc_cert_model(model_name) + + raise "?" if proc_cert_model_with_arch.nil? # Create the ConfiguredArchitecture object with knowledge of the ProcCertModel. # Needs a PortfolioGroup object so just create one with just one ProcCertModel (which is a child of Portfolio). - cfg_arch = pf_create_cfg_arch(PortfolioGroup.new(model_name, [proc_cert_model_with_arch])) + cfg_arch = pf_create_cfg_arch(PortfolioGroup.new(model_name, [proc_cert_model_with_arch]), bootstrap_cfg_arch.name) $logger.info "Creating ProcCertModel with a ConfiguredArchitecture object for #{model_name}" proc_cert_model_with_cfg_arch = cfg_arch.proc_cert_model(model_name) diff --git a/backends/proc_crd/tasks.rake b/backends/proc_crd/tasks.rake index a4e0a3969..28a9e4099 100644 --- a/backends/proc_crd/tasks.rake +++ b/backends/proc_crd/tasks.rake @@ -7,46 +7,46 @@ require "pathname" PROC_CRD_DOC_DIR = Pathname.new "#{$root}/backends/proc_crd" PROC_CRD_GEN_DIR = $root / "gen" / "proc_crd" -Dir.glob("#{$root}/arch/proc_cert_model/*.yaml") do |f| - model_name = File.basename(f, ".yaml") - model_obj = YAML.load_file(f, permitted_classes: [Date]) - class_name = File.basename(model_obj['class']['$ref'].split("#")[0], ".yaml") - raise "Ill-formed processor certificate model file #{f}: missing 'class' field" if model_obj['class'].nil? - - file "#{PROC_CRD_GEN_DIR}/adoc/#{model_name}-CRD.adoc" => [ - __FILE__, - "#{$root}/arch/proc_cert_class/#{class_name}.yaml", - "#{$root}/arch/proc_cert_model/#{model_name}.yaml", - "#{$root}/lib/arch_obj_models/certificate.rb", - "#{$root}/lib/arch_obj_models/portfolio.rb", - "#{$root}/lib/portfolio_design.rb", - "#{$root}/backends/portfolio/templates/ext_appendix.adoc.erb", - "#{$root}/backends/portfolio/templates/inst_appendix.adoc.erb", - "#{$root}/backends/portfolio/templates/csr_appendix.adoc.erb", - "#{$root}/backends/portfolio/templates/beginning.adoc.erb", - "#{$root}/backends/proc_cert/templates/typographic.adoc.erb", - "#{$root}/backends/proc_cert/templates/rev_history.adoc.erb", - "#{$root}/backends/proc_cert/templates/related_specs.adoc.erb", - "#{$root}/backends/proc_cert/templates/priv_modes.adoc.erb", - "#{$root}/backends/proc_cert/templates/rev_history.adoc.erb", - "#{PROC_CRD_DOC_DIR}/templates/proc_crd.adoc.erb" - ] do |t| - proc_cert_create_adoc("#{PROC_CRD_DOC_DIR}/templates/proc_crd.adoc.erb", t.name, model_name) - end +rule %r{#{PROC_CRD_GEN_DIR}/adoc/[^/]+-CRD.adoc} => [ + __FILE__, + "#{$root}/lib/arch_obj_models/certificate.rb", + "#{$root}/lib/arch_obj_models/portfolio.rb", + "#{$root}/lib/portfolio_design.rb", + "#{$root}/backends/portfolio/templates/ext_appendix.adoc.erb", + "#{$root}/backends/portfolio/templates/inst_appendix.adoc.erb", + "#{$root}/backends/portfolio/templates/csr_appendix.adoc.erb", + "#{$root}/backends/portfolio/templates/beginning.adoc.erb", + "#{$root}/backends/proc_cert/templates/typographic.adoc.erb", + "#{$root}/backends/proc_cert/templates/rev_history.adoc.erb", + "#{$root}/backends/proc_cert/templates/related_specs.adoc.erb", + "#{$root}/backends/proc_cert/templates/priv_modes.adoc.erb", + "#{$root}/backends/proc_cert/templates/rev_history.adoc.erb", + "#{PROC_CRD_DOC_DIR}/templates/proc_crd.adoc.erb" +] do |t| + model_name = File.basename(t.name, ".adoc")[0...-4] + proc_cert_create_adoc("#{PROC_CRD_DOC_DIR}/templates/proc_crd.adoc.erb", t.name, model_name, ENV["CONFIG"]) +end - file "#{PROC_CRD_GEN_DIR}/pdf/#{model_name}-CRD.pdf" => [ +rule %r{#{PROC_CRD_GEN_DIR}/pdf/[^/]+-CRD.pdf} => proc { |tname| + model_name = File.basename(tname, ".pdf")[0...-4] + [ __FILE__, "#{PROC_CRD_GEN_DIR}/adoc/#{model_name}-CRD.adoc" - ] do |t| - pf_adoc2pdf("#{PROC_CRD_GEN_DIR}/adoc/#{model_name}-CRD.adoc", t.name) - end + ] +} do |t| + model_name = File.basename(t.name, ".pdf")[0...-4] + pf_adoc2pdf("#{PROC_CRD_GEN_DIR}/adoc/#{model_name}-CRD.adoc", t.name) +end - file "#{PROC_CRD_GEN_DIR}/html/#{model_name}-CRD.html" => [ +rule %r{#{PROC_CRD_GEN_DIR}/html/[^/]+-CRD.html"} => proc { |tname| + model_name = File.basename(tname, ".html")[0...-4] + [ __FILE__, "#{PROC_CRD_GEN_DIR}/adoc/#{model_name}-CRD.adoc" - ] do |t| - pf_adoc2html("#{PROC_CRD_GEN_DIR}/adoc/#{model_name}-CRD.adoc", t.name) - end + ] +} do |t| + model_name = File.basename(t.name, ".html")[0...-4] + pf_adoc2html("#{PROC_CRD_GEN_DIR}/adoc/#{model_name}-CRD.adoc", t.name) end namespace :gen do @@ -54,16 +54,22 @@ namespace :gen do Generate Processor CRD (Certification Requirements Document) as a PDF. Required options: - model_name - The name of the certification model under arch/proc_cert_model + CONFIG - Configuration to use for base architecture + MODE - The name of the certification model under arch/proc_cert_model DESC - task :proc_crd_pdf, [:model_name] do |_t, args| - model_name = args[:model_name] + task :proc_crd_pdf do + raise "Missing required argument 'CONFIG'" unless ENV.key?("CONFIG") + raise "Missing required argument 'MODEL'" unless ENV.key?("MODEL") + + model_name = ENV["MODEL"] if model_name.nil? warn "Missing required option: 'model_name'" exit 1 end - unless File.exist?("#{$root}/arch/proc_cert_model/#{model_name}.yaml") + cfg_arch = cfg_arch_for(ENV["CONFIG"]) + + unless cfg_arch.proc_cert_models.any? { |model| model.name == model_name } warn "No certification model named '#{model_name}' found in arch/proc_cert_model" exit 1 end @@ -75,19 +81,26 @@ namespace :gen do Generate Processor CRD (Certification Requirements Document) as an HTML file. Required options: - model_name - The name of the certification model under arch/proc_cert_model + CONFIG - Configuration to use for base architecture + MODE - The name of the certification model under arch/proc_cert_model DESC - task :proc_crd_html, [:model_name] do |_t, args| - if args[:model_name].nil? + task :proc_crd_html do + raise "Missing required argument 'CONFIG'" unless ENV.key?("CONFIG") + raise "Missing required argument 'MODEL'" unless ENV.key?("MODEL") + + model_name = ENV["MODEL"] + if model_name.nil? warn "Missing required option: 'model_name'" exit 1 end - unless File.exist?("#{$root}/arch/proc_cert_model/#{args[:model_name]}.yaml") - warn "No certification model named '#{args[:model_name]}' found in arch/proc_cert_model" + cfg_arch = cfg_arch_for(ENV["CONFIG"]) + + unless cfg_arch.proc_cert_models.any? { |model| model.name == model_name } + warn "No certification model named '#{model_name}' found in arch/proc_cert_model" exit 1 end - Rake::Task["#{PROC_CRD_GEN_DIR}/html/#{args[:model_name]}-CRD.html"].invoke + Rake::Task["#{PROC_CRD_GEN_DIR}/html/#{model_name}-CRD.html"].invoke end end diff --git a/backends/proc_ctp/tasks.rake b/backends/proc_ctp/tasks.rake index 4c8e702ad..04c33ba28 100644 --- a/backends/proc_ctp/tasks.rake +++ b/backends/proc_ctp/tasks.rake @@ -7,48 +7,48 @@ require "pathname" PROC_CTP_DOC_DIR = Pathname.new "#{$root}/backends/proc_ctp" PROC_CTP_GEN_DIR = $root / "gen" / "proc_ctp" -Dir.glob("#{$root}/arch/proc_cert_model/*.yaml") do |f| - model_name = File.basename(f, ".yaml") - model_obj = YAML.load_file(f, permitted_classes: [Date]) - class_name = File.basename(model_obj['class']['$ref'].split("#")[0], ".yaml") - raise "Ill-formed processor certificate model file #{f}: missing 'class' field" if model_obj['class'].nil? - - file "#{PROC_CTP_GEN_DIR}/adoc/#{model_name}-CTP.adoc" => [ - __FILE__, - "#{$root}/arch/proc_cert_class/#{class_name}.yaml", - "#{$root}/arch/proc_cert_model/#{model_name}.yaml", - "#{$root}/lib/arch_obj_models/certificate.rb", - "#{$root}/lib/arch_obj_models/portfolio.rb", - "#{$root}/lib/portfolio_design.rb", - "#{$root}/backends/portfolio/templates/ext_appendix.adoc.erb", - "#{$root}/backends/portfolio/templates/inst_appendix.adoc.erb", - "#{$root}/backends/portfolio/templates/csr_appendix.adoc.erb", - "#{$root}/backends/portfolio/templates/beginning.adoc.erb", - "#{$root}/backends/portfolio/templates/normative_rules.adoc.erb", - "#{$root}/backends/portfolio/templates/test_procedures.adoc.erb", - "#{$root}/backends/proc_cert/templates/typographic.adoc.erb", - "#{$root}/backends/proc_cert/templates/rev_history.adoc.erb", - "#{$root}/backends/proc_cert/templates/related_specs.adoc.erb", - "#{$root}/backends/proc_cert/templates/priv_modes.adoc.erb", - "#{PROC_CTP_DOC_DIR}/templates/proc_ctp.adoc.erb" - ] do |t| - pf_get_latest_csc_isa_manual(t.name) - proc_cert_create_adoc("#{PROC_CTP_DOC_DIR}/templates/proc_ctp.adoc.erb", t.name, model_name) - end +rule %r{#{PROC_CTP_GEN_DIR}/adoc/[^/]+-CTP.adoc} => [ + __FILE__, + "#{$root}/lib/arch_obj_models/certificate.rb", + "#{$root}/lib/arch_obj_models/portfolio.rb", + "#{$root}/lib/portfolio_design.rb", + "#{$root}/backends/portfolio/templates/ext_appendix.adoc.erb", + "#{$root}/backends/portfolio/templates/inst_appendix.adoc.erb", + "#{$root}/backends/portfolio/templates/csr_appendix.adoc.erb", + "#{$root}/backends/portfolio/templates/beginning.adoc.erb", + "#{$root}/backends/portfolio/templates/normative_rules.adoc.erb", + "#{$root}/backends/portfolio/templates/test_procedures.adoc.erb", + "#{$root}/backends/proc_cert/templates/typographic.adoc.erb", + "#{$root}/backends/proc_cert/templates/rev_history.adoc.erb", + "#{$root}/backends/proc_cert/templates/related_specs.adoc.erb", + "#{$root}/backends/proc_cert/templates/priv_modes.adoc.erb", + "#{PROC_CTP_DOC_DIR}/templates/proc_ctp.adoc.erb" +] do |t| + model_name = File.basename(t.name, ".adoc")[0...-4] + pf_get_latest_csc_isa_manual(t.name) + proc_cert_create_adoc("#{PROC_CTP_DOC_DIR}/templates/proc_ctp.adoc.erb", t.name, model_name, ENV["CONFIG"]) +end - file "#{PROC_CTP_GEN_DIR}/pdf/#{model_name}-CTP.pdf" => [ +rule %r{#{PROC_CTP_GEN_DIR}/pdf/[^/]+-CTP.pdf} => proc { |tname| + model_name = File.basename(tname, ".pdf")[0...-4] + [ __FILE__, "#{PROC_CTP_GEN_DIR}/adoc/#{model_name}-CTP.adoc" - ] do |t| - pf_adoc2pdf("#{PROC_CTP_GEN_DIR}/adoc/#{model_name}-CTP.adoc", t.name) - end + ] +} do |t| + model_name = File.basename(t.name, ".pdf")[0...-4] + pf_adoc2pdf("#{PROC_CTP_GEN_DIR}/adoc/#{model_name}-CTP.adoc", t.name) +end - file "#{PROC_CTP_GEN_DIR}/html/#{model_name}-CTP.html" => [ +rule %r{#{PROC_CTP_GEN_DIR}/html/[^/]+-CTP.html} => proc { |tname| + model_name = File.basename(tname, ".html")[0...-4] + [ __FILE__, "#{PROC_CTP_GEN_DIR}/adoc/#{model_name}-CTP.adoc" - ] do |t| - pf_adoc2html("#{PROC_CTP_GEN_DIR}/adoc/#{model_name}-CTP.adoc", t.name) - end + ] +} do |t| + model_name = File.basename(t.name, ".html")[0...-4] + pf_adoc2html("#{PROC_CTP_GEN_DIR}/adoc/#{model_name}-CTP.adoc", t.name) end namespace :gen do @@ -56,16 +56,22 @@ namespace :gen do Generate Processor CTP (Certification Test Plan) as a PDF. Required options: - model_name - The name of the certification model under arch/proc_cert_model + CONFIG - Configuration to use for base architecture + MODE - The name of the certification model under arch/proc_cert_model DESC - task :proc_ctp_pdf, [:model_name] do |_t, args| - model_name = args[:model_name] + task :proc_ctp_pdf do |_t, args| + raise "Missing required argument 'CONFIG'" unless ENV.key?("CONFIG") + raise "Missing required argument 'MODEL'" unless ENV.key?("MODEL") + + model_name = ENV["MODEL"] if model_name.nil? warn "Missing required option: 'model_name'" exit 1 end - unless File.exist?("#{$root}/arch/proc_cert_model/#{model_name}.yaml") + cfg_arch = cfg_arch_for(ENV["CONFIG"]) + + unless cfg_arch.proc_cert_models.any? { |model| model.name == model_name } warn "No certification model named '#{model_name}' found in arch/proc_cert_model" exit 1 end @@ -77,19 +83,27 @@ namespace :gen do Generate Processor CTP (Certification Test Plan) as an HTML file. Required options: - model_name - The name of the certification model under arch/proc_cert_model + CONFIG - Configuration to use for base architecture + MODE - The name of the certification model under arch/proc_cert_model DESC task :proc_ctp_html, [:model_name] do |_t, args| - if args[:model_name].nil? + raise "Missing required argument 'CONFIG'" unless ENV.key?("CONFIG") + raise "Missing required argument 'MODEL'" unless ENV.key?("MODEL") + + model_name = ENV["MODEL"] + + if model_name.nil? warn "Missing required option: 'model_name'" exit 1 end - unless File.exist?("#{$root}/arch/proc_cert_model/#{args[:model_name]}.yaml") - warn "No certification model named '#{args[:model_name]}' found in arch/proc_cert_model" + cfg_arch = cfg_arch_for(ENV["CONFIG"]) + + unless cfg_arch.proc_cert_models.any? { |model| model.name == model_name } + warn "No certification model named '#{model_name}' found in arch/proc_cert_model" exit 1 end - Rake::Task["#{PROC_CTP_GEN_DIR}/html/#{args[:model_name]}-CTP.html"].invoke + Rake::Task["#{PROC_CTP_GEN_DIR}/html/#{model_name}-CTP.html"].invoke end end diff --git a/backends/profile/tasks.rake b/backends/profile/tasks.rake index a1ff7de34..5e71bc373 100644 --- a/backends/profile/tasks.rake +++ b/backends/profile/tasks.rake @@ -7,89 +7,79 @@ require "pathname" PROFILE_DOC_DIR = Pathname.new "#{$root}/backends/profile" PROFILE_GEN_DIR = $root / "gen" / "profile" -Dir.glob("#{$root}/arch/profile_release/*.yaml") do |f| - release_name = File.basename(f, ".yaml") - release_obj = YAML.load_file(f, permitted_classes: [Date]) - raise "Can't parse #{f}" if release_obj.nil? - - raise "Ill-formed profile release file #{f}: missing 'class' field" if release_obj['class'].nil? - class_name = File.basename(release_obj['class']['$ref'].split("#")[0], ".yaml") - raise "Ill-formed profile release file #{f}: can't parse class name" if class_name.nil? - - raise "Ill-formed profile release file #{f}: missing 'profiles' field" if release_obj['profiles'].nil? - profile_names = release_obj['profiles'].map {|p| File.basename(p['$ref'].split("#")[0], ".yaml") } - raise "Ill-formed profile release file #{f}: can't parse profile names" if profile_names.nil? - - profile_pathnames = profile_names.map {|profile_name| "#{$root}/arch/profile/#{profile_name}.yaml" } - - file "#{PROFILE_GEN_DIR}/adoc/#{release_name}ProfileRelease.adoc" => [ - __FILE__, - "#{$root}/arch/profile_class/#{class_name}.yaml", - "#{$root}/arch/profile_release/#{release_name}.yaml", - "#{$root}/lib/arch_obj_models/profile.rb", - "#{$root}/lib/arch_obj_models/portfolio.rb", - "#{$root}/lib/portfolio_design.rb", - "#{$root}/lib/backend_helpers.rb", - "#{$root}/backends/portfolio/templates/ext_appendix.adoc.erb", - "#{$root}/backends/portfolio/templates/inst_appendix.adoc.erb", - "#{$root}/backends/portfolio/templates/csr_appendix.adoc.erb", - "#{$root}/backends/portfolio/templates/beginning.adoc.erb", - "#{PROFILE_DOC_DIR}/templates/profile.adoc.erb" - ].concat(profile_pathnames) do |t| - # Create architecture object without any knowledge of the profile release. - # Just used to get the PortfolioGroup object. - arch = pf_create_arch - - # Create ProfileRelease for specific profile release as specified in its arch YAML file. - # The Architecture object also creates all other portfolio-related class instances from their arch YAML files. - # None of these objects are provided with a AbstractConfig or Design object when created. - $logger.info "Creating ProfileRelease with only an Architecture object for #{release_name}" - profile_release_with_arch = arch.profile_release(release_name) - - # Now create a ConfiguredArchitecture object for the PortfolioDesign. - cfg_arch = pf_create_cfg_arch(profile_release_with_arch.portfolio_grp) - - $logger.info "Creating ProfileRelease with a ConfiguredArchitecture object for #{release_name}" - profile_release_with_cfg_arch = cfg_arch.profile_release(release_name) - profile_class_with_cfg_arch = profile_release_with_cfg_arch.profile_class - - # Create the one PortfolioDesign object required for the ERB evaluation. - # Provide it with all the profiles in this ProfileRelease. - $logger.info "Creating PortfolioDesign object using profile release #{release_name}" - portfolio_design = PortfolioDesign.new( - release_name, - cfg_arch, - PortfolioDesign.profile_release_type, - profile_release_with_cfg_arch.profiles, - profile_release_with_cfg_arch.profile_class - ) - - # Create empty binding and then specify explicitly which variables the ERB template can access. - # Seems to use this method name in stack backtraces (hence its name). - def evaluate_erb - binding - end - erb_binding = evaluate_erb - portfolio_design.init_erb_binding(erb_binding) - erb_binding.local_variable_set(:profile_release, profile_release_with_cfg_arch) - erb_binding.local_variable_set(:profile_class, profile_release_with_cfg_arch.profile_class) - - pf_create_adoc("#{PROFILE_DOC_DIR}/templates/profile.adoc.erb", erb_binding, t.name, portfolio_design) +rule %r{#{PROFILE_GEN_DIR}/adoc/[^/]+ProfileRelease.adoc} => [ + __FILE__, + "#{$root}/lib/arch_obj_models/profile.rb", + "#{$root}/lib/arch_obj_models/portfolio.rb", + "#{$root}/lib/portfolio_design.rb", + "#{$root}/lib/backend_helpers.rb", + "#{$root}/backends/portfolio/templates/ext_appendix.adoc.erb", + "#{$root}/backends/portfolio/templates/inst_appendix.adoc.erb", + "#{$root}/backends/portfolio/templates/csr_appendix.adoc.erb", + "#{$root}/backends/portfolio/templates/beginning.adoc.erb", + "#{PROFILE_DOC_DIR}/templates/profile.adoc.erb" +] do |t| + # Create architecture object without any knowledge of the profile release. + # Just used to get the PortfolioGroup object. + bootstrap_cfg_arch = cfg_arch_for(ENV["CONFIG"]) + release_name = File.basename(t.name, ".adoc")[0...-14] + + # Create ProfileRelease for specific profile release as specified in its arch YAML file. + # The Architecture object also creates all other portfolio-related class instances from their arch YAML files. + # None of these objects are provided with a AbstractConfig or Design object when created. + $logger.info "Creating ProfileRelease with only an Architecture object for #{release_name}" + profile_release_with_arch = bootstrap_cfg_arch.profile_release(release_name) + + # Now create a ConfiguredArchitecture object for the PortfolioDesign. + cfg_arch = pf_create_cfg_arch(profile_release_with_arch.portfolio_grp, bootstrap_cfg_arch.name) + + $logger.info "Creating ProfileRelease with a ConfiguredArchitecture object for #{release_name}" + profile_release_with_cfg_arch = cfg_arch.profile_release(release_name) + + # Create the one PortfolioDesign object required for the ERB evaluation. + # Provide it with all the profiles in this ProfileRelease. + $logger.info "Creating PortfolioDesign object using profile release #{release_name}" + portfolio_design = PortfolioDesign.new( + release_name, + cfg_arch, + PortfolioDesign.profile_release_type, + profile_release_with_cfg_arch.profiles, + profile_release_with_cfg_arch.profile_class + ) + + # Create empty binding and then specify explicitly which variables the ERB template can access. + # Seems to use this method name in stack backtraces (hence its name). + def evaluate_erb + binding end + erb_binding = evaluate_erb + portfolio_design.init_erb_binding(erb_binding) + erb_binding.local_variable_set(:profile_release, profile_release_with_cfg_arch) + erb_binding.local_variable_set(:profile_class, profile_release_with_cfg_arch.profile_class) + + pf_create_adoc("#{PROFILE_DOC_DIR}/templates/profile.adoc.erb", erb_binding, t.name, portfolio_design) +end - file "#{PROFILE_GEN_DIR}/pdf/#{release_name}ProfileRelease.pdf" => [ +rule %r{#{PROFILE_GEN_DIR}/pdf/[^/]+ProfileRelease.pdf} => proc { |tname| + release_name = File.basename(tname, ".pdf")[0...-14] + [ __FILE__, "#{PROFILE_GEN_DIR}/adoc/#{release_name}ProfileRelease.adoc" - ] do |t| - pf_adoc2pdf("#{PROFILE_GEN_DIR}/adoc/#{release_name}ProfileRelease.adoc", t.name) - end + ] +} do |t| + release_name = File.basename(t.name, ".pdf")[0...-14] + pf_adoc2pdf("#{PROFILE_GEN_DIR}/adoc/#{release_name}ProfileRelease.adoc", t.name) +end - file "#{PROFILE_GEN_DIR}/html/#{release_name}ProfileRelease.html" => [ +rule %r{#{PROFILE_GEN_DIR}/html/[^/]+ProfileRelease.html} => proc { |tname| + release_name = File.basename(tname, ".html")[0...-14] + [ __FILE__, "#{PROFILE_GEN_DIR}/adoc/#{release_name}ProfileRelease.adoc" - ] do |t| - pf_adoc2html("#{PROFILE_GEN_DIR}/adoc/#{release_name}ProfileRelease.adoc", t.name) - end + ] +} do |t| + release_name = File.basename(t.name, ".html")[0...-14] + pf_adoc2html("#{PROFILE_GEN_DIR}/adoc/#{release_name}ProfileRelease.adoc", t.name) end namespace :gen do @@ -97,16 +87,23 @@ namespace :gen do Generate profile documentation for a profile release as a PDF. Required options: - release_name - The name of the profile release under arch/profile_release + CONFIG - Configuration to use for base architecture + RELEASE - The name of the profile release under arch/profile_release DESC - task :profile_release_pdf, [:release_name] do |_t, args| - release_name = args[:release_name] + task :profile_release_pdf do |_t, args| + raise "Missing required argument 'CONFIG'" unless ENV.key?("CONFIG") + raise "Missing required argument 'RELEASE'" unless ENV.key?("RELEASE") + + release_name = ENV["RELEASE"] + if release_name.nil? warn "Missing required option: 'release_name'" exit 1 end - unless File.exist?("#{$root}/arch/profile_release/#{release_name}.yaml") + cfg_arch = cfg_arch_for(ENV["CONFIG"]) + + unless cfg_arch.profile_releases.any? { |release| release.name == release_name } warn "No profile release named '#{release_name}' found in arch/profile_release" exit 1 end @@ -118,16 +115,22 @@ namespace :gen do Generate profile documentation for a profile release as an HTML. Required options: - release_name - The name of the profile release under arch/profile_release + CONFIG - Configuration to use for base architecture + RELEASE - The name of the profile release under arch/profile_release DESC task :profile_release_html, [:release_name] do |_t, args| - release_name = args[:release_name] + raise "Missing required argument 'CONFIG'" unless ENV.key?("CONFIG") + raise "Missing required argument 'RELEASE'" unless ENV.key?("RELEASE") + + release_name = ENV["RELEASE"] if release_name.nil? warn "Missing required option: 'release_name'" exit 1 end - unless File.exist?("#{$root}/arch/profile_release/#{release_name}.yaml") + cfg_arch = cfg_arch_for(ENV["CONFIG"]) + + unless cfg_arch.profile_releases.any? { |release| release.name == release_name } warn "No profile release named '#{release_name}' found in arch/profile_release" exit 1 end diff --git a/cfgs/mocks.yaml b/cfgs/mocks.yaml new file mode 100644 index 000000000..b31e0175b --- /dev/null +++ b/cfgs/mocks.yaml @@ -0,0 +1,8 @@ +# yaml-language-server: $schema=../schemas/config_schema.json +--- +$schema: config_schema.json# +kind: architecture configuration +type: unconfigured +name: mocks +description: A configuration containing mock data for testing +arch_overlay: mocks diff --git a/lib/config.rb b/lib/config.rb index e4f325c50..7c060b1b5 100644 --- a/lib/config.rb +++ b/lib/config.rb @@ -319,10 +319,6 @@ def initialize(portfolio_grp) @portfolio_grp = portfolio_grp - portfolio_grp.portfolios.each do |portfolio| - raise "Portfolio #{portfolio.name} shouldn't have a non-nil cfg_arch member" if portfolio.cfg_arch? - raise "Portfolio #{portfolio.name} shouldn't have a an arch member of type ConfiguredArchitecture" if portfolio.arch.is_a?(ConfiguredArchitecture) - end end ############################### diff --git a/lib/deploy.sh b/lib/deploy.sh index 0044b6ee0..a7c446a9b 100755 --- a/lib/deploy.sh +++ b/lib/deploy.sh @@ -75,6 +75,7 @@ deploy_mkdir $DEPLOY_DIR/htmls deploy_log "Resolve / Create Index" deploy_do "gen:resolved_arch" +deploy_do "gen:resolved_arch CONFIG=mocks" deploy_cp_recursive gen/resolved_arch/_ $DEPLOY_DIR/resolved_arch deploy_log "Create _site/isa_explorer" @@ -108,26 +109,26 @@ deploy_cp_recursive gen/cfg_html_doc/example_rv64_with_overlay/html $DEPLOY_DIR/ for profile in RVI20 RVA20 RVA22 RVA23 RVB23; do deploy_log "Create $profile Profile Release PDF Spec" - deploy_do "gen:profile_release_pdf[$profile]" + deploy_do "gen:profile_release_pdf RELEASE=$profile CONFIG=_" deploy_log "Copy $profile Profile Release PDF Spec" deploy_cp gen/profile/pdf/${profile}ProfileRelease.pdf $DEPLOY_DIR/pdfs done for crd in AC100 AC200 MC100-32 MC100-64 MC200-32 MC200-64 MC300-32 MC300-64; do deploy_log "Create $profile Profile Release PDF Spec" - deploy_do "gen:profile_release_pdf[$profile]" + deploy_do "gen:profile_release_pdf RELEASE=$profile CONFIG=_" deploy_log "Copy $profile Profile Release PDF Spec" deploy_cp gen/profile/pdf/${profile}ProfileRelease.pdf $DEPLOY_DIR/pdfs deploy_log "Create ${crd}-CRD PDF Spec" - deploy_do "gen:proc_crd_pdf[$crd]" + deploy_do "gen:proc_crd_pdf MODEL=$crd CONFIG=_" deploy_log "Copy ${crd}-CRD PDF" deploy_cp gen/proc_crd/pdf/${crd}-CRD.pdf $DEPLOY_DIR/pdfs done for ctp in MC100-32 MockProcessor; do deploy_log "Create ${ctp}-CTP PDF Spec" - deploy_do "gen:proc_ctp_pdf[$ctp]" + deploy_do "gen:proc_ctp_pdf MODEL=$ctp CONFIG=mocks" deploy_log "Copy ${ctp}-CTP PDF" deploy_cp gen/proc_ctp/pdf/${ctp}-CTP.pdf $DEPLOY_DIR/pdfs done