Compare commits

..

No commits in common. "c5f8f6ee0904ee0f75a0b67a9f964e55e9f7fb38" and "d021389637d55e57ad91a200a4515722c39f0bf8" have entirely different histories.

5 changed files with 20 additions and 41 deletions

View File

@ -64,6 +64,11 @@ if [ $args_count -eq 0 ]; then
print_help print_help
fi fi
function get_next_arg {
i=$((i+1))
safeprint "${args[i]}"
}
while [ $i -lt $args_count ] while [ $i -lt $args_count ]
do do
case "${args[i]}" in case "${args[i]}" in
@ -76,12 +81,10 @@ do
exit 0 exit 0
;; ;;
'-c' | '--config') '-c' | '--config')
i=$((i+1)) project_config_path="$(get_next_arg)"
project_config_path="${args[i]}"
;; ;;
'-n' | '--new-project') '-n' | '--new-project')
i=$((i+1)) new_project_dir="$(get_next_arg)"
new_project_dir="${args[i]}"
if [ -z "$new_project_dir" ]; then if [ -z "$new_project_dir" ]; then
new_project_dir="." new_project_dir="."
fi fi

View File

@ -15,6 +15,6 @@ else
done done
fi fi
[ ! -z "$SRC_C" ] && compile_c "$CMP_C" "$STD_C" "$WARN_C" "$C_ARGS" "$INCLUDE" "$SRC_C" compile_c "$C_ARGS" "$SRC_C"
[ ! -z "$SRC_CPP" ] && compile_cpp "$CMP_CPP" "$STD_CPP" "$WARN_CPP" "$CPP_ARGS" "$INCLUDE" "$SRC_CPP" compile_cpp "$CPP_ARGS" "$SRC_CPP"
link "$LINKER_ARGS" "$EXEC_FILE" link "$LINKER_ARGS" "$EXEC_FILE"

View File

@ -2,6 +2,6 @@
# delete old objects # delete old objects
clean_dir "$OBJDIR/objects" clean_dir "$OBJDIR/objects"
[ ! -z "$SRC_C" ] && compile_c "$CMP_C" "$STD_C" "$WARN_C" "$C_ARGS" "$INCLUDE" "$SRC_C" compile_c "$C_ARGS" "$SRC_C"
[ ! -z "$SRC_CPP" ] && compile_cpp "$CMP_CPP" "$STD_CPP" "$WARN_CPP" "$CPP_ARGS" "$INCLUDE" "$SRC_CPP" compile_cpp "$CPP_ARGS" "$SRC_CPP"
link "$LINKER_ARGS" "$SHARED_LIB_FILE" link "$LINKER_ARGS" "$SHARED_LIB_FILE"

View File

@ -2,6 +2,6 @@
# delete old objects # delete old objects
clean_dir "$OBJDIR/objects" clean_dir "$OBJDIR/objects"
[ ! -z "$SRC_C" ] && compile_c "$CMP_C" "$STD_C" "$WARN_C" "$C_ARGS" "$INCLUDE" "$SRC_C" compile_c "$C_ARGS" "$SRC_C"
[ ! -z "$SRC_CPP" ] && compile_cpp "$CMP_CPP" "$STD_CPP" "$WARN_CPP" "$CPP_ARGS" "$INCLUDE" "$SRC_CPP" compile_cpp "$CPP_ARGS" "$SRC_CPP"
pack_static_lib "$STATIC_LIB_FILE" pack_static_lib "$STATIC_LIB_FILE"

View File

