4 # Build Windows .dsp files.
5 # Build Windows Mobile .dsp and .vcproj files
6 # Build Windows .vcproj files.
14 projname="$1" # name of the .dsp file
15 match="$2" # the string used to egrep the $sources file
16 sources="$3" # a modified version of $SRCFILES to facilitate matches
17 dsptemplate="$4" # overall template file for the .dsp
18 extra_cppflags="$5" # extra flags to send to compiler
19 release_libs="$6" # libraries to link against in Release builds
20 debug_libs="$7" # libraries to link against in Debug builds
21 lib_suffix="$8" # the library name is libdb@lib_suffix@@VERSION@
22 proj_type="$9" # the project type dsp or vcp
23 proj_guid="${10}" # The project guid for VS2005 projects
25 # Set the default project type to be "dsp"
26 if [ ! "$proj_type" ] ; then
30 # template file for the src file fragments
31 srctemplate="$BUILDDIR/srcfile_$proj_type.src"
32 rsrctemplate="$BUILDDIR/rsrcfile_$proj_type.src"
33 dspoutput=$BUILDDIR/$projname.$proj_type
35 postbuild=$dspoutput.postbuild
36 if [ ! -f $postbuild ] ; then
40 rm -f $dspoutput.insert
41 for srcpath in `egrep "$match" $sources | sed -e 's/[ ].*//'`
43 # take the path name and break it up, converting / to \\.
44 # so many backslashes needed because of shell quoting and
45 # sed quoting -- we'll end up with two backslashes for every
46 # forward slash, but we need that when feeding that to the
48 set - `echo $srcpath | sed -e 's;\(.*\)/;../\\1 ;' \
53 if [ "${srcfile##*.}" = "rc" -a "$proj_type" = "vcproj" ] ; then
54 inptemplate=$rsrctemplate
56 inptemplate=$srctemplate
59 sed -e "s/@srcdir@/$srcdir/g" \
60 -e "s/@srcfile@/$srcfile/g" \
61 < $inptemplate >> $dspoutput.insert
63 sed -e "/@SOURCE_FILES@/r$dspoutput.insert" \
64 -e "/@SOURCE_FILES@/d" \
65 -e "/@POST_BUILD@/r$postbuild" \
66 -e "/@POST_BUILD@/d" \
67 -e "s/@project_name@/$projname/g" \
68 -e "s,@extra_cppflags@,$extra_cppflags,g" \
69 -e "s,@release_libs@,$release_libs,g" \
70 -e "s,@debug_libs@,$debug_libs,g" \
71 -e "s,@lib_suffix@,$lib_suffix,g" \
72 -e "s/@DB_VERSION_MAJOR@/$DB_VERSION_MAJOR/g" \
73 -e "s/@DB_VERSION_MINOR@/$DB_VERSION_MINOR/g" \
74 -e "s/@PROJ_GUID@/$proj_guid/g" \
75 < $dsptemplate > $dspoutput.new
77 # We run this script on Windows (under Cygwin). Fix up the line-endings
78 # for the temporary files. We don't test the platform, just run unix2dos
79 # if the command exists, ignoring any not-found error message.
80 (unix2dos.exe $dspoutput.new) >/dev/null 2>&1
82 # Set the file mode to 644 because the VC++ IDE needs a writeable file
83 # in our development environment.
84 cmp $dspoutput.new $dspoutput > /dev/null 2>&1 ||
85 (echo "Building $dspoutput" && rm -f $dspoutput &&
86 cp $dspoutput.new $dspoutput && chmod 664 $dspoutput)
87 rm -f $dspoutput.insert $dspoutput.new
91 trap "rm -f $TMPA; exit 1" 1 2 3 15
93 # create a copy of the srcfiles with comments and empty lines removed.
94 # add a space at the end of each list of modules so that each module
95 # can be unambiguously matched e.g. ' dynamic '
101 -e "s/$/ /" < $SRCFILES > $TMPA
103 # get a list of all modules mentioned
105 MODULES="`sed -e 's/^[^ ]* //' < $TMPA | tr ' ' '\012' | sort | uniq`"
107 for module in $MODULES
111 BUILDDIR=../build_windows
112 create_dsp db_dll " $module " $TMPA $BUILDDIR/dynamic_dsp.src \
113 '' 'ws2_32.lib' 'ws2_32.lib'
116 BUILDDIR=../build_windows
117 create_dsp db_small " $module " $TMPA $BUILDDIR/static_dsp.src \
118 '/D "HAVE_SMALLBUILD"' '' '' _small
121 BUILDDIR=../build_windows
122 create_dsp db_static " $module " $TMPA $BUILDDIR/static_dsp.src
125 BUILDDIR=../build_wince
126 create_dsp db_static " $module " $TMPA \
127 ../build_wince/static_vcp.src '' '' '' '' vcp
128 # Build VS2005 projects.
129 # The GUID passed in must match that in the .sln workspace.
130 # It would be ideal to grab the GUID from there if this
131 # project is already included there.
132 create_dsp db_static " $module " $TMPA \
133 ../build_wince/static_vcproj.src '' '' '' '' vcproj \
134 "4AB4958F-8DD0-49B5-8C02-014B5637C59A"
137 BUILDDIR=../build_wince
138 create_dsp db_small " $module " $TMPA \
139 ../build_wince/static_vcp.src '/D "HAVE_SMALLBUILD"' \
141 # Build VS2005 projects.
142 # The GUID passed in must match that in the .sln workspace.
143 # It would be ideal to grab the GUID from there if this
144 # project is already included there.
145 create_dsp db_small " $module " $TMPA \
146 ../build_wince/static_vcproj.src 'HAVE_SMALLBUILD' \
147 '' '' _small vcproj "6A2849DA-8F7C-4B50-BDAE-AE7752EF8213"
150 BUILDDIR=../build_windows
151 create_dsp db_java " $module " $TMPA $BUILDDIR/dynamic_dsp.src '' \
152 'libdb@DB_VERSION_MAJOR@@DB_VERSION_MINOR@.lib' \
153 'libdb@DB_VERSION_MAJOR@@DB_VERSION_MINOR@d.lib' _java
156 BUILDDIR=../build_windows
157 create_dsp db_tcl " $module " $TMPA $BUILDDIR/dynamic_dsp.src \
158 '/D "DB_TCL_SUPPORT"' \
159 'libdb@DB_VERSION_MAJOR@@DB_VERSION_MINOR@.lib tcl84.lib' \
160 'libdb@DB_VERSION_MAJOR@@DB_VERSION_MINOR@d.lib tcl84g.lib' _tcl
163 BUILDDIR=../build_windows
164 create_dsp db_test " $module " $TMPA $BUILDDIR/app_dsp.src \
165 '' '/out:"Win32\\Release\\dbkill.exe"' '/out:"Win32\\Debug\\dbkill.exe"'
168 BUILDDIR=../build_windows
169 appname=`echo $module | sed -e 's/^app=//'`
178 # Split into Windows CE and Win32/64 project creation.
181 BUILDDIR=../build_wince
182 create_dsp $appname " $module " $TMPA \
183 ../build_wince/app_vcp.src '/D "__NO_SYSTEM_INCLUDES"' \
185 # The GUID passed in must match that in the .sln workspace.
186 # It would be ideal to grab the GUID from there if this
187 # project is already included there.
188 create_dsp $appname " $module " $TMPA \
189 ../build_wince/app_vcproj.src '__NO_SYSTEM_INCLUDES' \
190 '' '' '' vcproj "F2CE670A-ABAE-414A-9A17-8079AB58613F"
191 BUILDDIR=../build_windows
194 create_dsp $appname " $module " $TMPA $BUILDDIR/app_dsp.src \
199 brew|s60|vx|vxsmall|vx6 )
203 "s_windows_dsp: module name $module in $SRCFILES is unknown type"
211 # Drive construction of Visual Studio (version 7.1) projects
212 # files, using an xquery script (genproject.template),an input XML
213 # document, and a file containing a list of project names.
216 # Source the Berkeley DB release version numbers.
222 # xquery script template, called genproject.template in DBXML tree.
223 TEMPLATE=genproject.template
225 # temporary script, post-sed-replacement
226 TEMP_SCRIPT=genproject.script
228 # xml document input template, called dbxml.template.xml in DBXML tree.
229 CONFIG_INPUT=projects.template.xml
231 # temporary xml document, post-sed-replacement, called dbxml.projects in DBXML
232 CONFIG_OUTPUT=projects.xml
234 # location for output project files
235 PROJECT_OUTPUT_DIR=../../build_windows
237 # substitute some variables in the XML document template
238 sed -e "s/@DB_VERSION_MAJOR@/$DB_VERSION_MAJOR/g" \
239 -e "s/@DB_VERSION_MINOR@/$DB_VERSION_MINOR/g" \
240 < $CONFIG_INPUT > $CONFIG_OUTPUT
242 echo "Building Visual Studio project files -- "
243 echo " output only for modified projects (this can take a while)"
245 # for each project, substitute 2 variables in the XQuery script, then run it
248 if [ $v = "VC7.1" ]; then
254 echo "Building for Visual Studio version $VERSION"
256 for i in `cat $PROJECTS`
258 sed -e "s!@PROJECT_NAME@!$i!g" -e "s!@PROJECT_INPUT@!$CONFIG_OUTPUT!g" -e "s!@VISUAL_STUDIO_VERSION@!$VERSION!g" < $TEMPLATE > $TEMP_SCRIPT
259 TMP=$PROJECT_OUTPUT_DIR/$i.tmp.vcproj
260 if [ $v = "VC7.1" ]; then
261 TARG=$PROJECT_OUTPUT_DIR/${i}_vs71.vcproj
263 TARG=$PROJECT_OUTPUT_DIR/${i}.vcproj
265 xqilla -o $TMP $TEMP_SCRIPT
267 cmp $TMP $TARG > /dev/null 2>&1 ||
268 (echo "Building $TARG" && rm -f $TARG &&
269 cp $TMP $TARG && chmod 664 $TARG)