From 22e3e07d4233c7d7924f924f887d84af4db73539 Mon Sep 17 00:00:00 2001 From: "T. Joseph Carter" Date: Wed, 25 Mar 2015 20:09:06 -0700 Subject: [PATCH] Changed how build summary is produced, start of new logging --- libretro-build-common.sh | 68 +++++++++++++++++++++++----------------- libretro-build.sh | 2 +- libretro-config.sh | 10 +++--- script-modules/util.sh | 10 ++++++ 4 files changed, 54 insertions(+), 36 deletions(-) diff --git a/libretro-build-common.sh b/libretro-build-common.sh index a52c9905..57b96f98 100755 --- a/libretro-build-common.sh +++ b/libretro-build-common.sh @@ -41,6 +41,9 @@ echo "$FORMAT_COMPILER_TARGET_ALT" RESET_FORMAT_COMPILER_TARGET=$FORMAT_COMPILER_TARGET RESET_FORMAT_COMPILER_TARGET_ALT=$FORMAT_COMPILER_TARGET_ALT +# FIXME: We should use the theos toolchain without their make system which is +# buggy on Linux and doesn't do what we want anyway. It'd remove need +# for this and other hacks. CORE_PREFIX="" CORE_SUFFIX="_libretro${FORMAT}.$FORMAT_EXT" if [ "$platform" = "theos_ios" ]; then @@ -195,7 +198,7 @@ build_makefile() { make_cmdline="$make_cmdline -f $core_build_makefile" fi - # TODO: Do this better + # TODO: Do $platform type stuff better (requires modding each core) make_cmdline="$make_cmdline platform=\"$core_build_platform\"" [ -n "$JOBS" ] && make_cmdline="$make_cmdline -j$JOBS" @@ -338,35 +341,42 @@ build_libretro_test() { build_summary() { - if [ -z "$NOBUILD_SUMMARY" ]; then - if command -v fmt > /dev/null; then - use_fmt=1 - fi - printf -v summary "=== Core Build Summary ===\n\n" - if [ -n "$build_success" ]; then - printf -v summary "%s%s%d%s\n" "$summary" "$(color 32)" "$(echo $build_success | wc -w)" " core(s)$(color) successfully built:" - if [ -n "$use_fmt" ]; then - printf -v summary "%s%s\n\n" "$summary" "$(echo " $build_success" | fmt)" - else - printf -v summary "%s%s\n\n" "$summary" "$(echo $build_success)" - fi - fi - if [ -n "$build_fail" ]; then - printf -v summary "%s%s%d%s\n" "$summary" "$(color 31)" "$(echo $build_fail | wc -w)" " core(s)$(color) failed to build:" - if [ -n "$use_fmt" ]; then - printf -v summary "%s%s\n\n" "$summary" "$(echo " $build_fail" | fmt)" - else - printf -v summary "%s%s\n\n" "$summary" "$(echo $build_fail)" - fi - fi - if [[ -z "$build_success" && -z "$build_fail" ]]; then - printf -v summary "%s%s\n\n" "$summary" "No build actions performed." - fi - if [ -n "$BUILD_SUMMARY" ]; then - echo "$summary" > "$BUILD_SUMMARY" - fi - echo "$summary" + fmt_output="$(find_tool "fmt" "cat")" + local num_success="$(echo $build_success | wc -w)" + local fmt_success="$(echo " $build_success" | $fmt_output)" + local num_fail="$(echo $build_fail | wc -w)" + local fmt_fail="$(echo " $build_fail" | $fmt_output)" + + echo "" + if [[ -z "$build_success" && -z "$build_fail" ]]; then + echo "No build actions performed." + return fi + + if [ -n "$build_success" ]; then + echo "$(color 32)$num_success core(s)$(color) successfully built:" + echo "$fmt_success" + fi + if [ -n "$build_fail" ]; then + echo "$(color 31)$num_fail core(s)$(color) failed to build:" + echo "$fmt_fail" + fi + if [ -n "$LIBRETRO_LOGDIR" ]; then + { + if [ -n "$build_success" ]; then + echo "$num_success core(s) successfully built:" + echo "$fmt_success" + fi + if [ -n "$build_fail" ]; then + echo "$num_fail core(s) failed to build:" + echo "$fmt_fail" + fi + } > $LIBRETRO_LOGDIR/build_summary.log 2>&1 + fi +} + +summary() { + build_summary } create_dist_dir() { diff --git a/libretro-build.sh b/libretro-build.sh index c4465495..9d733bce 100755 --- a/libretro-build.sh +++ b/libretro-build.sh @@ -194,4 +194,4 @@ if [ -n "$1" ]; then else build_default_cores fi -build_summary +summary diff --git a/libretro-config.sh b/libretro-config.sh index 1b5266fb..29415900 100755 --- a/libretro-config.sh +++ b/libretro-config.sh @@ -268,13 +268,11 @@ if [[ "$FORMAT_COMPILER_TARGET" = "osx" && -z "$NOUNIVERSAL" ]]; then esac fi -#CORE BUILD SUMMARY -#================== +#LOGGING +#======= -# Uncomment this to disable the core build summary -# NOBUILD_SUMMARY=1 - -BUILD_SUMMARY="$WORKDIR/build-summary.log" +# Uncomment this to enable per-core logging +#LIBRETRO_LOGDIR=$WORKDIR/log # BUILD_REVISIONS diff --git a/script-modules/util.sh b/script-modules/util.sh index a8abbf35..9b8b35b7 100644 --- a/script-modules/util.sh +++ b/script-modules/util.sh @@ -6,6 +6,16 @@ echo_cmd() { return $? } +find_tool() { + while [ -n "$1" ]; do + if [ -n "$1" ] && command -v "$1" > /dev/null; then + echo "$1" + return + fi + shift + done +} + color() { [ -n "$NO_COLOR" ] && return