@ -116,16 +116,16 @@ function compile {
print_hline "${BLUE}" "─" print_hline "${BLUE}" "─"
local cmp="$1" local cmp="$1"
local std="$2"
local warn="$3"
local args="$4"
local include="$5"
local sources="$6"
myprint "${BLUE}compiler: ${GRAY}$cmp" myprint "${BLUE}compiler: ${GRAY}$cmp"
local std="$2"
myprint "${BLUE}standard: ${GRAY}$std" myprint "${BLUE}standard: ${GRAY}$std"
local warn="$3"
myprint "${BLUE}warnings: ${GRAY}$warn" myprint "${BLUE}warnings: ${GRAY}$warn"
local args="$4"
myprint "${BLUE}args: ${GRAY}$args" myprint "${BLUE}args: ${GRAY}$args"
local include="$5"
myprint "${BLUE}include dirs: ${GRAY}$include" myprint "${BLUE}include dirs: ${GRAY}$include"
local sources="$6"
myprint "${BLUE}sources: ${GRAY}$sources" myprint "${BLUE}sources: ${GRAY}$sources"
for srcfile in $sources for srcfile in $sources
do ( do (
@ -141,26 +141,14 @@ function compile {
# (args, sources) # (args, sources)
function compile_c { function compile_c {
local cmp="$1"
local std="$2"
local warn="$3"
local args="$4"
local include="$5"
local sources="$6"
print_header "${CYAN}" "─" "$PROJECT/$TASK/compile_c" print_header "${CYAN}" "─" "$PROJECT/$TASK/compile_c"
compile "$cmp" "$std" "$warn" "$args" "$include" "$sources" compile "$CMP_C" "$STD_C" "$WARN_C" "$1" "$INCLUDE" "$2"
} }
# (args, sources) # (args, sources)
function compile_cpp { function compile_cpp {
local cmp="$1"
local std="$2"
local warn="$3"
local args="$4"
local include="$5"
local sources="$6"
print_header "${CYAN}" "─" "$PROJECT/$TASK/compile_cpp" print_header "${CYAN}" "─" "$PROJECT/$TASK/compile_cpp"
compile "$cmp" "$std" "$warn" "$args" "$include" "$sources" compile "$CMP_CPP" "$STD_CPP" "$WARN_CPP" "$1" "$INCLUDE" "$2"
} }
# (outfile) # (outfile)
@ -168,13 +156,8 @@ function pack_static_lib {
print_header "${CYAN}" "─" "$PROJECT/$TASK/pack_static_lib" print_header "${CYAN}" "─" "$PROJECT/$TASK/pack_static_lib"
local outfile="$1" local outfile="$1"
myprint "${BLUE}outfile: ${GRAY}$outfile" myprint "${BLUE}outfile: ${GRAY}$outfile"
local objects="$(find $OBJDIR/objects -type f,l | tr '\n' ' ')" local objects="$(find $OBJDIR/objects -type f,l | tr '\n' ' ')"
myprint "${BLUE}objects: ${GRAY}$objects" myprint "${BLUE}objects: ${GRAY}$objects"
if [ -z "$objects" ]; then
error "no compiled objects found"
fi
local command="ar rcs $OUTDIR/$outfile $objects" local command="ar rcs $OUTDIR/$outfile $objects"
myprint "$command" myprint "$command"
if $command if $command
@ -191,23 +174,16 @@ function link {
local outfile="$2" local outfile="$2"
myprint "${BLUE}args: ${GRAY}$args" myprint "${BLUE}args: ${GRAY}$args"
myprint "${BLUE}outfile: ${GRAY}$outfile" myprint "${BLUE}outfile: ${GRAY}$outfile"
local objects="$(find $OBJDIR/objects -type f,l | tr '\n' ' ')" local objects="$(find $OBJDIR/objects -type f,l | tr '\n' ' ')"
myprint "${BLUE}objects: ${GRAY}$objects" myprint "${BLUE}objects: ${GRAY}$objects"
if [ -z "$objects" ]; then
error "no compiled objects found"
fi
local static_libs="$(find $OBJDIR/static_libs -type f,l | tr '\n' ' ')" local static_libs="$(find $OBJDIR/static_libs -type f,l | tr '\n' ' ')"
myprint "${BLUE}static libraries: ${GRAY}$static_libs" myprint "${BLUE}static libraries: ${GRAY}$static_libs"
local dynamic_libs="$(find $OBJDIR/dynamic_libs -type f,l | tr '\n' ' ')" local dynamic_libs="$(find $OBJDIR/dynamic_libs -type f,l | tr '\n' ' ')"
myprint "${BLUE}dynamic libraries: ${GRAY}$dynamic_libs" myprint "${BLUE}dynamic libraries: ${GRAY}$dynamic_libs"
local dynamic_libs_args="-L $OBJDIR/dynamic_libs" local dynamic_libs_args="-L $OBJDIR/dynamic_libs"
for lib in $dynamic_libs; do for lib in $dynamic_libs; do
dynamic_libs_args="$dynamic_libs_args -l:$lib" dynamic_libs_args="$dynamic_libs_args -l:$lib"
done done
local command="$CMP_CPP $objects $static_libs $args $dynamic_libs_args -o $OUTDIR/$outfile" local command="$CMP_CPP $objects $static_libs $args $dynamic_libs_args -o $OUTDIR/$outfile"
myprint "$command" myprint "$command"
if $command if $command