Skip to content

Commit ad8139b

Browse files
committed
refactor: move mock data into arch_overlay
1 parent de3ea3e commit ad8139b

File tree

16 files changed

+262
-204
lines changed

16 files changed

+262
-204
lines changed

.github/workflows/regress.yml

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -93,24 +93,28 @@ jobs:
9393
runs-on: ubuntu-latest
9494
env:
9595
SINGULARITY: 1
96+
MODEL: MockProcessor
97+
CONFIG: mocks
9698
steps:
9799
- name: Clone Github Repo Action
98100
uses: actions/checkout@v4
99101
- name: singularity setup
100102
uses: ./.github/actions/singularity-setup
101103
- name: Generate extension PDF
102-
run: ./do gen:proc_crd_pdf[MockProcessor]
104+
run: ./do gen:proc_crd_pdf
103105
regress-gen-profile:
104106
runs-on: ubuntu-latest
105107
env:
106108
SINGULARITY: 1
109+
RELEASE: Mock
110+
CONFIG: mocks
107111
steps:
108112
- name: Clone Github Repo Action
109113
uses: actions/checkout@v4
110114
- name: singularity setup
111115
uses: ./.github/actions/singularity-setup
112116
- name: Generate extension PDF
113-
run: ./do gen:profile_release_pdf[Mock]
117+
run: ./do gen:profile_release_pdf
114118
build-llvm:
115119
runs-on: ubuntu-latest
116120
steps:

Rakefile

Lines changed: 31 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -121,8 +121,14 @@ namespace :gen do
121121
end
122122
end
123123

124-
desc "Resolve the standard in arch/, and write it to gen/resolved_arch/_"
125-
task "resolved_arch" => "#{$root}/.stamps/resolve-_.stamp"
124+
desc <<~DESC
125+
Resolve the architecture files, and write it to gen/resolved_arch/<CONFIG_NAME>
126+
127+
By default, resolves the standard architecture ("_") under arch.
128+
129+
To resolve an overlay, set the CONFIG enviornment variable to a config name that uses the overlay
130+
DESC
131+
task "resolved_arch" => "#{$root}/.stamps/resolve-#{ENV.key?('CONFIG') ? ENV['CONFIG'] : '_'}.stamp"
126132
end
127133

128134
# rule to generate standard for any configurations with an overlay
@@ -496,12 +502,18 @@ namespace :test do
496502
Rake::Task["gen:html"].invoke("example_rv64_with_overlay")
497503

498504
$logger.info "Generating MockProcessor-CRD.pdf"
505+
ENV["CONFIG"] = "mocks"
506+
ENV["MODEL"] = "MockProcessor"
499507
Rake::Task["#{$root}/gen/proc_crd/pdf/MockProcessor-CRD.pdf"].invoke
500508

501509
$logger.info "Generating MockProcessor-CTP.pdf"
510+
ENV["CONFIG"] = "mocks"
511+
ENV["MODEL"] = "MockProcessor"
502512
Rake::Task["#{$root}/gen/proc_ctp/pdf/MockProcessor-CTP.pdf"].invoke
503513

504514
$logger.info "Generating MockProfileRelease.pdf"
515+
ENV["CONFIG"] = "mocks"
516+
ENV["RELEASE"] = "Mock"
505517
Rake::Task["#{$root}/gen/profile/pdf/MockProfileRelease.pdf"].invoke
506518

