A lot of fixes for the automatic build system

This commit is contained in:
WolverinDEV
2019-07-02 02:23:51 +02:00
parent a827a2d64d
commit dc9dc62b2b
23 changed files with 241 additions and 131 deletions
+50 -9
View File
@@ -119,8 +119,8 @@ function cmake_build() {
return 1
fi
base_path=$(realpath $1)
build_path="$base_path/out/${build_os_type}_${build_os_arch}/"
local base_path=$(realpath $1)
local build_path="$base_path/out/${build_os_type}_${build_os_arch}/"
if [[ ! -d ${base_path} ]]; then
echo "Missing target directory. CMake build failed"
return 1
@@ -143,8 +143,8 @@ function cmake_build() {
return 1
}
parameters=(${@:2})
final_parms=()
local parameters=(${@:2})
local final_parms=()
declare -A final_definitions
#Merge env variables with definitions
@@ -175,7 +175,7 @@ function cmake_build() {
[[ ! -z "${C_FLAGS}" ]] && final_definitions["CMAKE_C_FLAGS"]="${final_definitions['CMAKE_C_FLAGS']} ${C_FLAGS}"
[[ ! -z "${CXX_FLAGS}" ]] && final_definitions["CMAKE_CXX_FLAGS"]="${final_definitions['CMAKE_CXX_FLAGS']} ${CXX_FLAGS}"
definition_string=""
local definition_string=""
for i in "${!final_definitions[@]}"
do
definition_string="${definition_string} -D$i=\"${final_definitions[$i]}\""
@@ -183,9 +183,9 @@ function cmake_build() {
#Cut of the start space
[[ ! -z ${definition_string} ]] && definition_string=${definition_string:1}
cmake_command="cmake $base_path$base_path_suffix ${final_parms[*]} ${definition_string} ${CMAKE_OPTIONS}"
local cmake_command="cmake $base_path$base_path_suffix ${final_parms[*]} ${definition_string} ${CMAKE_OPTIONS}"
origin_directory=$(pwd)
local origin_directory=$(pwd)
cd ${build_path}
[[ $? -ne 0 ]] && {
echo "Failed to enter build directory!"
@@ -203,7 +203,7 @@ function cmake_build() {
return 1
fi
make_command="make ${CMAKE_MAKE_OPTIONS}"
local make_command="make ${CMAKE_MAKE_OPTIONS}"
echo "Executing make command:"
echo "> $make_command"
eval "${make_command}"
@@ -212,7 +212,7 @@ function cmake_build() {
return 1
fi
make_install_command="make install"
local make_install_command="make install"
echo "Executing make install command:"
echo "> $make_install_command"
eval "${make_install_command}"
@@ -232,4 +232,45 @@ function check_err_exit() {
[[ ${#@} -gt 1 ]] && echo "${@:2}"
echo -e "Aborting build\e[0;39m"
exit 1
}
function pline() {
local width="150"
local padding="$(printf '%0.1s' ={1..120})"
printf "%*.*s $color_green%s$color_normal %*.*s\n" 0 "$(( ($width - 2 - ${#1}) / 2))" "$padding" "$1" 0 "$(( ($width - 1 - ${#1}) / 2 ))" "$padding"
}
function format_time() {
local time_needed_s=$(($1/1000000000))
local time_needed_m=$(($time_needed_s/60))
local time_needed_s=$(($time_needed_s - $time_needed_m * 60))
time=""
if [[ ${time_needed_m} != "0" ]]; then
[[ -z ${time} ]] && time="$time_needed_m min" || time="${time} $time_needed_m min"
fi
if [[ ${time_needed_s} != "0" ]]; then
[[ -z ${time} ]] && time="$time_needed_s sec" || time="${time} $time_needed_s sec"
fi
[[ -z ${time} ]] && time="0 sec"
}
declare -A task_timings
function begin_task() {
local name="$1"
local display_name="$2"
task_timings[$name]="$(date +%s%N)"
pline "$display_name"
}
function end_task() {
local name="$1"
local display_name="$2"
time_end=$(date +%s%N)
time_start=${task_timings[$name]}
format_time $(($time_end-$time_start))
pline "$display_name ($time)"
}