Skip to content
Merged
Show file tree
Hide file tree
Changes from 11 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@
"zhwu95.riscv",
"mathematic.vscode-pdf",
"CraigMaslowski.erb",
"HowerLimited.udb-extension-pack-vscode"
"HowerLimited.udb-extension-pack-vscode",
"sorbet.sorbet-vscode-extension"
]
}
},
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,4 @@ __pycache__/
.pytest_cache/
*.bak
*.log
sorbet
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,6 @@
[submodule "ext/riscv-tests"]
path = ext/riscv-tests
url = https://github.com/riscv-software-src/riscv-tests.git
[submodule "ext/rbi-central"]
path = ext/rbi-central
url = https://github.com/Shopify/rbi-central
1 change: 1 addition & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,7 @@ repos:
rev: v5.0.2
hooks:
- id: reuse-lint-file
exclude: COMMIT_EDITMSG

- repo: https://github.com/alessandrojcm/commitlint-pre-commit-hook
rev: v9.22.0
Expand Down
10 changes: 10 additions & 0 deletions .sorbet-config
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
--dir
lib
--dir
sorbet/rbi
--file
Rakefile
--file
backends/ext_pdf_doc/idl_lexer.rb
--file
backends/cpp_hart_gen/lib/template_helpers.rb
27 changes: 27 additions & 0 deletions .tapioca-config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
gem:
outdir: .home/.sorbet/rbi/gems
file_header: true
exclude:
[
rdoc,
asciidoctor-pdf,
solargraph,
webrick,
ttfunk,
tapioca,
rubocop,
rubocop-minitest,
spoom,
rdbg,
parser,
]
dsl:
outdir: .home/.sorbet/rbi/dsl
# Add your `dsl` command parameters here:
#
# exclude:
# - SomeGeneratorName
# workers: 5
annotations:
sources:
- ext/rbi-central
4 changes: 4 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ gem "pygments.rb"
gem "rake", "~> 13.0"
gem "rouge"
gem "ruby-progressbar", "~> 1.13"
gem "sorbet-runtime"
gem "treetop", "1.6.12"
gem "ttfunk", "1.7" # needed to avoid having asciidoctor-pdf dependencies pulling in a buggy version of ttunk (1.8)
gem "webrick"
Expand All @@ -31,4 +32,7 @@ group :development do
gem "ruby-prof"
gem "ruby-prof-flamegraph", git: "https://github.com/oozou/ruby-prof-flamegraph.git", ref: "fc3c437", require: false
gem "solargraph"
gem "sorbet"
gem "spoom"
gem "tapioca", require: false
end
38 changes: 38 additions & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ GEM
reline (>= 0.3.8)
diff-lcs (1.6.0)
drb (2.2.1)
erubi (1.13.1)
hana (1.3.7)
hashery (2.1.2)
i18n (1.14.7)
Expand All @@ -89,6 +90,7 @@ GEM
logger (1.6.6)
matrix (0.4.2)
minitest (5.25.5)
netrc (0.11.0)
nkf (0.2.0)
nokogiri (1.18.6-aarch64-linux-gnu)
racc (~> 1.4)
Expand Down Expand Up @@ -126,6 +128,7 @@ GEM
pdf-reader (~> 2.0)
prawn (~> 2.2)
prettyprint (0.2.0)
prism (1.4.0)
psych (5.2.3)
date
stringio
Expand All @@ -134,6 +137,10 @@ GEM
racc (1.8.1)
rainbow (3.1.1)
rake (13.2.1)
rbi (0.3.1)
prism (~> 1.0)
rbs (>= 3.4.4)
sorbet-runtime (>= 0.5.9204)
rbs (3.9.1)
logger
rdbg (0.1.0)
Expand Down Expand Up @@ -189,7 +196,31 @@ GEM
tilt (~> 2.0)
yard (~> 0.9, >= 0.9.24)
yard-solargraph (~> 0.1)
sorbet (0.5.11966)
sorbet-static (= 0.5.11966)
sorbet-runtime (0.5.11966)
sorbet-static (0.5.11966-aarch64-linux)
sorbet-static (0.5.11966-x86_64-linux)
sorbet-static-and-runtime (0.5.11966)
sorbet (= 0.5.11966)
sorbet-runtime (= 0.5.11966)
spoom (1.6.1)
erubi (>= 1.10.0)
prism (>= 0.28.0)
rbi (>= 0.2.3)
sorbet-static-and-runtime (>= 0.5.10187)
thor (>= 0.19.2)
stringio (3.1.5)
tapioca (0.16.11)
benchmark
bundler (>= 2.2.25)
netrc (>= 0.11.0)
parallel (>= 1.21.0)
rbi (~> 0.2)
sorbet-static-and-runtime (>= 0.5.11087)
spoom (>= 1.2.0)
thor (>= 1.2.0)
yard-sorbet
thor (1.3.2)
tilt (2.6.0)
treetop (1.6.12)
Expand All @@ -208,6 +239,9 @@ GEM
yard (0.9.37)
yard-solargraph (0.1.0)
yard (~> 0.9)
yard-sorbet (0.9.0)
sorbet-runtime
yard