507519
$logger.info "Generating Go Language Support"
@@ -528,38 +540,55 @@ desc <<~DESC
528540
DESC
529541
task :portfolios do
530542
portfolio_start_msg("MockProcessor-CRD")
543+
ENV["CONFIG"] = "mocks"
531544
Rake::Task["#{$root}/gen/proc_crd/pdf/MockProcessor-CRD.pdf"].invoke
532545
portfolio_start_msg("MockProcessor-CTP")
546+
ENV["CONFIG"] = "mocks"
533547
Rake::Task["#{$root}/gen/proc_ctp/pdf/MockProcessor-CTP.pdf"].invoke
534548
portfolio_start_msg("MockProfileRelease")
549+
ENV["CONFIG"] = "mocks"
535550
Rake::Task["#{$root}/gen/profile/pdf/MockProfileRelease.pdf"].invoke
536551
portfolio_start_msg("MC100-32-CTP")
552+
ENV["CONFIG"] = "_"
537553
Rake::Task["#{$root}/gen/proc_ctp/pdf/MC100-32-CTP.pdf"].invoke
538554
portfolio_start_msg("MC100-32-CRD")
555+
ENV["CONFIG"] = "_"
539556
Rake::Task["#{$root}/gen/proc_crd/pdf/MC100-32-CRD.pdf"].invoke
540557
portfolio_start_msg("MC100-64-CRD")
558+
ENV["CONFIG"] = "_"
541559
Rake::Task["#{$root}/gen/proc_crd/pdf/MC100-64-CRD.pdf"].invoke
542560
portfolio_start_msg("MC200-32-CRD")
561+
ENV["CONFIG"] = "_"
543562
Rake::Task["#{$root}/gen/proc_crd/pdf/MC200-32-CRD.pdf"].invoke
544563
portfolio_start_msg("MC200-64-CRD")
564+
ENV["CONFIG"] = "_"
545565
Rake::Task["#{$root}/gen/proc_crd/pdf/MC200-64-CRD.pdf"].invoke
546566
portfolio_start_msg("MC300-32-CRD")
567+
ENV["CONFIG"] = "_"
547568
Rake::Task["#{$root}/gen/proc_crd/pdf/MC300-32-CRD.pdf"].invoke
548569
portfolio_start_msg("MC300-64-CRD")
570+
ENV["CONFIG"] = "_"
549571
Rake::Task["#{$root}/gen/proc_crd/pdf/MC300-64-CRD.pdf"].invoke
550572
portfolio_start_msg("AC100-CRD")
573+
ENV["CONFIG"] = "_"
551574
Rake::Task["#{$root}/gen/proc_crd/pdf/AC100-CRD.pdf"].invoke
552575
portfolio_start_msg("AC200-CRD")
576+
ENV["CONFIG"] = "_"
553577
Rake::Task["#{$root}/gen/proc_crd/pdf/AC200-CRD.pdf"].invoke
554578
portfolio_start_msg("RVI20ProfileRelease")
579+
ENV["CONFIG"] = "_"
555580
Rake::Task["#{$root}/gen/profile/pdf/RVI20ProfileRelease.pdf"].invoke
556581
portfolio_start_msg("RVA20ProfileRelease")
582+
ENV["CONFIG"] = "_"
557583
Rake::Task["#{$root}/gen/profile/pdf/RVA20ProfileRelease.pdf"].invoke
558584
portfolio_start_msg("RVA22ProfileRelease")
585+
ENV["CONFIG"] = "_"
559586
Rake::Task["#{$root}/gen/profile/pdf/RVA22ProfileRelease.pdf"].invoke
560587
portfolio_start_msg("RVA23ProfileRelease")
588+
ENV["CONFIG"] = "_"
561589
Rake::Task["#{$root}/gen/profile/pdf/RVA23ProfileRelease.pdf"].invoke
562590
portfolio_start_msg("RVB23ProfileRelease")
591+
ENV["CONFIG"] = "_"
563592
Rake::Task["#{$root}/gen/profile/pdf/RVB23ProfileRelease.pdf"].invoke
564593
end
565594

arch/ext/Xmock.yaml renamed to arch_overlay/mocks/ext/Xmock.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# yaml-language-server: $schema=../../schemas/ext_schema.json
1+
# yaml-language-server: $schema=../../../schemas/ext_schema.json
22

33
$schema: "ext_schema.json#"
44
kind: extension
File renamed without changes.

backends/portfolio/tasks.rake

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -5,23 +5,11 @@
55
require "pathname"
66
require_relative "#{$lib}/idl/passes/gen_adoc"
77

