adding build.sh

This commit is contained in:
a-sansara 2017-04-30 02:16:30 +02:00
parent b1acee5292
commit 5fcea7dc9b
3 changed files with 113 additions and 89 deletions

118
dist/bes-build vendored
View File

@ -1,18 +1,56 @@
#!/bin/bash #!/bin/bash
bes.build(){
bes.echo.title "building project" "$APP_NAME"
if [ -d "$APP_DIR/src" ]; then
if [ ! -d "$APP_DIR/dist" ]; then
bes.echo.action "creating dist directory"
mkdir $APP_DIR/dist
bes.echo.state $?
fi
if [ -f "$APP_BIN" ]; then
bes.echo.action "removing ${Coff}dist/$APP_NAME${Coff}"
rm $APP_BIN
bes.echo.state $?
fi
echo "#!/bin/bash" > $APP_BIN
bes.echo.action "reading ${Coff}src/"
for entry in "$APP_DIR/src"/*.sh; do
if [ "$(basename $entry)" != "main.sh" ]; then
bes.echo " - appending ${Coff}src/$(basename $entry)"
tail -n +2 "$entry" >> "$APP_BIN"
fi
done
if [ -f "$APP_DIR/src/main.sh" ]; then
tail -n +2 "$APP_DIR/src/main.sh" >> "$APP_BIN"
bes.echo " - appending ${Coff}src/main.sh"
fi
bes.echo.state 0
bes.echo.action "set execution mode"
chmod +x $APP_BIN
bes.echo.state $?
else
bes.echo.error "no src/ directory. exit"
bes.echo.state 1
fi
echo
}
BES_TERM_WIDTH=105 BES_TERM_WIDTH=105
BES_NOCOLOR=0 BES_NOCOLOR=0
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
if [ "$BES_NOCOLOR" -eq 0 ]; then if [ "$BES_NOCOLOR" -eq 0 ]; then
Cok="\033[0;38;5;37m"; Cko="\033[0;38;5;217m" Cok="\033[0;38;5;37m"; Cko="\033[0;38;5;217m"
Coff="\033[m"; Ctitle="\033[1;48;5;23;1;38;5;15m" Coff="\033[m"; Ctitle="\033[1;48;5;23;1;38;5;15m"
Cspe="\033[1;38;5;223m"; Citem="\033[1;38;5;214m" Cdone="\033[1;48;5;36;1;38;5;15m"; Cfail="\033[1;48;5;196;1;38;5;15m"
Cval="\033[1;38;5;215m"; Cusa="\033[1;38;5;214m" Cspe="\033[1;38;5;223m"; Citem="\033[1;38;5;214m"
Cbra="\033[1;38;5;203m"; Crepo="\033[1;38;5;223m" Cval="\033[1;38;5;215m"; Cusa="\033[1;38;5;214m"
Cmeta="\033[1;38;5;30m"; Ctext="\033[1;38;5;30m" Cbra="\033[1;38;5;203m"; Crepo="\033[1;38;5;223m"
Copt="\033[1;38;5;81m"; Csep="\033[1;38;5;241m" Cmeta="\033[1;38;5;30m"; Ctext="\033[1;38;5;30m"
Cerr="\033[1;38;5;196m"; Ccom="\033[0;38;5;139m" Copt="\033[1;38;5;81m"; Csep="\033[1;38;5;241m"
Cerr="\033[1;38;5;196m"; Ccom="\033[0;38;5;139m"
Csection="\033[1;38;5;97m";
fi fi
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
bes.echo(){ bes.echo(){
@ -40,6 +78,11 @@ bes.echo.action(){
bes.echo "$1" 1 bes.echo "$1" 1
} }
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
bes.echo.title(){
bes.echo " ${Cspe}☪ ${Csection}$1 ${Copt}$2${Coff}"
echo
}
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
bes.echo.keyval(){ bes.echo.keyval(){
local c=': ' local c=': '
if [ ! "$BES_NOCOLOR" = 1 ]; then if [ ! "$BES_NOCOLOR" = 1 ]; then
@ -49,10 +92,12 @@ bes.echo.keyval(){
} }
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
bes.echo.state(){ bes.echo.state(){
local len=8
printf "%0.s " $(seq 1 $(($BES_TERM_WIDTH-${len})))
if [ "$1" = 0 ]; then if [ "$1" = 0 ]; then
echo " done !" echo -e "${Cdone} OK ${Coff}"
else else
echo " fail !" echo -e "${Cfail} KO ${Coff}"
fi fi
} }
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
@ -84,45 +129,18 @@ bes.title(){
} }
BES_BUILD_VERSION=0.2 BES_BUILD_VERSION=0.2
APP_DIR=$(pwd)
APP_NAME=$(basename $(pwd))
APP_BIN=$APP_DIR/dist/$APP_NAME
bes.title 'bes-build' $BES_BUILD_VERSION bes.main(){
bes.title 'bes-build' $BES_BUILD_VERSION
echo
if [ "$1" = "install" ]; then
bes.install
elif [ -z "$1" ]; then
bes.build "$1"
fi
}
APP_DIR=$(pwd) bes.main $*
APP_NAME=$(basename $(pwd))
APP_BIN=$APP_DIR/dist/$APP_NAME
echo
bes.echo " ${Cspe}building project ${Copt}$APP_NAME${Coff}" 0
echo
if [ -d "$APP_DIR/src" ]; then
if [ ! -d "$APP_DIR/dist" ]; then
bes.echo.action "creating dist directory"
mkdir $APP_DIR/dist
bes.echo.state $?
fi
if [ -f "$APP_BIN" ]; then
bes.echo.action "removing ${Coff}dist/$APP_NAME${Coff}"
rm $APP_BIN
bes.echo.state $?
fi
echo "#!/bin/bash" > $APP_BIN
bes.echo.action "reading ${Coff}src/"
for entry in "$APP_DIR/src"/*.sh; do
if [ "$(basename $entry)" != "main.sh" ]; then
bes.echo " - appending ${Coff}src/$(basename $entry)"
tail -n +2 "$entry" >> "$APP_BIN"
fi
done
if [ -f "$APP_DIR/src/main.sh" ]; then
tail -n +2 "$APP_DIR/src/main.sh" >> "$APP_BIN"
bes.echo " - appending ${Coff}src/main.sh"
fi
bes.echo.state 0
bes.echo.action "set execution mode"
chmod +x $APP_BIN
bes.echo.state $?
else
bes.echo.error "no src/ directory. exit"
bes.echo.state 1
fi
echo

37
src/build.sh Normal file
View File

@ -0,0 +1,37 @@
#!/bin/bash
bes.build(){
bes.echo.title "building project" "$APP_NAME"
if [ -d "$APP_DIR/src" ]; then
if [ ! -d "$APP_DIR/dist" ]; then
bes.echo.action "creating dist directory"
mkdir $APP_DIR/dist
bes.echo.state $?
fi
if [ -f "$APP_BIN" ]; then
bes.echo.action "removing ${Coff}dist/$APP_NAME${Coff}"
rm $APP_BIN
bes.echo.state $?
fi
echo "#!/bin/bash" > $APP_BIN
bes.echo.action "reading ${Coff}src/"
for entry in "$APP_DIR/src"/*.sh; do
if [ "$(basename $entry)" != "main.sh" ]; then
bes.echo " - appending ${Coff}src/$(basename $entry)"
tail -n +2 "$entry" >> "$APP_BIN"
fi
done
if [ -f "$APP_DIR/src/main.sh" ]; then
tail -n +2 "$APP_DIR/src/main.sh" >> "$APP_BIN"
bes.echo " - appending ${Coff}src/main.sh"
fi
bes.echo.state 0
bes.echo.action "set execution mode"
chmod +x $APP_BIN
bes.echo.state $?
else
bes.echo.error "no src/ directory. exit"
bes.echo.state 1
fi
echo
}

View File

@ -1,49 +1,18 @@
#!/bin/bash #!/bin/bash
BES_BUILD_VERSION=0.2 BES_BUILD_VERSION=0.2
APP_DIR=$(pwd)
bes.title 'bes-build' $BES_BUILD_VERSION APP_NAME=$(basename $(pwd))
APP_BIN=$APP_DIR/dist/$APP_NAME
APP_DIR=$(pwd)
APP_NAME=$(basename $(pwd))
APP_BIN=$APP_DIR/dist/$APP_NAME
bes.main(){ bes.main(){
bes.title 'bes-build' $BES_BUILD_VERSION
echo echo
bes.echo.title "building project" "$APP_NAME" if [ "$1" = "install" ]; then
if [ -d "$APP_DIR/src" ]; then bes.install
if [ ! -d "$APP_DIR/dist" ]; then elif [ -z "$1" ]; then
bes.echo.action "creating dist directory" bes.build "$1"
mkdir $APP_DIR/dist
bes.echo.state $?
fi
if [ -f "$APP_BIN" ]; then
bes.echo.action "removing ${Coff}dist/$APP_NAME${Coff}"
rm $APP_BIN
bes.echo.state $?
fi
echo "#!/bin/bash" > $APP_BIN
bes.echo.action "reading ${Coff}src/"
for entry in "$APP_DIR/src"/*.sh; do
if [ "$(basename $entry)" != "main.sh" ]; then
bes.echo " - appending ${Coff}src/$(basename $entry)"
tail -n +2 "$entry" >> "$APP_BIN"
fi
done
if [ -f "$APP_DIR/src/main.sh" ]; then
tail -n +2 "$APP_DIR/src/main.sh" >> "$APP_BIN"
bes.echo " - appending ${Coff}src/main.sh"
fi
bes.echo.state 0
bes.echo.action "set execution mode"
chmod +x $APP_BIN
bes.echo.state $?
else
bes.echo.error "no src/ directory. exit"
bes.echo.state 1
fi fi
echo
} }
bes.main $* bes.main $*