PLATFORMS
aarch64-linux-gnu
Expand All @@ -234,6 +268,10 @@ DEPENDENCIES
ruby-prof-flamegraph!
ruby-progressbar (~> 1.13)
solargraph
sorbet
sorbet-runtime
spoom
tapioca
treetop (= 1.6.12)
ttfunk (= 1.7)
webrick
Expand Down
41 changes: 27 additions & 14 deletions Rakefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
# frozen_string_literal: true
# typed: true

require "sorbet-runtime"
T.bind(self, T.all(Rake::DSL, Object))
extend T::Sig

Encoding.default_external = "UTF-8"

Expand Down Expand Up @@ -37,8 +42,8 @@ directory "#{$root}/.stamps"

# @param config_locator [String or Pathname]
# @return [ConfiguredArchitecture]
sig { params(config_locator: T.any(String, Pathname)).returns(ConfiguredArchitecture) }
def cfg_arch_for(config_locator)
raise ArgumentError, "expecting String or Pathname" unless config_locator.is_a?(String) || config_locator.is_a?(Pathname)
config_locator = config_locator.to_s

$cfg_archs ||= {}
Expand Down Expand Up @@ -163,6 +168,11 @@ namespace :serve do
end
end

sig { params(test_files: T::Array[String]).returns(String) }
def make_test_cmd(test_files)
"-Ilib:test -w -e 'require \"minitest/autorun\"; #{test_files.map{ |f| "require \"#{f}\""}.join("; ")}' --"
end

namespace :test do

# "Run the cross-validation against LLVM"
Expand All @@ -175,18 +185,20 @@ namespace :test do
end
# "Run the IDL compiler test suite"
task :idl_compiler do
t = Minitest::TestTask.new(:lib_test)
t.test_globs = ["#{$root}/lib/idl/tests/test_*.rb"]
t.process_env
ruby t.make_test_cmd
test_files = Dir["#{$root}/lib/idl/tests/test_*.rb"]
ruby make_test_cmd(test_files)
end

# "Run the Ruby library test suite"
task :lib do
t = Minitest::TestTask.new(:lib_test)
t.test_globs = ["#{$root}/lib/test/test_*.rb"]
t.process_env
ruby t.make_test_cmd
test_files = Dir["#{$root}/lib/test/test_*.rb"]

ruby make_test_cmd(test_files)
end

desc "Type-check the Ruby library"
task :sorbet do
sh "srb tc @.sorbet-config"
end
end

Expand All @@ -208,13 +220,13 @@ namespace :test do

cfg_arch = cfg_arch_for("_")
insts = cfg_arch.instructions
failed = false
failed = T.let(false, T::Boolean)
insts.each_with_index do |inst, idx|
[32, 64].each do |xlen|
next unless inst.defined_in_base?(xlen)

(idx...insts.size).each do |other_idx|
other_inst = insts[other_idx]
other_inst = T.must(insts[other_idx])
next unless other_inst.defined_in_base?(xlen)
next if other_inst == inst

Expand All @@ -236,13 +248,13 @@ namespace :test do

cfg_arch = cfg_arch_for("_")
csrs = cfg_arch.csrs
failed = false
failed = T.let(false, T::Boolean)
csrs.each_with_index do |csr, idx|
[32, 64].each do |xlen|
next unless csr.defined_in_base?(xlen)

(idx...csrs.size).each do |other_idx|
other_csr = csrs[other_idx]
other_csr = T.must(csrs[other_idx])
next unless other_csr.defined_in_base?(xlen)
next if other_csr == csr

Expand Down Expand Up @@ -287,7 +299,6 @@ def insert_warning(str, from)
first_line = lines.shift
lines.unshift(first_line, "\n# WARNING: This file is auto-generated from #{Pathname.new(from).relative_path_from($root)}").join("")
end
private :insert_warning

