moved the top-level and probably most important feisty meow variable from the seeming...
[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   export CRUDFILE="$(mktemp "$TMP/zz_whack_build.XXXXXX")"
24   echo "" &>"$CRUDFILE"
25
26 #  echo $(date): "  cleaning up the build products..."
27
28   # avoid accidentally removing important stuff if our variables have not been previously
29   # established.
30   if [ -z "$GENERATED_DIR" -o -z "$TEMPORARIES_DIR" ]; then
31     echo The build whacking script cannot run because either the GENERATED_DIR
32     echo variable or the TEMPORARIES_DIR variable have not been set.  This makes
33     echo it unsafe to remove anything in the build products.
34     exit 1
35   fi
36
37   # kerzap.  the cleanups in production directory remove older locations of generated files.
38   rm -rf \
39     "$GENERATED_DIR/clam_bin" \
40     "$GENERATED_DIR/binaries" \
41     "$GENERATED_DIR/install" \
42     "$GENERATED_DIR/logs" \
43     "$GENERATED_DIR/waste" \
44     "$FEISTY_MEOW_APEX/generatedJUnitFiles" \
45     "$TEMPORARIES_DIR" \
46     "$PRODUCTION_DIR/__build_"*.h \
47     "$PRODUCTION_DIR/manifest.txt" \
48     "$PRODUCTION_DIR/clam_bin" \
49     "$PRODUCTION_DIR/binaries" \
50     "$PRODUCTION_DIR/install" \
51     "$PRODUCTION_DIR/logs" \
52     "$PRODUCTION_DIR/waste" 
53
54 #  echo $(date): "  cleaning generated files in source hierarchy..."
55
56   if [ "$clean_src" == "clean" -o "$clean_src" == "CLEAN"  ]; then
57     echo $(date): "    ** aggressive cleaning activated..."
58     perl "$FEISTY_MEOW_SCRIPTS/files/zapdirs.pl" "$FEISTY_MEOW_APEX" >>"$CRUDFILE"
59   fi
60
61   echo $(date): "cleaned [$choprepo]."
62   rm -rf "$CRUDFILE"
63   return 0
64 }
65
66 ##############
67
68 # clean all known hierarchies of build products...
69
70 whack_single_build_area "$FEISTY_MEOW_APEX"
71