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_vs140.sln is for MSVC 2015
26 # openttd_vs140.vcxproj is for MSVC 2015
27 # openttd_vs140.vcxproj.filters is for MSVC 2015
28 # langs_vs140.vcxproj is for MSVC 2015
29 # strgen_vs140.vcxproj is for MSVC 2015
30 # strgen_vs140.vcxproj.filters is for MSVC 2015
31 # generate_vs140.vcxproj is for MSVC 2015
32 # version_vs140.vcxproj is for MSVC 2015
34 # openttd_vs100.sln is for MSVC 2010
35 # openttd_vs100.vcxproj is for MSVC 2010
36 # openttd_vs100.vcxproj.filters is for MSVC 2010
37 # langs_vs100.vcxproj is for MSVC 2010
38 # strgen_vs100.vcxproj is for MSVC 2010
39 # strgen_vs100.vcxproj.filters is for MSVC 2010
40 # generate_vs100.vcxproj is for MSVC 2010
41 # version_vs100.vcxproj is for MSVC 2010
43 # openttd_vs90.sln is for MSVC 2008
44 # openttd_vs90.vcproj is for MSVC 2008
45 # langs_vs90.vcproj is for MSVC 2008
46 # strgen_vs90.vcproj is for MSVC 2008
47 # generate_vs90.vcproj is for MSVC 2008
48 # version_vs90.vcproj is for MSVC 2008
50 # openttd_vs80.sln is for MSVC 2005
51 # openttd_vs80.vcproj is for MSVC 2005
52 # langs_vs80.vcproj is for MSVC 2005
53 # strgen_vs80.vcproj is for MSVC 2005
54 # generate_vs80.vcproj is for MSVC 2005
55 # version_vs80.vcproj is for MSVC 2005
58 grep '\.h' "$ROOT_DIR/source.list" |
grep -v '../objs/langs/table/strings.h\|../objs/settings/table/settings.h' |
sed 's/ //g' |
sort > tmp.headers.
source.list
59 find "$ROOT_DIR/src" -iname .svn
-prune -o \
( -iname '*.h' -o -iname '*.hpp' \
) -print |
sed "s~$ROOT_DIR/src/~~" |
sort > tmp.headers.src
60 if ! diff tmp.headers.
source.list tmp.headers.src
>/dev
/null
; then
61 echo "The following headers are missing in source.list and not in /src/ or vice versa."
62 diff tmp.headers.
source.list tmp.headers.src |
grep '[<>]' |
sort
69 echo "Generating $2..."
71 # Everything above the !!FILTERS!! marker
72 sed < "$ROOT_DIR/projects/$2".
in -n -e '
76 ' > "$ROOT_DIR/projects/$2"
78 printf "%s" "$3" >> "$ROOT_DIR/projects/$2"
80 # Everything between the !!FILTERS!! marker and the !!FILES!! marker
81 sed < "$ROOT_DIR/projects/$2".
in -n -e '
86 ' >> "$ROOT_DIR/projects/$2"
88 # Everything above the !!FILES!! marker
89 sed < "$ROOT_DIR/projects/$2".
in -n -e '
93 ' > "$ROOT_DIR/projects/$2"
96 printf "%s" "$1" >> "$ROOT_DIR/projects/$2"
98 # Everything below the !!FILES!! marker
99 sed < "$ROOT_DIR/projects/$2".
in -n -e '
103 ' >> "$ROOT_DIR/projects/$2"
107 # First, collect the list of Windows files
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 == "SDL" ) { skip
+= 1; }
124 if ($0 == "PNG" ) { skip
+= 1; }
125 if ($0 == "WIN32" ) { skip
+= 1; }
126 if ($0 == "MSVC" ) { skip
+= 1; }
127 if ($0 == "DIRECTMUSIC") { skip
+= 1; }
128 if ($0 == "AI" ) { skip
+= 1; }
129 if ($0 == "SSE" ) { skip
+= 1; }
130 if ($0 == "HAVE_THREAD") { skip
+= 1; }
143 openttd="`echo "$srclist" | awk '
145 configs
[0] = "Release|Win32";
146 configs
[1] = "Debug|Win32";
147 configs
[2] = "Release|x64";
148 configs
[3] = "Debug|x64";
154 if (first_time
!= 0) {
161 print
" Name=\\""$0"\\"";
168 gsub
("/", "\\\\", $0);
170 print
" RelativePath=\\".
\\\\'$file_prefix'"$0"\\"";
172 ndirs
= split($0, dirs, "\\\\");
173 if (ndirs
> 1 && match
($0, /\.cpp$
/)) {
174 dir
= "$(IntDir)\\\\";
175 for (i
= 1; i
< ndirs
; i
++) {
176 dir
= sprintf
("%s%s\\\\", dir
, dirs[i
]);
178 for (i
= 0; i
< 4; i
++) {
179 print
" <FileConfiguration";
180 print
" Name=\\"" configs[i] "\\"";
183 print
" Name=\\"VCCLCompilerTool
\\"";
184 print
" AssemblerListingLocation=\\""dir"\\"";
185 print
" ObjectFile=\\""dir"\\"";
186 print
" XMLDocumentationFileName=\\""dir"\\"";
188 print
" </FileConfiguration>";
193 END
{ print
" </Filter>"; }
197 openttdvcxproj="`echo "$srclist" | awk '
201 gsub
("/", "\\\\", $0);
202 split($0, file, ".");
204 if (file[2] == "cpp") cltype
= "ClCompile";
205 if (file[2] == "rc") cltype
= "ResourceCompile";
207 ndirs
= split($0, dirs, "\\\\");
208 if (ndirs
> 1 && cltype
== "ClCompile") {
209 dir
= "$(IntDir)\\\\";
210 for (i
= 1; i
< ndirs
; i
++) {
211 dir
= sprintf
("%s%s\\\\", dir
, dirs[i
]);
213 print
" <ClCompile Include=\\"'$file_prefix'"$0"\\">";
214 print
" <AssemblerListingLocation>"dir
"</AssemblerListingLocation>";
215 print
" <ObjectFileName>"dir
"</ObjectFileName>";
216 print
" <XMLDocumentationFileName>"dir
"</XMLDocumentationFileName>";
217 print
" </ClCompile>";
219 print
" <"cltype
" Include=\\"'$file_prefix'"$0"\\" />";
225 openttdfiles="`echo "$srclist" | awk '
236 gsub
("/", "\\\\", $0);
237 split($0, file, ".");
239 if (file[2] == "cpp") cltype
= "ClCompile";
240 if (file[2] == "rc") cltype
= "ResourceCompile";
241 print
" <"cltype
" Include=\\"'$file_prefix'"$0"\\">";
242 print
" <Filter>"filter
"</Filter>";
243 print
" </"cltype
">";
248 openttdfilters="`echo "$srclist" | awk '
253 print
" <Filter Include=\\""$0"\\">";
254 printf " <UniqueIdentifier>{c76ff9f1-1e62-46d8-8d55-%012d}</UniqueIdentifier>\n", i
;
261 generate "$openttd" "openttd_vs80.vcproj"
262 generate "$openttd" "openttd_vs90.vcproj"
263 generate "$openttdvcxproj" "openttd_vs100.vcxproj"
264 generate "$openttdfiles" "openttd_vs100.vcxproj.filters" "$openttdfilters"
265 generate "$openttdvcxproj" "openttd_vs140.vcxproj"
266 generate "$openttdfiles" "openttd_vs140.vcxproj.filters" "$openttdfilters"
269 txtfiles=`ls "$ROOT_DIR"/src/lang/*.txt | sed -e 's
,^.
*/,,' -e 's
/\.txt$
//' -e '/^english$
/d
'`
279 RelativePath=\"..\\src\\lang\\$i.txt\"
285 Name=\"VCCustomBuildTool\"
286 Description=\"Generating $i language file\"
287 CommandLine=\"..\\objs\\strgen\\strgen.exe -s ..\\src\\lang -d ..\\bin\\lang "\$(InputPath)"
exit 0
\"
288 AdditionalDependencies=\"..\\src\\lang\\english.txt;..\\objs\\strgen\\strgen.exe\"
289 Outputs=\"..\\bin\\lang\\$i.lng\"
294 langvcxproj="$langvcxproj\
295 <CustomBuild Include=\"..\\src\\lang\\$i.txt\">
296 <Message Condition=\"'\$
(Configuration
)|\$
(Platform
)'=='Debug|Win32
'\">Generating $i language file</Message>
297 <Command Condition=\"'\$
(Configuration
)|\$
(Platform
)'=='Debug|Win32
'\">..\\objs\\strgen\\strgen.exe -s ..\\src\\lang -d ..\\bin\\lang \"%(FullPath)\"</Command>
298 <AdditionalInputs Condition=\"'\$
(Configuration
)|\$
(Platform
)'=='Debug|Win32
'\">..\\src\\lang\\english.txt;..\\objs\\strgen\\strgen.exe;%(AdditionalInputs)</AdditionalInputs>
299 <Outputs Condition=\"'\$
(Configuration
)|\$
(Platform
)'=='Debug|Win32
'\">..\\bin\\lang\\$i.lng;%(Outputs)</Outputs>
302 langfiles="$langfiles\
303 <CustomBuild Include=\"..\\src\\lang\\$i.txt\">
304 <Filter>Translations</Filter>
309 generate "$lang" "langs_vs80.vcproj"
310 generate "$lang" "langs_vs90.vcproj"
311 generate "$langvcxproj" "langs_vs100.vcxproj"
312 generate "$langfiles" "langs_vs100.vcxproj.filters"
313 generate "$langvcxproj" "langs_vs140.vcxproj"
314 generate "$langfiles" "langs_vs140.vcxproj.filters"
317 inifiles=`ls "$ROOT_DIR"/src/table/*.ini | sed -e 's
,^.
*/,,'`
320 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 RelativePath=\"..\\src\\table\\$i\"
332 settingscommand="$settingscommand ..\\src\\table\\$i"
333 settingsvcxproj="$settingsvcxproj\
334 <None Include=\"..\\src\\table\\$i\" />
336 settingsfiles="$settingsfiles\
337 <None Include=\"..\\src\\table\\$i\">
343 settingscommand="$settingscommand
346 generate "$settings" "settings_vs80.vcproj" "$settingscommand"
347 generate "$settings" "settings_vs90.vcproj" "$settingscommand"
348 generate "$settingsvcxproj" "settings_vs100.vcxproj" "$settingscommand"
349 generate "$settingsfiles" "settings_vs100.vcxproj.filters"
350 generate "$settingsvcxproj" "settings_vs140.vcxproj" "$settingscommand"
351 generate "$settingsfiles" "settings_vs140.vcxproj.filters"