a ton of changes to fix the production directory. formerly this directory $FEISTY_ME...
[feisty_meow.git] / scripts / generator / whack_build.sh
1 #!/bin/bash
2
3 #hmmm: nice to set an interrupt handler for ctrl-c, to catch a break and send it to the cleanup of the crudfile.
4
5 # catch whether they want rigorous cleaning or not.
6 clean_src="$1"; shift
7
8 function whack_single_build_area()
9 {
10   local CLEANING_LOCALE="$1"; shift
11   if [ ! -d "$CLEANING_LOCALE" ]; then
12 #    echo "the folder $CLEANING_LOCALE does not exist.  not cleaning."
13     return 0
14   fi
15
16   local choprepo="$(basename "$(dirname "$CLEANING_LOCALE")" )/$(basename "$CLEANING_LOCALE")"
17   echo $(date): "cleaning up [$choprepo]..."
18   if [ -z "$CLEANING_LOCALE" ]; then
19     echo "The CLEANING_LOCALE variable is not set!"
20     exit 3
21   fi
22
23 #old  export NEW_TMP="$(mktemp -d "$CLEANING_LOCALE/TEMPS.XXXXXX")"
24   export NEW_TMP="$(mktemp -d "$TMP/temps-build-whacking.XXXXXX")"
25   export CRUDFILE="$(mktemp "$NEW_TMP/whack_build.XXXXXX")"
26   echo "" &>"$CRUDFILE"
27
28   CLEANING_TOP="$CLEANING_LOCALE/production"
29
30 #  echo $(date): "  cleaning up the build products..."
31
32   # avoid accidentally removing way too much important stuff if our variables have not
33   # been previously established.
34   local GENERATED_DIR="$CLEANING_TOP/generated-feisty_meow"
35 #*** hmmm: above is wrong place now!
36   local TEMPORARIES_DIR="$CLEANING_TOP/temporaries"
37
38   # kerzap.
39   rm -rf \
40     "$FEISTY_MEOW_DIR/generatedJUnitFiles" \
41     "$CLEANING_TOP/binaries" \
42     "$CLEANING_TOP/install" \
43     "$CLEANING_TOP/logs" \
44     "$CLEANING_TOP/objects" \
45     "$TEMPORARIES_DIR" \
46     "$GENERATED_DIR" \
47     "$CLEANING_TOP/__build_"*.h \
48     "$CLEANING_TOP/manifest.txt" 
49
50 #  echo $(date): "  cleaning generated files in source hierarchy..."
51
52   if [ "$clean_src" == "clean" -o "$clean_src" == "CLEAN"  ]; then
53     echo $(date): "    ** aggressive cleaning activated..."
54     perl "$FEISTY_MEOW_SCRIPTS/files/zapdirs.pl" "$FEISTY_MEOW_DIR" >>"$CRUDFILE"
55   fi
56
57   echo $(date): "cleaned [$choprepo]."
58   rm -rf "$NEW_TMP"
59   return 0
60 }
61
62 ##############
63
64 # clean all known hierarchies of build products...
65
66 whack_single_build_area "$FEISTY_MEOW_DIR"
67