8-
# @return [Architecture]
9-
def pf_create_arch
10-
# Ensure that unconfigured resolved architecture called "_" exists.
11-
Rake::Task["#{$root}/.stamps/resolve-_.stamp"].invoke
12-
13-
# Create architecture object using the unconfigured resolved architecture called "_".
14-
Architecture.new($root / "gen" / "resolved_arch" / "_")
15-
end
16-
178
# @param portfolio_grp_with_arch [PortfolioGroup] Contains one or more Portfolio objects that have an arch (not a cfg_arch).
189
# @return [ConfiguredArchitecture]
19-
def pf_create_cfg_arch(portfolio_grp_with_arch)
10+
def pf_create_cfg_arch(portfolio_grp_with_arch, config_name)
2011
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)
2112

22-
# Ensure that unconfigured resolved architecture called "_" exists.
23-
Rake::Task["#{$root}/.stamps/resolve-_.stamp"].invoke
24-
2513
# Create a ConfiguredArchitecture object and provide it a PortfolioGroupConfig object to implement the AbstractConfig API.
2614
# The DatabaseObjects in PortfolioGroup only have an Architecture object and not a ConfiguredArchitecture object
2715
# 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)
3018
ConfiguredArchitecture.new(
3119
portfolio_grp_with_arch.name,
3220
PortfolioGroupConfig.new(portfolio_grp_with_arch),
33-
$root / "gen" / "resolved_arch" / "_"
21+
$root / "gen" / "resolved_arch" / config_name
3422
)
3523
end
3624

backends/proc_cert/tasks.rake

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,20 +7,22 @@ require "pathname"
77
# @param erb_template_pname [String] Path to ERB template file
88
# @param target_pname [String] Full name of adoc file being generated
99
# @param model_name [String] Name of the processor certificate model
10-
def proc_cert_create_adoc(erb_template_pname, target_pname, model_name)
10+
def proc_cert_create_adoc(erb_template_pname, target_pname, model_name, config_locator)
1111
# Create Architecture object without any knowledge of certificate model.
12-
$logger.info "Creating Architecture object for #{model_name}"
13-
arch = pf_create_arch
12+
$logger.info "Creating Architecture object for #{model_name}, config #{config_locator}"
13+
bootstrap_cfg_arch = cfg_arch_for(config_locator)
1414

1515
# Create ProcCertModel for specific processor certificate model as specified in its arch YAML file.
1616
# The Architecture object also creates all other portfolio-related class instances from their arch YAML files.
1717
# None of these objects are provided with a AbstractConfig or Design object when created.
1818
$logger.info "Creating ProcCertModel with only an Architecture object for #{model_name}"
19-
proc_cert_model_with_arch = arch.proc_cert_model(model_name)
19+
proc_cert_model_with_arch = bootstrap_cfg_arch.proc_cert_model(model_name)
20+
21+
raise "?" if proc_cert_model_with_arch.nil?
2022

2123
# Create the ConfiguredArchitecture object with knowledge of the ProcCertModel.
2224
# Needs a PortfolioGroup object so just create one with just one ProcCertModel (which is a child of Portfolio).
23-
cfg_arch = pf_create_cfg_arch(PortfolioGroup.new(model_name, [proc_cert_model_with_arch]))
25+
cfg_arch = pf_create_cfg_arch(PortfolioGroup.new(model_name, [proc_cert_model_with_arch]), bootstrap_cfg_arch.name)
2426

2527
$logger.info "Creating ProcCertModel with a ConfiguredArchitecture object for #{model_name}"
2628
proc_cert_model_with_cfg_arch = cfg_arch.proc_cert_model(model_name)

backends/proc_crd/tasks.rake

Lines changed: 57 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -7,63 +7,69 @@ require "pathname"
77
PROC_CRD_DOC_DIR = Pathname.new "#{$root}/backends/proc_crd"
88
PROC_CRD_GEN_DIR = $root / "gen" / "proc_crd"
99

