Compare commits
10 Commits
d72aa0c809
...
60fa8c11c2
| Author | SHA1 | Date | |
|---|---|---|---|
| 60fa8c11c2 | |||
| ef6a3f82c4 | |||
| 5e23ef8156 | |||
| 9711d8fbb1 | |||
| 991ee072b3 | |||
| 888b1e05e7 | |||
| e8e42424d3 | |||
| dc5947f92d | |||
| e83a7affef | |||
| 2bebe76c7e |
12
CHANGELOG.md
12
CHANGELOG.md
@ -1,8 +1,20 @@
|
|||||||
|
# v7
|
||||||
|
+ added function `resolve_dependencies` to `link`
|
||||||
|
+ added variables `DEPS_BASEDIR` and `DEPS` to config
|
||||||
|
+ added script `rebuild_dep.sh` which can be called through `Makefile`
|
||||||
|
+ added dependency cleaning in `default_tasks/clean.sh`
|
||||||
|
+ added task `callgrind`
|
||||||
|
+ added task `no_task` which is been set in `init.sh` when `TASK` is empty
|
||||||
|
+ now `STATIC_LIB_FILE` starts with "lib"
|
||||||
|
|
||||||
# v6
|
# v6
|
||||||
+ `build_profile` task was split to `profile` and `gprof`
|
+ `build_profile` task was split to `profile` and `gprof`
|
||||||
+ added task `sanitize`
|
+ added task `sanitize`
|
||||||
+ default C++ standard set to `c++11`
|
+ default C++ standard set to `c++11`
|
||||||
+ added `INCLUDE` to `default.config`
|
+ added `INCLUDE` to `default.config`
|
||||||
|
+ moved `LINKER_ARGS` to the end of linkage command in `functions.sh` to properly link static libs
|
||||||
|
+ added function `try_delete_dir_or_file` for `clean` task
|
||||||
|
+ dead code removal in `build_exec` and `build_static_lib`
|
||||||
|
|
||||||
# v5
|
# v5
|
||||||
+ added task `clean`
|
+ added task `clean`
|
||||||
|
|||||||
@ -28,6 +28,12 @@ build_static_lib:
|
|||||||
build_static_lib_dbg:
|
build_static_lib_dbg:
|
||||||
@cbuild/call_task.sh build_static_lib_dbg 2>&1 | tee make_raw.log
|
@cbuild/call_task.sh build_static_lib_dbg 2>&1 | tee make_raw.log
|
||||||
|
|
||||||
|
# recompile libsome_dep.a in the next build task
|
||||||
|
#rebuild_some_dep:
|
||||||
|
# @cbuild/rebuild_dep.sh libsome_dep.a 2>&1 | tee make_raw.log
|
||||||
|
|
||||||
|
#rebuild_all: rebuild_some_dep
|
||||||
|
|
||||||
######################################
|
######################################
|
||||||
###### Launch tasks #######
|
###### Launch tasks #######
|
||||||
######################################
|
######################################
|
||||||
@ -49,10 +55,18 @@ profile:
|
|||||||
@cbuild/call_task.sh profile 2>&1 | tee make_raw.log
|
@cbuild/call_task.sh profile 2>&1 | tee make_raw.log
|
||||||
|
|
||||||
# compiles program with -pg and runs it with gprof
|
# compiles program with -pg and runs it with gprof
|
||||||
# uses gprof2dot python script to generate function call tree
|
# uses gprof2dot python script to generate function call tree (pip install gprof2dot)
|
||||||
|
# requires graphviz (https://www.graphviz.org/download/source/)
|
||||||
gprof:
|
gprof:
|
||||||
@cbuild/call_task.sh gprof 2>&1 | tee make_raw.log
|
@cbuild/call_task.sh gprof 2>&1 | tee make_raw.log
|
||||||
|
|
||||||
|
# compiles program and runs it with callgrind (part of valgrind)
|
||||||
|
# uses gprof2dot python script to generate function call tree (pip install gprof2dot)
|
||||||
|
# requires graphviz (https://www.graphviz.org/download/source/)
|
||||||
|
# P.S. detailed rezults can be viewed in KCacheGrind
|
||||||
|
callgrind:
|
||||||
|
@cbuild/call_task.sh callgrind 2>&1 | tee make_raw.log
|
||||||
|
|
||||||
# compiles executable with sanitizers and executes it to find errors and warnings
|
# compiles executable with sanitizers and executes it to find errors and warnings
|
||||||
sanitize:
|
sanitize:
|
||||||
@cbuild/call_task.sh sanitize 2>&1 | tee make_raw.log
|
@cbuild/call_task.sh sanitize 2>&1 | tee make_raw.log
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
CBUILD_VERSION=6
|
CBUILD_VERSION=7
|
||||||
CONFIG_VERSION=1
|
CONFIG_VERSION=1
|
||||||
|
|
||||||
PROJECT="NULL"
|
PROJECT="NULL"
|
||||||
@ -14,14 +14,23 @@ SRC_CPP="$( find src -name '*.cpp')"
|
|||||||
TESTS_C="$( find tests -name '*.c')"
|
TESTS_C="$( find tests -name '*.c')"
|
||||||
TESTS_CPP="$(find tests -name '*.cpp')"
|
TESTS_CPP="$(find tests -name '*.cpp')"
|
||||||
|
|
||||||
|
# dir with dependeicy dirs
|
||||||
|
DEPS_BASEDIR="."
|
||||||
|
# EXAMPLE: "dependency_dir='build_task out_dir lib_file'
|
||||||
|
# other_depndency_dir=..."
|
||||||
|
# Dependencies must be declared on separate lines
|
||||||
|
# Values can be override by resetting one of dependencies:
|
||||||
|
# DEPS="$DEPS
|
||||||
|
# dependency_dir='...'"
|
||||||
|
DEPS=""
|
||||||
|
|
||||||
# OBJDIR structure:
|
# OBJDIR structure:
|
||||||
# ├── objects - dir where compiled *.o files are stored. cleans every call of build task
|
# ├── objects/ - dir where compiled *.o files are stored. cleans every call of build task
|
||||||
# ├── profile - dir where gcc *.gcda profiling info files stored
|
# ├── profile/ - dir where gcc *.gcda profiling info files stored
|
||||||
# ├── libs - there you can put static libs and linker will find them
|
# └── libs/ - there you can put static libs and linker will find them
|
||||||
# └── out - output files are created here and then copied to OUTDIR
|
|
||||||
OBJDIR="obj"
|
OBJDIR="obj"
|
||||||
OUTDIR="bin"
|
OUTDIR="bin"
|
||||||
STATIC_LIB_FILE="$PROJECT.a"
|
STATIC_LIB_FILE="lib$PROJECT.a"
|
||||||
|
|
||||||
# OS-specific options
|
# OS-specific options
|
||||||
case "$OS" in
|
case "$OS" in
|
||||||
@ -50,7 +59,8 @@ case "$TASK" in
|
|||||||
# -fuse-linker-plugin is required to use static libs with lto
|
# -fuse-linker-plugin is required to use static libs with lto
|
||||||
# -fprofile-use enables compiler to use profiling info files to optimize executable
|
# -fprofile-use enables compiler to use profiling info files to optimize executable
|
||||||
# -fprofile-prefix-path sets path where profiling info about objects are be saved
|
# -fprofile-prefix-path sets path where profiling info about objects are be saved
|
||||||
C_ARGS="-O2 -flto=auto -fuse-linker-plugin -fprofile-use -fprofile-prefix-path=$(realpath $OBJDIR)/objects"
|
# -fdata-sections -ffunction-sections -Wl,--gc-sections removes unused code
|
||||||
|
C_ARGS="-O2 -flto=auto -fuse-linker-plugin -fprofile-use -fprofile-prefix-path=$(realpath $OBJDIR)/objects -fdata-sections -ffunction-sections -Wl,--gc-sections"
|
||||||
CPP_ARGS="$C_ARGS"
|
CPP_ARGS="$C_ARGS"
|
||||||
LINKER_ARGS="$CPP_ARGS"
|
LINKER_ARGS="$CPP_ARGS"
|
||||||
PRE_TASK_SCRIPT=
|
PRE_TASK_SCRIPT=
|
||||||
@ -86,7 +96,7 @@ case "$TASK" in
|
|||||||
;;
|
;;
|
||||||
# creates static library
|
# creates static library
|
||||||
build_static_lib)
|
build_static_lib)
|
||||||
C_ARGS="-O2 -fpic"
|
C_ARGS="-O2 -fpic -fdata-sections -ffunction-sections"
|
||||||
CPP_ARGS="$C_ARGS"
|
CPP_ARGS="$C_ARGS"
|
||||||
PRE_TASK_SCRIPT=
|
PRE_TASK_SCRIPT=
|
||||||
TASK_SCRIPT=cbuild/default_tasks/build_static_lib.sh
|
TASK_SCRIPT=cbuild/default_tasks/build_static_lib.sh
|
||||||
@ -106,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 --log-file=valgrind.log --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=$PROJECT/ --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
|
||||||
@ -138,6 +148,20 @@ case "$TASK" in
|
|||||||
TASK_SCRIPT=cbuild/default_tasks/gprof.sh
|
TASK_SCRIPT=cbuild/default_tasks/gprof.sh
|
||||||
POST_TASK_SCRIPT=
|
POST_TASK_SCRIPT=
|
||||||
;;
|
;;
|
||||||
|
# compiles program and runs it with callgrind (part of valgrind)
|
||||||
|
# uses gprof2dot python script to generate function call tree (pip install gprof2dot)
|
||||||
|
# requires graphviz (https://www.graphviz.org/download/source/)
|
||||||
|
# P.S. detailed rezults can be viewed in KCacheGrind
|
||||||
|
callgrind)
|
||||||
|
OUTDIR="$OUTDIR/callgrind"
|
||||||
|
# -pg adds code to executable, that generates file containing function call info (gmon.out)
|
||||||
|
C_ARGS="-O2 -flto=auto -fuse-linker-plugin"
|
||||||
|
CPP_ARGS="$C_ARGS"
|
||||||
|
LINKER_ARGS="$CPP_ARGS"
|
||||||
|
PRE_TASK_SCRIPT=tasks/pre_build.sh
|
||||||
|
TASK_SCRIPT=cbuild/default_tasks/build_exec.sh
|
||||||
|
POST_TASK_SCRIPT=cbuild/default_tasks/callgrind.sh
|
||||||
|
;;
|
||||||
# compiles executable with sanitizers and executes it to find errors and warnings
|
# compiles executable with sanitizers and executes it to find errors and warnings
|
||||||
sanitize)
|
sanitize)
|
||||||
OUTDIR="$OUTDIR/sanitize"
|
OUTDIR="$OUTDIR/sanitize"
|
||||||
@ -152,6 +176,9 @@ case "$TASK" in
|
|||||||
clean)
|
clean)
|
||||||
TASK_SCRIPT=cbuild/default_tasks/clean.sh
|
TASK_SCRIPT=cbuild/default_tasks/clean.sh
|
||||||
;;
|
;;
|
||||||
|
# nothing to do
|
||||||
|
no_task)
|
||||||
|
;;
|
||||||
# unknown task
|
# unknown task
|
||||||
*)
|
*)
|
||||||
error "task <$TASK> not found"
|
error "task <$TASK> not found"
|
||||||
|
|||||||
19
default_tasks/callgrind.sh
Normal file
19
default_tasks/callgrind.sh
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
cd "$OUTDIR"
|
||||||
|
|
||||||
|
# deleting all files except excutable
|
||||||
|
echo "$(find . ! -name $EXEC_FILE -type f -delete)"
|
||||||
|
|
||||||
|
# executing file with callgrind
|
||||||
|
myprint "${BLUE}executing $OUTDIR/$EXEC_FILE"
|
||||||
|
valgrind --tool=callgrind --callgrind-out-file=callgrind.out ./$EXEC_FILE > exec.log
|
||||||
|
myprint "${GREEN}execution log saved to ${CYAN}$OUTDIR/exec.log"
|
||||||
|
# exit 0
|
||||||
|
# generating function call graph
|
||||||
|
myprint "${BLUE}generating function call graph..."
|
||||||
|
gprof2dot -f callgrind callgrind.out > gprof2dot.graph
|
||||||
|
dot gprof2dot.graph -Tpng -Gdpi=300 -o gprof2dot.png
|
||||||
|
myprint "${GREEN}function call graph saved to ${CYAN}$OUTDIR/gprof2dot.png"
|
||||||
|
|
||||||
|
cd ../..
|
||||||
@ -1,6 +1,23 @@
|
|||||||
#!/usr/bin/bash
|
#!/usr/bin/bash
|
||||||
|
|
||||||
delete_dir "$OBJDIR"
|
try_delete_dir_or_file "$OBJDIR"
|
||||||
delete_dir "$OUTDIR"
|
try_delete_dir_or_file "$OUTDIR"
|
||||||
myprint "${WHITE}deleting build logs"
|
myprint "${WHITE}deleting build logs"
|
||||||
rm -rf *.log
|
rm -rf *.log
|
||||||
|
|
||||||
|
for tmpfile in $(ls -a | grep -e '\.rebuild.*\.tmp'); do
|
||||||
|
try_delete_dir_or_file "$tmpfile"
|
||||||
|
done
|
||||||
|
|
||||||
|
set +e
|
||||||
|
OLDIFS="$IFS"
|
||||||
|
IFS=$'\n'
|
||||||
|
for dep in $DEPS; do
|
||||||
|
dep_dir=$(echo ${dep/=*/} | tr -d '[:blank:]')
|
||||||
|
myprint "${CYAN}--------------[$dep_dir]--------------"
|
||||||
|
cd "$DEPS_BASEDIR/$dep_dir"
|
||||||
|
make clean
|
||||||
|
cd ..
|
||||||
|
done
|
||||||
|
IFS="$OLDIFS"
|
||||||
|
set -e
|
||||||
|
|||||||
@ -1,7 +1,10 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
cd "$OUTDIR"
|
cd "$OUTDIR"
|
||||||
valgrind $VALGRIND_ARGS ./$EXEC_FILE
|
rm -f "valgrind.log"
|
||||||
cat "valgrind.log"
|
set +e
|
||||||
myprint "${GREEN}valgrind log saved to ${CYAN}$OUTDIR/exec.log"
|
valgrind --log-file=valgrind.log $VALGRIND_ARGS ./$EXEC_FILE
|
||||||
|
set -e
|
||||||
|
[ -f "valgrind.log" ] && cat "valgrind.log" || error "valgrind exited with errors"
|
||||||
|
myprint "${GREEN}valgrind log saved to ${CYAN}$OUTDIR/valgrind.log"
|
||||||
cd ..
|
cd ..
|
||||||
|
|||||||
@ -9,10 +9,7 @@ case "$uname_rezult" in
|
|||||||
Msys | Cygwin | "MS/Windows")
|
Msys | Cygwin | "MS/Windows")
|
||||||
OS=WINDOWS
|
OS=WINDOWS
|
||||||
;;
|
;;
|
||||||
GNU/Linux)
|
Linux | GNU/Linux | Android)
|
||||||
OS=LINUX
|
|
||||||
;;
|
|
||||||
Linux)
|
|
||||||
OS=LINUX
|
OS=LINUX
|
||||||
;;
|
;;
|
||||||
FreeBSD)
|
FreeBSD)
|
||||||
|
|||||||
115
functions.sh
115
functions.sh
@ -1,7 +1,8 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
function myprint {
|
function myprint {
|
||||||
printf "$@${GRAY}\n"
|
# first gray is needed to print string trarting with -
|
||||||
|
printf "${GRAY}$@${GRAY}\n"
|
||||||
}
|
}
|
||||||
|
|
||||||
function error {
|
function error {
|
||||||
@ -22,6 +23,14 @@ function delete_dir {
|
|||||||
rm -rf "$dir"
|
rm -rf "$dir"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function try_delete_dir_or_file {
|
||||||
|
local path="$1"
|
||||||
|
if [ -f "$path" ] || [ -d "$path" ]; then
|
||||||
|
rm -rf "$path"
|
||||||
|
myprint "${WHITE}deleting $path"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
function compile {
|
function compile {
|
||||||
local cmp="$1"
|
local cmp="$1"
|
||||||
@ -36,25 +45,16 @@ function compile {
|
|||||||
myprint "${BLUE}include dirs: ${GRAY}$include"
|
myprint "${BLUE}include dirs: ${GRAY}$include"
|
||||||
local sources="$6"
|
local sources="$6"
|
||||||
myprint "${BLUE}sources: ${GRAY}$sources"
|
myprint "${BLUE}sources: ${GRAY}$sources"
|
||||||
local compilation_error=0
|
|
||||||
|
|
||||||
for srcfile in $sources
|
for srcfile in $sources
|
||||||
do (
|
do (
|
||||||
local object="$OBJDIR/objects/$(basename $srcfile).o"
|
local object="$OBJDIR/objects/$(basename $srcfile).o"
|
||||||
if ! $($cmp -std=$std $warn $args $include -c -o $object $srcfile)
|
if ! $($cmp -std=$std $warn $args $include -c -o $object $srcfile)
|
||||||
then
|
then
|
||||||
error "some error happened"
|
error "some error happened"
|
||||||
#TODO parallel variable assignement doesnt work in bash
|
# TODO stop all threads
|
||||||
compilation_error=1
|
|
||||||
fi
|
fi
|
||||||
) & done
|
) & done
|
||||||
wait
|
wait
|
||||||
|
|
||||||
#TODO doesnt work with multithreading
|
|
||||||
if [ $compilation_error != 0 ]
|
|
||||||
then
|
|
||||||
exit -50
|
|
||||||
fi
|
|
||||||
}
|
}
|
||||||
|
|
||||||
# (args, sources)
|
# (args, sources)
|
||||||
@ -69,28 +69,6 @@ function compile_cpp {
|
|||||||
compile "$CMP_CPP" "$STD_CPP" "$WARN_CPP" "$1" "$INCLUDE" "$2"
|
compile "$CMP_CPP" "$STD_CPP" "$WARN_CPP" "$1" "$INCLUDE" "$2"
|
||||||
}
|
}
|
||||||
|
|
||||||
# (args, outfile)
|
|
||||||
function link {
|
|
||||||
myprint "${CYAN}----------------[link]----------------"
|
|
||||||
local args="$1"
|
|
||||||
myprint "${BLUE}args: ${GRAY}$args"
|
|
||||||
local outfile="$2"
|
|
||||||
clean_dir $OBJDIR/out
|
|
||||||
myprint "${BLUE}outfile: ${GRAY}$outfile"
|
|
||||||
local objects="$(find $OBJDIR/objects -name '*.o')
|
|
||||||
$(find $OBJDIR/libs -name '*.a')"
|
|
||||||
myprint "${BLUE}objects: ${GRAY}$objects"
|
|
||||||
local command="$CMP_CPP $args $(echo "$objects" | tr '\n' ' ') -o $OBJDIR/out/$outfile"
|
|
||||||
myprint "$command"
|
|
||||||
if $command
|
|
||||||
then
|
|
||||||
cp "$OBJDIR/out/$outfile" "$OUTDIR/$outfile"
|
|
||||||
myprint "${GREEN}file $CYAN$outfile ${GREEN}created"
|
|
||||||
else
|
|
||||||
error "some error happened"
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
# (outfile)
|
# (outfile)
|
||||||
function pack_static_lib {
|
function pack_static_lib {
|
||||||
myprint "${CYAN}----------[pack_static_lib]-----------"
|
myprint "${CYAN}----------[pack_static_lib]-----------"
|
||||||
@ -99,9 +77,76 @@ function pack_static_lib {
|
|||||||
local objects="$(find $OBJDIR/objects -name *.o)
|
local objects="$(find $OBJDIR/objects -name *.o)
|
||||||
$(find $OBJDIR/libs -name '*.a')"
|
$(find $OBJDIR/libs -name '*.a')"
|
||||||
myprint "${BLUE}objects: ${GRAY}$objects"
|
myprint "${BLUE}objects: ${GRAY}$objects"
|
||||||
if gcc-ar rcs -o "$OBJDIR/out/$outfile" $(echo "$objects" | tr '\n' ' ')
|
if ar rcs "$OUTDIR/$outfile" $(echo "$objects" | tr '\n' ' ')
|
||||||
|
then
|
||||||
|
myprint "${GREEN}file $CYAN$outfile ${GREEN}created"
|
||||||
|
else
|
||||||
|
error "some error happened"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
# if $lib_file doesn't exist or rebuild_* task was executed, builds static lib
|
||||||
|
function handle_static_dependency {
|
||||||
|
local deps_basedir="${1%/}"
|
||||||
|
local lib_project_dir="$2"
|
||||||
|
local lib_build_task="$3"
|
||||||
|
local lib_build_dir="$4"
|
||||||
|
local lib_file="$5"
|
||||||
|
if [ ! -f "$OBJDIR/libs/$lib_file" ] || [ -f .rebuild_$lib_file.tmp ]; then
|
||||||
|
[[ -z "$lib_build_task" ]] && error "lib_build_task is empty"
|
||||||
|
myprint "${BLUE}making $lib_file by task $lib_build_task"
|
||||||
|
|
||||||
|
cd "$deps_basedir/$lib_project_dir"
|
||||||
|
if ! make "$lib_build_task"; then
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
cd ..
|
||||||
|
|
||||||
|
cp "$deps_basedir/$lib_project_dir/$lib_build_dir/$lib_file" "$OBJDIR/libs/"
|
||||||
|
myprint "${GREEN}copied ${CYAN}$lib_file to $OBJDIR/libs/"
|
||||||
|
rm -f .rebuild_$lib_file.tmp
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
function resolve_dependencies {
|
||||||
|
deps_basedir=$1
|
||||||
|
deps=$2
|
||||||
|
[[ -z "$deps_basedir" ]] && deps_basedir=.
|
||||||
|
OLDIFS="$IFS"
|
||||||
|
IFS=$'\n'
|
||||||
|
# Evalueting dependency expressions.
|
||||||
|
# Necessary for overriding dependency configurations.
|
||||||
|
for dep in $deps; do
|
||||||
|
eval $dep
|
||||||
|
done
|
||||||
|
# handling dependencies
|
||||||
|
for dep in $deps; do
|
||||||
|
IFS="$OLDIFS"
|
||||||
|
dep_dir=$(echo ${dep/=*/} | tr -d '[:blank:]')
|
||||||
|
eval 'dep_params=$'$dep_dir
|
||||||
|
f_args="$deps_basedir $dep_dir $dep_params"
|
||||||
|
myprint "${BLUE}resolving dependency ${WHITE}$dep_dir${BLUE}: ${GRAY}$f_args"
|
||||||
|
handle_static_dependency $f_args
|
||||||
|
IFS=$'\n'
|
||||||
|
done
|
||||||
|
IFS="$OLDIFS"
|
||||||
|
}
|
||||||
|
|
||||||
|
function link {
|
||||||
|
myprint "${CYAN}----------------[link]----------------"
|
||||||
|
local args="$1"
|
||||||
|
local outfile="$2"
|
||||||
|
resolve_dependencies "$DEPS_BASEDIR" "$DEPS"
|
||||||
|
myprint "${BLUE}args: ${GRAY}$args"
|
||||||
|
myprint "${BLUE}outfile: ${GRAY}$outfile"
|
||||||
|
local objects="$(find $OBJDIR/objects -name '*.o')
|
||||||
|
$(find $OBJDIR/libs -name '*.a')"
|
||||||
|
myprint "${BLUE}objects: ${GRAY}$objects"
|
||||||
|
local command="$CMP_CPP $(echo "$objects" | tr '\n' ' ') $args -o $OUTDIR/$outfile"
|
||||||
|
myprint "$command"
|
||||||
|
if $command
|
||||||
then
|
then
|
||||||
cp "$OBJDIR/out/$outfile" "$OUTDIR/$outfile"
|
|
||||||
myprint "${GREEN}file $CYAN$outfile ${GREEN}created"
|
myprint "${GREEN}file $CYAN$outfile ${GREEN}created"
|
||||||
else
|
else
|
||||||
error "some error happened"
|
error "some error happened"
|
||||||
|
|||||||
3
init.sh
3
init.sh
@ -35,6 +35,8 @@ exec_script_line default.config 3
|
|||||||
DEFAULT_CONFIG_VERSION="$CONFIG_VERSION"
|
DEFAULT_CONFIG_VERSION="$CONFIG_VERSION"
|
||||||
unset CONFIG_VERSION
|
unset CONFIG_VERSION
|
||||||
|
|
||||||
|
# undefined task
|
||||||
|
[ -z "$TASK" ] && TASK="no_task"
|
||||||
|
|
||||||
# error on undefined
|
# error on undefined
|
||||||
set -u
|
set -u
|
||||||
@ -69,7 +71,6 @@ mkdir -p "$OUTDIR"
|
|||||||
mkdir -p "$OBJDIR/libs"
|
mkdir -p "$OBJDIR/libs"
|
||||||
mkdir -p "$OBJDIR/objects"
|
mkdir -p "$OBJDIR/objects"
|
||||||
mkdir -p "$OBJDIR/profile"
|
mkdir -p "$OBJDIR/profile"
|
||||||
mkdir -p "$OBJDIR/out"
|
|
||||||
|
|
||||||
# dont thorw error on undefined variable
|
# dont thorw error on undefined variable
|
||||||
set +u
|
set +u
|
||||||
|
|||||||
7
rebuild_dep.sh
Normal file
7
rebuild_dep.sh
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
source "cbuild/init.sh"
|
||||||
|
|
||||||
|
target_file="$1"
|
||||||
|
touch ".rebuild_$target_file.tmp"
|
||||||
|
rm -fv "$OBJDIR/libs/$target_file.a"
|
||||||
|
myprint "${YELLOW}dependency ${WHITE}$target_file ${YELLOW}will be rebuilt with the next build task"
|
||||||
Loading…
Reference in New Issue
Block a user