# Instead this provides a functional example on what commands to perform to perform the bootstrap.
#
# This only accepts one argument, followed by these optional arguments:
-# 1) One of "individual", "level", "monolithic", "fake-individual", "fake-level", "fake-monolithic", "programs-individual", "programs-level", or "programs-monolithic".
-# 2) Optional, may be one of: +V, +q, +n, +l, +d, --enable-shared, --enable-static, --disable-shared, --disable-static.
+# 1) One of "Modes" from below.
+# 2) Optional, may be one of: +d, +l, +n, +V, +Q, +E, +N, +D, --enable-shared, --enable-static, --disable-shared, --disable-static.
# 3) Optional, may be one of: -w, --work.
# 4) Optional, may be: clang.
#
+# Modes:
+# - "individual"
+# - "level"
+# - "monolithic"
+# - "fake-individual"
+# - "fake-level"
+# - "fake-monolithic"
+# - "fake-stand_alone"
+# - "utf8-individual"
+# - "utf8-level"
+# - "utf8-monolithic"
+# - "utf8-stand_alone"
+# - "programs-individual"
+# - "programs-level"
+# - "programs-monolithic"
+#
# The -w/--work requires the path to the work directory following it.
# The clang parameter does not need the "-m".
#
static=
version=0.6.5
clang=
+mode_part=
+mode_parameter=
+mode_path=
+mode_value=
shell_command=bash
+suppress_first=""
if [[ $SHELL_ENGINE == "zsh" ]] ; then
shell_command=zsh
color="+l"
elif [[ $p == "+n" ]] ; then
color="+n"
- elif [[ $p == "+q" ]] ; then
- verbose="+q"
+ elif [[ $p == "+Q" ]] ; then
+ verbose="+Q"
+ verbose_common=
+ elif [[ $p == "+E" ]] ; then
+ verbose="+E"
verbose_common=
elif [[ $p == "+N" ]] ; then
verbose="+N"
$shell_command build/scripts/package.sh $verbose $color rebuild -i
if [[ $? -eq 0 ]] ; then
- for i in f_type f_status f_memory f_type_array f_string f_utf f_account f_capability f_color f_console f_control_group f_conversion f_directory f_environment f_execute f_file f_fss f_iki f_limit f_path f_pipe f_print f_status_string f_serialize f_signal f_socket f_thread fl_control_group fl_conversion fl_directory fl_environment fl_execute fl_fss fl_iki fl_print fl_signal fl_string fl_utf fl_utf_file fll_control_group fll_error fll_execute fll_file fll_fss fll_fss_status_string fll_iki fll_path fll_print fll_program fll_status_string ; do
+ for i in f_type f_status f_memory f_type_array f_string f_utf f_account f_capability f_color f_console f_control_group f_conversion f_directory f_environment f_execute f_file f_fss f_iki f_limit f_path f_pipe f_print f_status_string f_serialize f_signal f_socket f_thread fl_control_group fl_conversion fl_directory fl_environment fl_execute fl_fss fl_iki fl_path fl_print fl_signal fl_string fl_utf fl_utf_file fll_control_group fll_error fll_execute fll_file fll_fss fll_fss_status_string fll_iki fll_print fll_program fll_status_string ; do
echo && echo "Processing $i." &&
cd package/individual/$i-$version/ &&
- $shell_command ./bootstrap.sh clean $verbose $color &&
+ $shell_command ./bootstrap.sh clean $verbose $color $suppress_first &&
- $shell_command ./bootstrap.sh build $verbose $color $shared $static -w $path_work -m individual $clang &&
+ $shell_command ./bootstrap.sh build $verbose $color $suppress_first $shared $static -w $path_work -m individual $clang &&
- $shell_command ./install.sh $verbose $color $shared $static -w $path_work &&
+ $shell_command ./install.sh $verbose $color $suppress_first $shared $static -w $path_work &&
cd $path_original || break
done
cd package/level/fll-level_0-$version/ &&
- $shell_command ./bootstrap.sh clean $verbose $color &&
+ $shell_command ./bootstrap.sh clean $verbose $color $suppress_first &&
- $shell_command ./bootstrap.sh build $verbose $color $shared $static -w $path_work -m level $clang &&
+ $shell_command ./bootstrap.sh build $verbose $color $suppress_first $shared $static -w $path_work -m level $clang &&
- $shell_command ./install.sh $verbose $color $shared $static -w $path_work &&
+ $shell_command ./install.sh $verbose $color $suppress_first $shared $static -w $path_work &&
cd $path_original &&
cd package/level/fll-level_1-$version/ &&
- $shell_command ./bootstrap.sh clean $verbose $color &&
+ $shell_command ./bootstrap.sh clean $verbose $color $suppress_first &&
- $shell_command ./bootstrap.sh build $verbose $color $shared $static -w $path_work -m level &&
+ $shell_command ./bootstrap.sh build $verbose $color $suppress_first $shared $static -w $path_work -m level &&
- $shell_command ./install.sh $verbose $color $shared $static -w $path_work &&
+ $shell_command ./install.sh $verbose $color $suppress_first $shared $static -w $path_work &&
cd $path_original &&
cd package/level/fll-level_2-$version/ &&
- $shell_command ./bootstrap.sh clean $verbose $color &&
+ $shell_command ./bootstrap.sh clean $verbose $color $suppress_first &&
- $shell_command ./bootstrap.sh build $verbose $color $shared $static -w $path_work -m level &&
+ $shell_command ./bootstrap.sh build $verbose $color $suppress_first $shared $static -w $path_work -m level &&
- $shell_command ./install.sh $verbose $color $shared $static -w $path_work
+ $shell_command ./install.sh $verbose $color $suppress_first $shared $static -w $path_work
fi
if [[ $1 == "monolithic" ]] ; then
cd package/monolithic/fll-$version/ &&
- $shell_command ./bootstrap.sh clean $verbose $color &&
+ $shell_command ./bootstrap.sh clean $verbose $color $suppress_first &&
- $shell_command ./bootstrap.sh build $verbose $color $shared $static -w $path_work -m monolithic $clang &&
+ $shell_command ./bootstrap.sh build $verbose $color $suppress_first $shared $static -w $path_work -m monolithic $clang &&
- $shell_command ./install.sh $verbose $color $shared $static -w $path_work
+ $shell_command ./install.sh $verbose $color $shared $suppress_first $static -w $path_work
fi
-# The following in an example on building the Featureless Make project (fake) using the project bootstrapped from above.
-if [[ $1 == "fake-individual" || $1 == "fake-level" || $1 == "fake-monolithic" ]] ; then
- if [[ $1 == "fake-individual" ]] ; then
+# The following in an example on building individual projects.
+for mode_part in fake utf8 ; do
+ if [[ $1 == "$mode_part-individual" || $1 == "$mode_part-level" || $1 == "$mode_part-monolithic" || $1 == "$mode_part-stand_alone" ]] ; then
+ break;
+ fi
+
+ mode_part=
+done
+
+if [[ $mode_part != "" ]] ; then
+ mode_parameter="-p"
+ mode_path="program"
+ mode_value=
+
+ if [[ $1 == "$mode_part-individual" ]] ; then
build_mode="individual"
- elif [[ $1 == "fake-level" ]] ; then
+ elif [[ $1 == "$mode_part-level" ]] ; then
build_mode="level"
- elif [[ $1 == "fake-monolithic" ]] ; then
+ elif [[ $1 == "$mode_part-monolithic" ]] ; then
build_mode="monolithic"
+ elif [[ $1 == "$mode_part-stand_alone" ]] ; then
+ build_mode="stand_alone"
+ mode_path="stand_alone"
+ mode_parameter="-S"
+ mode_value="$mode_part"
fi
- $shell_command build/scripts/package.sh $verbose $color rebuild -p &&
+ $shell_command build/scripts/package.sh $verbose $color rebuild $mode_parameter $mode_value &&
- cd package/program/fake-$version/ &&
+ cd package/$mode_path/$mode_part-$version/ &&
- $shell_command ./bootstrap.sh clean $verbose $color &&
+ $shell_command ./bootstrap.sh clean $verbose $color $suppress_first &&
- $shell_command ./bootstrap.sh build $verbose $color $shared $static -w $path_work -m $build_mode &&
+ $shell_command ./bootstrap.sh build $verbose $color $suppress_first $shared $static -w $path_work -m $build_mode &&
- $shell_command ./install.sh $verbose $color $shared $static -w $path_work
+ $shell_command ./install.sh $verbose $color $suppress_first $shared $static -w $path_work
# The following in an example on building all FLL program projects using the project bootstrapped from above.
elif [[ $1 == "programs-individual" || $1 == "programs-level" || $1 == "programs-monolithic" ]] ; then
cd ${path_original}package/program/$i &&
- $shell_command ./bootstrap.sh clean $verbose $color &&
+ $shell_command ./bootstrap.sh clean $verbose $color $suppress_first &&
- $shell_command ./bootstrap.sh build $verbose $color $shared $static -w $path_work -m $build_mode &&
+ $shell_command ./bootstrap.sh build $verbose $color $suppress_first $shared $static -w $path_work -m $build_mode &&
- $shell_command ./install.sh $verbose $color $shared $static -w $path_work ||
+ $shell_command ./install.sh $verbose $color $suppress_first $shared $static -w $path_work ||
break
done
local grab_next=
local do_color=dark
local do_help=
+ local do_copyright=
local i=0
local m=
local p=
local key=
local -A variables=()
+ local failure=
local settings_name=settings
local settings_file=
local settings_defines=
local path_sources=sources/
local path_language=c/
local path_work=
+ local print_line_first="yes"
+ local print_line_last="yes"
local project_built=
local project_built_shared=
local project_built_static=
if [[ $grab_next == "" ]] ; then
if [[ $p == "-h" || $p == "--help" ]] ; then
do_help=yes
+ elif [[ $p == "+C" || $p == "++copyright" ]] ; then
+ do_copyright="yes"
elif [[ $p == "+d" || $p == "++dark" ]] ; then
do_color=dark
context="+d"
elif [[ $p == "+n" || $p == "++no_color" ]] ; then
do_color=none
context="+n"
- elif [[ $p == "+q" || $p == "++quiet" ]] ; then
+ elif [[ $p == "+Q" || $p == "++quiet" ]] ; then
verbosity="quiet"
- verbose="+q"
+ verbose="+Q"
+ verbose_common=
+ elif [[ $p == "+E" || $p == "++error" ]] ; then
+ verbosity="error"
+ verbose="+E"
verbose_common=
elif [[ $p == "+N" || $p == "++normal" ]] ; then
verbosity=
verbose_common="-v"
elif [[ $p == "+v" || $p == "++version" ]] ; then
echo $version
- return
+ return 0
elif [[ $p == "-d" || $p == "--define" ]] ; then
grab_next=define_extra
elif [[ $p == "-m" || $p == "--mode" ]] ; then
p=
fi
+ if [[ $verbosity == "quiet" ]] ; then
+ print_line_first="no"
+ print_line_last="no"
+ fi
+
# If the settings_name has a directory separator, then assume it is a path to the settings file.
if [[ $(echo $settings_name | grep -s -o '/') == "" ]] ; then
settings_file="${path_data}build/$settings_name"
return 0
fi
+ if [[ $do_copyright == "yes" ]] ; then
+ bootstrap_copyright
+ bootstrap_cleanup
+
+ return 0
+ fi
+
bootstrap_load_settings
# FSS and Featurless Make supports more flexible mode names, but for the purpose of this bootstrap script and avoiding potential problems, keep it simple.
for mode in $modes ; do
if [[ $(echo "$mode" | grep -s -o "[^_[:alnum:]+-]") != "" ]] ; then
if [[ $verbosity != "quiet" ]] ; then
+ bootstrap_print_first
+
echo -e "${c_error}ERROR: The mode ${c_notice}${mode}${c_error} includes invalid characters, only alphanumeric, underscore, minus, and plus are allowed.${c_reset}"
+
+ bootstrap_print_last
fi
bootstrap_cleanup
if [[ $modes_available == "" ]] ; then
if [[ $modes != "" ]] ; then
if [[ $verbosity != "quiet" ]] ; then
+ bootstrap_print_first
+
echo -e "${c_error}ERROR: The mode(s) ${c_notice}${modes}${c_error} are not a valid modes, there are no available modes.${c_error}${c_reset}"
+
+ bootstrap_print_last
fi
bootstrap_cleanup
if [[ $i -eq 0 ]] ; then
if [[ $verbosity != "quiet" ]] ; then
+ bootstrap_print_first
+
echo -e "${c_error}ERROR: The mode(s) ${c_notice}${modes}${c_error} are not valid modes, they must be one of: ${c_notice}$modes_available${c_error}.${c_reset}"
+
+ bootstrap_print_last
fi
bootstrap_cleanup
bootstrap_id "build_name"
if [[ ${variables[$key]} == "" ]] ; then
if [[ $verbosity != "quiet" ]] ; then
+ bootstrap_print_first
+
echo -e "${c_error}ERROR: The required setting '${c_notice}build_name${c_error}' is not specified in the build settings file '${c_notice}${settings_file}${c_error}'.${c_reset}"
+
+ bootstrap_print_last
fi
bootstrap_cleanup
bootstrap_id "version_major"
if [[ ${variables[$key]} == "" ]] ; then
if [[ $verbosity != "quiet" ]] ; then
+ bootstrap_print_first
+
echo -e "${c_error}ERROR: The required setting '${c_notice}version_major${c_error}' is not specified in the build settings file '${c_notice}${settings_file}${c_error}'.${c_reset}"
+
+ bootstrap_print_last
fi
bootstrap_cleanup
bootstrap_id "version_minor"
if [[ ${variables[$key]} == "" ]] ; then
if [[ $verbosity != "quiet" ]] ; then
+ bootstrap_print_first
+
echo -e "${c_error}ERROR: The required setting '${c_notice}version_minor${c_error}' is not specified in the build settings file '${c_notice}${settings_file}${c_error}'.${c_reset}"
+
+ bootstrap_print_last
fi
bootstrap_cleanup
bootstrap_id "version_micro"
if [[ ${variables[$key]} == "" ]] ; then
if [[ $verbosity != "quiet" ]] ; then
+ bootstrap_print_first
+
echo -e "${c_error}ERROR: The required setting '${c_notice}version_micro${c_error}' is not specified in the build settings file '${c_notice}${settings_file}${c_error}'.${c_reset}"
+
+ bootstrap_print_last
fi
bootstrap_cleanup
if [[ $path_data == "" || ! -d $path_data ]] ; then
if [[ $verbosity != "quiet" ]] ; then
+ bootstrap_print_first
+
echo -e "${c_error}ERROR: The data directory ${c_notice}${path_data}${c_error} is not a valid directory.${c_reset}"
+
+ bootstrap_print_last
fi
bootstrap_cleanup
if [[ $path_sources == "" || ! -d $path_sources ]] ; then
if [[ $verbosity != "quiet" ]] ; then
+ bootstrap_print_first
+
echo -e "${c_error}ERROR: The sources directory ${c_notice}${path_sources}${c_error} is not a valid directory.${c_reset}"
+
+ bootstrap_print_last
fi
bootstrap_cleanup
if [[ $path_work != "" && ! -d $path_work ]] ; then
if [[ $verbosity != "quiet" ]] ; then
+ bootstrap_print_first
+
echo -e "${c_error}ERROR: The work directory ${c_notice}${path_work}${c_error} is not a valid directory.${c_reset}"
+
+ bootstrap_print_last
fi
bootstrap_cleanup
if [[ $operation_failure == "fail-multiple" ]] ; then
if [[ $verbosity != "quiet" ]] ; then
+ bootstrap_print_first
+
echo -e "${c_error}ERROR: Only one operation may be specified at a time.${c_reset}"
+
+ bootstrap_print_last
fi
bootstrap_cleanup
return 1
elif [[ $operation == "build" ]] ; then
- if [[ $verbosity != "quiet" ]] ; then
- echo
+ if [[ $verbosity != "quiet" && $verbosity != "error" ]] ; then
+ bootstrap_print_first
+
echo -e "${c_highlight}Building:${c_reset} ${c_notice}${project_label}${c_highlight}.${c_reset}"
fi
return 1
fi
elif [[ $operation == "clean" ]] ; then
- if [[ $verbosity != "quiet" ]] ; then
- echo
+ if [[ $verbosity != "quiet" && $verbosity != "error" ]] ; then
+ bootstrap_print_first
+
echo -e "${c_highlight}Cleaning Project:${c_reset} ${c_notice}${project_label}${c_highlight}.${c_reset}"
fi
bootstrap_operation_clean
elif [[ $operation == "" ]] ; then
if [[ $verbosity != "quiet" ]] ; then
+ bootstrap_print_first
+
echo -e "${c_error}ERROR: No operation was given.${c_reset}"
fi
return 1
else
if [[ $verbosity != "quiet" ]] ; then
+ bootstrap_print_first
+
echo -e "${c_error}ERROR: The operation ${c_notice}${operation}${c_error} was not recognized.${c_reset}"
+
+ bootstrap_print_last
fi
bootstrap_cleanup
return 1
fi
+ if [[ $verbosity != "quiet" ]] ; then
+ if [[ $failure != "" || $verbosity != "error" ]] ; then
+ bootstrap_print_last
+ fi
+ fi
+
bootstrap_cleanup
return 0
bootstrap_help() {
- echo
+ bootstrap_print_first
+
echo -e "${c_title}${public_name}${c_reset}"
echo -e " ${c_notice}Version ${version}${c_reset}"
echo
echo -e " ${c_important}clean${c_reset} Delete all build files."
echo
echo -e "${c_highlight}Options:${c_reset}"
- echo -e " -${c_important}h${c_reset}, --${c_important}help${c_reset} Print this help screen."
- echo -e " +${c_important}d${c_reset}, ++${c_important}dark${c_reset} Use color modes that show up better on dark backgrounds."
- echo -e " +${c_important}l${c_reset}, ++${c_important}light${c_reset} Use color modes that show up better on light backgrounds."
- echo -e " +${c_important}n${c_reset}, ++${c_important}no_color${c_reset} Do not use color."
- echo -e " +${c_important}q${c_reset}, ++${c_important}quiet${c_reset} Decrease verbosity, silencing most output."
- echo -e " +${c_important}N${c_reset}, ++${c_important}normal${c_reset} Set verbosity to normal."
- echo -e " +${c_important}V${c_reset}, ++${c_important}verbose${c_reset} Increase verbosity beyond normal output."
- echo -e " +${c_important}D${c_reset}, ++${c_important}debug${c_reset} Enable debugging, significantly increasing verbosity beyond normal output."
- echo -e " +${c_important}v${c_reset}, ++${c_important}version${c_reset} Print the version number of this program."
+ echo -e " -${c_important}h${c_reset}, --${c_important}help${c_reset} Print this help message."
+ echo -e " +${c_important}C${c_reset}, ++${c_important}copyright${c_reset} Print the copyright."
+ echo -e " +${c_important}d${c_reset}, ++${c_important}dark${c_reset} Output using colors that show up better on dark backgrounds."
+ echo -e " +${c_important}l${c_reset}, ++${c_important}light${c_reset} Output using colors that show up better on light backgrounds."
+ echo -e " +${c_important}n${c_reset}, ++${c_important}no_color${c_reset} Do not print using color."
+ echo -e " +${c_important}Q${c_reset}, ++${c_important}quiet${c_reset} Decrease verbosity, silencing most print.to."
+ echo -e " +${c_important}E${c_reset}, ++${c_important}error${c_reset} Decrease verbosity, using only error print.to."
+ echo -e " +${c_important}N${c_reset}, ++${c_important}normal${c_reset} Set verbosity to normal."
+ echo -e " +${c_important}V${c_reset}, ++${c_important}verbose${c_reset} Increase verbosity beyond normal print.to."
+ echo -e " +${c_important}D${c_reset}, ++${c_important}debug${c_reset} Enable debugging, significantly increasing verbosity beyond normal print.to."
+ echo -e " +${c_important}v${c_reset}, ++${c_important}version${c_reset} Print only the version number."
echo
echo -e "${c_highlight}Bootstrap Options:${c_reset}"
echo -e " -${c_important}d${c_reset}, --${c_important}define${c_reset} Append an additional define after defines from settings file."
echo -e " --${c_important}disable-shared${c_reset} Forcibly do not build shared files."
echo -e " --${c_important}enable-static${c_reset} Forcibly do build static files."
echo -e " --${c_important}disable-static${c_reset} Forcibly do not build static files."
+
+ bootstrap_print_last
+}
+
+bootstrap_copyright() {
+
+ bootstrap_print_first
+
+ echo "Copyright © 2007-2023 Kevin Day."
echo
+ echo "Source code license lgpl-2.1-or-later."
+ echo "Standard and specification license open-standard-license-1.0."
+ echo "Documentation license cc-by-sa-4.0."
+
+ bootstrap_print_last
}
bootstrap_id() {
}
bootstrap_load_settings() {
- local -i failure=0
local i=
local key=
local value=
if [[ ! -d ${path_data}build/ ]] ; then
if [[ $verbosity != "quiet" ]] ; then
+ bootstrap_print_first
+
echo -e "${c_error}ERROR: No build settings directory '${c_notice}${path_data}build/${c_error}' could not be found or is not a valid directory.${c_reset}"
fi
let failure=1
elif [[ ! -f $settings_file ]] ; then
if [[ $verbosity != "quiet" ]] ; then
+ bootstrap_print_first
+
echo -e "${c_error}ERROR: No settings file ${c_notice}${settings_file}${c_error} could not be found or is not a valid file.${c_reset}"
fi
let failure=1
fi
- if [[ $failure -eq 1 ]] ; then
+ if [[ $failure != "" ]] ; then
return 1
fi
bootstrap_id "$i"
if [[ $key == "" ]] ; then
- if [[ $verbosity != "quiet" ]] ; then
+ if [[ $verbosity != "quiet" && $verbosity != "error" ]] ; then
echo -e "${c_warning}WARNING: Failed to find index for '${c_notice}${i}${c_warning}' when calling ${c_notice}bootstrap_id()${c_warning}.${c_reset}"
fi
bootstrap_id "$i"
if [[ $key == "" ]] ; then
- if [[ $verbosity != "quiet" ]] ; then
+ if [[ $verbosity != "quiet" && $verbosity != "error" ]] ; then
echo -e "${c_warning}WARNING: Failed to find index for '${c_notice}${i}${c_warning}' when calling ${c_notice}bootstrap_id()${c_warning}.${c_reset}"
fi
bootstrap_id "${i}-mode"
if [[ $key == "" ]] ; then
- if [[ $verbosity != "quiet" ]] ; then
+ if [[ $verbosity != "quiet" && $verbosity != "error" ]] ; then
echo -e "${c_warning}WARNING: Failed to find index for '${c_notice}$i-$m${c_warning}' when calling ${c_notice}bootstrap_id()${c_warning}.${c_reset}"
fi
bootstrap_id "${i}-mode"
if [[ $key == "" ]] ; then
- if [[ $verbosity != "quiet" ]] ; then
+ if [[ $verbosity != "quiet" && $verbosity != "error" ]] ; then
echo -e "${c_warning}WARNING: Failed to find index for '${c_notice}${i}-${m}${c_warning}' when calling ${c_notice}bootstrap_id()${c_warning}.${c_reset}"
fi
}
bootstrap_prepare_build() {
- local -i failure=0
local alt=$1
local i=
mkdir $verbose_common -p ${path_build}{documents,includes,libraries/{script,shared,static},objects/{script,shared,static},programs/{script,shared,static},settings,stage} || failure=1
- if [[ $failure -eq 1 ]] ; then
- if [[ $verbosity != "quiet" ]] ; then
+ if [[ $failure != "" ]] ; then
+ if [[ $verbosity != "quiet" && $verbosity != "error" ]] ; then
echo -e "${c_warning}WARNING: Failed to create build directories in '${c_notice}${path_build}${c_error}'.${c_reset}"
fi
- return $failure
+ return 1
fi
bootstrap_id "path_headers-mode"
fi
fi
- if [[ $failure -eq 1 ]] ; then
- if [[ $verbosity != "quiet" ]] ; then
+ if [[ $failure != "" ]] ; then
+ if [[ $verbosity != "quiet" && $verbosity != "error" ]] ; then
echo -e "${c_warning}WARNING: Failed to create ${c_notice}path_heades${c_error} build directories in '${c_notice}${path_build}${c_error}'.${c_reset}"
fi
- return $failure
+ return 1
fi
touch ${project_built}-${settings_name}.prepared
+
+ if [[ $failure == "" ]] ; then
+ return 0
+ fi
+
+ return 1
}
bootstrap_operation_build() {
- local -i failure=0
local i=
local n=
local version_file=
bootstrap_operation_build_prepare_remaining
if [[ $build_shared == "yes" && -f ${project_built_shared}.built || $build_static == "yes" && -f ${project_built_static}.built ]] ; then
- if [[ $verbosity != "quiet" ]] ; then
+ if [[ $verbosity != "quiet" && $verbosity != "error" ]] ; then
echo -e "${c_warning}WARNING: This project has already been built.${c_reset}"
fi
bootstrap_operation_build_validate_build
- if [[ $failure -eq 1 ]] ; then
+ if [[ $failure != "" ]] ; then
return 1
fi
else
mkdir $verbose_common -p ${path_build}documentation/${directory} || failure=1
- if [[ $failure -eq 0 ]] ; then
+ if [[ $failure == "" ]] ; then
cp $verbose_common -R ${path_documentation}${i} ${path_build}documentation/${directory}/ || failure=1
fi
fi
else
mkdir $verbose_common -p ${path_build}settings/${directory} || failure=1
- if [[ $failure -eq 0 ]] ; then
+ if [[ $failure == "" ]] ; then
cp $verbose_common -R ${path_settings}${i} ${path_build}settings/${directory}/ || failure=1
fi
fi
done
fi
- if [[ $failure -eq 0 && $sources_headers != "" ]] ; then
+ if [[ $failure == "" && $sources_headers != "" ]] ; then
if [[ $preserve_path_headers == "yes" ]] ; then
for i in $sources_headers ; do
directory=$(dirname $i)
mkdir $verbose_common -p ${path_build}includes/${path_headers}${directory} || failure=1
fi
- if [[ $failure -eq 0 ]] ; then
+ if [[ $failure == "" ]] ; then
cp $verbose_common -f ${path_sources}${path_language}${i} ${path_build}includes/${path_headers}${i} || failure=1
fi
fi
fi
fi
- if [[ $failure -eq 0 && $build_shared == "yes" && ! -f ${project_built_shared}.built ]] ; then
+ if [[ $failure == "" && $build_shared == "yes" && ! -f ${project_built_shared}.built ]] ; then
if [[ $sources_object != "" || $sources_object_shared != "" ]] ; then
sources=
let count=0
done
if [[ $count -gt 1 ]] ; then
- if [[ $verbosity != "quiet" ]] ; then
+ if [[ $verbosity != "quiet" && $verbosity != "error" ]] ; then
echo -e "${c_warning}WARNING: Multiple '${c_notice}sources_object_shared${c_warning}' found, only using the first one found is going to be used.${c_reset}"
fi
fi
for i in $sources_object_shared ; do
sources="${path_sources_object}${path_language}${i} "
+
break
done
else
done
if [[ $count -gt 1 ]] ; then
- if [[ $verbosity != "quiet" ]] ; then
+ if [[ $verbosity != "quiet" && $verbosity != "error" ]] ; then
echo -e "${c_warning}WARNING: Multiple '${c_notice}sources_object${c_warning}' found, only using the first one found is going to be used.${c_reset}"
fi
fi
for i in $sources_object ; do
sources="${path_sources_object}${path_language}${i} "
+
break
done
fi
$build_compiler $sources -shared -Wl,-soname,lib${build_name}.so${version_target} -o ${path_build}libraries/${path_library_shared}lib${build_name}.so$version_file $arguments_shared $arguments_include $libraries $libraries_shared $flags $flags_shared $flags_library $flags_library_shared $defines $defines_shared $defines_library $defines_library_shared $define_extra || failure=1
- if [[ $failure -eq 0 ]] ; then
+ if [[ $failure == "" ]] ; then
if [[ $version_file_value != "major" ]] ; then
if [[ $version_file_value == "minor" ]] ; then
ln $verbose_common -sf lib${build_name}.so${version_file} ${path_build}libraries/${path_library_shared}lib${build_name}.so${version_major_prefix}${version_major} || failure=1
else
ln $verbose_common -sf lib${build_name}.so${version_major_prefix}${version_major}${version_minor_prefix}${version_minor} ${path_build}libraries/${path_library_shared}lib${build_name}.so${version_major_prefix}${version_major} || failure=1
- if [[ $failure -eq 0 ]] ; then
+ if [[ $failure == "" ]] ; then
if [[ $version_file_value == "micro" ]] ; then
ln $verbose_common -sf lib$build_name.so$version_file ${path_build}libraries/${path_library_shared}lib$build_name.so$version_major_prefix$version_major$version_minor_prefix$version_minor || failure=1
else
ln $verbose_common -sf lib${build_name}.so${version_major_prefix}${version_major}${version_minor_prefix}${version_minor}${version_micro_prefix}${version_micro} ${path_build}libraries/${path_library_shared}lib${build_name}.so${version_major_prefix}${version_major}${version_minor_prefix}${version_minor} || failure=1
- if [[ $failure -eq 0 ]] ; then
+ if [[ $failure == "" ]] ; then
ln $verbose_common -sf lib${build_name}.so${version_file} ${path_build}libraries/${path_library_shared}lib${build_name}.so${version_major_prefix}${version_major}${version_minor_prefix}${version_minor_prefix}${version_minor}${version_micro_prefix}${version_micro} || failure=1
fi
fi
fi
fi
- if [[ $failure -eq 0 ]] ; then
+ if [[ $failure == "" ]] ; then
ln ${verbose_common} -sf lib${build_name}.so${version_major_prefix}${version_major} ${path_build}libraries/${path_library_shared}lib${build_name}.so || failure=1
fi
fi
fi
- if [[ $failure -eq 0 && $sources_program != "" ]] ; then
+ if [[ $failure == "" && $sources_program != "" ]] ; then
sources=
links=
$build_compiler $sources -o ${path_build}programs/${path_program_shared}${build_name} $arguments_shared $arguments_include $links $libraries $libraries_shared $flags $flags_shared $flags_program $flags_program_shared $defines $defines_shared $defines_program $defines_program_shared $define_extra || failure=1
fi
- if [[ $failure -eq 0 ]] ; then
+ if [[ $failure == "" ]] ; then
touch ${project_built_shared}-${settings_name}.built
fi
fi
- if [[ $failure -eq 0 && $build_static == "yes" && ! -f ${project_built_static}.built ]] ; then
+ if [[ $failure == "" && $build_static == "yes" && ! -f ${project_built_static}.built ]] ; then
if [[ $sources_object != "" || $sources_object_static != "" ]] ; then
let count=0
done
if [[ $count -gt 1 ]] ; then
- if [[ $verbosity != "quiet" ]] ; then
+ if [[ $verbosity != "quiet" && $verbosity != "error" ]] ; then
echo -e "${c_warning}WARNING: Multiple '${c_notice}sources_object_static${c_warning}' found, only using the first one found is going to be used.${c_reset}"
fi
fi
for i in $sources_object_static ; do
sources="${path_sources_object}${path_language}${i} "
+
break
done
else
done
if [[ $count -gt 1 ]] ; then
- if [[ $verbosity != "quiet" ]] ; then
+ if [[ $verbosity != "quiet" && $verbosity != "error" ]] ; then
echo -e "${c_warning}WARNING: Multiple '${c_notice}sources_object${c_warning}' found, only using the first one found is going to be used.${c_reset}"
fi
fi
for i in $sources_object ; do
sources="${path_sources_object}${path_language}${i} "
+
break
done
fi
$build_compiler ${path_sources}${path_language}${i} -c -static -o ${path_build}objects/${directory}/${n}.o $arguments_static $arguments_include $libraries $libraries_static $flags $flags_static $flags_library $flags_library_static $defines $defines_static $defines_library $defines_library_static $define_extra || failure=1
- if [[ $failure -eq 1 ]] ; then
+ if [[ $failure != "" ]] ; then
break;
fi
done
- if [[ $failure -eq 0 && ( $sources_library != "" || $sources_library_static != "" ) ]] ; then
+ if [[ $failure == "" && ( $sources_library != "" || $sources_library_static != "" ) ]] ; then
if [[ $verbosity == "verbose" ]] ; then
echo $build_indexer $build_indexer_arguments ${path_build}libraries/${path_library_static}lib${build_name}.a $sources
fi
fi
- if [[ $failure -eq 0 && $sources_program != "" ]] ; then
+ if [[ $failure == "" && $sources_program != "" ]] ; then
sources=
links=
$build_compiler $sources -static -o ${path_build}programs/${path_program_static}${build_name} $arguments_static $arguments_include $links $libraries $libraries_static $flags $flags_static $flags_program $flags_program_static $defines $defines_static $defines_program $defines_program_static $define_extra || failure=1
fi
- if [[ $failure -eq 0 ]] ; then
+ if [[ $failure == "" ]] ; then
touch ${project_built_static}-${settings_name}.built
fi
fi
- if [[ $failure -eq 1 ]] ; then
+ if [[ $failure != "" ]] ; then
if [[ $verbosity != "quiet" ]] ; then
+ bootstrap_print_first
+
echo -e "${c_error}ERROR: Failed to build.${c_reset}"
fi
+ let failure=1
+
return 1
fi
+
+ if [[ $failure == "" ]] ; then
+ return 0
+ fi
+
+ return 1
}
bootstrap_operation_build_prepare_defaults() {
if [[ $build_compiler == "" ]] ; then
if [[ $verbosity != "quiet" ]] ; then
+ bootstrap_print_first
+
echo -e "${c_error}ERROR: Cannot Build, no '${c_notice}build_compiler${c_error}' specified, such as '${c_notice}gcc${c_error}'.${c_reset}"
fi
if [[ $build_indexer == "" ]] ; then
if [[ $verbosity != "quiet" ]] ; then
+ bootstrap_print_first
+
echo -e "${c_error}ERROR: Cannot Build, no '${c_notice}build_indexer${c_error}' specified, such as '${c_notice}ar${c_error}'.${c_reset}"
fi
let failure=1
fi
+
+ if [[ $failure == "" ]] ; then
+ return 0
+ fi
+
+ return 1
}
bootstrap_operation_build_validate_paths() {
if [[ $path_sources == "" || ! -d $path_sources ]] ; then
if [[ $verbosity != "quiet" ]] ; then
+ bootstrap_print_first
+
echo -e "${c_error}ERROR: The sources directory ${c_notice}${path_sources}${c_error} is not a valid directory.${c_reset}"
fi
let failure=1
fi
- if [[ $failure -eq 0 && $path_sources_object != "" && ! -d $path_sources_object ]] ; then
+ if [[ $failure == "" && $path_sources_object != "" && ! -d $path_sources_object ]] ; then
if [[ $verbosity != "quiet" ]] ; then
+ bootstrap_print_first
+
echo -e "${c_error}ERROR: The sources object directory ${c_notice}${path_sources_object}${c_error} is not a valid directory.${c_reset}"
fi
let failure=1
fi
+
+ if [[ $failure == "" ]] ; then
+ return 0
+ fi
+
+ return 1
}
bootstrap_operation_build_validate_search() {
if [[ $build_shared != "yes" && $build_static != "yes" ]] ; then
if [[ $verbosity != "quiet" ]] ; then
+ bootstrap_print_first
+
echo -e "${c_error}ERROR: Cannot Build, either build_shared or build_static must be set to 'yes'.${c_reset}"
fi
if [[ $search_shared != "yes" && $search_static != "yes" ]] ; then
if [[ $verbosity != "quiet" ]] ; then
+ bootstrap_print_first
+
echo -e "${c_error}ERROR: Cannot Build, either search_shared or search_static must be set to 'yes'.${c_reset}"
fi
let failure=1
fi
+
+ if [[ $failure == "" ]] ; then
+ return 0
+ fi
+
+ return 1
}
bootstrap_operation_build_validate_sources() {
for i in $sources_script ; do
if [[ $i != "$(echo $i | sed -e 's|^//*||' -e 's|^\.\.//*||' -e 's|/*$||')" ]] ; then
if [[ $verbosity != "quiet" ]] ; then
+ bootstrap_print_first
+
echo -e "${c_error}ERROR: Cannot Build, invalid build_sources_script path provided: '${i}'.${c_reset}"
fi
for i in $sources_headers ; do
if [[ $i != "$(echo $i | sed -e 's|^//*||' -e 's|^\.\.//*||' -e 's|/*$||')" ]] ; then
if [[ $verbosity != "quiet" ]] ; then
+ bootstrap_print_first
+
echo -e "${c_error}ERROR: Cannot Build, invalid build_sources_headers path provided: '${i}'.${c_reset}"
fi
for i in $sources_library ; do
if [[ $i != "$(echo $i | sed -e 's|^//*||' -e 's|^\.\.//*||' -e 's|/*$||')" ]] ; then
if [[ $verbosity != "quiet" ]] ; then
+ bootstrap_print_first
+
echo -e "${c_error}ERROR: Cannot Build, invalid build_sources_library path provided: '${i}'.${c_reset}"
fi
for i in $sources_library_object ; do
if [[ $i != "$(echo $i | sed -e 's|^//*||' -e 's|^\.\.//*||' -e 's|/*$||')" ]] ; then
if [[ $verbosity != "quiet" ]] ; then
+ bootstrap_print_first
+
echo -e "${c_error}ERROR: Cannot Build, invalid build_sources_library_object path provided: '${i}'.${c_reset}"
fi
for i in $sources_program_object ; do
if [[ $i != "$(echo $i | sed -e 's|^//*||' -e 's|^\.\.//*||' -e 's|/*$||')" ]] ; then
if [[ $verbosity != "quiet" ]] ; then
+ bootstrap_print_first
+
echo -e "${c_error}ERROR: Cannot Build, invalid build_sources_program_object path provided: '${i}'.${c_reset}"
fi
for i in $sources_program ; do
if [[ $i != "$(echo $i | sed -e 's|^//*||' -e 's|^\.\.//*||' -e 's|/*$||')" ]] ; then
if [[ $verbosity != "quiet" ]] ; then
+ bootstrap_print_first
+
echo -e "${c_error}ERROR: Cannot Build, invalid build_sources_program path provided: '${i}'.${c_reset}"
fi
for i in $sources_documentation ; do
if [[ $i != "$(echo $i | sed -e 's|^//*||' -e 's|^\.\.//*||' -e 's|/*$||')" ]] ; then
if [[ $verbosity != "quiet" ]] ; then
+ bootstrap_print_first
+
echo -e "${c_error}ERROR: Cannot Build, invalid build_sources_documentation path provided: '${i}'.${c_reset}"
fi
for i in $sources_setting ; do
if [[ $i != "$(echo $i | sed -e 's|^//*||' -e 's|^\.\.//*||' -e 's|/*$||')" ]] ; then
if [[ $verbosity != "quiet" ]] ; then
+ bootstrap_print_first
+
echo -e "${c_error}ERROR: Cannot Build, invalid build_sources_setting path provided: '${i}'.${c_reset}"
fi
let failure=1
fi
done
+
+ if [[ $failure == "" ]] ; then
+ return 0
+ fi
+
+ return 1
}
bootstrap_operation_build_prepare_versions() {
fi
}
+bootstrap_print_first() {
+
+ if [[ $print_line_first == "yes" ]] ; then
+ echo
+
+ print_line_first=
+ fi
+}
+
+bootstrap_print_last() {
+
+ if [[ $print_line_last == "yes" ]] ; then
+ echo
+ fi
+}
+
bootstrap_cleanup() {
+ unset bootstrap_copyright
unset bootstrap_main
unset bootstrap_handle_colors
unset bootstrap_help
unset bootstrap_operation_build_validate_shared_static
unset bootstrap_operation_build_validate_sources
unset bootstrap_operation_clean
+ unset bootstrap_print_first
+ unset bootstrap_print_last
unset bootstrap_cleanup
}
local c_subtle="\\033[1;30m"
local c_prefix="\\"
+ local failure=
local operation=
local operation_failure=
local verbosity=normal
verbose_common="-v"
elif [[ $p == "+v" || $p == "++version" ]] ; then
echo $version
- return
+ return 0
elif [[ $p == "-b" || $p == "--build" ]] ; then
grab_next=path_build
elif [[ $p == "-P" || $p == "--prefix" ]] ; then
p=
fi
+ if [[ $verbosity == "quiet" ]] ; then
+ print_line_first="no"
+ print_line_last="no"
+ fi
+
install_handle_colors
if [[ $do_help == "yes" ]] ; then
if [[ $operation_failure == "fail-unsupported" ]] ; then
if [[ $verbosity != "quiet" ]] ; then
- if [[ $print_line_first == "yes" ]] ; then
- echo
- fi
+ install_print_first
echo -e "${c_error}ERROR: The operation ${c_notice}$operation${c_error} was not recognized.${c_reset}"
- if [[ $print_line_last == "yes" ]] ; then
- echo
- fi
+ install_print_last
fi
install_cleanup
if [[ ! -d $path_build ]] ; then
if [[ $verbosity != "quiet" ]] ; then
- if [[ $print_line_first == "yes" ]] ; then
- echo
- fi
+ install_print_first
echo -e "${c_error}ERROR: The build path ${c_notice}$path_build${c_error} is not a valid directory.${c_reset}"
- if [[ $print_line_last == "yes" ]] ; then
- echo
- fi
+ install_print_last
fi
install_cleanup
if [[ $work == "" && $destination_prefix != "" && ! -d $destination_prefix ]] ; then
if [[ $verbosity != "quiet" ]] ; then
- if [[ $print_line_first == "yes" ]] ; then
- echo
- fi
+ install_print_first
echo -e "${c_error}ERROR: The destination prefix ${c_notice}$destination_prefix${c_error} is not a valid directory.${c_reset}"
- if [[ $print_line_last == "yes" ]] ; then
- echo
- fi
+ install_print_last
fi
install_cleanup
if [[ $work != "" && ! -d $work ]] ; then
if [[ $verbosity != "quiet" ]] ; then
- if [[ $print_line_first == "yes" ]] ; then
- echo
- fi
+ install_print_first
echo -e "${c_error}ERROR: The work directory ${c_notice}$work${c_error} is not a valid directory.${c_reset}"
- if [[ $print_line_last == "yes" ]] ; then
- echo
- fi
+ install_print_last
fi
install_cleanup
if [[ $work == "" && -e $destination_programs && ! -d $destination_programs ]] ; then
if [[ $verbosity != "quiet" ]] ; then
- if [[ $print_line_first == "yes" ]] ; then
- echo
- fi
+ install_print_first
echo -e "${c_error}ERROR: The destination bindir ${c_notice}$destination_programs${c_error} is not a valid directory.${c_reset}"
- if [[ $print_line_last == "yes" ]] ; then
- echo
- fi
+ install_print_last
fi
install_cleanup
if [[ $work == "" && -e $destination_programs_static && ! -d $destination_programs_static ]] ; then
if [[ $verbosity != "quiet" ]] ; then
- if [[ $print_line_first == "yes" ]] ; then
- echo
- fi
+ install_print_first
echo -e "${c_error}ERROR: The destination (${c_notice}static${c_error}) bindir ${c_notice}$destination_programs_static${c_error} is not a valid directory.${c_reset}"
- if [[ $print_line_last == "yes" ]] ; then
- echo
- fi
+ install_print_last
fi
install_cleanup
if [[ $work == "" && -e $destination_programs_shared && ! -d $destination_programs_shared ]] ; then
if [[ $verbosity != "quiet" ]] ; then
- if [[ $print_line_first == "yes" ]] ; then
- echo
- fi
+ install_print_first
echo -e "${c_error}ERROR: The destination (${c_notice}shared${c_error}) bindir ${c_notice}$destination_programs_shared${c_error} is not a valid directory.${c_reset}"
- if [[ $print_line_last == "yes" ]] ; then
- echo
- fi
+ install_print_last
fi
install_cleanup
if [[ $work == "" && -e $destination_includes && ! -d $destination_includes ]] ; then
if [[ $verbosity != "quiet" ]] ; then
- if [[ $print_line_first == "yes" ]] ; then
- echo
- fi
+ install_print_first
echo -e "${c_error}ERROR: The destination incluedir ${c_notice}$destination_includes${c_error} is not a valid directory.${c_reset}"
- if [[ $print_line_last == "yes" ]] ; then
- echo
- fi
+ install_print_last
fi
install_cleanup
if [[ $work == "" && -e $destination_libraries_static && ! -d $destination_libraries_static ]] ; then
if [[ $verbosity != "quiet" ]] ; then
- if [[ $print_line_first == "yes" ]] ; then
- echo
- fi
+ install_print_first
echo -e "${c_error}ERROR: The destination (${c_notice}static${c_error}) libdir ${c_notice}$destination_libraries_static${c_error} is not a valid directory.${c_reset}"
- if [[ $print_line_last == "yes" ]] ; then
- echo
- fi
+ install_print_last
fi
install_cleanup
if [[ $work == "" && -e $destination_libraries_shared && ! -d $destination_libraries_shared ]] ; then
if [[ $verbosity != "quiet" ]] ; then
- if [[ $print_line_first == "yes" ]] ; then
- echo
- fi
+ install_print_first
echo -e "${c_error}ERROR: The destination (${c_notice}shared${c_error}) libdir ${c_notice}$destination_libraries_shared${c_error} is not a valid directory.${c_reset}"
- if [[ $print_line_last == "yes" ]] ; then
- echo
- fi
+ install_print_last
fi
install_cleanup
install_perform_install
+ if [[ $verbosity != "quiet" ]] ; then
+ if [[ $failure != "" || $verbosity != "error" ]] ; then
+ install_print_last
+ fi
+ fi
+
install_cleanup
- return 0
+ if [[ $failure == "" ]] ; then
+ return 0
+ fi
+
+ return 1
}
install_handle_colors() {
install_help() {
- if [[ $print_line_first == "yes" ]] ; then
- echo
- fi
+ install_print_first
echo -e "${c_title}${public_name}${c_reset}"
echo -e " ${c_notice}Version ${version}${c_reset}"
echo -e " --${c_important}programs-static${c_reset} Custom destination for static programs."
echo -e " --${c_important}programs-shared${c_reset} Custom destination for shared programs."
- if [[ $print_line_last == "yes" ]] ; then
- echo
- fi
+ install_print_last
}
install_copyright() {
- if [[ $print_line_first == "yes" ]] ; then
- echo
- fi
+ install_print_first
echo "Copyright © 2007-2023 Kevin Day."
echo
echo "Standard and specification license open-standard-license-1.0."
echo "Documentation license cc-by-sa-4.0."
- if [[ $print_line_last == "yes" ]] ; then
- echo
- fi
+ install_print_last
}
install_perform_install() {
local key=
local i=
local path=
- local failure=
local message=
if [[ $enable_shared == "no" ]] ; then
destination_settings=${work}settings/
fi
- if [[ $verbosity != "quiet" && $print_line_first == "yes" ]] ; then
- echo
- fi
-
- print_line_first="done"
-
if [[ ! -d ${destination_prefix} ]] ; then
mkdir $verbose_common ${destination_prefix}
if [[ $? -ne 0 ]] ; then
if [[ $verbosity != "quiet" ]] ; then
+ install_print_first
+
echo -e "${c_error}ERROR: Failed to create install ${message} ${c_notice}${destination_prefix}${c_error}.${c_reset}"
fi
- failure=1
+ let failure=1
fi
fi
if [[ $? -ne 0 ]] ; then
if [[ $verbosity != "quiet" ]] ; then
+ install_print_first
+
echo -e "${c_error}ERROR: Failed to create install ${message} ${c_notice}${destination_programs}${c_error}.${c_reset}"
fi
- failure=1
+ let failure=1
fi
fi
if [[ $? -ne 0 ]] ; then
if [[ $verbosity != "quiet" ]] ; then
+ install_print_first
+
echo -e "${c_error}ERROR: Failed to create install ${message} ${c_notice}${destination_programs_shared}${c_error}.${c_reset}"
fi
- failure=1
+ let failure=1
fi
fi
if [[ $? -ne 0 ]] ; then
if [[ $verbosity != "quiet" ]] ; then
+ install_print_first
+
echo -e "${c_error}ERROR: Failed to create install ${message} ${c_notice}${destination_programs_static}${c_error}.${c_reset}"
fi
- failure=1
+ let failure=1
fi
fi
fi
if [[ $? -ne 0 ]] ; then
if [[ $verbosity != "quiet" ]] ; then
+ install_print_first
+
echo -e "${c_error}ERROR: Failed to create install ${message} ${c_notice}${destination_libraries}${c_error}.${c_reset}"
fi
- failure=1
+ let failure=1
fi
fi
if [[ $? -ne 0 ]] ; then
if [[ $verbosity != "quiet" ]] ; then
+ install_print_first
+
echo -e "${c_error}ERROR: Failed to create ${message} ${c_notice}${destination_libraries_shared}${c_error}.${c_reset}"
fi
- failure=1
+ let failure=1
fi
fi
if [[ $? -ne 0 ]] ; then
if [[ $verbosity != "quiet" ]] ; then
+ install_print_first
+
echo -e "${c_error}ERROR: Failed to create ${message} ${c_notice}${destination_libraries_static}${c_error}.${c_reset}"
fi
- failure=1
+ let failure=1
fi
fi
fi
if [[ $? -ne 0 ]] ; then
if [[ $verbosity != "quiet" ]] ; then
+ install_print_first
+
echo -e "${c_error}ERROR: Failed to create ${message} ${c_notice}${destination_includes}${c_error}.${c_reset}"
fi
- failure=1
+ let failure=1
fi
fi
fi
if [[ $? -ne 0 ]] ; then
if [[ $verbosity != "quiet" ]] ; then
+ install_print_first
+
echo -e "${c_error}ERROR: Failed to create ${message} ${c_notice}${destination_documentation}${c_error}.${c_reset}"
fi
- failure=1
+ let failure=1
fi
fi
fi
if [[ $? -ne 0 ]] ; then
if [[ $verbosity != "quiet" ]] ; then
+ install_print_first
+
echo -e "${c_error}ERROR: Failed to create ${message} ${c_notice}${destination_settings}${c_error}.${c_reset}"
fi
- failure=1
+ let failure=1
fi
fi
fi
fi
if [[ $file != "" ]] ; then
- if [[ $verbosity != "quiet" ]] ; then
- install_print_first
+ if [[ $verbosity != "quiet" && $verbosity != "error" ]] ; then
+ install_print_first_or_always
echo -e "${c_highlight}Installing Includes to: ${c_reset}${c_notice}${destination_includes}${c_reset}${c_highlight}.${c_reset}"
fi
if [[ $? -ne 0 ]] ; then
if [[ $verbosity != "quiet" ]] ; then
+ install_print_first
+
echo -e "${c_error}ERROR: Failed to copy include files from ${c_notice}${path_build}${path_includes}${c_error} to ${c_notice}${destination_includes}${c_error}.${c_reset}"
fi
- failure=1
+ let failure=1
fi
fi
fi
fi
if [[ $file != "" ]] ; then
- if [[ $verbosity != "quiet" ]] ; then
- install_print_first
+ if [[ $verbosity != "quiet" && $verbosity != "error" ]] ; then
+ install_print_first_or_always
echo -e "${c_highlight}Installing (${c_notice}static${c_highlight}) Libraries to: ${c_reset}${c_notice}${destination_libraries_static}${c_reset}${c_highlight}.${c_reset}"
fi
if [[ $? -ne 0 ]] ; then
if [[ $verbosity != "quiet" ]] ; then
+ install_print_first
+
echo -e "${c_error}ERROR: Failed to copy (${c_notice}static${c_error}) library files from ${c_notice}${path_build}${path_libraries}${path_static}${c_error} to ${c_notice}${destination_libraries_static}${c_error}.${c_reset}"
fi
- failure=1
+ let failure=1
fi
fi
fi
fi
if [[ $file != "" ]] ; then
- if [[ $verbosity != "quiet" ]] ; then
- install_print_first
+ if [[ $verbosity != "quiet" && $verbosity != "error" ]] ; then
+ install_print_first_or_always
echo -e "${c_highlight}Installing (${c_notice}shared${c_highlight}) Libraries to: ${c_reset}${c_notice}${destination_libraries_shared}${c_reset}${c_highlight}.${c_reset}"
fi
if [[ $? -ne 0 ]] ; then
if [[ $verbosity != "quiet" ]] ; then
+ install_print_first
+
echo -e "${c_error}ERROR: Failed to copy (${c_notice}shared${c_error}) library files from ${c_notice}${path_build}${path_libraries}${path_shared}${c_error} to ${c_notice}${destination_libraries_shared}${c_error}.${c_reset}"
fi
- failure=1
+ let failure=1
fi
fi
fi
fi
if [[ $file != "" && $enable_static_programs == "yes" ]] ; then
- if [[ $verbosity != "quiet" ]] ; then
- install_print_first
+ if [[ $verbosity != "quiet" && $verbosity != "error" ]] ; then
+ install_print_first_or_always
echo -e "${c_highlight}Installing (${c_notice}static${c_highlight}) Programs to: ${c_reset}${c_notice}${destination_programs_static}${c_reset}${c_highlight}.${c_reset}"
fi
if [[ $? -ne 0 ]] ; then
if [[ $verbosity != "quiet" ]] ; then
+ install_print_first
+
echo -e "${c_error}ERROR: failed to copy (${c_notice}static${c_error}) program files from ${c_notice}${path_build}${path_programs}${path_static}${c_error} to ${c_notice}${destination_programs_static}${c_error}.${c_reset}"
fi
- failure=1
+ let failure=1
fi
fi
fi
fi
if [[ $file != "" ]] ; then
- if [[ $verbosity != "quiet" ]] ; then
- install_print_first
+ if [[ $verbosity != "quiet" && $verbosity != "error" ]] ; then
+ install_print_first_or_always
echo -e "${c_highlight}Installing (${c_notice}shared${c_highlight}) Programs to: ${c_reset}${c_notice}${destination_programs_shared}${c_reset}${c_highlight}.${c_reset}"
fi
if [[ $? -ne 0 ]] ; then
if [[ $verbosity != "quiet" ]] ; then
+ install_print_first
+
echo -e "${c_error}ERROR: failed to copy (${c_notice}shared${c_error}) program files from ${c_notice}${path_build}${path_programs}${path_shared}${c_error} to ${c_notice}${destination_programs_shared}${c_error}.${c_reset}"
fi
- failure=1
+ let failure=1
fi
fi
fi
fi
- if [[ $failure == "" && -d ${path_build}${path_settings} && $verbosity != "quiet" ]] ; then
+ if [[ $failure == "" && -d ${path_build}${path_settings} && $enable_settings == "yes" ]] ; then
for i in ${path_build}${path_settings}* ; do
file=$(echo $i | sed -e "s|^${path_build}${path_settings}||")
fi
if [[ $file != "" ]] ; then
- if [[ $verbosity != "quiet" ]] ; then
- install_print_first
+ if [[ $verbosity != "quiet" && $verbosity != "error" ]] ; then
+ install_print_first_or_always
- echo -e "${c_highlight}Installing Documentation to: ${c_reset}${c_notice}${destination_settings}${c_reset}${c_highlight}.${c_reset}"
+ echo -e "${c_highlight}Installing Settings to: ${c_reset}${c_notice}${destination_settings}${c_reset}${c_highlight}.${c_reset}"
fi
cp $verbose_common -R ${path_build}${path_settings}* ${destination_settings}
if [[ $? -ne 0 ]] ; then
if [[ $verbosity != "quiet" ]] ; then
- echo -e "${c_error}ERROR: failed to copy documentation files from ${c_notice}${path_build}${path_programs}${path_static}${c_error} to ${c_notice}${destination_settings}${c_error}.${c_reset}"
+ install_print_first
+
+ echo -e "${c_error}ERROR: failed to copy settings files from ${c_notice}${path_build}${path_settings}${c_error} to ${c_notice}${destination_settings}${c_error}.${c_reset}"
fi
- failure=1
+ let failure=1
fi
fi
fi
fi
if [[ $file != "" ]] ; then
- if [[ $verbosity != "quiet" ]] ; then
- install_print_first
+ if [[ $verbosity != "quiet" && $verbosity != "error" ]] ; then
+ install_print_first_or_always
echo -e "${c_highlight}Installing Documentation to: ${c_reset}${c_notice}${destination_documentation}${c_reset}${c_highlight}.${c_reset}"
fi
if [[ $? -ne 0 ]] ; then
if [[ $verbosity != "quiet" ]] ; then
- echo -e "${c_error}ERROR: failed to copy documentation files from ${c_notice}${path_build}${path_programs}${path_static}${c_error} to ${c_notice}${destination_documentation}${c_error}.${c_reset}"
+ install_print_first
+
+ echo -e "${c_error}ERROR: failed to copy documentation files from ${c_notice}${path_build}${path_documentation}${c_error} to ${c_notice}${destination_documentation}${c_error}.${c_reset}"
fi
- failure=1
+ let failure=1
fi
fi
fi
- if [[ $verbosity != "quiet" && $print_line_last == "yes" ]] ; then
- echo
+ if [[ $failure == "" ]] ; then
+ return 0
fi
- if [[ $failure != "" ]] ; then
- install_cleanup
+ return 1
+}
+
+install_print_first() {
+
+ if [[ $print_line_first == "yes" ]] ; then
+ echo
- exit $failure
+ print_line_first=
fi
}
-install_print_first() {
+install_print_first_or_always() {
- if [[ $print_line_first == "done" ]] ; then
+ if [[ $print_line_first == "yes" ]] ; then
+ echo
+
+ print_line_first=
+ elif [[ $print_line_first == "no" ]] ; then
print_line_first=
else
echo
fi
}
+install_print_last() {
+
+ if [[ $print_line_last == "yes" ]] ; then
+ echo
+ fi
+}
+
install_cleanup() {
unset install_copyright
unset install_help
unset install_perform_install
unset install_print_first
-
+ unset install_print_first_or_always
+ unset install_print_last
unset install_cleanup
}
local grab_next=
local do_color=dark
local do_help=
+ local do_copyright=
local i=0
local p=
local t=0
local c_prefix="\\"
local -A variables=()
+ local failure=
local operation=
local operation_failure=
local mode_individual=
local path_destination=package/
local path_sources=./
local prepend=
+ local print_line_first="yes"
+ local print_line_last="yes"
local verbosity=normal
local verbose=
local verbose_common=
if [[ $grab_next == "" ]] ; then
if [[ $p == "-h" || $p == "--help" ]] ; then
do_help=yes
+ elif [[ $p == "+C" || $p == "++copyright" ]] ; then
+ do_copyright="yes"
elif [[ $p == "+d" || $p == "++dark" ]] ; then
do_color=dark
context="+d"
elif [[ $p == "+n" || $p == "++no_color" ]] ; then
do_color=none
context="+n"
- elif [[ $p == "+q" || $p == "++quiet" ]] ; then
+ elif [[ $p == "+Q" || $p == "++quiet" ]] ; then
verbosity="quiet"
- verbose="+q"
+ verbose="+Q"
+ verbose_common=
+ elif [[ $p == "+E" || $p == "++error" ]] ; then
+ verbosity="error"
+ verbose="+E"
verbose_common=
elif [[ $p == "+N" || $p == "++normal" ]] ; then
verbosity=
verbose_common="-v"
elif [[ $p == "+v" || $p == "++version" ]] ; then
echo $version
- return
+ return 0
elif [[ $p == "-b" || $p == "--build" ]] ; then
grab_next=path_build
elif [[ $p == "-d" || $p == "--destination" ]] ; then
p=
fi
+ if [[ $verbosity == "quiet" ]] ; then
+ print_line_first="no"
+ print_line_last="no"
+ fi
+
package_handle_colors
if [[ $do_help == "yes" ]] ; then
return 0
fi
+ if [[ $do_copyright == "yes" ]] ; then
+ package_copyright
+ package_cleanup
+
+ return 0
+ fi
+
if [[ $operation_failure == "fail-multiple" ]] ; then
if [[ $verbosity != "quiet" ]] ; then
+ package_print_first
+
echo -e "${c_error}ERROR: Only one operation may be specified at a time.${c_reset}"
+
+ package_print_last
fi
package_cleanup
if [[ ! -f build/stand_alone/$i.settings ]] ; then
if [[ $verbosity != "quiet" ]] ; then
+ package_print_first
+
echo -e "${c_error}ERROR: Unknown or unsupported stand alone program '${c_notice}$i${c_error}'.${c_reset}"
+
+ package_print_last
fi
package_cleanup
if [[ $operation == "build" || $operation == "rebuild" ]] ; then
if [[ ! -d $path_build ]] ; then
if [[ $verbosity != "quiet" ]] ; then
+ package_print_first
+
echo -e "${c_error}ERROR: Build directory '${c_notice}$path_build${c_error}' is invalid or missing.${c_reset}"
+
+ package_print_last
fi
package_cleanup
if [[ ! -d $path_destination ]] ; then
mkdir $verbose_common -p $path_destination
+
if [[ $? -ne 0 ]] ; then
if [[ $verbosity != "quiet" ]] ; then
+ package_print_first
+
echo -e "${c_error}ERROR: Package directory '${c_notice}$path_destination${c_error}' is invalid or could not be created.${c_reset}"
+
+ package_print_last
fi
package_cleanup
if [[ ! -d $path_sources ]] ; then
if [[ $verbosity != "quiet" ]] ; then
+ package_print_first
+
echo -e "${c_error}ERROR: Sources directory '${c_notice}$path_sources${c_error}' is invalid or missing.${c_reset}"
+
+ package_print_last
fi
package_cleanup
if [[ ! -d ${path_sources}level_0/ ]] ; then
if [[ $verbosity != "quiet" ]] ; then
+ package_print_first
+
echo -e "${c_error}ERROR: Build sources directory '${c_notice}${path_sources}level_0/${c_error}' is invalid or missing.${c_reset}"
+
+ package_print_last
fi
package_cleanup
if [[ ! -d ${path_sources}level_1/ ]] ; then
if [[ $verbosity != "quiet" ]] ; then
+ package_print_first
+
echo -e "${c_error}ERROR: Build sources directory '${c_notice}${path_sources}level_1/${c_error}' is invalid or missing.${c_reset}"
+
+ package_print_last
fi
package_cleanup
if [[ ! -d ${path_sources}level_2/ ]] ; then
if [[ $verbosity != "quiet" ]] ; then
+ package_print_first
+
echo -e "${c_error}ERROR: Build sources directory '${c_notice}${path_sources}level_2/${c_error}' is invalid or missing.${c_reset}"
+
+ package_print_last
fi
package_cleanup
if [[ ! -d ${path_sources}level_3/ ]] ; then
if [[ $verbosity != "quiet" ]] ; then
+ package_print_first
+
echo -e "${c_error}ERROR: Build sources directory '${c_notice}${path_sources}level_3/${c_error}' is invalid or missing.${c_reset}"
+
+ package_print_last
fi
package_cleanup
if [[ $operation == "rebuild" ]] ; then
package_operation_clean
- if [[ $failure -ne 0 ]] ; then
- return 1
+ if [[ $? -ne 0 ]] ; then
+ failure=1
fi
fi
mode_individual="yes"
fi
- if [[ $mode_individual == "yes" ]] ; then
+ if [[ $failure == "" && $mode_individual == "yes" ]] ; then
package_operation_individual
+
+ if [[ $? -ne 0 ]] ; then
+ failure=1
+ fi
fi
- if [[ $mode_level == "yes" ]] ; then
+ if [[ $failure == "" && $mode_level == "yes" ]] ; then
package_operation_level
+
+ if [[ $? -ne 0 ]] ; then
+ failure=1
+ fi
fi
- if [[ $mode_monolithic == "yes" ]] ; then
+ if [[ $failure == "" && $mode_monolithic == "yes" ]] ; then
package_operation_monolithic
+
+ if [[ $? -ne 0 ]] ; then
+ failure=1
+ fi
fi
- if [[ $mode_program == "yes" ]] ; then
+ if [[ $failure == "" && $mode_program == "yes" ]] ; then
package_operation_program
+
+ if [[ $? -ne 0 ]] ; then
+ failure=1
+ fi
fi
- if [[ $mode_stand_alone != "" ]] ; then
+ if [[ $failure == "" && $mode_stand_alone != "" ]] ; then
package_operation_stand_alone
+
+ if [[ $? -ne 0 ]] ; then
+ failure=1
+ fi
fi
elif [[ $operation == "dependencies" ]] ; then
if [[ ! -d $path_sources ]] ; then
if [[ $verbosity != "quiet" ]] ; then
+ package_print_first
+
echo -e "${c_error}ERROR: Sources directory '${c_notice}${path_sources}${c_error}' is invalid or missing.${c_reset}"
+
+ package_print_last
fi
package_cleanup
package_operation_dependencies
elif [[ $operation == "clean" ]] ; then
if [[ ! -d $path_destination ]] ; then
- if [[ $verbosity != "quiet" ]] ; then
+ if [[ $verbosity != "quiet" && $verbosity != "error" ]] ; then
+ package_print_first
+
echo -e "${c_warning}WARNING: Package directory '${c_notice}${path_destination}${c_error}' does not exist, there is nothing to clean.${c_reset}"
+
+ package_print_last
fi
package_cleanup
package_operation_clean
elif [[ $operation == "" ]] ; then
if [[ $verbosity != "quiet" ]] ; then
+ package_print_first
+
echo -e "${c_error}ERROR: No operation was given.${c_reset}"
+
+ package_print_last
fi
package_cleanup
return 1
else
if [[ $verbosity != "quiet" ]] ; then
+ package_print_first
+
echo -e "${c_error}ERROR: The operation ${c_notice}${operation}${c_error} was not recognized.${c_reset}"
+
+ package_print_last
fi
package_cleanup
return 1
fi
- # Always append a new line at the end.
if [[ $verbosity != "quiet" ]] ; then
- echo
+ if [[ $failure != "" || $verbosity != "error" ]] ; then
+ package_print_last
+ fi
fi
package_cleanup
- return 0
+ if [[ $failure == "" ]] ; then
+ return 0
+ fi
+
+ return 1
}
package_handle_colors() {
package_help() {
- echo
+ package_print_first
+
echo -e "${c_title}${public_name}${c_reset}"
echo -e " ${c_notice}Version ${version}${c_reset}"
echo
echo -e " ${c_important}rebuild${c_reset} Delete all built packages then build the package."
echo
echo -e "${c_highlight}Options:${c_reset}"
- echo -e " -${c_important}h${c_reset}, --${c_important}help${c_reset} Print this help screen."
- echo -e " +${c_important}d${c_reset}, ++${c_important}dark${c_reset} Use color modes that show up better on dark backgrounds."
- echo -e " +${c_important}l${c_reset}, ++${c_important}light${c_reset} Use color modes that show up better on light backgrounds."
- echo -e " +${c_important}n${c_reset}, ++${c_important}no_color${c_reset} Do not use color."
- echo -e " +${c_important}q${c_reset}, ++${c_important}quiet${c_reset} Decrease verbosity, silencing most output."
- echo -e " +${c_important}N${c_reset}, ++${c_important}normal${c_reset} Set verbosity to normal."
- echo -e " +${c_important}V${c_reset}, ++${c_important}verbose${c_reset} Increase verbosity beyond normal output."
- echo -e " +${c_important}D${c_reset}, ++${c_important}debug${c_reset} Enable debugging, significantly increasing verbosity beyond normal output."
- echo -e " +${c_important}v${c_reset}, ++${c_important}version${c_reset} Print the version number of this program."
+ echo -e " -${c_important}h${c_reset}, --${c_important}help${c_reset} Print this help message."
+ echo -e " +${c_important}C${c_reset}, ++${c_important}copyright${c_reset} Print the copyright."
+ echo -e " +${c_important}d${c_reset}, ++${c_important}dark${c_reset} Output using colors that show up better on dark backgrounds."
+ echo -e " +${c_important}l${c_reset}, ++${c_important}light${c_reset} Output using colors that show up better on light backgrounds."
+ echo -e " +${c_important}n${c_reset}, ++${c_important}no_color${c_reset} Do not print using color."
+ echo -e " +${c_important}Q${c_reset}, ++${c_important}quiet${c_reset} Decrease verbosity, silencing most print.to."
+ echo -e " +${c_important}E${c_reset}, ++${c_important}error${c_reset} Decrease verbosity, using only error print.to."
+ echo -e " +${c_important}N${c_reset}, ++${c_important}normal${c_reset} Set verbosity to normal."
+ echo -e " +${c_important}V${c_reset}, ++${c_important}verbose${c_reset} Increase verbosity beyond normal print.to."
+ echo -e " +${c_important}D${c_reset}, ++${c_important}debug${c_reset} Enable debugging, significantly increasing verbosity beyond normal print.to."
+ echo -e " +${c_important}v${c_reset}, ++${c_important}version${c_reset} Print only the version number."
echo
echo -e "${c_highlight}Package Options:${c_reset}"
echo -e " -${c_important}d${c_reset}, --${c_important}destination${c_reset} Specify a custom package destination directory."
echo
}
+package_copyright() {
+
+ package_print_first
+
+ echo "Copyright © 2007-2023 Kevin Day."
+ echo
+ echo "Source code license lgpl-2.1-or-later."
+ echo "Standard and specification license open-standard-license-1.0."
+ echo "Documentation license cc-by-sa-4.0."
+
+ package_print_last
+}
+
package_create_base_files() {
if [[ ! -d $package ]] ; then
if [[ $? -ne 0 ]] ; then
if [[ $verbosity != "quiet" ]] ; then
+ package_print_first
+
echo -e "${c_error}ERROR: Failed to create directory ${c_notice}${package}${c_error}.${c_reset}"
fi
if [[ $failure == "" && ! -d ${path_build}documents ]] ; then
if [[ $verbosity != "quiet" ]] ; then
+ package_print_first
+
echo -e "${c_error}ERROR: The build directory ${c_notice}${path_build}documents${c_error} cannot be found or is invalid.${c_reset}"
fi
if [[ $? -ne 0 ]] ; then
if [[ $verbosity != "quiet" ]] ; then
+ package_print_first
+
echo -e "${c_error}ERROR: Failed to copy directory ${c_notice}${path_build}documents${c_error} to ${c_notice}$package${c_error}.${c_reset}"
fi
if [[ $? -ne 0 ]] ; then
if [[ $verbosity != "quiet" ]] ; then
+ package_print_first
+
echo -e "${c_error}ERROR: Failed to copy directory ${c_notice}${path_build}licenses${c_error} to ${c_notice}${package}${c_error}.${c_reset}"
fi
if [[ $? -ne 0 ]] ; then
if [[ $verbosity != "quiet" ]] ; then
+ package_print_first
+
echo -e "${c_error}ERROR: Failed to copy directory ${c_notice}${path_build}../licenses${c_error} to ${c_notice}${package}${c_error}.${c_reset}"
fi
fi
else
if [[ $verbosity != "quiet" ]] ; then
+ package_print_first
+
echo -e "${c_error}ERROR: Neither directory ${c_notice}${path_build}licenses${c_error} nor ${c_notice}${path_build}../licenses${c_error} can be found or are invalid.${c_reset}"
fi
if [[ $? -ne 0 ]] ; then
if [[ $verbosity != "quiet" ]] ; then
+ package_print_first
+
echo -e "${c_error}ERROR: Failed to copy script ${c_notice}${path_build}bootstrap.sh${c_error} to ${c_notice}${package}${c_error}.${c_reset}"
fi
if [[ $? -ne 0 ]] ; then
if [[ $verbosity != "quiet" ]] ; then
+ package_print_first
+
echo -e "${c_error}ERROR: Failed to set executable permissions on script ${c_notice}${package}bootstrap.sh${c_error}.${c_reset}"
fi
if [[ $? -ne 0 ]] ; then
if [[ $verbosity != "quiet" ]] ; then
+ package_print_first
+
echo -e "${c_error}ERROR: Failed to copy script ${c_notice}${path_build}install.sh${c_error} to ${c_notice}${package}${c_error}.${c_reset}"
fi
if [[ $? -ne 0 ]] ; then
if [[ $verbosity != "quiet" ]] ; then
+ package_print_first
+
echo -e "${c_error}ERROR: Failed to set executable permissions on script ${c_notice}${package}install.sh${c_error}.${c_reset}"
fi
if [[ $? -ne 0 ]] ; then
if [[ $verbosity != "quiet" ]] ; then
+ package_print_first
+
echo -e "${c_error}ERROR: Failed to create directory ${c_notice}${package}build${c_error}.${c_reset}"
fi
if [[ $? -ne 0 ]] ; then
if [[ $verbosity != "quiet" ]] ; then
+ package_print_first
+
echo -e "${c_error}ERROR: Failed to create directory ${c_notice}${package}sources${c_error}.${c_reset}"
fi
if [[ $? -ne 0 ]] ; then
if [[ $verbosity != "quiet" ]] ; then
+ package_print_first
+
echo -e "${c_error}ERROR: Failed to create directory ${c_notice}${package}documents${c_error}.${c_reset}"
fi
if [[ $? -ne 0 ]] ; then
if [[ $verbosity != "quiet" ]] ; then
+ package_print_first
+
echo -e "${c_error}ERROR: Failed to create directory ${c_notice}${package}licenses${c_error}.${c_reset}"
fi
fi
fi
- if [[ $failure != "" ]] ; then
- package_cleanup
-
- exit $failure
+ if [[ $failure == "" ]] ; then
+ return 0
fi
+
+ return 1
}
package_dependencies_individual() {
level_current="$(echo $directory | grep -o '\<level_[[:digit:]]/' | sed -e 's|level_||' -e 's|/$||')"
- if [[ $verbosity != "quiet" ]] ; then
- echo
+ if [[ $verbosity != "quiet" && $verbosity != "error" ]] ; then
+ package_print_first_or_always
+
echo -e "${c_highlight}Building Dependencies for ${c_reset}${c_notice}${name}${c_reset}${c_highlight}.${c_reset}"
fi
if [[ ! -d ${directory}/data/build/ ]] ; then
- if [[ $verbosity != "quiet" ]] ; then
+ if [[ $verbosity != "quiet" && $verbosity != "error" ]] ; then
+ package_print_first
+
echo -e "${c_warning}WARNING: The project build directory ${c_notice}${dependency_file}${c_warning} is not found.${c_reset}"
fi
if [[ ! -f $dependency_file ]] ; then
if [[ $dependency_files == "yes" && "${directory}/data/build/dependencies" != $dependency_file ]] ; then
- if [[ $verbosity != "quiet" ]] ; then
+ if [[ $verbosity != "quiet" && $verbosity != "error" ]] ; then
+ package_print_first
+
echo -e "${c_warning}WARNING: The dependency file ${c_notice}${dependency_file}${c_warning} is not found.${c_reset}"
fi
elif [[ $dependency_files == "no" && "${directory}/data/build/dependencies.*" != $dependency_file ]] ; then
if [[ $verbosity != "quiet" ]] ; then
+ package_print_first
+
echo -e "${c_error}ERROR: Cannot build dependencies, failed to find ${c_notice}${dependency_file}${c_error} file(s).${c_reset}"
fi
fi
if [[ ! -f ${directory}/data/build/settings${dependency_suffix} ]] ; then
if [[ $verbosity != "quiet" ]] ; then
+ package_print_first
+
echo -e "${c_error}ERROR: Cannot build dependencies for ${c_reset}${c_notice}${name}${c_reset}${c_error}, failed to find ${c_notice}${directory}/data/build/settings${dependency_suffix}${c_error}.${c_reset}"
fi
let failure=1
- return
+ return 1
fi
dependencies=
elif [[ $(echo "$dependency" | grep -o "^fll_") != "" ]] ; then
level=level_2
else
- if [[ $verbosity != "quiet" ]] ; then
+ if [[ $verbosity != "quiet" && $verbosity != "error" ]] ; then
+ package_print_first
+
echo -e "${c_warning}WARNING: Failed to detect level for dependency ${c_notice}${dependency}${c_warning}.${c_reset}"
fi
if [[ ! -d ${path_sources}${level}/${dependency}/data/build/ ]] ; then
if [[ $verbosity != "quiet" ]] ; then
+ package_print_first
+
echo -e "${c_error}ERROR: Failed to find dependency data directory ${c_notice}${path_sources}${level}/${dependency}/data/build/${c_error}.${c_reset}"
fi
let failure=1
- return
+ return 1
fi
sub_dependencies=
elif [[ $(echo "$sub_dependency" | grep -o "^fl_") != "" ]] ; then
sub_level=level_1
else
- if [[ $verbosity != "quiet" ]] ; then
+ if [[ $verbosity != "quiet" && $verbosity != "error" ]] ; then
+ package_print_first
+
echo -e "${c_warning}WARNING: Failed to detect level for sub-dependency ${c_notice}${sub_dependency}${c_warning}.${c_reset}"
fi
if [[ ! -d ${path_sources}${sub_level}/${sub_dependency}/data/build/ ]] ; then
if [[ $verbosity != "quiet" ]] ; then
+ package_print_first
+
echo -e "${c_error}ERROR: Failed to find dependency data directory ${c_notice}${path_sources}${sub_level}/${sub_dependency}/data/build/${c_error}.${c_reset}"
fi
let failure=1
- return
+ return 1
fi
sub_sub_dependencies=
if [[ $(echo "$sub_sub_dependency" | grep -o "^f_") != "" ]] ; then
sub_sub_level=level_0
else
- if [[ $verbosity != "quiet" ]] ; then
+ if [[ $verbosity != "quiet" && $verbosity != "error" ]] ; then
+ package_print_first
+
echo -e "${c_warning}WARNING: Failed to detect level for sub-sub-dependency ${c_notice}$sub_sub_dependency${c_warning}.${c_reset}"
fi
if [[ $? -ne 0 ]] ; then
if [[ $verbosity != "quiet" ]] ; then
+ package_print_first
+
echo -e "${c_error}ERROR: Failed to update settings file ${c_notice}${settings}${c_error}.${c_reset}"
fi
dependencies_individual_threadless=$(echo "$dependencies_individual" | sed -e "s| \-lf_thread\>||g")
if [[ $verbosity == "verbose" ]] ; then
+ package_print_first
+
echo -e " (threadless) $dependencies_individual_threadless"
fi
if [[ $? -ne 0 ]] ; then
if [[ $verbosity != "quiet" ]] ; then
+ package_print_first
+
echo -e "${c_error}ERROR: Failed to update settings file ${c_notice}${settings}${c_error}.${c_reset}"
fi
if [[ $? -ne 0 ]] ; then
if [[ $verbosity != "quiet" ]] ; then
+ package_print_first
+
echo -e "${c_error}ERROR: Failed to update settings file ${c_notice}${settings}${c_error}.${c_reset}"
fi
if [[ $? -ne 0 ]] ; then
if [[ $verbosity != "quiet" ]] ; then
+ package_print_first
+
echo -e "${c_error}ERROR: Failed to update settings file ${c_notice}${settings}${c_error}.${c_reset}"
fi
break;
fi
done
+
+ if [[ $failure == "" ]] ; then
+ return 0
+ fi
+
+ return 1
}
package_dependencies_individual_append() {
settings=${path_sources}${level}/${dependency}/data/build/settings
if [[ ! -f $settings ]] ; then
if [[ $verbosity != "quiet" ]] ; then
+ package_print_first
+
echo -e "${c_error}ERROR: Failed to find dependency settings file ${c_notice}${settings}${c_error}.${c_reset}"
fi
let failure=1
- return
+ return 1
fi
libraries=$(grep -o '^\s*build_sources_library\s.*$' $settings | sed -e 's|^\s*build_sources_library\>||' -e 's|^\s*||' -e 's|\s*$||')
fi
fi
fi
+
+ if [[ $failure == "" ]] ; then
+ return 0
+ fi
+
+ return 1
}
package_dependencies_level() {
package_dependencies_level_update "level_0" ""
- if [[ $failure != "" ]] ; then
- return;
+ if [[ $failure == "" ]] ; then
+ package_dependencies_level_update "level_1" " -lfll_0"
fi
- package_dependencies_level_update "level_1" " -lfll_0"
+ if [[ $failure == "" ]] ; then
+ package_dependencies_level_update "level_2" " -lfll_1 -lfll_0"
+ fi
- if [[ $failure != "" ]] ; then
- return;
+ if [[ $failure == "" ]] ; then
+ return 0
fi
- package_dependencies_level_update "level_2" " -lfll_1 -lfll_0"
+ return 1
}
package_dependencies_level_update() {
local monolithic_libraries_threaded=
local monolithic_headers_threaded=
- if [[ $verbosity != "quiet" ]] ; then
- echo
+ if [[ $verbosity != "quiet" && $verbosity != "error" ]] ; then
+ package_print_first_or_always
+
echo -e "${c_highlight}Building Dependencies: ${c_notice}${level}${c_highlight}.${c_reset}"
fi
settings=${directory}/data/build/settings
if [[ ! -f $settings ]] ; then
if [[ $verbosity != "quiet" ]] ; then
+ package_print_first
+
echo -e "${c_error}ERROR: Failed to find settings file ${c_notice}${settings}${c_error}.${c_reset}"
fi
let failure=1
- return
+ return 1
fi
libraries=$(grep -o '^\s*build_sources_library\s.*$' $settings | sed -e 's|^\s*build_sources_library\>||' -e 's|^\s*||' -e 's|\s*$||')
if [[ ! -f $settings ]] ; then
if [[ $verbosity != "quiet" ]] ; then
+ package_print_first
+
echo -e "${c_error}ERROR: Failed to find settings file ${c_notice}${settings}${c_error}.${c_reset}"
fi
let failure=1
- return
+ return 1
fi
sed -i -e "s|^\s*build_libraries-level\s.*\$|build_libraries-level${level_libraries}|" $settings &&
if [[ $? -ne 0 ]] ; then
if [[ $verbosity != "quiet" ]] ; then
+ package_print_first
+
echo -e "${c_error}ERROR: Failed to update libraries for settings file ${c_notice}${settings}${c_error}.${c_reset}"
fi
let failure=1
- return
+ return 1
fi
level_sources_library=$(echo "$level_sources_library" | sed -e 's|^[[:space:]]*||' -e 's|[[:space:]]*$||')
if [[ $? -ne 0 ]] ; then
if [[ $verbosity != "quiet" ]] ; then
+ package_print_first
+
echo -e "${c_error}ERROR: Failed to update libraries for settings file ${c_notice}${settings}${c_error}.${c_reset}"
fi
let failure=1
- return
+ return 1
fi
level_sources_headers=$(echo "$level_sources_headers" | sed -e 's|^[[:space:]]*||' -e 's|[[:space:]]*$||')
if [[ $? -ne 0 ]] ; then
if [[ $verbosity != "quiet" ]] ; then
+ package_print_first
+
echo -e "${c_error}ERROR: Failed to update headers for settings file ${c_notice}${settings}${c_error}.${c_reset}"
fi
let failure=1
- return
+ return 1
fi
if [[ $level == "level_0" ]] ; then
level_2_libraries_threaded=$(echo "$monolithic_libraries_threaded" | sed -e 's|^[[:space:]]*||' -e 's|[[:space:]]*$||')
level_2_headers_threaded=$(echo "$monolithic_headers_threaded" | sed -e 's|^[[:space:]]*||' -e 's|[[:space:]]*$||')
fi
+
+ return 0
}
package_dependencies_monolithic() {
local monolithic_headers=""
local monolithic_headers_threaded=""
- if [[ $verbosity != "quiet" ]] ; then
- echo
+ if [[ $verbosity != "quiet" && $verbosity != "error" ]] ; then
+ package_print_first_or_always
+
echo -e "${c_highlight}Building Dependencies: ${c_notice}monolithic${c_highlight}.${c_reset}"
fi
settings=${path_sources}/build/monolithic/settings
if [[ $monolithic_libraries != "" ]] ; then
- if [[ $verbosity != "quiet" ]] ; then
+ if [[ $verbosity != "quiet" && $verbosity != "error" ]] ; then
echo " $monolithic_libraries"
fi
fi
if [[ $monolithic_libraries_threaded != "" ]] ; then
- if [[ $verbosity != "quiet" ]] ; then
+ if [[ $verbosity != "quiet" && $verbosity != "error" ]] ; then
echo " (threaded) $monolithic_libraries_threaded"
fi
if [[ $? -ne 0 ]] ; then
if [[ $verbosity != "quiet" ]] ; then
+ package_print_first
+
echo -e "${c_error}ERROR: Failed to update libraries for settings file ${c_notice}${settings}${c_error}.${c_reset}"
fi
let failure=1
- return
+ return 1
fi
if [[ $monolithic_headers != "" ]] ; then
- if [[ $verbosity != "quiet" ]] ; then
+ if [[ $verbosity != "quiet" && $verbosity != "error" ]] ; then
echo " $monolithic_headers"
fi
fi
if [[ $monolithic_headers_threaded != "" ]] ; then
- if [[ $verbosity != "quiet" ]] ; then
+ if [[ $verbosity != "quiet" && $verbosity != "error" ]] ; then
echo " (threaded) $monolithic_headers_threaded"
fi
if [[ $? -ne 0 ]] ; then
if [[ $verbosity != "quiet" ]] ; then
+ package_print_first
+
echo -e "${c_error}ERROR: Failed to update headers for settings file ${c_notice}${settings}${c_error}.${c_reset}"
fi
let failure=1
- return
+ return 1
fi
+
+ return 0
}
package_operation_clean() {
local i=
+ if [[ $verbosity != "quiet" && $verbosity != "error" ]] ; then
+ package_print_first_or_always
+
+ echo -e "${c_highlight}Cleaning Package Directory '${c_reset}${c_notice}${path_destination}${c_reset}${c_highlight}'.${c_reset}"
+ fi
+
if [[ $mode_individual == "yes" ]] ; then
if [[ -d ${path_destination}individual ]] ; then
rm $verbose_common -Rf ${path_destination}individual
if [[ $? -ne 0 ]] ; then
let failure=1
- return
+ return 1
fi
fi
- if [[ $verbosity != "quiet" ]] ; then
- echo
+ if [[ $verbosity != "quiet" && $verbosity != "error" ]] ; then
+ package_print_first_or_always
+
echo "Cleaned '${path_destination}individual'."
fi
fi
if [[ $? -ne 0 ]] ; then
let failure=1
- return
+ return 1
fi
fi
- if [[ $verbosity != "quiet" ]] ; then
- echo
+ if [[ $verbosity != "quiet" && $verbosity != "error" ]] ; then
+ package_print_first_or_always
+
echo "Cleaned '${path_destination}level'."
fi
fi
if [[ $? -ne 0 ]] ; then
let failure=1
- return
+ return 1
fi
fi
- if [[ $verbosity != "quiet" ]] ; then
- echo
+ if [[ $verbosity != "quiet" && $verbosity != "error" ]] ; then
+ package_print_first_or_always
+
echo "Cleaned '${path_destination}monolithic'."
fi
fi
if [[ $? -ne 0 ]] ; then
let failure=1
- return
+ return 1
fi
fi
- if [[ $verbosity != "quiet" ]] ; then
- echo
+ if [[ $verbosity != "quiet" && $verbosity != "error" ]] ; then
+ package_print_first_or_always
+
echo "Cleaned '${path_destination}program'."
fi
fi
if [[ $? -ne 0 ]] ; then
let failure=1
- return
+ return 1
fi
fi
- if [[ $verbosity != "quiet" ]] ; then
- echo
+ if [[ $verbosity != "quiet" && $verbosity != "error" ]] ; then
+ package_print_first_or_always
+
echo "Cleaned '${path_destination}stand_alone/${prepend}${i}-${version}/'."
fi
done
rmdir $verbose_common --ignore-fail-on-non-empty ${path_destination}stand_alone
- if [[ $verbosity != "quiet" ]] ; then
- echo
+ if [[ $verbosity != "quiet" && $verbosity != "error" ]] ; then
+ package_print_first_or_always
+
echo "Cleaned '${path_destination}stand_alone'."
fi
fi
fi
+
+ return 0
}
package_operation_copy_package() {
if [[ $? -ne 0 ]] ; then
if [[ $verbosity != "quiet" ]] ; then
+ package_print_first
+
echo -e "${c_error}ERROR: Failed to copy the data directory ${c_notice}${package}sources/data${c_error} to ${c_notice}$package${c_error}.${c_reset}"
fi
let failure=1
- return $failure
+ return 1
fi
rm $verbose_common -Rf ${package}sources/data
if [[ $? -ne 0 ]] ; then
if [[ $verbosity != "quiet" ]] ; then
+ package_print_first
+
echo -e "${c_error}ERROR: Failed to remove directory ${c_notice}${package}sources/data${c_error}.${c_reset}"
fi
let failure=1
- return $failure
+ return 1
fi
package_operation_create_config_stubs
if [[ $? -ne 0 ]] ; then
if [[ $verbosity != "quiet" ]] ; then
+ package_print_first
+
echo -e "${c_error}ERROR: Failed to move sources documents directory ${c_notice}${path_sources}sources/documents${c_error} to ${c_notice}${package}${c_error}.${c_reset}"
fi
let failure=1
- return $failure
+ return 1
fi
rm $verbose_common -Rf ${package}sources/documents/
if [[ $? -ne 0 ]] ; then
if [[ $verbosity != "quiet" ]] ; then
+ package_print_first
+
echo -e "${c_error}ERROR: Failed to remove sources documents directory ${c_notice}${path_sources}sources/documents${c_error} to ${c_notice}${package}${c_error}.${c_reset}"
fi
let failure=1
- return $failure
+ return 1
fi
fi
if [[ $? -ne 0 ]] ; then
if [[ $verbosity != "quiet" ]] ; then
+ package_print_first
+
echo -e "${c_error}ERROR: Failed to move sources licenses directory ${c_notice}${path_sources}sources/licenses${c_error} to ${c_notice}${package}${c_error}.${c_reset}"
fi
let failure=1
- return $failure
+ return 1
fi
rm $verbose_common -Rf ${package}sources/licenses/
if [[ $? -ne 0 ]] ; then
if [[ $verbosity != "quiet" ]] ; then
+ package_print_first
+
echo -e "${c_error}ERROR: Failed to remove sources licenses directory ${c_notice}${path_sources}sources/licenses${c_error} to ${c_notice}${package}${c_error}.${c_reset}"
fi
let failure=1
- return $failure
+ return 1
fi
fi
if [[ $? -ne 0 ]] ; then
if [[ $verbosity != "quiet" ]] ; then
+ package_print_first
+
echo -e "${c_error}ERROR: Failed to move sources specifications directory ${c_notice}${path_sources}sources/specifications${c_error} to ${c_notice}${package}${c_error}.${c_reset}"
fi
if [[ $? -ne 0 ]] ; then
if [[ $verbosity != "quiet" ]] ; then
+ package_print_first
+
echo -e "${c_error}ERROR: Failed to remove sources specifications directory ${c_notice}${path_sources}sources/specifications${c_error} to ${c_notice}${package}${c_error}.${c_reset}"
fi
let failure=1
- return $failure
+ return 1
fi
fi
if [[ $? -ne 0 ]] ; then
if [[ $verbosity != "quiet" ]] ; then
+ package_print_first
+
echo -e "${c_error}ERROR: Failed to move sources tests directory ${c_notice}${path_sources}sources/tests${c_error} to ${c_notice}${package}${c_error}.${c_reset}"
fi
let failure=1
- return $failure
+ return 1
fi
rm $verbose_common -Rf ${package}sources/tests/
if [[ $? -ne 0 ]] ; then
if [[ $verbosity != "quiet" ]] ; then
+ package_print_first
+
echo -e "${c_error}ERROR: Failed to remove sources tests directory ${c_notice}${path_sources}sources/tests${c_error} to ${c_notice}${package}${c_error}.${c_reset}"
fi
let failure=1
- return $failure
+ return 1
fi
fi
}
if [[ $? -ne 0 ]] ; then
if [[ $verbosity != "quiet" ]] ; then
+ package_print_first
+
echo -e "${c_error}ERROR: Failed to insert the config.c into ${c_notice}${package}data/build/settings${c_error}.${c_reset}"
fi
if [[ $? -ne 0 ]] ; then
if [[ $verbosity != "quiet" ]] ; then
+ package_print_first
+
echo -e "${c_error}ERROR: Failed to insert the config.c into ${c_notice}${package}data/build/settings${c_error}.${c_reset}"
fi
if [[ $? -ne 0 ]] ; then
if [[ $verbosity != "quiet" ]] ; then
+ package_print_first
+
echo -e "${c_error}ERROR: Failed to create the config.c at ${c_notice}${package}sources/c/config.c${c_error}.${c_reset}"
fi
if [[ $? -ne 0 ]] ; then
if [[ $verbosity != "quiet" ]] ; then
+ package_print_first
+
echo -e "${c_error}ERROR: Failed to insert the config.cpp into ${c_notice}${package}data/build/settings${c_error}.${c_reset}"
fi
if [[ $? -ne 0 ]] ; then
if [[ $verbosity != "quiet" ]] ; then
+ package_print_first
+
echo -e "${c_error}ERROR: Failed to insert the config.cpp into ${c_notice}${package}data/build/settings${c_error}.${c_reset}"
fi
if [[ $? -ne 0 ]] ; then
if [[ $verbosity != "quiet" ]] ; then
+ package_print_first
+
echo -e "${c_error}ERROR: Failed to create the config.cpp at ${c_notice}${package}sources/c++/config.cpp${c_error}.${c_reset}"
fi
if [[ $? -ne 0 ]] ; then
if [[ $verbosity != "quiet" ]] ; then
+ package_print_first
+
echo -e "${c_error}ERROR: Failed to create the config.cpp at ${c_notice}${package}sources/c/config.h${c_error}.${c_reset}"
fi
if [[ $? -ne 0 ]] ; then
if [[ $verbosity != "quiet" ]] ; then
+ package_print_first
+
echo -e "${c_error}ERROR: Failed to create the config.cpp at ${c_notice}${package}sources/c++/config.h${c_error}.${c_reset}"
fi
fi
fi
fi
+
+ return 0
}
package_operation_dependencies() {
- local failure=
local level_0_libraries=
local level_1_libraries=
local level_2_libraries=
package_dependencies_individual
if [[ $failure != "" ]] ; then
- return;
+ return $failure;
fi
package_dependencies_level
if [[ $failure != "" ]] ; then
- return;
+ return $failure;
fi
package_dependencies_monolithic
+
+ return 0
}
package_operation_individual() {
- local failure=
local name=
local directory=
local package=
if [[ $? -ne 0 ]] ; then
if [[ $verbosity != "quiet" ]] ; then
+ package_print_first
+
echo -e "${c_error}ERROR: Failed to create directory ${c_notice}${path_destination}individual${c_error}.${c_reset}"
fi
- package_cleanup
-
- exit $failure
+ return $failure
fi
fi
name="$(echo $directory | sed -e "s|${path_sources}level_0/||" -e "s|${path_sources}level_1/||" -e "s|${path_sources}level_2/||")"
package="${path_destination}individual/${prepend}${name}-${version}/"
- if [[ $verbosity != "quiet" ]] ; then
- echo
+ if [[ $verbosity != "quiet" && $verbosity != "error" ]] ; then
+ package_print_first_or_always
+
echo -e "${c_highlight}Packaging Project${c_reset} (individual) ${c_notice}${prepend}${name}-${version}${c_reset}${c_highlight}.${c_reset}"
fi
if [[ $? -ne 0 ]] ; then
if [[ $verbosity != "quiet" ]] ; then
+ package_print_first
+
echo -e "${c_error}ERROR: Failed to copy sources directory ${c_notice}${directory}${c_error} to ${c_notice}${package}sources${c_error}.${c_reset}"
fi
fi
done
- if [[ $failure != "" ]] ; then
- package_cleanup
-
- exit $failure
+ if [[ $failure == "" ]] ; then
+ return 0
fi
+
+ return 1
}
package_operation_level() {
- local failure=
local name=
local level=
local directory=
name="fll-$level"
package="${path_destination}level/${prepend}${name}-${version}/"
- if [[ $verbosity != "quiet" ]] ; then
- echo
+ if [[ $verbosity != "quiet" && $verbosity != "error" ]] ; then
+ package_print_first_or_always
+
echo -e "${c_highlight}Packaging Project${c_reset} (level) ${c_notice}${prepend}${name}-${version}${c_reset}${c_highlight}.${c_reset}"
fi
if [[ ! -d $path_build$level ]] ; then
if [[ $verbosity != "quiet" ]] ; then
+ package_print_first
+
echo -e "${c_error}ERROR: Build settings directory ${c_notice}${path_build}${level}${c_error} is invalid or missing.${c_reset}"
fi
if [[ $? -ne 0 ]] ; then
if [[ $verbosity != "quiet" ]] ; then
+ package_print_first
+
echo -e "${c_error}ERROR: Failed to create directory ${c_notice}${package}data${c_error}.${c_reset}"
fi
if [[ $? -ne 0 ]] ; then
if [[ $verbosity != "quiet" ]] ; then
+ package_print_first
+
echo -e "${c_error}ERROR: Failed to move the directory ${c_notice}${path_build}${level}${c_error} as ${c_notice}${path_build}${level}build${c_error}.${c_reset}"
fi
if [[ $? -ne 0 ]] ; then
if [[ $verbosity != "quiet" ]] ; then
+ package_print_first
+
echo -e "${c_error}ERROR: Failed to create directory ${c_notice}${package}sources${c_error}.${c_reset}"
fi
if [[ $? -ne 0 ]] ; then
if [[ $verbosity != "quiet" ]] ; then
+ package_print_first
+
echo -e "${c_error}ERROR: Failed to copy files from sources directory ${c_notice}${directory}${c_error} to ${c_notice}${package}sources${c_error}.${c_reset}"
fi
if [[ $? -ne 0 ]] ; then
if [[ $verbosity != "quiet" ]] ; then
+ package_print_first
+
echo -e "${c_error}ERROR: Failed to remove directory ${c_notice}${package}sources/data/build${c_error}.${c_reset}"
fi
fi
done
- if [[ $failure != "" ]] ; then
- package_cleanup
-
- exit $failure
+ if [[ $failure == "" ]] ; then
+ return 0
fi
+
+ return 1
}
package_operation_monolithic() {
- local failure=
local name=
local level=
local directory=
name="fll"
package="${path_destination}monolithic/${prepend}${name}-${version}/"
- if [[ $verbosity != "quiet" ]] ; then
- echo
+ if [[ $verbosity != "quiet" && $verbosity != "error" ]] ; then
+ package_print_first_or_always
+
echo -e "${c_highlight}Packaging Project${c_reset} (monolithic) ${c_notice}${prepend}${name}-${version}${c_reset}${c_highlight}.${c_reset}"
fi
if [[ ! -d ${path_build}monolithic ]] ; then
if [[ $verbosity != "quiet" ]] ; then
+ package_print_first
+
echo -e "${c_error}ERROR: Build settings directory ${c_notice}${path_build}monolithic${c_error} is invalid or missing.${c_reset}"
fi
if [[ $? -ne 0 ]] ; then
if [[ $verbosity != "quiet" ]] ; then
+ package_print_first
+
echo -e "${c_error}ERROR: Failed to create directory ${c_notice}${package}data${c_error}.${c_reset}"
fi
if [[ $? -ne 0 ]] ; then
if [[ $verbosity != "quiet" ]] ; then
+ package_print_first
+
echo -e "${c_error}ERROR: Failed to move the directory ${c_notice}${path_build}${level}${c_error} as ${c_notice}${path_build}${level}build${c_error}.${c_reset}"
fi
if [[ $? -ne 0 ]] ; then
if [[ $verbosity != "quiet" ]] ; then
+ package_print_first
+
echo -e "${c_error}ERROR: Failed to create directory ${c_notice}${package}sources${c_error}.${c_reset}"
fi
if [[ $? -ne 0 ]] ; then
if [[ $verbosity != "quiet" ]] ; then
+ package_print_first
+
echo -e "${c_error}ERROR: Failed to create directory ${c_notice}${package}tests${c_error}.${c_reset}"
fi
if [[ $? -ne 0 ]] ; then
if [[ $verbosity != "quiet" ]] ; then
+ package_print_first
+
echo -e "${c_error}ERROR: Failed to create package data directory ${c_notice}${package}data/${level}${c_error}.${c_reset}"
fi
if [[ $? -ne 0 ]] ; then
if [[ $verbosity != "quiet" ]] ; then
+ package_print_first
+
echo -e "${c_error}ERROR: Failed to copy files from data directory ${c_notice}${directory_sub}${c_error} to ${c_notice}${package}sources/data$level${c_error}.${c_reset}"
fi
if [[ $? -ne 0 ]] ; then
if [[ $verbosity != "quiet" ]] ; then
+ package_print_first
+
echo -e "${c_error}ERROR: Failed to remove directory ${c_notice}${package}sources/data/build${c_error}.${c_reset}"
fi
if [[ $? -ne 0 ]] ; then
if [[ $verbosity != "quiet" ]] ; then
+ package_print_first
+
echo -e "${c_error}ERROR: Failed to copy the data directory ${c_notice}${package}sources/data/${level}/data${c_error} to ${c_notice}${package}data/${level}${c_error}.${c_reset}"
fi
if [[ $? -ne 0 ]] ; then
if [[ $verbosity != "quiet" ]] ; then
+ package_print_first
+
echo -e "${c_error}ERROR: Failed to remove directory ${c_notice}${package}sources/data${c_error}.${c_reset}"
fi
if [[ $? -ne 0 ]] ; then
if [[ $verbosity != "quiet" ]] ; then
+ package_print_first
+
echo -e "${c_error}ERROR: Failed to copy files from data directory ${c_notice}${directory_sub}${c_error} to ${c_notice}${package}sources/documents${c_error}.${c_reset}"
fi
if [[ $? -ne 0 ]] ; then
if [[ $verbosity != "quiet" ]] ; then
+ package_print_first
+
echo -e "${c_error}ERROR: Failed to copy files from data directory ${c_notice}${directory_sub}${c_error} to ${c_notice}${package}sources/licenses${c_error}.${c_reset}"
fi
if [[ $? -ne 0 ]] ; then
if [[ $verbosity != "quiet" ]] ; then
+ package_print_first
+
echo -e "${c_error}ERROR: Failed to copy files from data directory ${c_notice}${directory_sub}${c_error} to ${c_notice}${package}sources/specifications${c_error}.${c_reset}"
fi
if [[ $? -ne 0 ]] ; then
if [[ $verbosity != "quiet" ]] ; then
+ package_print_first
+
echo -e "${c_error}ERROR: Failed to copy files from data directory ${c_notice}${directory_sub}${c_error} to ${c_notice}${package}tests${c_error}.${c_reset}"
fi
if [[ $? -ne 0 ]] ; then
if [[ $verbosity != "quiet" ]] ; then
+ package_print_first
+
echo -e "${c_error}ERROR: Failed to create package sources directory ${c_notice}${package}sources/${path_name}/${level}${c_error}.${c_reset}"
fi
if [[ $? -ne 0 ]] ; then
if [[ $verbosity != "quiet" ]] ; then
+ package_print_first
+
echo -e "${c_error}ERROR: Failed to copy files from sources directory ${c_notice}${directory_sub}${c_error} to ${c_notice}${package}sources/${path_name}/${level}${c_error}.${c_reset}"
fi
if [[ $failure == "" ]] ; then
package_operation_create_config_stubs
- fi
- if [[ $failure != "" ]] ; then
- package_cleanup
+ if [[ $? -ne 0 ]] ; then
+ let failure=1
+ fi
+ fi
- exit $failure
+ if [[ $failure == "" ]] ; then
+ return 0
fi
+
+ return 1
}
package_operation_program() {
- local failure=
local name=
local directory=
local package=
if [[ $? -ne 0 ]] ; then
if [[ $verbosity != "quiet" ]] ; then
+ package_print_first
+
echo -e "${c_error}ERROR: Failed to create directory ${c_notice}${path_destination}program${c_error}.${c_reset}"
fi
name="$(echo $directory | sed -e "s|${path_sources}level_3/||")"
package="${path_destination}program/${prepend}${name}-${version}/"
- if [[ $verbosity != "quiet" ]] ; then
- echo
+ if [[ $verbosity != "quiet" && $verbosity != "error" ]] ; then
+ package_print_first_or_always
+
echo -e "${c_highlight}Packaging Project${c_reset} (program) ${c_notice}${prepend}${name}-${version}${c_reset}${c_highlight}.${c_reset}"
fi
if [[ $? -ne 0 ]] ; then
if [[ $verbosity != "quiet" ]] ; then
+ package_print_first
+
echo -e "${c_error}ERROR: Failed to copy sources directory ${c_notice}${directory}${c_error} to ${c_notice}${package}sources${c_error}.${c_reset}"
fi
package_operation_copy_package
- if [[ $failure != "" ]] ; then
+ if [[ $? -ne 0 ]] ; then
+ let failure=1
+
break
fi
done
- if [[ $failure != "" ]] ; then
- package_cleanup
-
- exit $failure
+ if [[ $failure == "" ]] ; then
+ return 0
fi
+
+ return 1
}
package_operation_stand_alone() {
- local failure=
local name=
local directory=
local directory_level=
if [[ $? -ne 0 ]] ; then
if [[ $verbosity != "quiet" ]] ; then
+ package_print_first
+
echo -e "${c_error}ERROR: Failed to create directory ${c_notice}${path_destination}stand_alone${c_error}.${c_reset}"
fi
package_cleanup
- exit $failure
+ return 1
fi
fi
directory="${path_sources}level_3/${name}"
package="${path_destination}stand_alone/${prepend}${name}-${version}/"
- if [[ $verbosity != "quiet" ]] ; then
- echo
+ if [[ $verbosity != "quiet" && $verbosity != "error" ]] ; then
+ package_print_first_or_always
+
echo -e "${c_highlight}Packaging Project${c_reset} (stand_alone) ${c_notice}${prepend}${name}-${version}${c_reset}${c_highlight}.${c_reset}"
fi
package_create_base_files
+ if [[ $? -ne 0 ]] ; then
+ let failure=1
+
+ break
+ fi
+
cp $verbose_common -R $directory ${package}sources/
if [[ $? -ne 0 ]] ; then
if [[ $verbosity != "quiet" ]] ; then
+ package_print_first
+
echo -e "${c_error}ERROR: Failed to copy sources directory ${c_notice}${directory}${c_error} to ${c_notice}${package}sources${c_error}.${c_reset}"
fi
package_operation_copy_package
- if [[ $failure != "" ]] ; then
+ if [[ $? -ne 0 ]] ; then
+ let failure=1
+
break
fi
if [[ $? -ne 0 ]] ; then
if [[ $verbosity != "quiet" ]] ; then
+ package_print_first
+
echo -e "${c_error}ERROR: Failed to copy file ${c_notice}${path_build}stand_alone/${name}.settings${c_error} to ${c_notice}${package}data/build/settings${c_error}.${c_reset}"
fi
if [[ $? -ne 0 ]] ; then
if [[ $verbosity != "quiet" ]] ; then
+ package_print_first
+
echo -e "${c_error}ERROR: Failed to create package sources directory ${c_notice}${package}sources/c/program/${name}/${c_error}.${c_reset}"
fi
if [[ $? -ne 0 ]] ; then
if [[ $verbosity != "quiet" ]] ; then
+ package_print_first
+
echo -e "${c_error}ERROR: Failed to create package sources directory ${c_notice}${package}sources/${path_name}/program/${name}/${c_error}.${c_reset}"
fi
if [[ $? -ne 0 ]] ; then
if [[ $verbosity != "quiet" ]] ; then
+ package_print_first
+
echo -e "${c_error}ERROR: Failed to move path ${c_notice}${path_sub}${c_error} to ${c_notice}${package}sources/${path_name}/program/${name}/${c_error}.${c_reset}"
fi
if [[ $? -ne 0 ]] ; then
if [[ $verbosity != "quiet" ]] ; then
+ package_print_first
+
echo -e "${c_error}ERROR: Failed to copy file ${c_notice}${path_build}stand_alone/config.h${c_error} to ${c_notice}${package}sources/c/${c_error}.${c_reset}"
fi
if [[ $? -ne 0 ]] ; then
if [[ $verbosity != "quiet" ]] ; then
+ package_print_first
+
echo -e "${c_error}ERROR: Failed to create package sources directory ${c_notice}${package}sources/${path_name}/fll/${level}/${c_error}.${c_reset}"
fi
if [[ $? -ne 0 ]] ; then
if [[ $verbosity != "quiet" ]] ; then
+ package_print_first
+
echo -e "${c_error}ERROR: Failed to copy files from sources directory ${c_notice}${directory_level}${path_name}/${c_error} to ${c_notice}${package}sources/${path_name}/fll/${level}/${c_error}.${c_reset}"
fi
fi
done
- if [[ $failure != "" ]] ; then
- package_cleanup
+ if [[ $failure == "" ]] ; then
+ return 0
+ fi
+
+ return 1
+}
+
+package_print_first() {
+
+ if [[ $print_line_first == "yes" ]] ; then
+ echo
+
+ print_line_first=
+ fi
+}
- exit $failure
+package_print_first_or_always() {
+
+ if [[ $print_line_first == "yes" ]] ; then
+ echo
+
+ print_line_first=
+ elif [[ $print_line_first == "no" ]] ; then
+ print_line_first=
+ else
+ echo
+ fi
+}
+
+package_print_last() {
+
+ if [[ $print_line_last == "yes" ]] ; then
+ echo
fi
}
package_cleanup() {
+ unset package_copyright
unset package_main
unset package_handle_colors
unset package_help
unset package_operation_monolithic
unset package_operation_program
unset package_operation_stand_alone
+ unset package_print_first
+ unset package_print_first_or_always
+ unset package_print_last
unset package_cleanup
}
local grab_next=
local do_color=dark
local do_help=
+ local do_copyright=
local i=0
local p=
local t=0
local path_test_work=${path_test}work/
local path_test_package_individual=${path_test_package}individual/
local path_test_package_stand_alone=${path_test_package}stand_alone/
+ local print_line_first="yes"
+ local print_line_last="yes"
local test_system=
local context=
local verbose=
local verbose_common=
- local projects="f_type f_status f_memory f_type_array f_string f_utf f_account f_capability f_color f_console f_control_group f_conversion f_directory f_environment f_execute f_file f_fss f_iki f_limit f_path f_pipe f_print f_serialize f_signal f_socket f_status_string f_thread fl_control_group fl_conversion fl_directory fl_environment fl_execute fl_fss fl_iki fl_print fl_signal fl_string fl_utf fl_utf_file fll_control_group fll_error fll_execute fll_file fll_fss fll_fss_status_string fll_iki fll_path fll_print fll_program fll_status_string"
+ local projects="f_type f_status f_memory f_type_array f_string f_utf f_account f_capability f_color f_console f_control_group f_conversion f_directory f_environment f_execute f_file f_fss f_iki f_limit f_path f_pipe f_print f_serialize f_signal f_socket f_status_string f_thread fl_control_group fl_conversion fl_directory fl_environment fl_execute fl_fss fl_iki fl_path fl_print fl_signal fl_string fl_utf fl_utf_file fll_control_group fll_error fll_execute fll_file fll_fss fll_fss_status_string fll_iki fll_print fll_program fll_status_string"
local projects_no_tests="f_type"
let failure=0
if [[ $grab_next == "" ]] ; then
if [[ $p == "-h" || $p == "--help" ]] ; then
do_help=yes
+ elif [[ $p == "+C" || $p == "++copyright" ]] ; then
+ do_copyright="yes"
elif [[ $p == "+d" || $p == "++dark" ]] ; then
do_color=dark
context="+d"
elif [[ $p == "+n" || $p == "++no_color" ]] ; then
do_color=none
context="+n"
- elif [[ $p == "+q" || $p == "++quiet" ]] ; then
+ elif [[ $p == "+Q" || $p == "++quiet" ]] ; then
verbosity="quiet"
- verbose="+q"
+ verbose="+Q"
+ verbose_common=
+ elif [[ $p == "+E" || $p == "++error" ]] ; then
+ verbosity="error"
+ verbose="+E"
verbose_common=
elif [[ $p == "+N" || $p == "++normal" ]] ; then
verbosity=
verbose_common="-v"
elif [[ $p == "+v" || $p == "++version" ]] ; then
echo $version
- return
+ return 0
elif [[ $p == "-c" || $p == "--compiler" ]] ; then
grab_next=build_compiler
elif [[ $p == "-p" || $p == "--project" ]] ; then
p=
fi
+ if [[ $verbosity == "quiet" ]] ; then
+ print_line_first="no"
+ print_line_last="no"
+ fi
+
test_handle_colors
if [[ $do_help == "yes" ]] ; then
return 0
fi
+ if [[ $do_copyright == "yes" ]] ; then
+ test_copyright
+ test_cleanup
+
+ return 0
+ fi
+
if [[ $operation_failure == "fail-too_many" ]] ; then
if [[ $verbosity != "quiet" ]] ; then
+ test_print_first
+
echo -e "${c_error}ERROR: Only a single build system is supported, received the following test systems ${c_notice}${test_system} ${operation}${c_error} was not recognized.${c_reset}"
fi
if [[ $failure -eq 0 && $test_system != "normal" && $test_system != "github" && $test_system != "gitlab" ]] ; then
if [[ $verbosity != "quiet" ]] ; then
+ test_print_first
+
echo -e "${c_error}ERROR: The test system must be one of ${c_notice}normal${c_error}, ${c_notice}github${c_error}, or ${c_notice}gitlab${c_error}.${c_reset}"
fi
if [[ $failure -eq 0 && $build_compiler != "gcc" && $build_compiler != "clang" ]] ; then
if [[ $verbosity != "quiet" ]] ; then
+ test_print_first
+
echo -e "${c_error}ERROR: The build compiler ${c_notice}${build_compiler}${c_error} is not currently directly supported.${c_reset}"
fi
if [[ $failure -eq 0 && ! -d $path_scripts ]] ; then
if [[ $verbosity != "quiet" ]] ; then
+ test_print_first
+
echo -e "${c_error}ERROR: The build scripts path ${c_notice}${path_scripts}${c_error} is not a valid directory.${c_reset}"
fi
if [[ $failure -eq 0 && ! -f $path_scripts_package ]] ; then
if [[ $verbosity != "quiet" ]] ; then
+ test_print_first
+
echo -e "${c_error}ERROR: Unable to find the package build script file under the build scripts path at ${c_notice}${path_scripts_package}${c_error}.${c_reset}"
fi
if [[ $? -ne 0 ]] ; then
if [[ $verbosity != "quiet" ]] ; then
+ print_line_first
+
echo -e "${c_error}ERROR: The test path ${c_notice}${path_test}${c_error}, does not exist and could not be created or exists and is not a valid directory.${c_reset}"
fi
if [[ $? -ne 0 ]] ; then
if [[ $verbosity != "quiet" ]] ; then
+ print_line_first
+
echo -e "${c_error}ERROR: The package path ${c_notice}${path_test_package}${c_error}, does not exist and could not be created or exists and is not a valid directory.${c_reset}"
fi
if [[ $? -ne 0 ]] ; then
if [[ $verbosity != "quiet" ]] ; then
+ print_line_first
+
echo -e "${c_error}ERROR: The test project path ${c_notice}${path_test_project}${c_error}, does not exist and could not be created or exists and is not a valid directory.${c_reset}"
fi
if [[ $? -ne 0 ]] ; then
if [[ $verbosity != "quiet" ]] ; then
+ print_line_first
+
echo -e "${c_error}ERROR: The test work path ${c_notice}${path_test_work}${c_error}, does not exist and could not be created or exists and is not a valid directory.${c_reset}"
fi
fi
if [[ $verbosity != "quiet" ]] ; then
- echo
+ if [[ $failure != "" || $verbosity != "error" ]] ; then
+ test_print_last
+ fi
fi
test_cleanup
- return $failure
+ if [[ $failure == "" ]] ; then
+ return 0
+ fi
+
+ return 1
}
test_handle_colors() {
test_help() {
- echo
+ test_print_first
+
echo -e "${c_title}${public_name}${c_reset}"
echo -e " ${c_notice}Version ${version}${c_reset}"
echo
echo -e " ${c_important}gitlab${c_reset} Perform a test meant to be used within Gitlab (not yet supported)."
echo
echo -e "${c_highlight}Options:${c_reset}"
- echo -e " -${c_important}h${c_reset}, --${c_important}help${c_reset} Print this help screen."
- echo -e " +${c_important}d${c_reset}, ++${c_important}dark${c_reset} Use color modes that show up better on dark backgrounds."
- echo -e " +${c_important}l${c_reset}, ++${c_important}light${c_reset} Use color modes that show up better on light backgrounds."
- echo -e " +${c_important}n${c_reset}, ++${c_important}no_color${c_reset} Do not use color."
- echo -e " +${c_important}q${c_reset}, ++${c_important}quiet${c_reset} Decrease verbosity, silencing most output."
- echo -e " +${c_important}N${c_reset}, ++${c_important}normal${c_reset} Set verbosity to normal."
- echo -e " +${c_important}V${c_reset}, ++${c_important}verbose${c_reset} Increase verbosity beyond normal output."
- echo -e " +${c_important}D${c_reset}, ++${c_important}debug${c_reset} Enable debugging, significantly increasing verbosity beyond normal output."
- echo -e " +${c_important}v${c_reset}, ++${c_important}version${c_reset} Print the version number of this program."
+ echo -e " -${c_important}h${c_reset}, --${c_important}help${c_reset} Print this help message."
+ echo -e " +${c_important}C${c_reset}, ++${c_important}copyright${c_reset} Print the copyright."
+ echo -e " +${c_important}d${c_reset}, ++${c_important}dark${c_reset} Output using colors that show up better on dark backgrounds."
+ echo -e " +${c_important}l${c_reset}, ++${c_important}light${c_reset} Output using colors that show up better on light backgrounds."
+ echo -e " +${c_important}n${c_reset}, ++${c_important}no_color${c_reset} Do not print using color."
+ echo -e " +${c_important}Q${c_reset}, ++${c_important}quiet${c_reset} Decrease verbosity, silencing most print.to."
+ echo -e " +${c_important}E${c_reset}, ++${c_important}error${c_reset} Decrease verbosity, using only error print.to."
+ echo -e " +${c_important}N${c_reset}, ++${c_important}normal${c_reset} Set verbosity to normal."
+ echo -e " +${c_important}V${c_reset}, ++${c_important}verbose${c_reset} Increase verbosity beyond normal print.to."
+ echo -e " +${c_important}D${c_reset}, ++${c_important}debug${c_reset} Enable debugging, significantly increasing verbosity beyond normal print.to."
+ echo -e " +${c_important}v${c_reset}, ++${c_important}version${c_reset} Print only the version number."
echo
echo -e "${c_highlight}Install Options:${c_reset}"
echo -e " -${c_important}c${c_reset}, --${c_important}compiler${c_reset} Specify the compiler, either gcc (default) or clang."
echo -e " -${c_important}p${c_reset}, --${c_important}project${c_reset} Designate that the project files must also be built."
echo -e " -${c_important}s${c_reset}, --${c_important}path_scripts${c_reset} Specify a custom directory where the build scripts are found."
echo -e " -${c_important}t${c_reset}, --${c_important}path_test${c_reset} Specify a custom directory where the test environment is found."
+
+ test_print_last
+}
+
+test_copyright() {
+
+ test_print_first
+
+ echo "Copyright © 2007-2023 Kevin Day."
echo
+ echo "Source code license lgpl-2.1-or-later."
+ echo "Standard and specification license open-standard-license-1.0."
+ echo "Documentation license cc-by-sa-4.0."
+
+ test_print_last
}
test_operate() {
test_operate_ci_prebuild
if [[ $? -ne 0 ]] ; then
+ let failure=1
+
return 1
fi
fi
test_operate_build_tools
if [[ $? -ne 0 ]] ; then
+ let failure=1
+
return 1
fi
fi
test_operate_build_individual
if [[ $? -ne 0 ]] ; then
+ let failure=1
+
return 1
fi
test_operate_ci_pretest
if [[ $? -ne 0 ]] ; then
+ let failure=1
+
return 1
fi
fi
}
test_operate_build_individual() {
- local -i failure=0
local project=
local path_original="$PWD/"
- if [[ $verbosity != "quiet" ]] ; then
- echo
+ if [[ $verbosity != "quiet" && $verbosity != "error" ]] ; then
+ test_print_first_or_always
+
echo -e "${c_highlight}Cleaning and building package.${c_reset}"
echo -e "${c_title}------------------------------${c_reset}"
fi
if [[ $verbosity == "debug" ]] ; then
- echo
+ test_print_first_or_always
+
echo "$shell_command ${path_scripts_package} $verbose $context -d $path_test_package -i rebuild"
fi
if [[ $? -ne 0 ]] ; then
if [[ $verbosity != "quiet" ]] ; then
- echo
+ test_print_first
+
echo -e "${c_error}ERROR: Failed to clean and build the individual packages.${c_reset}"
fi
cd $path_original
done
- return $failure
+ if [[ $failure == "" ]] ; then
+ return 0
+ fi
+
+ return 1
}
test_operate_build_project() {
if [[ ! -d ${path_}${project}-${version}/ ]] ; then
if [[ $verbosity != "quiet" ]] ; then
- echo
+ test_print_first
+
echo -e "${c_error}ERROR: Package directory '${c_notice}${path_}${project}-${version}${c_error}' is invalid or missing.${c_reset}"
fi
fi
if [[ $verbosity == "debug" ]] ; then
- echo
+ test_print_first_or_always
+
echo -e "Running '${c_notice}cd ${path_}${project}-${version}/${c_reset}'."
fi
if [[ $? -ne 0 ]] ; then
if [[ $verbosity != "quiet" ]] ; then
- echo
+ test_print_first
+
echo -e "${c_error}ERROR: Failed to change into directory '${c_notice}${path_}${project}-${version}${c_error}'.${c_reset}"
fi
+ let failure=1
+
return 1
fi
if [[ $bootstrap == "" ]] ; then
if [[ $verbosity == "debug" ]] ; then
- echo
+ test_print_first_or_always
if [[ $build_compiler == "gcc" ]] ; then
echo "PATH=\"$env_path\" LD_LIBRARY_PATH=\"$env_libs\" fake $verbose $context -w \"$destination\" -m $mode clean build $ci_arguments"
else
if [[ $SHELL_ENGINE == "zsh" ]] ; then
if [[ $verbosity == "debug" ]] ; then
- echo
+ test_print_first_or_always
if [[ $build_compiler == "gcc" ]] ; then
echo "zsh ./bootstrap.sh $verbose $context -w \"$destination\" -m $mode -m test build"
fi
else
if [[ $verbosity == "debug" ]] ; then
- echo
+ test_print_first_or_always
if [[ $build_compiler == "gcc" ]] ; then
echo "./bootstrap.sh $verbose $context -w \"$destination\" -m $mode -m test build"
if [[ $? -ne 0 ]] ; then
if [[ $verbosity != "quiet" ]] ; then
- echo
+ test_print_first
+
echo -e "${c_error}ERROR: Failed to build $mode project '${c_notice}$project${c_reset}${c_error}'.${c_reset}"
fi
+ let failure=1
+
return 1
fi
- if [[ $verbosity != "quiet" ]] ; then
- echo
+ if [[ $verbosity != "quiet" && $verbosity != "error" ]] ; then
echo -e "Installing $mode project '${c_notice}$project${c_reset}'."
+ echo
fi
if [[ $SHELL_ENGINE == "zsh" ]] ; then
if [[ $? -ne 0 ]] ; then
if [[ $verbosity != "quiet" ]] ; then
- echo
+ test_print_first
+
echo -e "${c_error}ERROR: Failed to install $mode project '${c_notice}$project${c_reset}${c_error}'.${c_reset}"
fi
+ let failure=1
+
return 1
fi
}
test_operate_build_tools() {
- local -i failure=0
local path_original="$PWD/"
- if [[ $verbosity != "quiet" ]] ; then
- echo
+ if [[ $verbosity != "quiet" && $verbosity != "error" ]] ; then
+ test_print_first_or_always
+
echo -e "${c_highlight}Building project build tools.${c_reset}"
echo -e "${c_title}-----------------------------${c_reset}"
fi
if [[ $verbosity == "debug" ]] ; then
- echo
+ test_print_first_or_always
+
echo "$shell_command ${path_scripts_package} $verbose $context -d $path_test_package -S fake rebuild"
fi
if [[ $? -ne 0 ]] ; then
if [[ $verbosity != "quiet" ]] ; then
- echo
+ test_print_first
+
echo -e "${c_error}ERROR: Failed to clean and build the stand_alone fake package.${c_reset}"
fi
cd $path_original
- return $failure
+ if [[ $failure == "" ]] ; then
+ return 0
+ fi
+
+ return 1
}
test_operate_ci_prebuild() {
clone_quiet="-q"
fi
- if [[ $verbosity != "quiet" ]] ; then
- echo
+ if [[ $verbosity != "quiet" && $verbosity != "error" ]] ; then
+ test_print_first_or_always
+
echo -e "${c_highlight}Performing Github Specific Pre-Build Operations.${c_reset}"
echo -e "${c_title}------------------------------------------------${c_reset}"
fi
test_operate_ci_prebuild_libcap
- result=$?
+
+ if [[ $? -ne 0 ]] ; then
+ let failure=1
+ fi
cd ${path_original}
- return $result
+ if [[ $failure == "" ]] ; then
+ return 0
+ fi
+
+ return 1
}
test_operate_ci_pretest() {
clone_quiet="-q"
fi
- if [[ $verbosity != "quiet" ]] ; then
- echo
+ if [[ $verbosity != "quiet" && $verbosity != "error" ]] ; then
+ test_print_first_or_always
+
echo -e "${c_highlight}Performing Github Specific Pre-Test Operations.${c_reset}"
echo -e "${c_title}-----------------------------------------------${c_reset}"
fi
test_operate_ci_pretest_cmocka
- result=$?
+
+ if [[ $? -ne 0 ]] ; then
+ let failure=1
+ fi
cd ${path_original}
- return $result
+ if [[ $failure == "" ]] ; then
+ return 0
+ fi
+
+ return 1
}
test_operate_ci_pretest_cmocka() {
local cmocka_branch="cmocka-1.1.5"
if [[ -d $cmocka_path ]] ; then
- if [[ $verbosity != "quiet" ]] ; then
- echo
+ if [[ $verbosity != "quiet" && $verbosity != "error" ]] ; then
+ test_print_first_or_always
+
echo -e "Detected existing cmocka repository at \"${c_notice}$cmocka_path${c_reset}\", skipping the cmocka process."
fi
fi
if [[ $verbosity == "debug" ]] ; then
- echo
+ test_print_first_or_always
+
echo "git clone $clone_quiet --single-branch -b $cmocka_branch \"$cmocka_uri\" $cmocka_path"
fi
if [[ $? -ne 0 ]] ; then
if [[ $verbosity != "quiet" ]] ; then
- echo
+ test_print_first
+
echo -e "${c_error}ERROR: Failed to git clone '${c_notice}$cmocka_uri${c_error}' onto '${c_notice}$cmocka_path${c_error}'.${c_reset}"
fi
+ let failure=1
+
return 1
fi
if [[ $verbosity == "debug" ]] ; then
- echo
+ test_print_first_or_always
+
echo "mkdir $verbose_common -p $cmocka_data"
fi
if [[ $? -ne 0 ]] ; then
if [[ $verbosity != "quiet" ]] ; then
- echo
+ test_print_first
+
echo -e "${c_error}ERROR: Failed to create cmocka build data directory '${c_notice}$cmocka_data${c_error}'.${c_reset}"
fi
+ let failure=1
+
return 1
fi
if [[ $verbosity == "debug" ]] ; then
- echo
+ test_print_first_or_always
+
echo "cp $verbose_common $cmocka_settings $cmocka_data"
fi
if [[ $? -ne 0 ]] ; then
if [[ $verbosity != "quiet" ]] ; then
- echo
+ test_print_first
+
echo -e "${c_error}ERROR: Failed to copy cmocka build settings: '${c_notice}$cmocka_settings${c_error}'.${c_reset}"
fi
+ let failure=1
+
return 1
fi
if [[ $verbosity == "debug" ]] ; then
- echo
+ test_print_first_or_always
+
echo "cd $cmocka_path"
fi
if [[ $? -ne 0 ]] ; then
if [[ $verbosity != "quiet" ]] ; then
- echo
+ test_print_first
+
echo -e "${c_error}ERROR: Failed to change cmocka source directory '${c_notice}$cmocka_path${c_error}'.${c_reset}"
fi
+ let failure=1
+
return 1
fi
if [[ $verbosity == "debug" ]] ; then
- echo
+ test_print_first_or_always
+
echo "PATH=\"$env_path\" LD_LIBRARY_PATH=\"$env_libs\" fake $verbose $context -w \"$path_test_work\" -m $build_compiler clean build $ci_arguments"
fi
if [[ $? -ne 0 ]] ; then
if [[ $verbosity != "quiet" ]] ; then
- echo
+ test_print_first
+
echo -e "${c_error}ERROR: Failed to build '${c_notice}cmocka${c_error}'.${c_reset}"
fi
+ let failure=1
+
return 1
fi
if [[ $verbosity == "debug" ]] ; then
- echo
+ test_print_first_or_always
+
echo "cp $verbose_common -R ${cmocka_build}includes/* ${work_path}includes/"
fi
if [[ $? -ne 0 ]] ; then
if [[ $verbosity != "quiet" ]] ; then
- echo
+ test_print_first
+
echo -e "${c_error}ERROR: Failed to install cmocka headers to '${c_notice}${work_path}includes/${c_error}'.${c_reset}"
fi
+ let failure=1
+
return 1
fi
if [[ $verbosity == "debug" ]] ; then
- echo
+ test_print_first_or_always
+
echo "cp $verbose_common -R ${cmocka_build}libraries/shared/* ${work_path}libraries/shared/"
fi
if [[ $? -ne 0 ]] ; then
if [[ $verbosity != "quiet" ]] ; then
- echo
+ test_print_first
+
echo -e "${c_error}ERROR: Failed to install cmocka libraries to '${c_notice}${work_path}libraries/shared/${c_error}'.${c_reset}"
fi
+ let failure=1
+
return 1
fi
local libcap_branch="master"
if [[ -d $libcap_path ]] ; then
- if [[ $verbosity != "quiet" ]] ; then
- echo
+ if [[ $verbosity != "quiet" && $verbosity != "error" ]] ; then
+ test_print_first_or_always
+
echo -e "Detected existing libcap repository at \"${c_notice}$libcap_path${c_reset}\", skipping the libcap process."
fi
fi
if [[ $verbosity == "debug" ]] ; then
- echo
+ test_print_first_or_always
+
echo "git clone $clone_quiet --single-branch -b $libcap_branch \"$libcap_uri\" $libcap_path"
fi
if [[ $? -ne 0 ]] ; then
if [[ $verbosity != "quiet" ]] ; then
- echo
+ test_print_first
+
echo -e "${c_error}ERROR: Failed to git clone '${c_notice}$libcap_uri${c_error}' onto '${c_notice}$libcap_path${c_error}'.${c_reset}"
fi
+ let failure=1
+
return 1
fi
if [[ $verbosity == "debug" ]] ; then
- echo
+ test_print_first_or_always
+
echo "cd $libcap_path"
fi
if [[ $? -ne 0 ]] ; then
if [[ $verbosity != "quiet" ]] ; then
- echo
+ test_print_first
+
echo -e "${c_error}ERROR: Failed to change libcap source directory '${c_notice}$libcap_path${c_error}'.${c_reset}"
+
+ test_print_last
fi
+ let failure=1
+
return 1
fi
if [[ $verbosity == "debug" ]] ; then
- echo
+ test_print_first_or_always
+
echo "make MANDIR=${work_path}fake/ SBINDIR=${work_path}fake/ INCDIR=${work_path}includes/ LIBDIR=${work_path}libraries/shared/ PKGCONFIGDIR=${work_path}fake/ install"
fi
if [[ $? -ne 0 ]] ; then
if [[ $verbosity != "quiet" ]] ; then
- echo
+ test_print_first
+
echo -e "${c_error}ERROR: Failed to build and install libcap into the work directory '${c_notice}${work_path}${c_error}'.${c_reset}"
+
+ test_print_last
fi
+ let failure=1
+
return 1
fi
}
test_operate_tests() {
- local -i failure=0
local project=
local path_original="$PWD/"
local destination="$path_test_work"
for project in $projects ; do
- if [[ $verbosity != "quiet" ]] ; then
- echo
+ if [[ $verbosity != "quiet" && $verbosity != "error" ]] ; then
+ test_print_first_or_always
+
echo -e "${c_highlight}Testing Project $project.${c_reset}"
echo -e "${c_title}--------------------------------------${c_reset}"
fi
if [[ ! -d $path_test_package_individual$project-$version/ ]] ; then
if [[ $verbosity != "quiet" ]] ; then
- echo
+ test_print_first
+
echo -e "${c_error}ERROR: Package directory '${c_notice}$path_test_package_individual$project-$version${c_error}' is invalid or missing.${c_reset}"
+
+ test_print_last
fi
let failure=1
fi
- if [[ $failure -eq 0 ]] ; then
+ if [[ $failure == "" ]] ; then
if [[ ! -f $path_test_package_individual$project-$version/data/build/testfile ]] ; then
if [[ $(echo $projects_no_tests | grep -o "\<$project\>") == "" ]] ; then
if [[ $verbosity == "verbose" || $verbosity == "debug" ]] ; then
- echo
+ test_print_first_or_always
+
echo -e "${c_warning}WARNING: Project '${c_notice}$project${c_warning}' does not have a testfile.${c_reset}"
fi
else
- echo
+ test_print_first_or_always
+
echo -e "Project '${c_notice}$project${c_reset}' has no tests and is not expected to.${c_reset}"
fi
fi
fi
- if [[ $failure -eq 0 ]] ; then
+ if [[ $failure == "" ]] ; then
if [[ $verbosity == "debug" ]] ; then
- echo
+ test_print_first_or_always
+
echo -e "Running '${c_notice}cd $path_test_package_individual$project-$version/${c_reset}'."
fi
if [[ $? -ne 0 ]] ; then
if [[ $verbosity != "quiet" ]] ; then
- echo
+ test_print_first
+
echo -e "${c_error}ERROR: Failed to change into directory '${c_notice}$path_test_package_individual$project-$version${c_error}'.${c_reset}"
+
+ test_print_last
fi
let failure=1
fi
fi
- if [[ $failure -eq 0 ]] ; then
+ if [[ $failure == "" ]] ; then
if [[ $verbosity == "debug" ]] ; then
- echo
+ test_print_first_or_always
if [[ $build_compiler == "gcc" ]] ; then
echo "PATH=\"$env_path\" LD_LIBRARY_PATH=\"$env_libs\" fake $verbose $context -w \"$destination\" -m individual -m test clean make -f testfile $ci_arguments"
if [[ $? -ne 0 ]] ; then
if [[ $verbosity != "quiet" ]] ; then
- echo
+ test_print_first
+
echo -e "${c_error}ERROR: Failure while testing project '${c_notice}$project${c_reset}${c_error}'.${c_reset}"
+
+ test_print_last
fi
let failure=1
cd $path_original
- if [[ $failure -ne 0 ]] ; then
+ if [[ $failure != "" ]] ; then
break;
fi
done
- return $failure
+ if [[ $failure == "" ]] ; then
+ return 0
+ fi
+
+ return 1
+}
+
+test_print_first() {
+
+ if [[ $print_line_first == "yes" ]] ; then
+ echo
+
+ print_line_first=
+ fi
+}
+
+test_print_first_or_always() {
+
+ if [[ $print_line_first == "yes" ]] ; then
+ echo
+
+ print_line_first=
+ elif [[ $print_line_first == "no" ]] ; then
+ print_line_first=
+ else
+ echo
+ fi
+}
+
+test_print_last() {
+
+ if [[ $print_line_last == "yes" ]] ; then
+ echo
+ fi
}
test_cleanup() {
+ unset test_copyright
unset test_main
unset test_handle_colors
unset test_help
-
- unset test_cleanup
unset test_operate
unset test_operate_build_individual
unset test_operate_build_project
unset test_operate_ci_pretest
unset test_operate_ci_pretest_cmocka
unset test_operate_tests
+ unset test_print_first
+ unset test_print_first_or_always
+ unset test_print_last
+ unset test_cleanup
}
test_main $*