10-
Dir.glob("#{$root}/arch/proc_cert_model/*.yaml") do |f|
11-
model_name = File.basename(f, ".yaml")
12-
model_obj = YAML.load_file(f, permitted_classes: [Date])
13-
class_name = File.basename(model_obj['class']['$ref'].split("#")[0], ".yaml")
14-
raise "Ill-formed processor certificate model file #{f}: missing 'class' field" if model_obj['class'].nil?
15-
16-
file "#{PROC_CRD_GEN_DIR}/adoc/#{model_name}-CRD.adoc" => [
17-
__FILE__,
18-
"#{$root}/arch/proc_cert_class/#{class_name}.yaml",
19-
"#{$root}/arch/proc_cert_model/#{model_name}.yaml",
20-
"#{$root}/lib/arch_obj_models/certificate.rb",
21-
"#{$root}/lib/arch_obj_models/portfolio.rb",
22-
"#{$root}/lib/portfolio_design.rb",
23-
"#{$root}/backends/portfolio/templates/ext_appendix.adoc.erb",
24-
"#{$root}/backends/portfolio/templates/inst_appendix.adoc.erb",
25-
"#{$root}/backends/portfolio/templates/csr_appendix.adoc.erb",
26-
"#{$root}/backends/portfolio/templates/beginning.adoc.erb",
27-
"#{$root}/backends/proc_cert/templates/typographic.adoc.erb",
28-
"#{$root}/backends/proc_cert/templates/rev_history.adoc.erb",
29-
"#{$root}/backends/proc_cert/templates/related_specs.adoc.erb",
30-
"#{$root}/backends/proc_cert/templates/priv_modes.adoc.erb",
31-
"#{$root}/backends/proc_cert/templates/rev_history.adoc.erb",
32-
"#{PROC_CRD_DOC_DIR}/templates/proc_crd.adoc.erb"
33-
] do |t|
34-
proc_cert_create_adoc("#{PROC_CRD_DOC_DIR}/templates/proc_crd.adoc.erb", t.name, model_name)
35-
end
10+
rule %r{#{PROC_CRD_GEN_DIR}/adoc/[^/]+-CRD.adoc} => [
11+
__FILE__,
12+
"#{$root}/lib/arch_obj_models/certificate.rb",
13+
"#{$root}/lib/arch_obj_models/portfolio.rb",
14+
"#{$root}/lib/portfolio_design.rb",
15+
"#{$root}/backends/portfolio/templates/ext_appendix.adoc.erb",
16+
"#{$root}/backends/portfolio/templates/inst_appendix.adoc.erb",
17+
"#{$root}/backends/portfolio/templates/csr_appendix.adoc.erb",
18+
"#{$root}/backends/portfolio/templates/beginning.adoc.erb",
19+
"#{$root}/backends/proc_cert/templates/typographic.adoc.erb",
20+
"#{$root}/backends/proc_cert/templates/rev_history.adoc.erb",
21+
"#{$root}/backends/proc_cert/templates/related_specs.adoc.erb",
22+
"#{$root}/backends/proc_cert/templates/priv_modes.adoc.erb",
23+
"#{$root}/backends/proc_cert/templates/rev_history.adoc.erb",
24+
"#{PROC_CRD_DOC_DIR}/templates/proc_crd.adoc.erb"
25+
] do |t|
26+
model_name = File.basename(t.name, ".adoc")[0...-4]
27+
proc_cert_create_adoc("#{PROC_CRD_DOC_DIR}/templates/proc_crd.adoc.erb", t.name, model_name, ENV["CONFIG"])
28+
end
3629

37-
file "#{PROC_CRD_GEN_DIR}/pdf/#{model_name}-CRD.pdf" => [
30+
rule %r{#{PROC_CRD_GEN_DIR}/pdf/[^/]+-CRD.pdf} => proc { |tname|
31+
model_name = File.basename(tname, ".pdf")[0...-4]
32+
[
3833
__FILE__,
3934
"#{PROC_CRD_GEN_DIR}/adoc/#{model_name}-CRD.adoc"
40-
] do |t|
41-
pf_adoc2pdf("#{PROC_CRD_GEN_DIR}/adoc/#{model_name}-CRD.adoc", t.name)
42-
end
35+
]
36+
} do |t|
37+
model_name = File.basename(t.name, ".pdf")[0...-4]
38+
pf_adoc2pdf("#{PROC_CRD_GEN_DIR}/adoc/#{model_name}-CRD.adoc", t.name)
39+
end
4340

