Skip to content

Commit

Permalink
Merge branch 'main' into AFOliveira/fixZicsr
Browse files Browse the repository at this point in the history
  • Loading branch information
dhower-qc authored Nov 18, 2024
2 parents 0be3458 + 11b54fe commit afbf421
Show file tree
Hide file tree
Showing 12 changed files with 90 additions and 44 deletions.
3 changes: 2 additions & 1 deletion .devcontainer/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
FROM ubuntu:24.04 AS spython-base
RUN export DEBIAN_FRONTEND=noninteractive
RUN apt-get update
RUN apt-get install -y --no-install-recommends git
RUN apt-get install -y --no-install-recommends git gh
RUN apt-get install -y --no-install-recommends less
RUN apt-get install -y --no-install-recommends python3
RUN apt-get install -y --no-install-recommends python3.12-venv python3-pip
RUN apt-get install -y --no-install-recommends build-essential
Expand Down
2 changes: 1 addition & 1 deletion bin/.container-tag
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.2
0.3
6 changes: 6 additions & 0 deletions bin/bash
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#!/bin/bash

ROOT=$(dirname $(realpath $BASH_SOURCE[0]))
source $ROOT/setup

$BASH "$@"
2 changes: 1 addition & 1 deletion bin/node
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@
ROOT=$(dirname $(realpath $BASH_SOURCE[0]))
source $ROOT/setup

$NODE "$@"
$NODE "$@"
2 changes: 1 addition & 1 deletion bin/npx
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@
ROOT=$(dirname $(realpath $BASH_SOURCE[0]))
source $ROOT/setup

$NPX "$@"
$NPX "$@"
10 changes: 10 additions & 0 deletions bin/pip
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#!/bin/bash

ROOT=$(dirname $(realpath $BASH_SOURCE[0]))
source $ROOT/setup

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

$PIP "$@"
6 changes: 6 additions & 0 deletions bin/pre-commit
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#!/bin/bash

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

${ROOT}/bin/bash -c "source ${ROOT}/.home/.venv/bin/activate && pre-commit $@"

6 changes: 6 additions & 0 deletions bin/python
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#!/bin/bash

ROOT=$(dirname $(realpath $BASH_SOURCE[0]))
source $ROOT/setup

$PYTHON "$@"
2 changes: 1 addition & 1 deletion bin/ruby
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@
ROOT=$(dirname $(realpath $BASH_SOURCE[0]))
source $ROOT/setup

$RUBY "$@"
$RUBY "$@"
87 changes: 50 additions & 37 deletions bin/setup
Original file line number Diff line number Diff line change
Expand Up @@ -25,70 +25,83 @@ if [ -f $ROOT/.git ]; then
HOME_OPT="${HOME_OPT} --bind ${GIT_PATH}:${GIT_PATH}"
fi

if [ -v DEVCONTAINER_ENV ]; then
RUN=""
else
RUN="singularity run ${HOME_OPT} ${CONTAINER_PATH} "
fi

if [ ! -d $ROOT/.home ]; then
mkdir $ROOT/.home
fi

if [ ! -f ${CONTAINER_PATH} ]; then
echo "Fetching container..."
if [ ! -d "${ROOT}/.singularity" ]; then
mkdir -p ${ROOT}/.singularity
if [ ! -v DEVCONTAINER_ENV ]; then
if [ ! -f ${CONTAINER_PATH} ]; then
echo "Fetching container..."
if [ ! -d "${ROOT}/.singularity" ]; then
mkdir -p ${ROOT}/.singularity
fi
singularity pull ${SINGULARITY_CACHE} ${CONTAINER_PATH} oras://docker.io/riscvintl/spec-generator:$CONTAINER_TAG
fi
singularity pull ${SINGULARITY_CACHE} ${CONTAINER_PATH} oras://docker.io/riscvintl/spec-generator:$CONTAINER_TAG
fi

if [ ! -f $ROOT/.bundle/config ]; then
OLDDIR=$PWD
cd $ROOT
singularity run ${HOME_OPT} ${CONTAINER_PATH} bundle config set --local path ${ROOT}/.home/.gems
singularity run ${HOME_OPT} ${CONTAINER_PATH} bundle config set --local cache_path ${ROOT}/.home/.cache
${RUN} bundle config set --local path ${ROOT}/.home/.gems
${RUN} bundle config set --local cache_path ${ROOT}/.home/.cache
cd $OLDDIR
fi

