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_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
59 # First, collect the list of Windows files
67 enable_directmusic
="1"
69 file_prefix
="..\\\\src\\\\"
73 for i
in `cat $1 | grep -v "#\|ottdres.rc\|win32.cpp\|win32_v.cpp" | xargs -n 1 basename | sort`; do
74 if [ "$li" = "$i" ]; then
77 echo "The filename '$i' is already used in this project."
78 echo "Because MSVC uses one single directory for all object files, it"
79 echo "cannot handle filenames with the same name inside the same project."
80 echo "Please rename either one of the file and try generating again."
89 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
90 find "$ROOT_DIR/src" \
( -iname "*.h" -or -iname "*.hpp" \
) -and -not -ipath "*/.svn/*" |
sed "s~$ROOT_DIR/src/~~" |
sort > tmp.headers.src
91 if [ -n "`diff tmp.headers.source.list tmp.headers.src`" ]; then
92 echo "The following headers are missing in source.list and not in /src/ or vice versa."
93 diff tmp.headers.
source.list tmp.headers.src |
grep '[<>]' |
sort
99 # Read the source.list and process it
100 RES
="`cat $1 | tr '\r' '\n' | awk '
101 /^( *)#end/ { if (deep == skip) { skip -= 1; } deep -= 1; next; }
102 /^( *)#else/ { if (deep == skip) { skip -= 1; } else if (deep - 1 == skip) { skip += 1; } next; }
105 gsub("^
#if", "", $0);
108 if (deep
!= skip
) { deep
+= 1; next
; }
112 if ($0 == "ALLEGRO" && "'$allegro_config'" == "") { next
; }
113 if ($0 == "SDL" && "'$sdl_config'" == "") { next
; }
114 if ($0 == "PNG" && "'$png_config'" == "") { next
; }
115 if ($0 == "OSX" && "'$os'" != "OSX") { next
; }
116 if ($0 == "OS2" && "'$os'" != "OS2") { next
; }
117 if ($0 == "PSP" && "'$os'" != "PSP") { next
; }
118 if ($0 == "DOS" && "'$os'" != "DOS") { next
; }
119 if ($0 == "DEDICATED" && "'$enable_dedicated'" != "1") { next
; }
120 if ($0 == "AI" && "'$enable_ai'" == "0") { next
; }
121 if ($0 == "COCOA" && "'$with_cocoa'" == "0") { next
; }
122 if ($0 == "BEOS" && "'$os'" != "BEOS") { next
; }
123 if ($0 == "WIN32" && "'$os'" != "MINGW" &&
124 "'$os'" != "CYGWIN" && "'$os'" != "MSVC" ) { next
; }
125 if ($0 == "WINCE" && "'$os'" != "WINCE") { next
; }
126 if ($0 == "MSVC" && "'$os'" != "MSVC") { next
; }
127 if ($0 == "DIRECTMUSIC" && "'$enable_directmusic'" != "1") { next
; }
128 if ($0 == "LIBTIMIDITY" && "'$libtimidity'" == "" ) { next
; }
129 if ($0 == "HAVE_THREAD" && "'$with_threads'" == "0") { next
; }
141 if (first_time
!= 0) {
142 print
"#1 </Filter>";
149 print
"#1 Name=\\""filter"\\"";
151 print
"#3 <Filter Include=\\""filter"\\">";
152 printf "#3 <UniqueIdentifier>{c76ff9f1-1e62-46d8-8d55-%012d}</UniqueIdentifier>\n", i
;
153 print
"#3 </Filter>";
163 gsub
("/", "\\\\", $0);
165 print
"#1 RelativePath=\\".
\\\\'$file_prefix'"$0"\\"";
168 split($0, file, ".");
170 if (file[2] == "cpp") cltype
= "ClCompile";
171 if (file[2] == "rc") cltype
= "ResourceCompile";
172 print
"#2 <"cltype
" Include=\\"'$file_prefix'"$0"\\" />";
173 print
"#4 <"cltype
" Include=\\"'$file_prefix'"$0"\\">";
174 print
"#4 <Filter>"filter
"</Filter>";
175 print
"#4 </"cltype
">";
178 END
{ print
"#1 </Filter>"; }
188 i=`basename $i | sed s~.txt$~~g`
189 if [ "$i" == "english" ]
195 #1 RelativePath=\"..\\src\\lang\\"$i".txt\"
197 #1 <FileConfiguration
198 #1 Name=\"Debug|Win32\"
201 #1 Name=\"VCCustomBuildTool\"
202 #1 Description=\"Generating "$i" language file\"
203 #1 CommandLine=\"..\\objs\\strgen\\strgen.exe -s ..\\src\\lang -d ..\\bin\\lang "\$(InputPath)"
exit 0
\"
204 #1 AdditionalDependencies=\"..\\src\\lang\\english.txt;..\\objs\\strgen\\strgen.exe\"
205 #1 Outputs=\"..\\bin\\lang\\"$i".lng\"
207 #1 </FileConfiguration>
209 #2 <CustomBuild Include=\"..\\src\\lang\\"$i".txt\">
210 #2 <Message Condition=\"'\$
(Configuration
)|\$
(Platform
)'=='Debug|Win32
'\">Generating "$i" language file</Message>
211 #2 <Command Condition=\"'\$
(Configuration
)|\$
(Platform
)'=='Debug|Win32
'\">..\\objs\\strgen\\strgen.exe -s ..\\src\\lang -d ..\\bin\\lang \"%(FullPath)\"</Command>
212 #2 <AdditionalInputs Condition=\"'\$
(Configuration
)|\$
(Platform
)'=='Debug|Win32
'\">..\\src\\lang\\english.txt;..\\objs\\strgen\\strgen.exe;%(AdditionalInputs)</AdditionalInputs>
213 #2 <Outputs Condition=\"'\$
(Configuration
)|\$
(Platform
)'=='Debug|Win32
'\">..\\bin\\lang\\"$i".lng;%(Outputs)</Outputs>
215 #3 <CustomBuild Include=\"..\\src\\lang\\"$i".txt\">
216 #3 <Filter>Translations</Filter>
223 load_settings_data() {
226 #3..\\objs\\settings\\settings_gen.exe -o ..\\objs\\settings\\table\\settings.h -b ..\\src\\table\\settings.h.preamble -a ..\\src\\table\\settings.h.postamble"
232 #1 RelativePath=\"..\\src\\table\\"$i"\"
235 #2 <None Include=\"..\\src\\table\\"$i"\" />
236 #4 <None Include=\"..\\src\\table\\"$i"\">
237 #4 <Filter>INI</Filter>
239 RES2="$RES2 ..\\src\\table\\"$i
242 eval "$2=\"\$RES\$RES2\""
246 echo "Generating $2..."
247 if [ $# -eq 3 ]; then
248 # Everything above the !!FILTERS!! marker
249 cat "$ROOT_DIR/projects/$2".in | tr '\r' '\n' | awk '
251 /!!FILTERS
!!/ { stop
= 1; }
253 if (stop
== 0) { print
$0 }
255 ' > "$ROOT_DIR/projects/$2"
257 echo "$3" >> "$ROOT_DIR/projects/$2"
259 # Everything below the !!FILTERS!! marker and above the !!FILES!! marker
260 cat "$ROOT_DIR/projects/$2".in | tr '\r' '\n' | awk '
263 /!!FILTERS
!!/ { stop
= 2; }
264 /!!FILES
!!/ { stop
= 1; }
266 if (stop
== 0) { print
$0 }
267 if (stop
== 2) { stop
= 0 }
269 ' >> "$ROOT_DIR/projects/$2"
271 # Everything above the !!FILES!! marker
272 cat "$ROOT_DIR/projects/$2".in | tr '\r' '\n' | awk '
274 /!!FILES
!!/ { stop
= 1; }
276 if (stop
== 0) { print
$0 }
278 ' > "$ROOT_DIR/projects/$2"
281 echo "$1" >> "$ROOT_DIR/projects/$2"
283 # Everything below the !!FILES!! marker
284 cat "$ROOT_DIR/projects/$2".in | tr '\r' '\n' | awk '
287 /!!FILES
!!/ { stop
= 2; }
289 if (stop
== 0) { print
$0 }
290 if (stop
== 2) { stop
= 0 }
292 ' >> "$ROOT_DIR/projects/$2"
295 safety_check "$ROOT_DIR/source.list"
297 load_main_data "$ROOT_DIR/source.list" openttd
298 openttdfiles=`echo "$openttd" | grep "^#4" | sed "s~#4~~g"`
299 openttdfilters=`echo "$openttd" | grep "^#3" | sed "s~#3~~g"`
300 openttdvcxproj=`echo "$openttd" | grep "^#2" | sed "s~#2~~g"`
301 openttd=`echo "$openttd" | grep "^#1" | sed "s~#1~~g"`
303 load_lang_data "$ROOT_DIR/src/lang/*.txt" lang
304 langfiles=`echo "$lang" | grep "^#3" | sed "s~#3~~g"`
305 langvcxproj=`echo "$lang" | grep "^#2" | sed "s~#2~~g"`
306 lang=`echo "$lang" | grep "^#1" | sed "s~#1~~g"`
308 load_settings_data "$ROOT_DIR/src/table/*.ini" settings
309 settingsfiles=`echo "$settings" | grep "^#4" | sed "s~#4~~g"`
310 settingscommand=`echo "$settings" | grep "^#3" | sed "s~#3~~g"`
311 settingsvcxproj=`echo "$settings" | grep "^#2" | sed "s~#2~~g"`
312 settings=`echo "$settings" | grep "^#1" | sed "s~#1~~g"`
314 generate "$openttd" "openttd_vs80.vcproj"
315 generate "$openttd" "openttd_vs90.vcproj"
316 generate "$openttdvcxproj" "openttd_vs100.vcxproj"
317 generate "$openttdfiles" "openttd_vs100.vcxproj.filters" "$openttdfilters"
318 generate "$openttdvcxproj" "openttd_vs141.vcxproj"
319 generate "$openttdfiles" "openttd_vs141.vcxproj.filters" "$openttdfilters"
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_vs141.vcxproj"
325 generate "$langfiles" "langs_vs141.vcxproj.filters"
326 generate "$settings" "settings_vs80.vcproj" "$settingscommand"
327 generate "$settings" "settings_vs90.vcproj" "$settingscommand"
328 generate "$settingsvcxproj" "settings_vs100.vcxproj" "$settingscommand"
329 generate "$settingsfiles" "settings_vs100.vcxproj.filters"
330 generate "$settingsvcxproj" "settings_vs141.vcxproj" "$settingscommand"
331 generate "$settingsfiles" "settings_vs141.vcxproj.filters"