From 8bbb261fabb28ebd79997902178b28ef66884866 Mon Sep 17 00:00:00 2001 From: "Taihsiang Ho (tai271828)" Date: Sat, 5 Jun 2021 10:37:08 +0200 Subject: [PATCH 1/2] feat(launch): init support of launching applications issue: #26 --- applications/solvcon/prepare-solvcon-dev.sh | 17 ++++++++++++++++- bin/devenv | 11 ++++++----- scripts/application.d/solvcon | 21 +++++++++++++++++++++ scripts/cmd.d/launch | 17 +++++++++++++++++ scripts/func.d/bash_utils | 3 +++ scripts/init | 5 +++++ 6 files changed, 68 insertions(+), 6 deletions(-) create mode 100644 scripts/application.d/solvcon create mode 100644 scripts/cmd.d/launch diff --git a/applications/solvcon/prepare-solvcon-dev.sh b/applications/solvcon/prepare-solvcon-dev.sh index 578fe34..df9475a 100755 --- a/applications/solvcon/prepare-solvcon-dev.sh +++ b/applications/solvcon/prepare-solvcon-dev.sh @@ -6,7 +6,14 @@ # source # set -x -SOLVCON_PROJECT=${1:-${HOME}/solvcon} + +if [ -z "${DEVENVFLAVOR}" ] +then + SOLVCON_PROJECT=${1:-${HOME}/solvcon} +else + SOLVCON_PROJECT=${1:-${DEVENVAPPLICATION}} +fi + SCSRC="${SOLVCON_PROJECT}/solvcon" SCSRC_WORKING="${SOLVCON_PROJECT}/solvcon-working" SCDE_SRC=${SCDE_SRC:-${SOLVCON_PROJECT}/devenv} @@ -78,3 +85,11 @@ pushd ${SCSRC}/sandbox/gas/tube ./go run popd + +# A workaround to use packages built or managed by conda. We could abandon +# this workaround when devenv is fully integrated and used for SOLVCON +echo "Re-launch SOLVCON by the following commands:" +echo "" +echo "export PATH="${SCSRC}:${MINICONDA_DIR}/bin:${PATH}"" +echo "" + diff --git a/bin/devenv b/bin/devenv index 297c904..1b16313 100755 --- a/bin/devenv +++ b/bin/devenv @@ -21,11 +21,12 @@ Description: devenv management tool Commands: -add - create a new devenv environment -use - select an environment to use -del - delete an environment directory -off - deactivate environment -build - build applications" +add - create a new devenv environment +use - select an environment to use +del - delete an environment directory +off - deactivate environment +build - build package +launch - launch application" else display -e "Unrecognized command line argument: '${cmd}'" fi diff --git a/scripts/application.d/solvcon b/scripts/application.d/solvcon new file mode 100644 index 0000000..f2a91e5 --- /dev/null +++ b/scripts/application.d/solvcon @@ -0,0 +1,21 @@ +#!/usr/bin/env bash + +set -e + +application_name=solvcon +application_branch=${VERSION:-master} +application_full=$application_name-$application_branch +application_src=${DEVENVROOT}/flavors/${DEVENVFLAVOR}/src/${application_full} + +syncgit https://github.com/solvcon ${application_name} ${application_branch} + +export DEVENVAPPLICATION=${DEVENVROOT}/flavors/${DEVENVFLAVOR}/application-${application_name} +mkdir -p ${DEVENVAPPLICATION} + +ln -s ${application_src} ${DEVENVAPPLICATION}/${application_name} + + +echo "launching solvcon..." +${DEVENVROOT}/bin/build-application-solvcon-devenv.sh + +# vim: set et nobomb ft=bash ff=unix fenc=utf8: diff --git a/scripts/cmd.d/launch b/scripts/cmd.d/launch new file mode 100644 index 0000000..ba45771 --- /dev/null +++ b/scripts/cmd.d/launch @@ -0,0 +1,17 @@ +. ${DEVENVROOT}/scripts/func.d/bash_utils + +script="${DEVENVROOT}/scripts/application.d/$1" +if [ ! -f "${script}" ]; then + display -e "'$1' not defined" +fi + +if [ -z "${DEVENVFLAVOR}" ] ; then + display -e "\$DEVENVFLAVOR not defined" +fi + +. ${DEVENVROOT}/scripts/func.d/build_utils +display "Execute building script \"${script}\" ${@:$(($#+1))} ..." +. ${script} +display "Finished building script \"${script}\"." + +# vim: set et nu nobomb fenc=utf8 ft=sh ff=unix sw=2 ts=2: diff --git a/scripts/func.d/bash_utils b/scripts/func.d/bash_utils index 42564c4..70ddde3 100644 --- a/scripts/func.d/bash_utils +++ b/scripts/func.d/bash_utils @@ -18,6 +18,9 @@ get_list() { build) dir="${DEVENVROOT}/scripts/build.d" ;; + applicatioin) + dir="${DEVENVROOT}/scripts/application.d" + ;; cmd) dir="${DEVENVROOT}/scripts/cmd.d" ;; diff --git a/scripts/init b/scripts/init index 8a877b4..224350f 100644 --- a/scripts/init +++ b/scripts/init @@ -52,6 +52,11 @@ _devenv() { COMPREPLY=( $(compgen -W "$(get_list build)" -- ${cur}) ) return 0 ;; + launch) + [[ $COMP_CWORD > 2 ]] && return 1 + COMPREPLY=( $(compgen -W "$(get_list application)" -- ${cur}) ) + return 0 + ;; *) [[ $COMP_CWORD > 1 ]] && return 1 cmds=$(get_list cmd) From 6e92061016c0fafbb574dc1469ee07009048f1e5 Mon Sep 17 00:00:00 2001 From: "Taihsiang Ho (tai271828)" Date: Sun, 6 Jun 2021 09:47:31 +0200 Subject: [PATCH 2/2] refactor: fixup of typo and rename DEVENVAPPLICATION to DEVENVAPP --- applications/solvcon/prepare-solvcon-dev.sh | 2 +- scripts/application.d/solvcon | 6 +++--- scripts/func.d/bash_utils | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/applications/solvcon/prepare-solvcon-dev.sh b/applications/solvcon/prepare-solvcon-dev.sh index df9475a..2715e9c 100755 --- a/applications/solvcon/prepare-solvcon-dev.sh +++ b/applications/solvcon/prepare-solvcon-dev.sh @@ -11,7 +11,7 @@ if [ -z "${DEVENVFLAVOR}" ] then SOLVCON_PROJECT=${1:-${HOME}/solvcon} else - SOLVCON_PROJECT=${1:-${DEVENVAPPLICATION}} + SOLVCON_PROJECT=${1:-${DEVENVAPP}} fi SCSRC="${SOLVCON_PROJECT}/solvcon" diff --git a/scripts/application.d/solvcon b/scripts/application.d/solvcon index f2a91e5..282cc0a 100644 --- a/scripts/application.d/solvcon +++ b/scripts/application.d/solvcon @@ -9,10 +9,10 @@ application_src=${DEVENVROOT}/flavors/${DEVENVFLAVOR}/src/${application_full} syncgit https://github.com/solvcon ${application_name} ${application_branch} -export DEVENVAPPLICATION=${DEVENVROOT}/flavors/${DEVENVFLAVOR}/application-${application_name} -mkdir -p ${DEVENVAPPLICATION} +export DEVENVAPP=${DEVENVROOT}/flavors/${DEVENVFLAVOR}/application-${application_name} +mkdir -p ${DEVENVAPP} -ln -s ${application_src} ${DEVENVAPPLICATION}/${application_name} +ln -s ${application_src} ${DEVENVAPP}/${application_name} echo "launching solvcon..." diff --git a/scripts/func.d/bash_utils b/scripts/func.d/bash_utils index 70ddde3..faa40fb 100644 --- a/scripts/func.d/bash_utils +++ b/scripts/func.d/bash_utils @@ -18,7 +18,7 @@ get_list() { build) dir="${DEVENVROOT}/scripts/build.d" ;; - applicatioin) + application) dir="${DEVENVROOT}/scripts/application.d" ;; cmd)