44-
file "#{PROC_CRD_GEN_DIR}/html/#{model_name}-CRD.html" => [
41+
rule %r{#{PROC_CRD_GEN_DIR}/html/[^/]+-CRD.html"} => proc { |tname|
42+
model_name = File.basename(tname, ".html")[0...-4]
43+
[
4544
__FILE__,
4645
"#{PROC_CRD_GEN_DIR}/adoc/#{model_name}-CRD.adoc"
47-
] do |t|
48-
pf_adoc2html("#{PROC_CRD_GEN_DIR}/adoc/#{model_name}-CRD.adoc", t.name)
49-
end
46+
]
47+
} do |t|
48+
model_name = File.basename(t.name, ".html")[0...-4]
49+
pf_adoc2html("#{PROC_CRD_GEN_DIR}/adoc/#{model_name}-CRD.adoc", t.name)
5050
end
5151

5252
namespace :gen do
5353
desc <<~DESC
5454
Generate Processor CRD (Certification Requirements Document) as a PDF.
5555
5656
Required options:
57-
model_name - The name of the certification model under arch/proc_cert_model
57+
CONFIG - Configuration to use for base architecture
58+
MODE - The name of the certification model under arch/proc_cert_model
5859
DESC
59-
task :proc_crd_pdf, [:model_name] do |_t, args|
60-
model_name = args[:model_name]
60+
task :proc_crd_pdf do
61+
raise "Missing required argument 'CONFIG'" unless ENV.key?("CONFIG")
62+
raise "Missing required argument 'MODEL'" unless ENV.key?("MODEL")
63+
64+
model_name = ENV["MODEL"]
6165
if model_name.nil?
6266
warn "Missing required option: 'model_name'"
6367
exit 1
6468
end
6569

66-
unless File.exist?("#{$root}/arch/proc_cert_model/#{model_name}.yaml")
70+
cfg_arch = cfg_arch_for(ENV["CONFIG"])
71+
72+
unless cfg_arch.proc_cert_models.any? { |model| model.name == model_name }
6773
warn "No certification model named '#{model_name}' found in arch/proc_cert_model"
6874
exit 1
6975
end
@@ -75,19 +81,26 @@ namespace :gen do
7581
Generate Processor CRD (Certification Requirements Document) as an HTML file.
7682
7783
Required options:
78-
model_name - The name of the certification model under arch/proc_cert_model
84+
CONFIG - Configuration to use for base architecture
85+
MODE - The name of the certification model under arch/proc_cert_model
7986
DESC
80-
task :proc_crd_html, [:model_name] do |_t, args|
81-
if args[:model_name].nil?
87+
task :proc_crd_html do
88+
raise "Missing required argument 'CONFIG'" unless ENV.key?("CONFIG")
89+
raise "Missing required argument 'MODEL'" unless ENV.key?("MODEL")
90+
91+
model_name = ENV["MODEL"]
92+
if model_name.nil?
8293
warn "Missing required option: 'model_name'"
8394
exit 1
8495
end
8596

86-
unless File.exist?("#{$root}/arch/proc_cert_model/#{args[:model_name]}.yaml")
87-
warn "No certification model named '#{args[:model_name]}' found in arch/proc_cert_model"
97+
cfg_arch = cfg_arch_for(ENV["CONFIG"])
98+
99+
unless cfg_arch.proc_cert_models.any? { |model| model.name == model_name }
100+
warn "No certification model named '#{model_name}' found in arch/proc_cert_model"
88101
exit 1
89102
end
90103

91-
Rake::Task["#{PROC_CRD_GEN_DIR}/html/#{args[:model_name]}-CRD.html"].invoke
104+
Rake::Task["#{PROC_CRD_GEN_DIR}/html/#{model_name}-CRD.html"].invoke
92105
end
93106
end

0 commit comments

Comments
 (0)