--new-project
This commit is contained in:
parent
0ebc1c47ee
commit
fc833508b8
15
.gitignore
vendored
15
.gitignore
vendored
@ -1,8 +1,6 @@
|
|||||||
# build results
|
# build results
|
||||||
bin/
|
bin/
|
||||||
obj/
|
obj/
|
||||||
*.log
|
|
||||||
*.tmp
|
|
||||||
|
|
||||||
# IDE files
|
# IDE files
|
||||||
.vs/
|
.vs/
|
||||||
@ -11,6 +9,17 @@ obj/
|
|||||||
*.user
|
*.user
|
||||||
*.vcxproj.filters
|
*.vcxproj.filters
|
||||||
|
|
||||||
|
# local cbuild config giles
|
||||||
|
current.config
|
||||||
|
*.current.config
|
||||||
|
|
||||||
# other files
|
# other files
|
||||||
.old*/
|
.old*/
|
||||||
current.config
|
old/
|
||||||
|
tmp/
|
||||||
|
temp/
|
||||||
|
*.tmp
|
||||||
|
*.temp
|
||||||
|
logs/
|
||||||
|
log/
|
||||||
|
*.log
|
||||||
|
|||||||
@ -1,3 +1,9 @@
|
|||||||
|
# HEAD
|
||||||
|
+ fixed bugs in `myprint.sh`
|
||||||
|
+ fixed bugs in `--new-project`
|
||||||
|
+ updated `.gitignore`
|
||||||
|
+ added `pwd` call to `valgrind` task in config
|
||||||
|
|
||||||
# 2.0.0
|
# 2.0.0
|
||||||
+ updated setup.sh to do system-wide installation
|
+ updated setup.sh to do system-wide installation
|
||||||
+ deleted makefile (call `./cbuild.sh` or installed `cbuild`)
|
+ deleted makefile (call `./cbuild.sh` or installed `cbuild`)
|
||||||
|
|||||||
31
cbuild.sh
31
cbuild.sh
@ -30,7 +30,7 @@ include "cbuild/myprint.sh"
|
|||||||
include "cbuild/functions.sh"
|
include "cbuild/functions.sh"
|
||||||
include "cbuild/config.sh"
|
include "cbuild/config.sh"
|
||||||
|
|
||||||
function print_help_and_exit {
|
function print_help {
|
||||||
myprint "cbuild v$INSTALLED_CBUILD_VERSION"
|
myprint "cbuild v$INSTALLED_CBUILD_VERSION"
|
||||||
myprint "C/C++ project build system written in bash."
|
myprint "C/C++ project build system written in bash."
|
||||||
myprint "Usage: cbuild [OPTIONS] [TASK]"
|
myprint "Usage: cbuild [OPTIONS] [TASK]"
|
||||||
@ -39,17 +39,16 @@ function print_help_and_exit {
|
|||||||
myprint " -n, --new-project [PROJ_DIR] Initialize new cbuild project directory (default=./)"
|
myprint " -n, --new-project [PROJ_DIR] Initialize new cbuild project directory (default=./)"
|
||||||
myprint " -c, --current-config FILE Set current config file path (default=./current.config)"
|
myprint " -c, --current-config FILE Set current config file path (default=./current.config)"
|
||||||
myprint " -d, --default-config FILE Set default config file path (default=./current.config)"
|
myprint " -d, --default-config FILE Set default config file path (default=./current.config)"
|
||||||
exit 0
|
|
||||||
}
|
}
|
||||||
|
|
||||||
current_config_path="./current.config"
|
current_config_path="./current.config"
|
||||||
default_config_path="./default.config"
|
default_config_path="./default.config"
|
||||||
args=($@)
|
args=($@)
|
||||||
args_len=${#args[@]}
|
args_count=${#args[@]}
|
||||||
selected_tasks_array=()
|
selected_tasks_array=()
|
||||||
i=0
|
i=0
|
||||||
if [ $args_len -eq 0 ]; then
|
if [ $args_count -eq 0 ]; then
|
||||||
print_help_and_exit
|
print_help
|
||||||
fi
|
fi
|
||||||
|
|
||||||
function get_next_arg {
|
function get_next_arg {
|
||||||
@ -57,15 +56,14 @@ function get_next_arg {
|
|||||||
safeprint "${args[i]}"
|
safeprint "${args[i]}"
|
||||||
}
|
}
|
||||||
|
|
||||||
while [ $i -lt $args_len ]
|
while [ $i -lt $args_count ]
|
||||||
do
|
do
|
||||||
case "${args[i]}" in
|
case "${args[i]}" in
|
||||||
'-h' | '--help')
|
'-h' | '--help')
|
||||||
print_help_and_exit
|
print_help
|
||||||
;;
|
;;
|
||||||
'-v' | '--version')
|
'-v' | '--version')
|
||||||
myprint $INSTALLED_CBUILD_VERSION
|
myprint $INSTALLED_CBUILD_VERSION
|
||||||
exit 0
|
|
||||||
;;
|
;;
|
||||||
'-c' | '--current-config')
|
'-c' | '--current-config')
|
||||||
i=$((i+1))
|
i=$((i+1))
|
||||||
@ -84,8 +82,9 @@ do
|
|||||||
|
|
||||||
if ask_yn "create default.config?"; then
|
if ask_yn "create default.config?"; then
|
||||||
cp "$CBUILD_INSTALL_DIR/default.config" "$new_project_dir"
|
cp "$CBUILD_INSTALL_DIR/default.config" "$new_project_dir"
|
||||||
project_name="$(ask 'Enter project name')"
|
myprint "Enter project name: "
|
||||||
sed -i "s,\%PROJECT_NAME\%,$project_name,g"
|
read -r project_name
|
||||||
|
sed -i "s,\%PROJECT_NAME\%,$project_name,g" "default.config"
|
||||||
fi
|
fi
|
||||||
if ask_yn "Copy default .gitignore?"; then
|
if ask_yn "Copy default .gitignore?"; then
|
||||||
cp "$CBUILD_INSTALL_DIR/.gitignore" "$new_project_dir"
|
cp "$CBUILD_INSTALL_DIR/.gitignore" "$new_project_dir"
|
||||||
@ -129,9 +128,14 @@ function call_tasks {
|
|||||||
print_hline "${WHITE}" "═"
|
print_hline "${WHITE}" "═"
|
||||||
}
|
}
|
||||||
|
|
||||||
time call_tasks "${selected_tasks_array[@]}" #2>&1 | tee cbuild.log
|
selected_tasks_count=${#selected_tasks_array[@]}
|
||||||
# remove terminal escape codes
|
if [ $selected_tasks_count -gt 0 ]; then
|
||||||
sed -e 's/[^[:blank:][:print:]]//g' \
|
time call_tasks "${selected_tasks_array[@]}" #2>&1 | tee cbuild.log
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ -f cbuild.log ]; then
|
||||||
|
# remove terminal escape codes
|
||||||
|
sed -e 's/[^[:blank:][:print:]]//g' \
|
||||||
-e 's/\[0;[0-9][0-9]m//g' \
|
-e 's/\[0;[0-9][0-9]m//g' \
|
||||||
-e 's/\[0;[0-9]m//g' \
|
-e 's/\[0;[0-9]m//g' \
|
||||||
-e 's/\[[0-9][0-9]m//g' \
|
-e 's/\[[0-9][0-9]m//g' \
|
||||||
@ -139,3 +143,4 @@ sed -e 's/[^[:blank:][:print:]]//g' \
|
|||||||
-e 's/ H //g' \
|
-e 's/ H //g' \
|
||||||
-e 's/\[3gH //g' \
|
-e 's/\[3gH //g' \
|
||||||
-i cbuild.log
|
-i cbuild.log
|
||||||
|
fi
|
||||||
@ -116,7 +116,7 @@ case "$TASK" in
|
|||||||
;;
|
;;
|
||||||
# executes $EXEC_FILE with valgrind memory checker
|
# executes $EXEC_FILE with valgrind memory checker
|
||||||
valgrind)
|
valgrind)
|
||||||
VALGRIND_ARGS="-s --read-var-info=yes --track-origins=yes --fullpath-after=$PROJECT/ --leak-check=full --show-leak-kinds=all"
|
VALGRIND_ARGS="-s --read-var-info=yes --track-origins=yes --fullpath-after=$(pwd)/ --leak-check=full --show-leak-kinds=all"
|
||||||
TASK_SCRIPT=cbuild/default_tasks/valgrind.sh
|
TASK_SCRIPT=cbuild/default_tasks/valgrind.sh
|
||||||
;;
|
;;
|
||||||
# generates profiling info
|
# generates profiling info
|
||||||
|
|||||||
@ -36,14 +36,6 @@ function ask_yn {
|
|||||||
return $([[ "$answ" = [Yy] ]]);
|
return $([[ "$answ" = [Yy] ]]);
|
||||||
}
|
}
|
||||||
|
|
||||||
# asks a question and prints answer
|
|
||||||
function ask {
|
|
||||||
local answ=""
|
|
||||||
myprint "$@: "
|
|
||||||
read -r answ
|
|
||||||
safeprint "$answ"
|
|
||||||
}
|
|
||||||
|
|
||||||
# prints horizontal line occupying whole terminal row
|
# prints horizontal line occupying whole terminal row
|
||||||
# https://en.wikipedia.org/wiki/Box-drawing_characters
|
# https://en.wikipedia.org/wiki/Box-drawing_characters
|
||||||
function print_hline {
|
function print_hline {
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user