printf
This commit is contained in:
parent
01ce7c6a45
commit
0b610276d1
@ -2,14 +2,14 @@
|
|||||||
|
|
||||||
tabs 4
|
tabs 4
|
||||||
TASK=$1
|
TASK=$1
|
||||||
myprintf "${CYAN}===========[$TASK]===========\n"
|
printf "${CYAN}===========[$TASK]===========\n"
|
||||||
source cbuild/init.sh
|
source cbuild/init.sh
|
||||||
|
|
||||||
#pre_build
|
#pre_build
|
||||||
clear_dir $OBJDIR
|
clear_dir $OBJDIR
|
||||||
clear_dir $OUTDIR
|
clear_dir $OUTDIR
|
||||||
if [ -f "$PRE_BUILD_SCRIPT" ]; then
|
if [ -f "$PRE_BUILD_SCRIPT" ]; then
|
||||||
myprintf "${BLUE}executing $PRE_BUILD_SCRIPT"
|
printf "${BLUE}executing $PRE_BUILD_SCRIPT"
|
||||||
source "$PRE_BUILD_SCRIPT"
|
source "$PRE_BUILD_SCRIPT"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|||||||
40
functions.sh
40
functions.sh
@ -1,22 +1,22 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
function clear_dir {
|
function clear_dir {
|
||||||
myprintf "${BLUE}clearing $1\n"
|
printf "${BLUE}clearing $1\n"
|
||||||
rm -rf $1
|
rm -rf $1
|
||||||
mkdir $1
|
mkdir $1
|
||||||
}
|
}
|
||||||
|
|
||||||
function compile {
|
function compile {
|
||||||
local cmp=$1
|
local cmp=$1
|
||||||
myprintf "${BLUE}compiler: ${GRAY}$cmp\n"
|
printf "${BLUE}compiler: ${GRAY}$cmp\n"
|
||||||
local std=$2
|
local std=$2
|
||||||
myprintf "${BLUE}standard: ${GRAY}$std\n"
|
printf "${BLUE}standard: ${GRAY}$std\n"
|
||||||
local warn=$3
|
local warn=$3
|
||||||
myprintf "${BLUE}warnings: ${GRAY}$warn\n"
|
printf "${BLUE}warnings: ${GRAY}$warn\n"
|
||||||
local args=$4
|
local args=$4
|
||||||
myprintf "${BLUE}args: ${GRAY}$args\n"
|
printf "${BLUE}args: ${GRAY}$args\n"
|
||||||
local sources=$5
|
local sources=$5
|
||||||
myprintf "${BLUE}sources: ${GRAY}$sources\n"
|
printf "${BLUE}sources: ${GRAY}$sources\n"
|
||||||
local compilation_error=0
|
local compilation_error=0
|
||||||
|
|
||||||
for srcfile in $sources
|
for srcfile in $sources
|
||||||
@ -24,7 +24,7 @@ function compile {
|
|||||||
local object="$OBJDIR/$(basename $srcfile).o"
|
local object="$OBJDIR/$(basename $srcfile).o"
|
||||||
if ! $($cmp -std=$std $warn $args -c -o $object $srcfile)
|
if ! $($cmp -std=$std $warn $args -c -o $object $srcfile)
|
||||||
then
|
then
|
||||||
myprintf "${RED}some error happened\n"
|
printf "${RED}some error happened\n"
|
||||||
compilation_error=1
|
compilation_error=1
|
||||||
fi
|
fi
|
||||||
) & done
|
) & done
|
||||||
@ -38,49 +38,49 @@ function compile {
|
|||||||
|
|
||||||
# (args, sources)
|
# (args, sources)
|
||||||
function compile_c {
|
function compile_c {
|
||||||
myprintf "${CYAN}-------------[compile_c]--------------\n"
|
printf "${CYAN}-------------[compile_c]--------------\n"
|
||||||
compile $CMP_C $STD_C "$WARN_C" "$1" "$2"
|
compile $CMP_C $STD_C "$WARN_C" "$1" "$2"
|
||||||
}
|
}
|
||||||
|
|
||||||
# (args, sources)
|
# (args, sources)
|
||||||
function compile_cpp {
|
function compile_cpp {
|
||||||
myprintf "${CYAN}------------[compile_cpp]-------------\n"
|
printf "${CYAN}------------[compile_cpp]-------------\n"
|
||||||
compile $CMP_CPP $STD_CPP "$WARN_CPP" "$1" "$2"
|
compile $CMP_CPP $STD_CPP "$WARN_CPP" "$1" "$2"
|
||||||
}
|
}
|
||||||
|
|
||||||
# (args, outfile)
|
# (args, outfile)
|
||||||
function link {
|
function link {
|
||||||
myprintf "${CYAN}----------------[link]----------------\n"
|
printf "${CYAN}----------------[link]----------------\n"
|
||||||
local args=$1
|
local args=$1
|
||||||
myprintf "${BLUE}args: ${GRAY}$args\n"
|
printf "${BLUE}args: ${GRAY}$args\n"
|
||||||
local outfile=$OUTDIR/$2
|
local outfile=$OUTDIR/$2
|
||||||
myprintf "${BLUE}outfile: ${GRAY}$outfile\n"
|
printf "${BLUE}outfile: ${GRAY}$outfile\n"
|
||||||
local objects="$(find $OBJDIR -name '*.o')
|
local objects="$(find $OBJDIR -name '*.o')
|
||||||
$(find $OBJDIR -name '*.a')"
|
$(find $OBJDIR -name '*.a')"
|
||||||
myprintf "${BLUE}objects: ${GRAY}$objects\n"
|
printf "${BLUE}objects: ${GRAY}$objects\n"
|
||||||
if $CMP_CPP $args -o $outfile $(echo $objects | tr '\n' ' ')
|
if $CMP_CPP $args -o $outfile $(echo $objects | tr '\n' ' ')
|
||||||
then
|
then
|
||||||
myprintf "${GREEN}file $CYAN$outfile ${GREEN}created\n"
|
printf "${GREEN}file $CYAN$outfile ${GREEN}created\n"
|
||||||
rm -rf $OBJDIR
|
rm -rf $OBJDIR
|
||||||
else
|
else
|
||||||
myprintf "${RED}some error happened\n"
|
printf "${RED}some error happened\n"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
# (outfile)
|
# (outfile)
|
||||||
function pack_static_lib {
|
function pack_static_lib {
|
||||||
myprintf "${CYAN}----------------[link]----------------\n"
|
printf "${CYAN}----------------[link]----------------\n"
|
||||||
local outfile=$OUTDIR/$1
|
local outfile=$OUTDIR/$1
|
||||||
myprintf "${BLUE}outfile: ${GRAY}$outfile\n"
|
printf "${BLUE}outfile: ${GRAY}$outfile\n"
|
||||||
local objects="$(find $OBJDIR -name *.o)"
|
local objects="$(find $OBJDIR -name *.o)"
|
||||||
myprintf "${BLUE}objects: ${GRAY}$objects\n"
|
printf "${BLUE}objects: ${GRAY}$objects\n"
|
||||||
if ar rcs $outfile $(echo $objects | tr '\n' ' ')
|
if ar rcs $outfile $(echo $objects | tr '\n' ' ')
|
||||||
then
|
then
|
||||||
myprintf "${GREEN}file $CYAN$outfile ${GREEN}created\n"
|
printf "${GREEN}file $CYAN$outfile ${GREEN}created\n"
|
||||||
rm -rf $OBJDIR
|
rm -rf $OBJDIR
|
||||||
else
|
else
|
||||||
myprintf "${RED}some error happened\n"
|
printf "${RED}some error happened\n"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|||||||
10
init.sh
10
init.sh
@ -9,12 +9,12 @@ function create_default_config(){
|
|||||||
else
|
else
|
||||||
cp cbuild/default.config .config
|
cp cbuild/default.config .config
|
||||||
fi
|
fi
|
||||||
myprintf "${YELLOW}Default config created.\nEdit it.\n"
|
printf "${YELLOW}Default config created.\nEdit it.\n"
|
||||||
}
|
}
|
||||||
|
|
||||||
#.config
|
#.config
|
||||||
if [ ! -f ".config" ]; then
|
if [ ! -f ".config" ]; then
|
||||||
myprintf "${YELLOW}./.config doesn't exist\n"
|
printf "${YELLOW}./.config doesn't exist\n"
|
||||||
create_default_config
|
create_default_config
|
||||||
exit
|
exit
|
||||||
fi
|
fi
|
||||||
@ -22,9 +22,9 @@ source .config
|
|||||||
|
|
||||||
#version check
|
#version check
|
||||||
if [ ! $CONFIG_VER -eq 2 ]; then
|
if [ ! $CONFIG_VER -eq 2 ]; then
|
||||||
myprintf "${RED}Your config version isn't correct\n"
|
printf "${RED}Your config version isn't correct\n"
|
||||||
while true; do
|
while true; do
|
||||||
myprintf "${WHITE}Backup current config and create default one? (y/n) "
|
printf "${WHITE}Backup current config and create default one? (y/n) "
|
||||||
read answ
|
read answ
|
||||||
case $answ in
|
case $answ in
|
||||||
[Yy] )
|
[Yy] )
|
||||||
@ -32,7 +32,7 @@ if [ ! $CONFIG_VER -eq 2 ]; then
|
|||||||
create_default_config
|
create_default_config
|
||||||
exit;;
|
exit;;
|
||||||
[Nn] ) exit;;
|
[Nn] ) exit;;
|
||||||
* ) myprintf "${RED}incorrect answer\n";;
|
* ) printf "${RED}incorrect answer\n";;
|
||||||
esac
|
esac
|
||||||
done
|
done
|
||||||
fi
|
fi
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user