| 1 |
#!/bin/bash - |
| 2 |
# $Id$ |
| 3 |
# |
| 4 |
# Build Windows CE .vcproj files |
| 5 |
# Build Windows .vcproj files. |
| 6 |
|
| 7 |
. ./RELEASE |
| 8 |
|
| 9 |
create_projects() |
| 10 |
{ |
| 11 |
# project name list |
| 12 |
PROJECTS=$1 |
| 13 |
|
| 14 |
# xquery script template |
| 15 |
TEMPLATE=genproject.template |
| 16 |
TEMPLATE_VS2010=vs2010.template |
| 17 |
|
| 18 |
# vs2010 common properties template |
| 19 |
LIBTEMPLATE=library.props.template |
| 20 |
APPTEMPLATE=application.props.template |
| 21 |
|
| 22 |
# temporary script, post-sed-replacement |
| 23 |
TEMP_SCRIPT=genproject.script |
| 24 |
|
| 25 |
# temporary common properties for vs2010 |
| 26 |
TEMP_LIB=library.props |
| 27 |
TEMP_APP=application.props |
| 28 |
|
| 29 |
# xml document input template |
| 30 |
CONFIG_INPUT=$2 |
| 31 |
|
| 32 |
# temporary xml document, post-sed-replacement |
| 33 |
CONFIG_OUTPUT=projects.xml |
| 34 |
|
| 35 |
# location for output project files |
| 36 |
PROJECT_OUTPUT_PARENT_DIR=$3 |
| 37 |
|
| 38 |
# judge Windows or Win CE for vs2010 |
| 39 |
WinVersion=$4 |
| 40 |
|
| 41 |
if [ $WinVersion = "WinCE" ]; then |
| 42 |
VLoop=VS8 |
| 43 |
else |
| 44 |
VLoop="VS8 VS10" |
| 45 |
fi |
| 46 |
|
| 47 |
# for each project, substitute 2 variables in the XQuery script, then run it |
| 48 |
# temporarily use only VS10 here to omit the generation of VS8 |
| 49 |
for v in $VLoop |
| 50 |
do |
| 51 |
|
| 52 |
if [ $v = "VS71" ]; then |
| 53 |
VERSION="7.10" |
| 54 |
elif [ $v = "VS8" ]; then |
| 55 |
VERSION="8.00" |
| 56 |
elif [ $v = "VS10" ]; then |
| 57 |
VERSION="10.0" |
| 58 |
fi |
| 59 |
|
| 60 |
PROJECT_OUTPUT_DIR="$PROJECT_OUTPUT_PARENT_DIR/$v" |
| 61 |
|
| 62 |
# substitute some variables in the XML document template |
| 63 |
if [ $v = "VS10" ]; then |
| 64 |
sed -e "s/@DB_VERSION_MAJOR@/$DB_VERSION_MAJOR/g" \ |
| 65 |
-e "s/@DB_VERSION_MINOR@/$DB_VERSION_MINOR/g" \ |
| 66 |
-e "s/$/
/" \ |
| 67 |
< $LIBTEMPLATE > $TEMP_LIB |
| 68 |
|
| 69 |
sed -e "s/@DB_VERSION_MAJOR@/$DB_VERSION_MAJOR/g" \ |
| 70 |
-e "s/@DB_VERSION_MINOR@/$DB_VERSION_MINOR/g" \ |
| 71 |
-e "s/$/
/" \ |
| 72 |
< $APPTEMPLATE > $TEMP_APP |
| 73 |
|
| 74 |
mv $TEMP_LIB $PROJECT_OUTPUT_DIR/$TEMP_LIB |
| 75 |
mv $TEMP_APP $PROJECT_OUTPUT_DIR/$TEMP_APP |
| 76 |
fi |
| 77 |
sed -e "s/@DB_VERSION_MAJOR@/$DB_VERSION_MAJOR/g" \ |
| 78 |
-e "s/@DB_VERSION_MINOR@/$DB_VERSION_MINOR/g" \ |
| 79 |
< $CONFIG_INPUT > $CONFIG_OUTPUT |
| 80 |
|
| 81 |
|
| 82 |
|
| 83 |
echo "Building for Visual Studio version $VERSION" |
| 84 |
|
| 85 |
for i in `cat $PROJECTS` |
| 86 |
do |
| 87 |
if [ $v = "VS10" ]; then |
| 88 |
sed -e "s!@PROJECT_NAME@!$i!g" -e "s!@PROJECT_INPUT@!$CONFIG_OUTPUT!g" -e "s!@VISUAL_STUDIO_VERSION@!$VERSION!g" < $TEMPLATE_VS2010 > $TEMP_SCRIPT |
| 89 |
else |
| 90 |
sed -e "s!@PROJECT_NAME@!$i!g" -e "s!@PROJECT_INPUT@!$CONFIG_OUTPUT!g" -e "s!@VISUAL_STUDIO_VERSION@!$VERSION!g" < $TEMPLATE > $TEMP_SCRIPT |
| 91 |
fi |
| 92 |
if [ $v = "VS7.1" ]; then |
| 93 |
TMP=$PROJECT_OUTPUT_DIR/$i.tmp.vcproj |
| 94 |
TARG=$PROJECT_OUTPUT_DIR/${i}_vs71.vcproj |
| 95 |
elif [ $v = "VS8" ]; then |
| 96 |
TMP=$PROJECT_OUTPUT_DIR/$i.tmp.vcproj |
| 97 |
TARG=$PROJECT_OUTPUT_DIR/${i}.vcproj |
| 98 |
else |
| 99 |
TMP=$PROJECT_OUTPUT_DIR/$i.tmp.vcxproj |
| 100 |
TARG=$PROJECT_OUTPUT_DIR/${i}.vcxproj |
| 101 |
fi |
| 102 |
xqilla -o $TMP $TEMP_SCRIPT |
| 103 |
rm -f $TEMP_SCRIPT |
| 104 |
chmod 644 $TMP |
| 105 |
cmp $TMP $TARG > /dev/null 2>&1 || |
| 106 |
(echo "Building $TARG" && rm -f $TARG && |
| 107 |
cp $TMP $TARG) |
| 108 |
rm -f $TMP |
| 109 |
done |
| 110 |
done |
| 111 |
|
| 112 |
# Cleanup. |
| 113 |
rm -f $CONFIG_OUTPUT |
| 114 |
} |
| 115 |
|
| 116 |
create_projects_csharp() |
| 117 |
{ |
| 118 |
# project name list |
| 119 |
PROJECTS=$1 |
| 120 |
|
| 121 |
# xquery script template |
| 122 |
TEMPLATE=genproject_csharp.template |
| 123 |
|
| 124 |
# temporary script, post-sed-replacement |
| 125 |
TEMP_SCRIPT=genproject.script |
| 126 |
|
| 127 |
# xml document input template |
| 128 |
CONFIG_INPUT=$2 |
| 129 |
|
| 130 |
# temporary xml document, post-sed-replacement |
| 131 |
CONFIG_OUTPUT=projects.xml |
| 132 |
|
| 133 |
# substitute some variables in the XML document template |
| 134 |
sed -e "s/@DB_VERSION_MAJOR@/$DB_VERSION_MAJOR/g" \ |
| 135 |
-e "s/@DB_VERSION_MINOR@/$DB_VERSION_MINOR/g" \ |
| 136 |
< $CONFIG_INPUT > $CONFIG_OUTPUT |
| 137 |
|
| 138 |
# for each project, substitute 2 variables in the XQuery script, then run it |
| 139 |
for i in `cat $PROJECTS` |
| 140 |
do |
| 141 |
# Split project path into dir + basename |
| 142 |
PROJECT_OUTPUT_DIR=`dirname $i` |
| 143 |
i=`basename $i` |
| 144 |
|
| 145 |
sed -e "s!@PROJECT_NAME@!$i!g" -e "s!@PROJECT_INPUT@!$CONFIG_OUTPUT!g" -e "s!@VISUAL_STUDIO_VERSION@!$VERSION!g" < $TEMPLATE > $TEMP_SCRIPT |
| 146 |
TMP=$PROJECT_OUTPUT_DIR/$i.tmp.csproj |
| 147 |
TARG=$PROJECT_OUTPUT_DIR/${i}.csproj |
| 148 |
xqilla -o $TMP $TEMP_SCRIPT |
| 149 |
rm -f $TEMP_SCRIPT |
| 150 |
chmod 644 $TMP |
| 151 |
cmp $TMP $TARG > /dev/null 2>&1 || |
| 152 |
(echo "Building $TARG" && rm -f $TARG && |
| 153 |
cp $TMP $TARG) |
| 154 |
rm -f $TMP |
| 155 |
done |
| 156 |
|
| 157 |
# Cleanup. |
| 158 |
rm -f $CONFIG_OUTPUT |
| 159 |
} |
| 160 |
|
| 161 |
# Detect XQilla |
| 162 |
which xqilla > /dev/null 2>&1 |
| 163 |
if [ $? -ne 0 ]; then |
| 164 |
echo "Can not find xqilla command." |
| 165 |
exit 1 |
| 166 |
fi |
| 167 |
|
| 168 |
cd win_projects |
| 169 |
|
| 170 |
# Create/Update Windows project files |
| 171 |
echo "Building Visual Studio project files for Windows -- " |
| 172 |
echo " output only for modified projects (this can take a while)" |
| 173 |
create_projects db.projects projects.template.xml ../../build_windows Win |
| 174 |
|
| 175 |
# Create/Update Windows CE project files |
| 176 |
echo "Building Visual Studio project files for Windows CE -- " |
| 177 |
echo " output only for modified projects (this can take a while)" |
| 178 |
create_projects db_wince.projects projects_wince.template.xml ../../build_wince WinCE |
| 179 |
|
| 180 |
# Create/Update C Sharp project files |
| 181 |
echo "Building C Sharp project files -- " |
| 182 |
echo " output only for modified projects (this can take a while)" |
| 183 |
create_projects_csharp db_csharp.projects projects_csharp.template.xml |
| 184 |
|
| 185 |
cd .. |
| 186 |
|