@@ -25,70 +25,83 @@ if [ -f $ROOT/.git ]; then
2525 HOME_OPT=" ${HOME_OPT} --bind ${GIT_PATH} :${GIT_PATH} "
2626fi
2727
28+ if [ -v DEVCONTAINER_ENV ]; then
29+ RUN=" "
30+ else
31+ RUN=" singularity run ${HOME_OPT} ${CONTAINER_PATH} "
32+ fi
33+
2834if [ ! -d $ROOT /.home ]; then
2935 mkdir $ROOT /.home
3036fi
3137
32- if [ ! -f ${CONTAINER_PATH} ]; then
33- echo " Fetching container..."
34- if [ ! -d " ${ROOT} /.singularity" ]; then
35- mkdir -p ${ROOT} /.singularity
38+ if [ ! -v DEVCONTAINER_ENV ]; then
39+ if [ ! -f ${CONTAINER_PATH} ]; then
40+ echo " Fetching container..."
41+ if [ ! -d " ${ROOT} /.singularity" ]; then
42+ mkdir -p ${ROOT} /.singularity
43+ fi
44+ singularity pull ${SINGULARITY_CACHE} ${CONTAINER_PATH} oras://docker.io/riscvintl/spec-generator:$CONTAINER_TAG
3645 fi
37- singularity pull ${SINGULARITY_CACHE} ${CONTAINER_PATH} oras://docker.io/riscvintl/spec-generator:$CONTAINER_TAG
3846fi
3947
4048if [ ! -f $ROOT /.bundle/config ]; then
4149 OLDDIR=$PWD
4250 cd $ROOT
43- singularity run ${HOME_OPT} ${CONTAINER_PATH } bundle config set --local path ${ROOT} /.home/.gems
44- singularity run ${HOME_OPT} ${CONTAINER_PATH } bundle config set --local cache_path ${ROOT} /.home/.cache
51+ ${RUN } bundle config set --local path ${ROOT} /.home/.gems
52+ ${RUN } bundle config set --local cache_path ${ROOT} /.home/.cache
4553 cd $OLDDIR
4654fi
4755
4856if [ ! -d $ROOT /.home/.gems ]; then
4957 OLDDIR=$PWD
5058 cd $ROOT
51- singularity run ${HOME_OPT} ${CONTAINER_PATH } bundle install
59+ ${RUN } bundle install
5260 cd $OLDDIR
5361fi
5462
55- if [ ! -f $ROOT /ext/riscv-opcodes/README.md ]; then
56- git submodule update --init ext/riscv-opcodes
63+ if [ ! -d $ROOT /.home/.venv ]; then
64+ ${RUN} /usr/bin/python3 -m venv ${ROOT} /.home/.venv
65+ fi
66+ source ${ROOT} /.home/.venv/bin/activate
67+ if [ ! -f ${ROOT} /.home/.venv/bin/pre-commit ]; then
68+ ${RUN} ${ROOT} /.home/.venv/bin/pip install -r requirements.txt
5769fi
5870
71+ # if [ ! -f $ROOT/ext/riscv-opcodes/README.md ]; then
72+ # git submodule update --init ext/riscv-opcodes
73+ # fi
74+
5975if [[ ! -z " $DEVELOPMENT " && $DEVELOPMENT -eq 1 ]]; then
6076 if [ ! -d " ${ROOT} /.home/.yard/gem_index" ]; then
61- singularity run ${HOME_OPT} ${CONTAINER_PATH } bundle exec --gemfile ${ROOT} /Gemfile yard config --gem-install-yri
62- singularity run ${HOME_OPT} ${CONTAINER_PATH } bundle exec --gemfile ${ROOT} /Gemfile yard gems
77+ ${RUN } bundle exec --gemfile ${ROOT} /Gemfile yard config --gem-install-yri
78+ ${RUN } bundle exec --gemfile ${ROOT} /Gemfile yard gems
6379 touch ${ROOT} /.stamps/dev_gems
6480 fi
6581fi
6682
67- if [[ ! -z " $VSCODE " && $VSCODE -eq 1 ]]; then
68- declare -a exts=(
69- castwide.solargraph,
70- redhat.vscode-yaml,
71- onnovalkering.vscode-singularity,
72- asciidoctor.asciidoctor-vscode
73- )
74- for ext in " ${exts[@]} " ; do
75- ignore=` code --list-extensions | grep " ${ext} " `
76- if [ $? -eq 1 ]; then
77- echo " Installing VS Code extension ${ext} "
78- code --install-extension ${ext}
79- else
80- echo " Extension ${ext} already installed"
81- fi
82- done
83- fi
84-
8583if [ ! -d ${ROOT} /node_modules ]; then
86- singularity run ${HOME_OPT} ${CONTAINER_PATH } npm i
84+ ${RUN } npm i
8785fi
8886
89- BUNDLE=" singularity run ${HOME_OPT} ${CONTAINER_PATH} bundle"
90- RUBY=" singularity run ${HOME_OPT} ${CONTAINER_PATH} bundle exec ruby"
91- RAKE=" singularity run ${HOME_OPT} ${CONTAINER_PATH} bundle exec rake"
92- NPM=" singularity run ${HOME_OPT} ${CONTAINER_PATH} npm"
93- NPX=" singularity run ${HOME_OPT} ${CONTAINER_PATH} npx"
94- NODE=" singularity run ${HOME_OPT} ${CONTAINER_PATH} node"
87+ if [ -v DEVCONTAINER_ENV ]; then
88+ BUNDLE=" bundle"
89+ RUBY=" bundle exec ruby"
90+ RAKE=" bundle exec rake"
91+ NPM=" npm"
92+ NPX=" npx"
93+ NODE=" node"
94+ PYTHON=" python3"
95+ PIP=" ${ROOT} /.home/.venv/bin/pip"
96+ BASH=" bash"
97+ else
98+ BUNDLE=" singularity run ${HOME_OPT} ${CONTAINER_PATH} bundle"
99+ RUBY=" singularity run ${HOME_OPT} ${CONTAINER_PATH} bundle exec ruby"
100+ RAKE=" singularity run ${HOME_OPT} ${CONTAINER_PATH} bundle exec rake"
101+ NPM=" singularity run ${HOME_OPT} ${CONTAINER_PATH} npm"
102+ NPX=" singularity run ${HOME_OPT} ${CONTAINER_PATH} npx"
103+ NODE=" singularity run ${HOME_OPT} ${CONTAINER_PATH} node"
104+ PYTHON=" singularity run ${HOME_OPT} ${CONTAINER_PATH} python3"
105+ PIP=" singularity run ${HOME_OPT} ${CONTAINER_PATH} ${ROOT} /.home/.venv/bin/pip"
106+ BASH=" singularity run ${HOME_OPT} ${CONTAINER_PATH} bash"
107+ fi
0 commit comments