Introduce ForwardList as an implementation of a forward list
[openttd/fttd.git] / projects / generate
blobd5c25722d284ea6f07695b2dc0f3e176af36c6c2
1 #!/bin/bash
3 # $Id$
5 # This file is part of OpenTTD.
6 # OpenTTD is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 2.
7 # OpenTTD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
8 # See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenTTD. If not, see <http://www.gnu.org/licenses/>.
10 # This file generates all project files based on sources.list, so everyone who
11 # can start a bash process, can update the project files.
13 ROOT_DIR="`pwd`/.."
14 if ! [ -e "$ROOT_DIR/source.list" ]
15 then
16 ROOT_DIR="`pwd`"
18 if ! [ -e "$ROOT_DIR/source.list" ]
19 then
20 echo "Can't find source.list, needed in order to make this run. Please go to either"
21 echo " the project dir, or the root dir of a clean SVN checkout."
22 exit 1
25 # openttd_vs100.sln is for MSVC 2010
26 # openttd_vs100.vcxproj is for MSVC 2010
27 # openttd_vs100.vcxproj.filters is for MSVC 2010
28 # langs_vs100.vcxproj is for MSVC 2010
29 # strgen_vs100.vcxproj is for MSVC 2010
30 # strgen_vs100.vcxproj.filters is for MSVC 2010
31 # generate_vs100.vcxproj is for MSVC 2010
32 # version_vs100.vcxproj is for MSVC 2010
34 # openttd_vs90.sln is for MSVC 2008
35 # openttd_vs90.vcproj is for MSVC 2008
36 # langs_vs90.vcproj is for MSVC 2008
37 # strgen_vs90.vcproj is for MSVC 2008
38 # generate_vs90.vcproj is for MSVC 2008
39 # version_vs90.vcproj is for MSVC 2008
41 # openttd_vs80.sln is for MSVC 2005
42 # openttd_vs80.vcproj is for MSVC 2005
43 # langs_vs80.vcproj is for MSVC 2005
44 # strgen_vs80.vcproj is for MSVC 2005
45 # generate_vs80.vcproj is for MSVC 2005
46 # version_vs80.vcproj is for MSVC 2005
49 grep '\.h' "$ROOT_DIR/source.list" | grep -v '../objs/langs/table/strings.h\|../objs/settings/table/settings.h' | sed 's/ //' | sort > tmp.headers.source.list
50 find "$ROOT_DIR/src" -iname .svn -prune -o \( -iname '*.h' -o -iname '*.hpp' \) -print | sed "s~$ROOT_DIR/src/~~" | sort > tmp.headers.src
51 if ! diff tmp.headers.source.list tmp.headers.src >/dev/null; then
52 echo "The following headers are missing in source.list and not in /src/ or vice versa."
53 diff tmp.headers.source.list tmp.headers.src | grep '[<>]' | sort
54 echo ""
56 rm tmp.headers.*
59 generate() {
60 echo "Generating $2..."
61 if [ $# -eq 3 ]; then
62 # Everything above the !!FILTERS!! marker
63 sed < "$ROOT_DIR/projects/$2".in -n -e '
64 s/\r$//
65 /!!FILTERS!!/ q
67 ' > "$ROOT_DIR/projects/$2"
69 printf "%s" "$3" >> "$ROOT_DIR/projects/$2"
71 # Everything between the !!FILTERS!! marker and the !!FILES!! marker
72 sed < "$ROOT_DIR/projects/$2".in -n -e '
73 s/\r$//
74 1,/!!FILTERS!!/ d
75 /!!FILES!!/ q
77 ' >> "$ROOT_DIR/projects/$2"
78 else
79 # Everything above the !!FILES!! marker
80 sed < "$ROOT_DIR/projects/$2".in -n -e '
81 s/\r$//
82 /!!FILES!!/ q
84 ' > "$ROOT_DIR/projects/$2"
87 printf "%s" "$1" >> "$ROOT_DIR/projects/$2"
89 # Everything below the !!FILES!! marker
90 sed < "$ROOT_DIR/projects/$2".in -n -e '
91 s/\r$//
92 1,/!!FILES!!/ d
94 ' >> "$ROOT_DIR/projects/$2"
98 # First, collect the list of Windows files
99 allegro_config=""
100 sdl_config="1"
101 png_config="1"
102 os="MSVC"
103 enable_dedicated="0"
104 enable_ai="1"
105 with_cocoa="0"
106 enable_directmusic="1"
107 with_threads="1"
108 file_prefix="..\\\\src\\\\"
110 # Read the source.list and process it
111 srclist="`cat "$ROOT_DIR/source.list" | tr '\r' '\n' | awk '
112 /^( *)#end/ { if (deep == skip) { skip -= 1; } deep -= 1; next; }
113 /^( *)#else/ { if (deep == skip) { skip -= 1; } else if (deep - 1 == skip) { skip += 1; } next; }
114 /^( *)#if/ {
115 gsub(" ", "", $0);
116 gsub("^#if", "", $0);
117 gsub("^ ", "", $0);
119 if (deep != skip) { deep += 1; next; }
121 deep += 1;
123 if ($0 == "ALLEGRO" && "'$allegro_config'" == "") { next; }
124 if ($0 == "SDL" && "'$sdl_config'" == "") { next; }
125 if ($0 == "PNG" && "'$png_config'" == "") { next; }
126 if ($0 == "OSX" && "'$os'" != "OSX") { next; }
127 if ($0 == "OS2" && "'$os'" != "OS2") { next; }
128 if ($0 == "PSP" && "'$os'" != "PSP") { next; }
129 if ($0 == "DOS" && "'$os'" != "DOS") { next; }
130 if ($0 == "DEDICATED" && "'$enable_dedicated'" != "1") { next; }
131 if ($0 == "AI" && "'$enable_ai'" == "0") { next; }
132 if ($0 == "COCOA" && "'$with_cocoa'" == "0") { next; }
133 if ($0 == "BEOS" && "'$os'" != "BEOS") { next; }
134 if ($0 == "WIN32" && "'$os'" != "MINGW" && "'$os'" != "CYGWIN" && "'$os'" != "MSVC" ) { next; }
135 if ($0 == "WINCE" && "'$os'" != "WINCE") { next; }
136 if ($0 == "MSVC" && "'$os'" != "MSVC") { next; }
137 if ($0 == "DIRECTMUSIC" && "'$enable_directmusic'" != "1") { next; }
138 if ($0 == "LIBTIMIDITY" && "'$libtimidity'" == "" ) { next; }
139 if ($0 == "HAVE_THREAD" && "'$with_threads'" == "0") { next; }
141 skip += 1;
143 next;
145 /^$/ { next }
147 if (deep == skip) {
148 gsub(" ", "", $0);
149 print;
154 openttd="`echo "$srclist" | awk '
155 BEGIN {
156 configs[0] = "Release|Win32";
157 configs[1] = "Debug|Win32";
158 configs[2] = "Release|x64";
159 configs[3] = "Debug|x64";
161 /^#/ {
162 gsub("^#", "", $0);
163 gsub("^ ", "", $0);
165 if (first_time != 0) {
166 print " </Filter>";
167 } else {
168 first_time = 1;
171 print " <Filter";
172 print " Name=\\""$0"\\"";
173 print " >";
175 next;
178 gsub(" ", "", $0);
179 gsub("/", "\\\\", $0);
180 print " <File";
181 print " RelativePath=\\".\\\\'$file_prefix'"$0"\\"";
182 print " >";
183 ndirs = split($0, dirs, "\\\\");
184 if (ndirs > 1 && match($0, /\.cpp$/)) {
185 dir = "$(IntDir)\\\\";
186 for (i = 1; i < ndirs; i++) {
187 dir = sprintf("%s%s\\\\", dir, dirs[i]);
189 for (i = 0; i < 4; i++) {
190 print " <FileConfiguration";
191 print " Name=\\"" configs[i] "\\"";
192 print " >";
193 print " <Tool";
194 print " Name=\\"VCCLCompilerTool\\"";
195 print " AssemblerListingLocation=\\""dir"\\"";
196 print " ObjectFile=\\""dir"\\"";
197 print " XMLDocumentationFileName=\\""dir"\\"";
198 print " />";
199 print " </FileConfiguration>";
202 print " </File>";
204 END { print " </Filter>"; }
208 openttdvcxproj="`echo "$srclist" | awk '
209 /^#/ { next; }
211 gsub(" ", "", $0);
212 gsub("/", "\\\\", $0);
213 split($0, file, ".");
214 cltype = "ClInclude"
215 if (file[2] == "cpp") cltype = "ClCompile";
216 if (file[2] == "rc") cltype = "ResourceCompile";
218 ndirs = split($0, dirs, "\\\\");
219 if (ndirs > 1 && cltype == "ClCompile") {
220 dir = "$(IntDir)\\\\";
221 for (i = 1; i < ndirs; i++) {
222 dir = sprintf("%s%s\\\\", dir, dirs[i]);
224 print " <ClCompile Include=\\"'$file_prefix'"$0"\\">";
225 print " <AssemblerListingLocation>"dir"</AssemblerListingLocation>";
226 print " <ObjectFileName>"dir"</ObjectFileName>";
227 print " <XMLDocumentationFileName>"dir"</XMLDocumentationFileName>";
228 print " </ClCompile>";
229 } else {
230 print " <"cltype" Include=\\"'$file_prefix'"$0"\\" />";
236 openttdfiles="`echo "$srclist" | awk '
237 /^#/ {
238 gsub("^#", "", $0);
239 gsub("^ ", "", $0);
241 filter = $0;
243 next;
246 gsub(" ", "", $0);
247 gsub("/", "\\\\", $0);
248 split($0, file, ".");
249 cltype = "ClInclude"
250 if (file[2] == "cpp") cltype = "ClCompile";
251 if (file[2] == "rc") cltype = "ResourceCompile";
252 print " <"cltype" Include=\\"'$file_prefix'"$0"\\">";
253 print " <Filter>"filter"</Filter>";
254 print " </"cltype">";
259 openttdfilters="`echo "$srclist" | awk '
260 /^#/ {
261 gsub("^#", "", $0);
262 gsub("^ ", "", $0);
264 print " <Filter Include=\\""$0"\\">";
265 printf " <UniqueIdentifier>{c76ff9f1-1e62-46d8-8d55-%012d}</UniqueIdentifier>\n", i;
266 print " </Filter>";
267 i += 1;
272 generate "$openttd" "openttd_vs80.vcproj"
273 generate "$openttd" "openttd_vs90.vcproj"
274 generate "$openttdvcxproj" "openttd_vs100.vcxproj"
275 generate "$openttdfiles" "openttd_vs100.vcxproj.filters" "$openttdfilters"
278 txtfiles=`ls "$ROOT_DIR"/src/lang/*.txt | sed -e 's,^.*/,,' -e 's/\.txt$//' -e '/^english$/d'`
280 lang=""
281 langvcxproj=""
282 langfiles=""
284 for i in $txtfiles
286 lang="$lang\
287 <File
288 RelativePath=\"..\\src\\lang\\$i.txt\"
290 <FileConfiguration
291 Name=\"Debug|Win32\"
293 <Tool
294 Name=\"VCCustomBuildTool\"
295 Description=\"Generating $i language file\"
296 CommandLine=\"..\\objs\\strgen\\strgen.exe -s ..\\src\\lang -d ..\\bin\\lang &quot;\$(InputPath)&quot;&#x0D;&#x0A;exit 0&#x0D;&#x0A;\"
297 AdditionalDependencies=\"..\\src\\lang\\english.txt;..\\objs\\strgen\\strgen.exe\"
298 Outputs=\"..\\bin\\lang\\$i.lng\"
300 </FileConfiguration>
301 </File>
303 langvcxproj="$langvcxproj\
304 <CustomBuild Include=\"..\\src\\lang\\$i.txt\">
305 <Message Condition=\"'\$(Configuration)|\$(Platform)'=='Debug|Win32'\">Generating $i language file</Message>
306 <Command Condition=\"'\$(Configuration)|\$(Platform)'=='Debug|Win32'\">..\\objs\\strgen\\strgen.exe -s ..\\src\\lang -d ..\\bin\\lang \"%(FullPath)\"</Command>
307 <AdditionalInputs Condition=\"'\$(Configuration)|\$(Platform)'=='Debug|Win32'\">..\\src\\lang\\english.txt;..\\objs\\strgen\\strgen.exe;%(AdditionalInputs)</AdditionalInputs>
308 <Outputs Condition=\"'\$(Configuration)|\$(Platform)'=='Debug|Win32'\">..\\bin\\lang\\$i.lng;%(Outputs)</Outputs>
309 </CustomBuild>
311 langfiles="$langfiles\
312 <CustomBuild Include=\"..\\src\\lang\\$i.txt\">
313 <Filter>Translations</Filter>
314 </CustomBuild>
316 done
318 generate "$lang" "langs_vs80.vcproj"
319 generate "$lang" "langs_vs90.vcproj"
320 generate "$langvcxproj" "langs_vs100.vcxproj"
321 generate "$langfiles" "langs_vs100.vcxproj.filters"
324 inifiles=`ls "$ROOT_DIR"/src/table/*.ini | sed -e 's,^.*/,,'`
326 settings=""
327 settingscommand="..\\objs\\settings\\settings_gen.exe -o ..\\objs\\settings\\table\\settings.h -b ..\\src\\table\\settings.h.preamble -a ..\\src\\table\\settings.h.postamble"
328 settingsvcxproj=""
329 settingsfiles=""
331 for i in $inifiles
333 settings="$settings\
334 <File
335 RelativePath=\"..\\src\\table\\$i\"
337 </File>
339 settingscommand="$settingscommand ..\\src\\table\\$i"
340 settingsvcxproj="$settingsvcxproj\
341 <None Include=\"..\\src\\table\\$i\" />
343 settingsfiles="$settingsfiles\
344 <None Include=\"..\\src\\table\\$i\">
345 <Filter>INI</Filter>
346 </None>
348 done
350 settingscommand="$settingscommand
353 generate "$settings" "settings_vs80.vcproj" "$settingscommand"
354 generate "$settings" "settings_vs90.vcproj" "$settingscommand"
355 generate "$settingsvcxproj" "settings_vs100.vcxproj" "$settingscommand"
356 generate "$settingsfiles" "settings_vs100.vcxproj.filters"