Browse Source

makefile: Add percent complete calculation and display.

tags/non-daw-v1.1.0
Jonathan Moore Liles 17 years ago
parent
commit
452292a943
2 changed files with 32 additions and 1 deletions
  1. +12
    -1
      Makefile
  2. +20
    -0
      scripts/percent-complete

+ 12
- 1
Makefile View File

@@ -9,6 +9,11 @@

VERSION := 0.5.0

# a bit of a hack to make sure this runs before any rules
ifneq ($(CALCULATING),yes)
TOTAL := $(shell $(MAKE) CALCULATING=yes -n | sed -n 's/^.*Compiling: \([^"]\+\)"/\1/p' > .files )
endif

all: make.conf FL Timeline

make.conf: configure
@@ -30,8 +35,14 @@ INCLUDES := -I. -Iutil -IFL

include scripts/colors

ifneq ($(CALCULATING),yes)
COMPILING="$(BOLD)$(BLACK)[$(SGR0)$(CYAN)`scripts/percent-complete .files "$<"`$(SGR0)$(BOLD)$(BLACK)]$(SGR0) Compiling: $(BOLD)$(YELLOW)$<$(SGR0)"
else
COMPILING="Compiling: $<"
endif

.C.o:
@ echo "Compiling: $(BOLD)$(YELLOW)$<$(SGR0)"
@ echo $(COMPILING)
@ $(CXX) $(CXXFLAGS) $(INCLUDES) -c $< -o $@

%.C : %.fl


+ 20
- 0
scripts/percent-complete View File

@@ -0,0 +1,20 @@
#!/bin/sh

# May 2008 Jonathan Moore Liles
#
# Given the name of a file containing a list of files and a filename
# from that list, return the percentage of the distance from the
# beginning of the list.

[ $# -ne 2 ] && exit

MATCH="`grep -nFx \"$2\" \"$1\"`"
MATCH=${MATCH%%:*}
TOTAL="`cat \"$1\" | wc -l`"

if [ -z "$MATCH" ]
then
echo "0%"
else
printf "%3s%%" $(( $MATCH * 100 / $TOTAL ))
fi

Loading…
Cancel
Save