(3..31).each do |hpm_num|
file "#{$root}/arch/csr/Zihpm/mhpmcounter#{hpm_num}.yaml" => [
Expand Down Expand Up @@ -440,6 +451,8 @@ namespace :test do
Rake::Task["test:idl_compiler"].invoke
$logger.info "Running test:lib"
Rake::Task["test:lib"].invoke
$logger.info "UPDATE: Running test:sorbet"
Rake::Task["test:sorbet"].invoke
$logger.info "Running test:schema"
Rake::Task["test:schema"].invoke
$logger.info "Running test:idl"
Expand Down
4 changes: 0 additions & 4 deletions backends/cpp_hart_gen/templates/csrs_impl.hxx.erb
Original file line number Diff line number Diff line change
Expand Up @@ -56,11 +56,7 @@ void <%= name_of(:csr_field, cfg_arch, csr.name, field.name) %><SocType>::reset(
<%- end -%>
<%- else -%>
auto val_fn = [this]() ->
<%- if field.could_be_undefined? -%>
PossiblyUnknownBits<<%= max_width + 1 %>>
<%- else -%>
Bits<<%= max_width + 1 %>>
<%- end -%>
{
<%= ast.gen_cpp(cfg_arch.symtab, 8) %>
};
Expand Down
3 changes: 0 additions & 3 deletions backends/ext_pdf_doc/tasks.rake
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,6 @@

require "pathname"

require "asciidoctor-pdf"
require "asciidoctor-diagram"

require_relative "#{$lib}/idl/passes/gen_adoc"

EXT_PDF_DOC_DIR = Pathname.new "#{$root}/backends/ext_pdf_doc"
Expand Down
2 changes: 0 additions & 2 deletions backends/portfolio/tasks.rake
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@
# Contains common methods called from portfolio-based tasks.rake files.

require "pathname"
require "asciidoctor-pdf"
require "asciidoctor-diagram"
require_relative "#{$lib}/idl/passes/gen_adoc"

# @return [Architecture]
Expand Down
2 changes: 0 additions & 2 deletions backends/proc_cert/tasks.rake
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@
# Contains common methods called from certification backend tasks.rake files.

require "pathname"
require "asciidoctor-pdf"
require "asciidoctor-diagram"

# @param erb_template_pname [String] Path to ERB template file
# @param target_pname [String] Full name of adoc file being generated
Expand Down
9 changes: 8 additions & 1 deletion bin/clobber
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,11 @@

ROOT=$(dirname $(dirname $(realpath ${BASH_SOURCE[0]})))

rm -rf ${ROOT}/.stamps ${ROOT}/.home ${ROOT}/.bundle ${ROOT}/.singularity ${ROOT}/gen ${ROOT}/node_modules
rm -rf \
${ROOT}/.stamps \
${ROOT}/.home \
${ROOT}/.bundle \
${ROOT}/.singularity \
${ROOT}/gen \
${ROOT}/node_modules \
${ROOT}/sorbet
17 changes: 17 additions & 0 deletions bin/setup
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,23 @@ if [ ! -d $ROOT/.home/.gems ]; then
cd $OLDDIR
fi

if [ ! -f $ROOT/ext/rbi-central/README.md ]; then
git submodule update --init ext/rbi-central
fi

if [ ! -d $ROOT/.home/.sorbet ]; then
mkdir .home/.sorbet
ln -s .home/.sorbet sorbet
cd .home/.sorbet
ln -s ../../.sorbet-config config
cd $ROOT
${RUN} bundle exec tapioca init -c ${ROOT}/.tapioca-config.yml
${RUN} bundle exec tapioca dsl -c ${ROOT}/.tapioca-config.yml
cd .home/.sorbet/rbi/dsl
ln -s ${ROOT}/lib/architecture.rbi
cd $ROOT
fi

if [ ! -d $ROOT/.home/.venv ]; then
${RUN} /usr/bin/python3 -m venv ${ROOT}/.home/.venv
fi
Expand Down
27 changes: 27 additions & 0 deletions bin/tapioca
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#!/usr/bin/env ruby3.2
# frozen_string_literal: true

#
# This file was generated by Bundler.
#
# The application 'tapioca' is installed as part of a gem, and
# this file is here to facilitate running it.
#

ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../Gemfile", __dir__)

bundle_binstub = File.expand_path("bundle", __dir__)

if File.file?(bundle_binstub)
if File.read(bundle_binstub, 300).include?("This file was generated by Bundler")
load(bundle_binstub)
else
abort("Your `bin/bundle` was not generated by Bundler, so this binstub cannot run.
Replace `bin/bundle` by running `bundle binstubs bundler --force`, then run this command again.")
end
end

require "rubygems"
require "bundler/setup"

load Gem.bin_path("tapioca", "tapioca")
1 change: 1 addition & 0 deletions ext/rbi-central
Submodule rbi-central added at 46f1b5
Loading
Loading