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_vs141.sln is for MSVC 2017
26 # openttd_vs141.vcxproj is for MSVC 2017
27 # openttd_vs141.vcxproj.filters is for MSVC 2017
28 # langs_vs141.vcxproj is for MSVC 2017
29 # strgen_vs141.vcxproj is for MSVC 2017
30 # strgen_vs141.vcxproj.filters is for MSVC 2017
31 # generate_vs141.vcxproj is for MSVC 2017
32 # version_vs141.vcxproj is for MSVC 2017
34 # openttd_vs140.sln is for MSVC 2015
35 # openttd_vs140.vcxproj is for MSVC 2015
36 # openttd_vs140.vcxproj.filters is for MSVC 2015
37 # langs_vs140.vcxproj is for MSVC 2015
38 # strgen_vs140.vcxproj is for MSVC 2015
39 # strgen_vs140.vcxproj.filters is for MSVC 2015
40 # generate_vs140.vcxproj is for MSVC 2015
41 # version_vs140.vcxproj is for MSVC 2015
43 # openttd_vs100.sln is for MSVC 2010
44 # openttd_vs100.vcxproj is for MSVC 2010
45 # openttd_vs100.vcxproj.filters is for MSVC 2010
46 # langs_vs100.vcxproj is for MSVC 2010
47 # strgen_vs100.vcxproj is for MSVC 2010
48 # strgen_vs100.vcxproj.filters is for MSVC 2010
49 # generate_vs100.vcxproj is for MSVC 2010
50 # version_vs100.vcxproj is for MSVC 2010
52 # openttd_vs90.sln is for MSVC 2008
53 # openttd_vs90.vcproj is for MSVC 2008
54 # langs_vs90.vcproj is for MSVC 2008
55 # strgen_vs90.vcproj is for MSVC 2008
56 # generate_vs90.vcproj is for MSVC 2008
57 # version_vs90.vcproj is for MSVC 2008
59 # openttd_vs80.sln is for MSVC 2005
60 # openttd_vs80.vcproj is for MSVC 2005
61 # langs_vs80.vcproj is for MSVC 2005
62 # strgen_vs80.vcproj is for MSVC 2005
63 # generate_vs80.vcproj is for MSVC 2005
64 # version_vs80.vcproj is for MSVC 2005
67 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
68 find "$ROOT_DIR/src" -iname .svn
-prune -o \
( -iname '*.h' -o -iname '*.hpp' \
) -print |
sed "s~$ROOT_DIR/src/~~" |
sort > tmp.headers.src
69 if ! diff tmp.headers.
source.list tmp.headers.src
>/dev
/null
; then
70 echo "The following headers are missing in source.list and not in /src/ or vice versa."
71 diff tmp.headers.
source.list tmp.headers.src |
grep '[<>]' |
sort
78 echo "Generating $2..."
80 # Everything above the !!FILTERS!! marker
81 sed < "$ROOT_DIR/projects/$2".
in -n -e '
85 ' > "$ROOT_DIR/projects/$2"
87 printf "%s" "$3" >> "$ROOT_DIR/projects/$2"
89 # Everything between the !!FILTERS!! marker and the !!FILES!! marker
90 sed < "$ROOT_DIR/projects/$2".
in -n -e '
95 ' >> "$ROOT_DIR/projects/$2"
97 # Everything above the !!FILES!! marker
98 sed < "$ROOT_DIR/projects/$2".
in -n -e '
102 ' > "$ROOT_DIR/projects/$2"
105 printf "%s" "$1" >> "$ROOT_DIR/projects/$2"
107 # Everything below the !!FILES!! marker
108 sed < "$ROOT_DIR/projects/$2".
in -n -e '
112 ' >> "$ROOT_DIR/projects/$2"
116 # First, collect the list of Windows files
117 file_prefix
="..\\\\src\\\\"
119 # Read the source.list and process it
120 srclist
="`cat "$ROOT_DIR/source.list
" | tr '\r' '\n' | awk '
121 /^( *)#end/ { if (deep == skip) { skip -= 1; } deep -= 1; next; }
122 /^( *)#else/ { if (deep == skip) { skip -= 1; } else if (deep - 1 == skip) { skip += 1; } next; }
125 gsub("^
#if", "", $0);
128 if (deep
!= skip
) { deep
+= 1; next
; }
132 if ($0 == "SDL" ) { skip
+= 1; }
133 if ($0 == "PNG" ) { skip
+= 1; }
134 if ($0 == "WIN32" ) { skip
+= 1; }
135 if ($0 == "MSVC" ) { skip
+= 1; }
136 if ($0 == "DIRECTMUSIC") { skip
+= 1; }
137 if ($0 == "AI" ) { skip
+= 1; }
138 if ($0 == "SSE" ) { skip
+= 1; }
139 if ($0 == "HAVE_THREAD") { skip
+= 1; }
152 openttd="`echo "$srclist" | awk '
154 configs
[0] = "Release|Win32";
155 configs
[1] = "Debug|Win32";
156 configs
[2] = "Release|x64";
157 configs
[3] = "Debug|x64";
163 if (first_time
!= 0) {
170 print
" Name=\\""$0"\\"";
177 gsub
("/", "\\\\", $0);
179 print
" RelativePath=\\".
\\\\'$file_prefix'"$0"\\"";
181 ndirs
= split($0, dirs, "\\\\");
182 if (ndirs
> 1 && match
($0, /\.cpp$
/)) {
183 dir
= "$(IntDir)\\\\";
184 for (i
= 1; i
< ndirs
; i
++) {
185 dir
= sprintf
("%s%s\\\\", dir
, dirs[i
]);
187 for (i
= 0; i
< 4; i
++) {
188 print
" <FileConfiguration";
189 print
" Name=\\"" configs[i] "\\"";
192 print
" Name=\\"VCCLCompilerTool
\\"";
193 print
" AssemblerListingLocation=\\""dir"\\"";
194 print
" ObjectFile=\\""dir"\\"";
195 print
" XMLDocumentationFileName=\\""dir"\\"";
197 print
" </FileConfiguration>";
202 END
{ print
" </Filter>"; }
206 openttdvcxproj="`echo "$srclist" | awk '
210 gsub
("/", "\\\\", $0);
211 split($0, file, ".");
213 if (file[2] == "cpp") cltype
= "ClCompile";
214 if (file[2] == "rc") cltype
= "ResourceCompile";
216 ndirs
= split($0, dirs, "\\\\");
217 if (ndirs
> 1 && cltype
== "ClCompile") {
218 dir
= "$(IntDir)\\\\";
219 for (i
= 1; i
< ndirs
; i
++) {
220 dir
= sprintf
("%s%s\\\\", dir
, dirs[i
]);
222 print
" <ClCompile Include=\\"'$file_prefix'"$0"\\">";
223 print
" <AssemblerListingLocation>"dir
"</AssemblerListingLocation>";
224 print
" <ObjectFileName>"dir
"</ObjectFileName>";
225 print
" <XMLDocumentationFileName>"dir
"</XMLDocumentationFileName>";
226 print
" </ClCompile>";
228 print
" <"cltype
" Include=\\"'$file_prefix'"$0"\\" />";
234 openttdfiles="`echo "$srclist" | awk '
245 gsub
("/", "\\\\", $0);
246 split($0, file, ".");
248 if (file[2] == "cpp") cltype
= "ClCompile";
249 if (file[2] == "rc") cltype
= "ResourceCompile";
250 print
" <"cltype
" Include=\\"'$file_prefix'"$0"\\">";
251 print
" <Filter>"filter
"</Filter>";
252 print
" </"cltype
">";
257 openttdfilters="`echo "$srclist" | awk '
262 print
" <Filter Include=\\""$0"\\">";
263 printf " <UniqueIdentifier>{c76ff9f1-1e62-46d8-8d55-%012d}</UniqueIdentifier>\n", i
;
270 generate "$openttd" "openttd_vs80.vcproj"
271 generate "$openttd" "openttd_vs90.vcproj"
272 generate "$openttdvcxproj" "openttd_vs100.vcxproj"
273 generate "$openttdfiles" "openttd_vs100.vcxproj.filters" "$openttdfilters"
274 generate "$openttdvcxproj" "openttd_vs140.vcxproj"
275 generate "$openttdfiles" "openttd_vs140.vcxproj.filters" "$openttdfilters"
276 generate "$openttdvcxproj" "openttd_vs141.vcxproj"
277 generate "$openttdfiles" "openttd_vs141.vcxproj.filters" "$openttdfilters"
280 txtfiles=`ls "$ROOT_DIR"/src/lang/*.txt | sed -e 's
,^.
*/,,' -e 's
/\.txt$
//' -e '/^english$
/d
'`
290 RelativePath=\"..\\src\\lang\\$i.txt\"
296 Name=\"VCCustomBuildTool\"
297 Description=\"Generating $i language file\"
298 CommandLine=\"..\\objs\\strgen\\strgen.exe -s ..\\src\\lang -d ..\\bin\\lang "\$(InputPath)"
exit 0
\"
299 AdditionalDependencies=\"..\\src\\lang\\english.txt;..\\objs\\strgen\\strgen.exe\"
300 Outputs=\"..\\bin\\lang\\$i.lng\"
305 langvcxproj="$langvcxproj\
306 <CustomBuild Include=\"..\\src\\lang\\$i.txt\">
307 <Message Condition=\"'\$
(Configuration
)|\$
(Platform
)'=='Debug|Win32
'\">Generating $i language file</Message>
308 <Command Condition=\"'\$
(Configuration
)|\$
(Platform
)'=='Debug|Win32
'\">..\\objs\\strgen\\strgen.exe -s ..\\src\\lang -d ..\\bin\\lang \"%(FullPath)\"</Command>
309 <AdditionalInputs Condition=\"'\$
(Configuration
)|\$
(Platform
)'=='Debug|Win32
'\">..\\src\\lang\\english.txt;..\\objs\\strgen\\strgen.exe;%(AdditionalInputs)</AdditionalInputs>
310 <Outputs Condition=\"'\$
(Configuration
)|\$
(Platform
)'=='Debug|Win32
'\">..\\bin\\lang\\$i.lng;%(Outputs)</Outputs>
313 langfiles="$langfiles\
314 <CustomBuild Include=\"..\\src\\lang\\$i.txt\">
315 <Filter>Translations</Filter>
320 generate "$lang" "langs_vs80.vcproj"
321 generate "$lang" "langs_vs90.vcproj"
322 generate "$langvcxproj" "langs_vs100.vcxproj"
323 generate "$langfiles" "langs_vs100.vcxproj.filters"
324 generate "$langvcxproj" "langs_vs140.vcxproj"
325 generate "$langfiles" "langs_vs140.vcxproj.filters"
326 generate "$langvcxproj" "langs_vs141.vcxproj"
327 generate "$langfiles" "langs_vs141.vcxproj.filters"
330 inifiles=`ls "$ROOT_DIR"/src/table/*.ini | sed -e 's
,^.
*/,,'`
333 settingscommand="..\\objs\\settings\\settings_gen.exe -o ..\\objs\\settings\\table\\settings.h -b ..\\src\\table\\settings.h.preamble -a ..\\src\\table\\settings.h.postamble"
341 RelativePath=\"..\\src\\table\\$i\"
345 settingscommand="$settingscommand ..\\src\\table\\$i"
346 settingsvcxproj="$settingsvcxproj\
347 <None Include=\"..\\src\\table\\$i\" />
349 settingsfiles="$settingsfiles\
350 <None Include=\"..\\src\\table\\$i\">
356 settingscommand="$settingscommand
359 generate "$settings" "settings_vs80.vcproj" "$settingscommand"
360 generate "$settings" "settings_vs90.vcproj" "$settingscommand"
361 generate "$settingsvcxproj" "settings_vs100.vcxproj" "$settingscommand"
362 generate "$settingsfiles" "settings_vs100.vcxproj.filters"
363 generate "$settingsvcxproj" "settings_vs140.vcxproj" "$settingscommand"
364 generate "$settingsfiles" "settings_vs140.vcxproj.filters"
365 generate "$settingsvcxproj" "settings_vs141.vcxproj" "$settingscommand"
366 generate "$settingsfiles" "settings_vs141.vcxproj.filters"