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.
14 if ! [ -e "$ROOT_DIR/source.list" ]
18 if ! [ -e "$ROOT_DIR/source.list" ]
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."
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
60 echo "Generating $2..."
62 # Everything above the !!FILTERS!! marker
63 sed < "$ROOT_DIR/projects/$2".
in -n -e '
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 '
77 ' >> "$ROOT_DIR/projects/$2"
79 # Everything above the !!FILES!! marker
80 sed < "$ROOT_DIR/projects/$2".
in -n -e '
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 '
94 ' >> "$ROOT_DIR/projects/$2"
98 # First, collect the list of Windows files
106 enable_directmusic
="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; }
116 gsub("^
#if", "", $0);
119 if (deep
!= skip
) { deep
+= 1; next
; }
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
; }
154 openttd="`echo "$srclist" | awk '
156 configs
[0] = "Release|Win32";
157 configs
[1] = "Debug|Win32";
158 configs
[2] = "Release|x64";
159 configs
[3] = "Debug|x64";
165 if (first_time
!= 0) {
172 print
" Name=\\""$0"\\"";
179 gsub
("/", "\\\\", $0);
181 print
" RelativePath=\\".
\\\\'$file_prefix'"$0"\\"";
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] "\\"";
194 print
" Name=\\"VCCLCompilerTool
\\"";
195 print
" AssemblerListingLocation=\\""dir"\\"";
196 print
" ObjectFile=\\""dir"\\"";
197 print
" XMLDocumentationFileName=\\""dir"\\"";
199 print
" </FileConfiguration>";
204 END
{ print
" </Filter>"; }
208 openttdvcxproj="`echo "$srclist" | awk '
212 gsub
("/", "\\\\", $0);
213 split($0, file, ".");
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>";
230 print
" <"cltype
" Include=\\"'$file_prefix'"$0"\\" />";
236 openttdfiles="`echo "$srclist" | awk '
247 gsub
("/", "\\\\", $0);
248 split($0, file, ".");
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 '
264 print
" <Filter Include=\\""$0"\\">";
265 printf " <UniqueIdentifier>{c76ff9f1-1e62-46d8-8d55-%012d}</UniqueIdentifier>\n", i
;
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
'`
288 RelativePath=\"..\\src\\lang\\$i.txt\"
294 Name=\"VCCustomBuildTool\"
295 Description=\"Generating $i language file\"
296 CommandLine=\"..\\objs\\strgen\\strgen.exe -s ..\\src\\lang -d ..\\bin\\lang "\$(InputPath)"
exit 0
\"
297 AdditionalDependencies=\"..\\src\\lang\\english.txt;..\\objs\\strgen\\strgen.exe\"
298 Outputs=\"..\\bin\\lang\\$i.lng\"
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>
311 langfiles="$langfiles\
312 <CustomBuild Include=\"..\\src\\lang\\$i.txt\">
313 <Filter>Translations</Filter>
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
,^.
*/,,'`
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"
335 RelativePath=\"..\\src\\table\\$i\"
339 settingscommand="$settingscommand ..\\src\\table\\$i"
340 settingsvcxproj="$settingsvcxproj\
341 <None Include=\"..\\src\\table\\$i\" />
343 settingsfiles="$settingsfiles\
344 <None Include=\"..\\src\\table\\$i\">
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"