3 # This file is part of OpenTTD.
4 # 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.
5 # 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.
6 # 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/>.
8 # This file generates all project files based on sources.list, so everyone who
9 # can start a bash process, can update the project files.
11 # Set neutral locale so sort behaves the same everywhere
15 # We really need gawk for this!
18 ${AWK} --version > /dev
/null
2> /dev
/null
19 if [ "$?" != "0" ]; then
20 echo "This script needs gawk to run properly"
25 if ! [ -e "$ROOT_DIR/source.list" ]
29 if ! [ -e "$ROOT_DIR/source.list" ]
31 echo "Can't find source.list, needed in order to make this run. Please go to either"
32 echo " the project dir, or the root dir of a clean SVN checkout."
36 # openttd_vs142.sln is for MSVC 2019
37 # openttd_vs142.vcxproj is for MSVC 2019
38 # openttd_vs142.vcxproj.filters is for MSVC 2019
39 # langs_vs142.vcxproj is for MSVC 2019
40 # strgen_vs142.vcxproj is for MSVC 2019
41 # strgen_vs142.vcxproj.filters is for MSVC 2019
42 # generate_vs142.vcxproj is for MSVC 2019
43 # version_vs142.vcxproj is for MSVC 2019
44 # basesets_vs142.vcxproj is for MSVC 2019
46 # openttd_vs141.sln is for MSVC 2017
47 # openttd_vs141.vcxproj is for MSVC 2017
48 # openttd_vs141.vcxproj.filters is for MSVC 2017
49 # langs_vs141.vcxproj is for MSVC 2017
50 # strgen_vs141.vcxproj is for MSVC 2017
51 # strgen_vs141.vcxproj.filters is for MSVC 2017
52 # generate_vs141.vcxproj is for MSVC 2017
53 # version_vs141.vcxproj is for MSVC 2017
54 # basesets_vs141.vcxproj is for MSVC 2017
56 # openttd_vs140.sln is for MSVC 2015
57 # openttd_vs140.vcxproj is for MSVC 2015
58 # openttd_vs140.vcxproj.filters is for MSVC 2015
59 # langs_vs140.vcxproj is for MSVC 2015
60 # strgen_vs140.vcxproj is for MSVC 2015
61 # strgen_vs140.vcxproj.filters is for MSVC 2015
62 # generate_vs140.vcxproj is for MSVC 2015
63 # version_vs140.vcxproj is for MSVC 2015
64 # basesets_vs140.vcxproj is for MSVC 2015
69 # First, collect the list of Windows files
77 enable_directmusic
="1"
80 file_prefix
="..\\\\\\\\src\\\\\\\\"
84 for i
in `cat $1 | grep -v "#\|ottdres.rc\|win32.cpp\|win32_v.cpp" | xargs -n 1 basename | sort`; do
85 if [ "$li" = "$i" ]; then
88 echo "The filename '$i' is already used in this project."
89 echo "Because MSVC uses one single directory for all object files, it"
90 echo "cannot handle filenames with the same name inside the same project."
91 echo "Please rename either one of the file and try generating again."
100 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
101 find "$ROOT_DIR/src" \
( -iname "*.h" -or -iname "*.hpp" \
) -and -not -ipath "*/.svn/*" |
sed "s~$ROOT_DIR/src/~~" |
sort > tmp.headers.src
102 if [ -n "`diff tmp.headers.source.list tmp.headers.src`" ]; then
103 echo "The following headers are missing in source.list and not in /src/ or vice versa."
104 diff tmp.headers.
source.list tmp.headers.src |
grep '[<>]' |
sort
110 # Read the source.list and process it
111 RES
="`cat $1 | ${AWK} -v BINMODE=1 '
112 { gsub("\\r
", "", $0); }
113 /^( *)#end/ { if (deep == skip) { skip -= 1; } deep -= 1; next; }
114 /^( *)#else/ { if (deep == skip) { skip -= 1; } else if (deep - 1 == skip) { skip += 1; } next; }
117 gsub("^
#if", "", $0);
120 if (deep
!= skip
) { deep
+= 1; next
; }
124 if ($0 == "ALLEGRO" && "'$allegro_config'" == "") { next
; }
125 if ($0 == "SDL" && "'$sdl_config'" == "") { next
; }
126 if ($0 == "PNG" && "'$png_config'" == "") { next
; }
127 if ($0 == "OSX" && "'$os'" != "OSX") { next
; }
128 if ($0 == "OS2" && "'$os'" != "OS2") { 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 == "HAIKU" && "'$os'" != "HAIKU") { next
; }
134 if ($0 == "WIN32" && "'$os'" != "MINGW" &&
135 "'$os'" != "CYGWIN" && "'$os'" != "MSVC" ) { next
; }
136 if ($0 == "MSVC" && "'$os'" != "MSVC") { next
; }
137 if ($0 == "DIRECTMUSIC" && "'$enable_directmusic'" != "1") { next
; }
138 if ($0 == "FLUIDSYNTH" && "'$enable_fluidsynth'" != "1") { next
; }
139 if ($0 == "USE_XAUDIO2" && "'$with_xaudio2'" == "0") { next
; }
140 if ($0 == "USE_THREADS" && "'$with_threads'" == "0") { next
; }
152 print
"#3 <Filter Include=\\""filter"\\">";
153 printf "#3 <UniqueIdentifier>{c76ff9f1-1e62-46d8-8d55-%012d}</UniqueIdentifier>\n", i
;
154 print
"#3 </Filter>";
164 gsub
("/", "\\\\\\\\", $0);
165 split($0, file, ".");
167 if (file[2] == "cpp") cltype
= "ClCompile";
168 if (file[2] == "rc") cltype
= "ResourceCompile";
169 print
"#2 <"cltype
" Include=\\"'$file_prefix'"$0"\\" />";
170 print
"#4 <"cltype
" Include=\\"'$file_prefix'"$0"\\">";
171 print
"#4 <Filter>"filter
"</Filter>";
172 print
"#4 </"cltype
">";
182 # Windows Folder sort and Linux Folder sort are slightly different.
183 # By removing the extension and sorting it on Linux, they are the same.
184 for i in `ls $1 | sed s~.txt$~~g | sort`
187 if [ "$i" == "english" ]
192 #2 <CustomBuild Include=\"..\\\\src\\\\lang\\\\"$i".txt\">
193 #2 <Message Condition=\"'\$
(Configuration
)|\$
(Platform
)'=='Debug|Win32
'\">Generating "$i" language file</Message>
194 #2 <Command Condition=\"'\$
(Configuration
)|\$
(Platform
)'=='Debug|Win32
'\">..\\\\objs\\\\strgen\\\\strgen.exe -s ..\\\\src\\\\lang -d ..\\\\bin\\\\lang \"%(FullPath)\"</Command>
195 #2 <AdditionalInputs Condition=\"'\$
(Configuration
)|\$
(Platform
)'=='Debug|Win32
'\">..\\\\src\\\\lang\\\\english.txt;..\\\\objs\\\\strgen\\\\strgen.exe;%(AdditionalInputs)</AdditionalInputs>
196 #2 <Outputs Condition=\"'\$
(Configuration
)|\$
(Platform
)'=='Debug|Win32
'\">..\\\\bin\\\\lang\\\\"$i".lng;%(Outputs)</Outputs>
198 #3 <CustomBuild Include=\"..\\\\src\\\\lang\\\\"$i".txt\">
199 #3 <Filter>Translations</Filter>
206 load_settings_data() {
209 #3..\\\\objs\\\\settings\\\\settings_gen.exe -o ..\\\\objs\\\\settings\\\\table\\\\settings.h -b ..\\\\src\\\\table\\\\settings.h.preamble -a ..\\\\src\\\\table\\\\settings.h.postamble"
214 #2 <None Include=\"..\\\\src\\\\table\\\\"$i"\" />
215 #4 <None Include=\"..\\\\src\\\\table\\\\"$i"\">
216 #4 <Filter>INI</Filter>
218 RES2="$RES2 ..\\\\src\\\\table\\\\"$i
221 eval "$2=\"\$RES\$RES2\""
224 load_baseset_data() {
229 # Windows Folder sort and Linux Folder sort are slightly different.
230 # By removing the extension and sorting it on Linux, they are the same.
231 for i in `ls $2 | sed s~.txt$~~g | sort`
233 if [ "$FIRST" != "" ]; then
239 RES2="$RES2..\\\\src\\\\lang\\\\$i.txt"
242 # Windows Folder sort and Linux Folder sort are slightly different.
243 # By fiddling with the extension and sorting it on Linux, they are the same.
244 for i in `ls $1 | sed s~\\\.~000~g | sort | sed s~000~.~g`
248 #2 <CustomBuild Include=\"..\\\\media\\\\baseset\\\\"$i"\">
249 #2 <Message Condition=\"'\$
(Configuration
)|\$
(Platform
)'=='Debug|Win32
'\">Generating "$i" baseset metadata file</Message>
250 #2 <Command Condition=\"'\$
(Configuration
)|\$
(Platform
)'=='Debug|Win32
'\">cscript //nologo ..\\\\media\\\\baseset\\\\translations.vbs \"%(FullPath)\" \"\$(OutputPath)$i\" ..\\\\src\\\\lang ..\\\\bin\\\\baseset\\\\orig_extra.grf</Command>
251 #2 <AdditionalInputs Condition=\"'\$
(Configuration
)|\$
(Platform
)'=='Debug|Win32
'\">\$(Langs);..\\\\bin\\\\baseset\\\\orig_extra.grf;%(AdditionalInputs)</AdditionalInputs>
252 #2 <Outputs Condition=\"'\$
(Configuration
)|\$
(Platform
)'=='Debug|Win32
'\">..\\\\bin\\\\baseset\\\\"$i";%(Outputs)</Outputs>
254 #3 <CustomBuild Include=\"..\\\\media\\\\baseset\\\\"$i"\">
255 #3 <Filter>Baseset Metadata</Filter>
259 eval "$3=\"\$RES\$RES2\""
263 echo "Generating $2..."
264 # Everything above the !!FILTERS!! marker
265 cat "$ROOT_DIR/projects/$2".in | ${AWK} -v BINMODE=1 -v FILTERS="$3" -v FILES="$1" '
266 { CR
= (match
($0, "\\r$") > 0 ?
"\r" : "") }
269 split(FILTERS
, filters
, "\n");
270 for (i
= 1; filters
[i
] != ""; i
++) {
276 split(FILES
, files
, "\n");
277 for (i
= 1; files
[i
] != ""; i
++) {
285 ' > "$ROOT_DIR/projects/$2"
288 safety_check "$ROOT_DIR/source.list"
290 load_main_data "$ROOT_DIR/source.list" openttd
291 openttdfiles=`echo "$openttd" | grep "^#4" | sed "s~#4~~g"`
292 openttdfilters=`echo "$openttd" | grep "^#3" | sed "s~#3~~g"`
293 openttdvcxproj=`echo "$openttd" | grep "^#2" | sed "s~#2~~g"`
295 load_lang_data "$ROOT_DIR/src/lang/*.txt" lang
296 langfiles=`echo "$lang" | grep "^#3" | sed "s~#3~~g"`
297 langvcxproj=`echo "$lang" | grep "^#2" | sed "s~#2~~g"`
299 load_settings_data "$ROOT_DIR/src/table/*.ini" settings
300 settingsfiles=`echo "$settings" | grep "^#4" | sed "s~#4~~g"`
301 settingscommand=`echo "$settings" | grep "^#3" | sed "s~#3~~g"`
302 settingsvcxproj=`echo "$settings" | grep "^#2" | sed "s~#2~~g"`
304 load_baseset_data "$ROOT_DIR/media/baseset/*.ob?" "$ROOT_DIR/src/lang/*.txt" baseset
305 basesetfiles=`echo "$baseset" | grep "^#3" | sed "s-#3--g"`
306 basesetvcxproj=`echo "$baseset" | grep "^#2" | sed "s~#2~~g"`
307 basesetlangs=`echo "$baseset" | grep "^#4" | sed "s~#4~~g"`
309 generate "$openttdvcxproj" "openttd_vs140.vcxproj"
310 generate "$openttdfiles" "openttd_vs140.vcxproj.filters" "$openttdfilters"
311 generate "$openttdvcxproj" "openttd_vs141.vcxproj"
312 generate "$openttdfiles" "openttd_vs141.vcxproj.filters" "$openttdfilters"
313 generate "$openttdvcxproj" "openttd_vs142.vcxproj"
314 generate "$openttdfiles" "openttd_vs142.vcxproj.filters" "$openttdfilters"
315 generate "$langvcxproj" "langs_vs140.vcxproj"
316 generate "$langfiles" "langs_vs140.vcxproj.filters"
317 generate "$langvcxproj" "langs_vs141.vcxproj"
318 generate "$langfiles" "langs_vs141.vcxproj.filters"
319 generate "$langvcxproj" "langs_vs142.vcxproj"
320 generate "$langfiles" "langs_vs142.vcxproj.filters"
321 generate "$settingsvcxproj" "settings_vs140.vcxproj" "$settingscommand"
322 generate "$settingsfiles" "settings_vs140.vcxproj.filters"
323 generate "$settingsvcxproj" "settings_vs141.vcxproj" "$settingscommand"
324 generate "$settingsfiles" "settings_vs141.vcxproj.filters"
325 generate "$settingsvcxproj" "settings_vs142.vcxproj" "$settingscommand"
326 generate "$settingsfiles" "settings_vs142.vcxproj.filters"
327 generate "$basesetvcxproj" "basesets_vs140.vcxproj" "$basesetlangs"
328 generate "$basesetfiles" "basesets_vs140.vcxproj.filters"
329 generate "$basesetvcxproj" "basesets_vs141.vcxproj" "$basesetlangs"
330 generate "$basesetfiles" "basesets_vs141.vcxproj.filters"
331 generate "$basesetvcxproj" "basesets_vs142.vcxproj" "$basesetlangs"
332 generate "$basesetfiles" "basesets_vs142.vcxproj.filters"