if [ ! -d $ROOT/.home/.gems ]; then
OLDDIR=$PWD
cd $ROOT
singularity run ${HOME_OPT} ${CONTAINER_PATH} bundle install
${RUN} bundle install
cd $OLDDIR
fi

if [ ! -f $ROOT/ext/riscv-opcodes/README.md ]; then
git submodule update --init ext/riscv-opcodes
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

if [[ ! -z "$DEVELOPMENT" && $DEVELOPMENT -eq 1 ]]; then
if [ ! -d "${ROOT}/.home/.yard/gem_index"]; then
singularity run ${HOME_OPT} ${CONTAINER_PATH} bundle exec --gemfile ${ROOT}/Gemfile yard config --gem-install-yri
singularity run ${HOME_OPT} ${CONTAINER_PATH} bundle exec --gemfile ${ROOT}/Gemfile yard gems
${RUN} bundle exec --gemfile ${ROOT}/Gemfile yard config --gem-install-yri
${RUN} bundle exec --gemfile ${ROOT}/Gemfile yard gems
touch ${ROOT}/.stamps/dev_gems
fi
fi

if [[ ! -z "$VSCODE" && $VSCODE -eq 1 ]]; then
declare -a exts=(
castwide.solargraph,
redhat.vscode-yaml,
onnovalkering.vscode-singularity,
asciidoctor.asciidoctor-vscode
)
for ext in "${exts[@]}"; do
ignore=`code --list-extensions | grep "${ext}"`
if [ $? -eq 1 ]; then
echo "Installing VS Code extension ${ext}"
code --install-extension ${ext}
else
echo "Extension ${ext} already installed"
fi
done
fi

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

BUNDLE="singularity run ${HOME_OPT} ${CONTAINER_PATH} bundle"
RUBY="singularity run ${HOME_OPT} ${CONTAINER_PATH} bundle exec ruby"
RAKE="singularity run ${HOME_OPT} ${CONTAINER_PATH} bundle exec rake"
NPM="singularity run ${HOME_OPT} ${CONTAINER_PATH} npm"
NPX="singularity run ${HOME_OPT} ${CONTAINER_PATH} npx"
NODE="singularity run ${HOME_OPT} ${CONTAINER_PATH} node"
if [ -v DEVCONTAINER_ENV ]; then
BUNDLE="bundle"
RUBY="bundle exec ruby"
RAKE="bundle exec rake"
NPM="npm"
NPX="npx"
NODE="node"
PYTHON="python3"
PIP="${ROOT}/.home/.venv/bin/pip"
BASH="bash"
else
BUNDLE="singularity run ${HOME_OPT} ${CONTAINER_PATH} bundle"
RUBY="singularity run ${HOME_OPT} ${CONTAINER_PATH} bundle exec ruby"
RAKE="singularity run ${HOME_OPT} ${CONTAINER_PATH} bundle exec rake"
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} python3"
PIP="singularity run ${HOME_OPT} ${CONTAINER_PATH} ${ROOT}/.home/.venv/bin/pip"
BASH="singularity run ${HOME_OPT} ${CONTAINER_PATH} bash"
fi
6 changes: 4 additions & 2 deletions container.def
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,14 @@ From: ubuntu:24.04
# package.json $HOME/

%post
export DEBIAN_FRONTEND=noninteractive
export DEBIAN_FRONTEND=noninteractive

apt-get update

apt-get install -y --no-install-recommends git
apt-get install -y --no-install-recommends gh

apt-get install -y --no-install-recommends less

apt-get install -y --no-install-recommends python3
apt-get install -y --no-install-recommends python3.12-venv python3-pip
Expand All @@ -34,4 +37,3 @@ From: ubuntu:24.04

# npm i wavedrom-cli
# npm i i -E @antora/[email protected] @antora/[email protected] @antora/lunr-extension asciidoctor-kroki

2 changes: 2 additions & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
pre_commit==4.0.1
PyYAML==6.0.2

0 comments on commit afbf421

Please sign in to comment.