Skip to content
Merged
Show file tree
Hide file tree
Changes from 6 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
15 changes: 15 additions & 0 deletions .devcontainer/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -42,4 +42,19 @@ RUN apt-get clean autoclean
RUN apt-get autoremove -y
RUN rm -rf /var/lib/{apt,dpkg,cache,log}/*

# Create Python virtual environment and install packages
COPY requirements.txt /tmp/requirements.txt
RUN /usr/bin/python3 -m venv /opt/venv && \
/opt/venv/bin/pip install -r /tmp/requirements.txt && \
rm /tmp/requirements.txt
ENV PATH="/opt/venv/bin:$PATH"

# Install npm packages globally in the container
COPY package.json package-lock.json /opt/node/
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

with the npm install happening in the container now, shouldn't we drop package-lock.json from the repo entirely? It's not going to be kept up to date since npm no longer runs at the root

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm installing packages using npm ci right now, which uses the versions from package-lock.json. We were previously using npm i which didn't actually fix the versions. I'd be in favor of marinating the lock file so that all of the dependencies are clear.

It might make sense to enable Dependabot for npm packages so that we get automatically get PRs to bump them.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See #1229

RUN cd /opt/node && \
/usr/bin/npm ci && \
rm /opt/node/package.json /opt/node/package-lock.json
ENV NODE_PATH="/opt/node/node_modules"
ENV PATH="/opt/node/node_modules/.bin:$PATH"

WORKDIR /workspace
2 changes: 1 addition & 1 deletion .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "RISC-V UnifiedDB Dev",
"build": { "dockerfile": "Dockerfile" },
"build": { "dockerfile": "Dockerfile", "context": ".." },
"updateContentCommand": "${containerWorkspaceFolder}/.devcontainer/updateContentCommand.sh",
"onCreateCommand": "${containerWorkspaceFolder}/.devcontainer/onCreateCommand.sh",
"remoteEnv": {
Expand Down
1 change: 0 additions & 1 deletion .devcontainer/onCreateCommand.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
#!/bin/bash

npm i
bundle install
2 changes: 1 addition & 1 deletion Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ namespace :test do
# "Run the cross-validation against LLVM"
task :llvm do
begin
sh "#{$root}/.home/.venv/bin/python3 -m pytest ext/auto-inst/test_parsing.py -v"
sh "/opt/venv/bin/python3 -m pytest ext/auto-inst/test_parsing.py -v"
rescue => e
raise unless e.message.include?("status (5)") # don't fail on skipped tests
end
Expand Down
11 changes: 5 additions & 6 deletions backends/cfg_html_doc/html_gen.rake
Original file line number Diff line number Diff line change
Expand Up @@ -119,9 +119,9 @@ rule %r{#{$root}/gen/cfg_html_doc/.*/antora/playbook.yaml} => proc { |tname|
snapshot: true
supplemental_files:
- path: css/vendor/tabs.css
contents: #{$root}/node_modules/@asciidoctor/tabs/dist/css/tabs.css
contents: /opt/node/node_modules/@asciidoctor/tabs/dist/css/tabs.css
- path: js/vendor/tabs.js
contents: #{$root}/node_modules/@asciidoctor/tabs/dist/js/tabs.js
contents: /opt/node/node_modules/@asciidoctor/tabs/dist/js/tabs.js
- path: partials/footer-scripts.hbs
contents: |
<script id="site-script" src="{{{uiRootPath}}}/js/site.js" data-ui-root-path="{{{uiRootPath}}}"></script>
Expand Down Expand Up @@ -234,10 +234,9 @@ rule %r{#{$root}/\.stamps/html-gen-.*\.stamp} => proc { |tname|
playbook_path = $root / "gen" / "cfg_html_doc" / config_name / "antora" / "playbook.yaml"
Rake::Task[playbook_path].invoke

$logger.info "Running Antora under npm to create #{config_name}"

$logger.info "Running Antora to create #{config_name}"
sh [
"npm exec -- antora",
"/opt/node/node_modules/.bin/antora",
"--stacktrace",
"generate",
"--cache-dir=#{$root}/.home/.antora",
Expand All @@ -247,7 +246,7 @@ rule %r{#{$root}/\.stamps/html-gen-.*\.stamp} => proc { |tname|
playbook_path
].join(" ")

$logger.info "Done running Antora under npm to create #{config_name}"
$logger.info "Done running Antora to create #{config_name}"

FileUtils.touch t.name
end
Expand Down
4 changes: 2 additions & 2 deletions backends/ext_pdf_doc/tasks.rake
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ rule %r{#{$resolver.gen_path}/ext_pdf_doc/.*/pdf/.*_extension\.pdf} => proc { |t
"-a pdf-theme=#{ENV['THEME']}",
"-a pdf-fontsdir=#{$root}/ext/docs-resources/fonts",
"-a imagesdir=#{$root}/ext/docs-resources/images",
"-a wavedrom=#{$root}/node_modules/.bin/wavedrom-cli",
"-a wavedrom=/opt/node/node_modules/.bin/wavedrom-cli",
"-r asciidoctor-diagram",
"-r idl_highlighter",
"-o #{t.name}",
Expand Down Expand Up @@ -63,7 +63,7 @@ rule %r{#{$resolver.gen_path}/ext_pdf_doc/.*/html/.*_extension\.html} => proc {
"-v",
"-a toc",
"-r asciidoctor-diagram",
"-a wavedrom=#{$root}/node_modules/.bin/wavedrom-cli",
"-a wavedrom=/opt/node/node_modules/.bin/wavedrom-cli",
"-o #{t.name}",
adoc_file
].join(" ")
Expand Down
8 changes: 4 additions & 4 deletions backends/generators/tasks.rake
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,9 @@ namespace :gen do
inst_dir = cfg_arch.path / "inst"
csr_dir = cfg_arch.path / "csr"

# Run the Go generator script using the same Python environment
# Run the Go generator script
# Note: The script uses --output not --output-dir
sh "#{$root}/.home/.venv/bin/python3 #{$root}/backends/generators/Go/go_generator.py --inst-dir=#{inst_dir} --csr-dir=#{csr_dir} --output=#{output_dir}inst.go"
sh "/opt/venv/bin/python3 #{$root}/backends/generators/Go/go_generator.py --inst-dir=#{inst_dir} --csr-dir=#{csr_dir} --output=#{output_dir}inst.go"
end

desc <<~DESC
Expand Down Expand Up @@ -79,9 +79,9 @@ namespace :gen do
resolved_codes_file.flush

begin
# Run the C header generator script using the same Python environment
# Run the C header generator script
# The script generates encoding.h for inclusion in C programs
sh "#{$root}/.home/.venv/bin/python3 #{$root}/backends/generators/c_header/generate_encoding.py --inst-dir=#{inst_dir} --csr-dir=#{csr_dir} --ext-dir=#{ext_dir} --resolved-codes=#{resolved_codes_file.path} --output=#{output_dir}encoding.out.h --include-all"
sh "/opt/venv/bin/python3 #{$root}/backends/generators/c_header/generate_encoding.py --inst-dir=#{inst_dir} --csr-dir=#{csr_dir} --ext-dir=#{ext_dir} --resolved-codes=#{resolved_codes_file.path} --output=#{output_dir}encoding.out.h --include-all"
ensure
resolved_codes_file.close
resolved_codes_file.unlink
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
= Instruction Appendix
:doctype: book
:wavedrom: /workspaces/riscv-unified-db/node_modules/.bin/wavedrom-cli
:wavedrom: /opt/node/node_modules/.bin/wavedrom-cli
// Now the document header is complete and the wavedrom attribute is active.


Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
= Instruction Appendix
:doctype: book
:wavedrom: <%= $root %>/node_modules/.bin/wavedrom-cli
:wavedrom: /opt/node/node_modules/.bin/wavedrom-cli
// Now the document header is complete and the wavedrom attribute is active.

<% instructions.sort_by(&:name).each do |inst| %>
Expand Down
6 changes: 3 additions & 3 deletions backends/manual/tasks.rake
Original file line number Diff line number Diff line change
Expand Up @@ -434,10 +434,10 @@ namespace :gen do
playbook_path = MANUAL_GEN_DIR / ENV["MANUAL_NAME"] / "top" / output_hash / "antora" / "playbook" / "playbook.yml"
Rake::Task[playbook_path].invoke

$logger.info "Running Antora under npm for HTML site to create '#{MANUAL_GEN_DIR / ENV['MANUAL_NAME'] / output_hash / 'html'}'"
$logger.info "Running Antora for HTML site to create '#{MANUAL_GEN_DIR / ENV['MANUAL_NAME'] / output_hash / 'html'}'"

sh [
"npm exec -- antora",
"/opt/node/node_modules/.bin/antora",
"--stacktrace",
"generate",
"--cache-dir=#{$root}/.home/.antora",
Expand All @@ -447,7 +447,7 @@ namespace :gen do
playbook_path.to_s
].join(" ")

$logger.info "Done running Antora under npm for HTML site to create '#{MANUAL_GEN_DIR / ENV['MANUAL_NAME'] / output_hash / 'html'}'"
$logger.info "Done running Antora for HTML site to create '#{MANUAL_GEN_DIR / ENV['MANUAL_NAME'] / output_hash / 'html'}'"
end
end

Expand Down
4 changes: 2 additions & 2 deletions backends/manual/templates/playbook.yml.erb
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,9 @@ ui:
snapshot: true
supplemental_files:
- path: css/vendor/tabs.css
contents: <%= $root %>/node_modules/@asciidoctor/tabs/dist/css/tabs.css
contents: /opt/node/node_modules/@asciidoctor/tabs/dist/css/tabs.css
- path: js/vendor/tabs.js
contents: <%= $root %>/node_modules/@asciidoctor/tabs/dist/js/tabs.js
contents: /opt/node/node_modules/@asciidoctor/tabs/dist/js/tabs.js
- path: partials/footer-scripts.hbs
contents: |
<script id="site-script" src="{{{uiRootPath}}}/js/site.js" data-ui-root-path="{{{uiRootPath}}}"></script>
Expand Down
4 changes: 2 additions & 2 deletions backends/portfolio/tasks.rake
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ def pf_adoc2pdf(adoc_file, target_pname)
"-a pdf-theme=#{$root}/ext/docs-resources/themes/riscv-pdf.yml",
"-a pdf-fontsdir=#{$root}/ext/docs-resources/fonts",
"-a imagesdir=#{$root}/ext/docs-resources/images",
"-a bytefield-svg=#{$root}/node_modules/.bin/bytefield-svg",
"-a bytefield-svg=/opt/node/node_modules/.bin/bytefield-svg",
"-r asciidoctor-diagram",
"-r idl_highlighter",
"-o #{target_pname}",
Expand Down Expand Up @@ -135,7 +135,7 @@ def pf_adoc2html(adoc_file, target_pname)
"-v",
"-a toc",
"-a imagesdir=#{$root}/ext/docs-resources/images",
"-a bytefield-svg=#{$root}/node_modules/.bin/bytefield-svg",
"-a bytefield-svg=/opt/node/node_modules/.bin/bytefield-svg",
"-r asciidoctor-diagram",
"-r idl_highlighter",
"-o #{target_pname}",
Expand Down
2 changes: 1 addition & 1 deletion backends/portfolio/templates/beginning.adoc.erb
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
// Settings
:experimental:
:reproducible:
:wavedrom: <%= $root %>/node_modules/.bin/wavedrom-cli
:wavedrom: /opt/node/node_modules/.bin/wavedrom-cli
// TODO: needs to be changed
:imagesoutdir: images
:icons: font
Expand Down
4 changes: 2 additions & 2 deletions backends/prm_pdf/templates/prm_main.adoc.erb
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@
:pdf-themesdir: <%= @prm_pdf_dir / 'pdf-theme' %>
:pdf-theme: custom
:title-logo-image: image:<%= @prm_pdf_dir / 'pdf-theme' / 'logo.svg' %>[top=10%,align=left,pdfwidth=4in]
<%- wavedrom_path = @root_path / "node_modules/.bin/wavedrom-cli" -%>
<%- wavedrom_path = Pathname.new("/opt/node") / "node_modules/.bin/wavedrom-cli" -%>
<%- if File.exist?(wavedrom_path) -%>
:wavedrom: <%= wavedrom_path %>
<%- end -%>
<%- bytefield_path = @root_path / "node_modules/.bin/bytefield-svg" -%>
<%- bytefield_path = Pathname.new("/opt/node") / "node_modules/.bin/bytefield-svg" -%>
<%- if File.exist?(bytefield_path) -%>
:bytefield-svg: <%= bytefield_path %>
<%- end -%>
Expand Down
1 change: 0 additions & 1 deletion bin/clobber
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,4 @@ rm -rf \
${ROOT}/.bundle \
${ROOT}/.singularity \
${ROOT}/gen \
${ROOT}/node_modules \
${ROOT}/sorbet
4 changes: 0 additions & 4 deletions bin/pip
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,4 @@
ROOT=$(dirname $(realpath ${BASH_SOURCE[0]}))
source $ROOT/setup

if [ ! -v VIRTUAL_ENV ]; then
source ${ROOT}/.home/.venv/bin/activate
fi

$PIP "$@"
26 changes: 6 additions & 20 deletions bin/setup
Original file line number Diff line number Diff line change
Expand Up @@ -197,16 +197,6 @@ if [ ! -f $ROOT/ext/rbi-central/README.md ]; then
git submodule update --init ext/rbi-central
fi

if [ ! -d $ROOT/.home/.venv ]; then
${RUN} /usr/bin/python3 -m venv ${ROOT}/.home/.venv
fi

source ${ROOT}/.home/.venv/bin/activate

if [ ! -f ${ROOT}/.home/.venv/bin/pre-commit ]; then
${RUN} ${ROOT}/.home/.venv/bin/pip install -r requirements.txt
fi

# if [ ! -f $ROOT/ext/riscv-opcodes/README.md ]; then
# git submodule update --init ext/riscv-opcodes
# fi
Expand All @@ -219,19 +209,15 @@ if [[ ! -z "$DEVELOPMENT" && $DEVELOPMENT -eq 1 ]]; then
fi
fi

if [ ! -d ${ROOT}/node_modules ]; then
${RUN} npm i
fi

if [ "${CONTAINER_TYPE}" == "devcontainer" ]; then
BUNDLE="bundle"
RUBY="bundle exec ruby"
RAKE="bundle exec rake"
NPM="npm"
NPX="npx"
NODE="node"
PYTHON="${ROOT}/.home/.venv/bin/python3"
PIP="${ROOT}/.home/.venv/bin/pip"
PYTHON="/opt/venv/bin/python3"
PIP="/opt/venv/bin/pip"
BASH="bash"
GPP="g++"
GDB="gdb"
Expand All @@ -245,8 +231,8 @@ elif [ "${CONTAINER_TYPE}" == "docker" -o "${CONTAINER_TYPE}" == "podman" ]; the
NPM="${CONTAINER_BASE} npm"
NPX="${CONTAINER_BASE} npx"
NODE="${CONTAINER_BASE} node"
PYTHON="${CONTAINER_BASE} ${ROOT}/.home/.venv/bin/python3"
PIP="${CONTAINER_BASE} ${ROOT}/.home/.venv/bin/pip"
PYTHON="${CONTAINER_BASE} /opt/venv/bin/python3"
PIP="${CONTAINER_BASE} /opt/venv/bin/pip"
BASH="${CONTAINER_BASE} bash"
GPP="${CONTAINER_BASE} g++"
GDB="${CONTAINER_BASE} gdb"
Expand All @@ -260,8 +246,8 @@ elif [ "${CONTAINER_TYPE}" == "singularity" ]; then
NPM="singularity run ${HOME_OPT} ${CONTAINER_PATH} npm"
NPX="singularity run ${HOME_OPT} ${CONTAINER_PATH} npx"
NODE="singularity run ${HOME_OPT} ${CONTAINER_PATH} node"
PYTHON="singularity run ${HOME_OPT} ${CONTAINER_PATH} ${ROOT}/.home/.venv/bin/python3"
PIP="singularity run ${HOME_OPT} ${CONTAINER_PATH} ${ROOT}/.home/.venv/bin/pip"
PYTHON="singularity run ${HOME_OPT} ${CONTAINER_PATH} /opt/venv/bin/python3"
PIP="singularity run ${HOME_OPT} ${CONTAINER_PATH} /opt/venv/bin/pip"
BASH="singularity run ${HOME_OPT} ${CONTAINER_PATH} bash"
GPP="singularity run ${HOME_OPT} ${CONTAINER_PATH} g++"
GDB="singularity run ${HOME_OPT} ${CONTAINER_PATH} gdb"
Expand Down
23 changes: 17 additions & 6 deletions container.def
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
Bootstrap: docker
From: ubuntu:24.04

# %files

# Gemfile $HOME/
# package.json $HOME/
%files
requirements.txt /opt/requirements.txt
package.json /opt/node/package.json
package-lock.json /opt/node/package-lock.json

%post
export DEBIAN_FRONTEND=noninteractive
Expand Down Expand Up @@ -46,8 +46,19 @@ From: ubuntu:24.04
apt-get autoremove -y
rm -rf /var/lib/{apt, dpkg, cache, log}

# Create Python virtual environment and install packages
/usr/bin/python3 -m venv /opt/venv
/opt/venv/bin/pip install -r /opt/requirements.txt
rm /opt/requirements.txt

# Install npm packages globally in the container
cd /opt/node
/usr/bin/npm ci
rm /opt/node/package.json /opt/node/package-lock.json

# cd $HOME
# bundle install

# npm i wavedrom-cli
# npm i i -E @antora/[email protected] @antora/[email protected] @antora/lunr-extension asciidoctor-kroki
%environment
export PATH="/opt/venv/bin:/opt/node/node_modules/.bin:$PATH"
export NODE_PATH="/opt/node/node_modules"
Loading
Loading