resurrecting the gnu c++ build on windows
[feisty_meow.git] / scripts / z_outgoing / dotnet-retired / postconditions.sh
1 #!/bin/bash
2 # copies the final products of the current project into the repository.
3
4 # check whether a failure should prevent promotion from occurring.
5 if [ -f $FAILURE_FILE ]; then
6   echo Postconditions will not promote due to a failure:
7   cat $FAILURE_FILE
8   . $CLAM_SCRIPTS/exit_make.sh
9 fi
10
11 # make sure that we actually did something during the make.
12 if [ ! -f "$DIRTY_FILE" -a ! -f "$SUBMAKE_FLAG" ]; then
13   # nothing was built, seemingly, so we do no promotion.
14   exit
15 fi
16
17 # toss the flag files so we don't see them again.
18 rm -f "$DIRTY_FILE" "$SUBMAKE_FLAG"
19
20 # clean up generated resource files after the build.
21 for i in *.resources; do rm -f "$i"; done
22
23 # these variables define the locations for final products.  all of them
24 # descend from the root of the repository.
25 ROOT=$TARGETS_STORE
26 LIB_DIR=$ROOT/lib
27 DLL_DIR=$ROOT/dll
28 EXE_DIR=$ROOT/exe
29 TEST_ROOT=$ROOT/tests
30 TEST_DIR=$TEST_ROOT/$PROJECT
31
32 # causes the shell to quit.
33 DIE=". $CLAM_SCRIPTS/exit_make.sh"
34
35 if [ "$TYPE" = "library" ]; then
36
37   # make sure the required directories exist.
38   if [ ! -d $ROOT ]; then mkdir -p $ROOT; fi
39   if [ ! -d $LIB_DIR ]; then mkdir $LIB_DIR; fi
40   if [ ! -d $DLL_DIR ]; then mkdir $DLL_DIR; fi
41
42   if [ -z "$NO_COMPILE" ]; then
43     # we ensure that none of the normal products are copied for a non-compiling
44     # style of project.
45
46     # copy the import libraries for any DLLs.
47     if [ ! -z "`$FIND "$DYNAMIC_LIBRARY_DIR" -iname "*.lib"`" ]; then
48       echo Moving import libraries to $LIB_DIR.
49       mv "$DYNAMIC_LIBRARY_DIR"/*.lib $LIB_DIR
50     fi
51
52   fi
53
54 elif [ "$TYPE" = "application" ]; then
55
56   # sets up the directory for executable programs and copies any found in the
57   # this project's final directory.
58
59   # first make sure the executable directory is around.
60   if [ ! -d $EXE_DIR ]; then mkdir $EXE_DIR; fi
61
62   if [ -z "$NO_COMPILE" ]; then
63     # we ensure that none of the normal products are copied for a non-compiling
64     # style of project.
65
66     # copy anything extra over.
67     if [ ! -z "$EXTRA_COPIES" ]; then
68       echo Copying extra files to $EXE_DIR.
69       echo [$EXTRA_COPIES]
70       cp -f $EXTRA_COPIES $EXE_DIR || $DIE
71     fi
72
73   fi
74
75 elif [ "$TYPE" = "test" ]; then
76
77   # sets up a directory for test programs based on the project name and copies
78   # the generated programs into there.
79
80   # first make sure the test program root directory is around.
81   if [ ! -d $TEST_ROOT ]; then mkdir $TEST_ROOT; fi
82
83   # create the target directory if it doesn't exist.
84   if [ ! -d $TEST_DIR ]; then mkdir $TEST_DIR; fi
85
86   if [ -z "$NO_COMPILE" ]; then
87     # we ensure that none of the normal products are copied for a non-compiling
88     # style of project.
89
90     # make the files writable.  this is required for some tests' data files,
91     # which come in from the build and could be read-only.
92     chmod 777 $TEST_DIR/* $TEST_DIR/*/* $TEST_DIR/*/*/* >/dev/null 2>&1
93
94     # copy anything extra over.
95     if [ ! -z "$EXTRA_COPIES" ]; then
96       echo Copying extra files to $TEST_DIR.
97       echo [$EXTRA_COPIES]
98       cp -f $EXTRA_COPIES $TEST_DIR || $DIE
99     fi
100
101   fi
102
103 else
104   echo "Unknown type for project [$TYPE]; cancelling postconditions!"
105   . $CLAM_SCRIPTS/exit_make.sh
106 fi
107